ZHANGYUXUAN-zR commited on
Commit
5e1d900
·
verified ·
1 Parent(s): 3979d57

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. md/dev/MSBDFwGYwwt/MSBDFwGYwwt.md +297 -0
  2. md/dev/ZlCpRiZN7n/ZlCpRiZN7n.md +315 -0
  3. md/dev/nrksGSRT7kX/nrksGSRT7kX.md +362 -0
  4. md/train/0lz69oI5iZP/0lz69oI5iZP.md +241 -0
  5. md/train/B1IzH7cxl/B1IzH7cxl.md +401 -0
  6. md/train/BJE-4xW0W/BJE-4xW0W.md +0 -0
  7. md/train/BJbD_Pqlg/BJbD_Pqlg.md +398 -0
  8. md/train/BJgcwh4FwS/BJgcwh4FwS.md +467 -0
  9. md/train/BJl_VnR9Km/BJl_VnR9Km.md +320 -0
  10. md/train/ByG8A7cee/ByG8A7cee.md +331 -0
  11. md/train/CoJibBRjPXQ/CoJibBRjPXQ.md +509 -0
  12. md/train/FsLTUzZlsgT/FsLTUzZlsgT.md +360 -0
  13. md/train/H1e_cC4twS/H1e_cC4twS.md +358 -0
  14. md/train/H1eqOnNYDH/H1eqOnNYDH.md +396 -0
  15. md/train/H1xk8jAqKQ/H1xk8jAqKQ.md +398 -0
  16. md/train/HJBhEMbRb/HJBhEMbRb.md +557 -0
  17. md/train/HJWHIKqgl/HJWHIKqgl.md +214 -0
  18. md/train/HJem3yHKwH/HJem3yHKwH.md +256 -0
  19. md/train/HJx8HANFDH/HJx8HANFDH.md +409 -0
  20. md/train/Hkg5lAEtvS/Hkg5lAEtvS.md +278 -0
  21. md/train/HkpYwMZRb/HkpYwMZRb.md +0 -0
  22. md/train/OU98jZWS3x_/OU98jZWS3x_.md +267 -0
  23. md/train/S1c2cvqee/S1c2cvqee.md +308 -0
  24. md/train/S1lvm305YQ/S1lvm305YQ.md +365 -0
  25. md/train/S1vuO-bCW/S1vuO-bCW.md +450 -0
  26. md/train/SJeeL04KvH/SJeeL04KvH.md +204 -0
  27. md/train/SJlhPMWAW/SJlhPMWAW.md +268 -0
  28. md/train/SJxstlHFPH/SJxstlHFPH.md +333 -0
  29. md/train/Sk-oDY9ge/Sk-oDY9ge.md +277 -0
  30. md/train/SkEqro0ctQ/SkEqro0ctQ.md +410 -0
  31. md/train/SkVhlh09tX/SkVhlh09tX.md +315 -0
  32. md/train/Skgb5h4KPH/Skgb5h4KPH.md +597 -0
  33. md/train/Skn9Shcxe/Skn9Shcxe.md +341 -0
  34. md/train/SyxnvsAqFm/SyxnvsAqFm.md +309 -0
  35. md/train/TR-Nj6nFx42/TR-Nj6nFx42.md +283 -0
  36. md/train/YUEFlzlG_0c/YUEFlzlG_0c.md +324 -0
  37. md/train/fIn4wLS2XzU/fIn4wLS2XzU.md +266 -0
  38. md/train/hm0i-cunzGW/hm0i-cunzGW.md +243 -0
  39. md/train/i_Q1yrOegLY/i_Q1yrOegLY.md +318 -0
  40. md/train/iklDP-v1sgi/iklDP-v1sgi.md +596 -0
  41. md/train/lM2971LAwV/lM2971LAwV.md +270 -0
  42. md/train/q8qLAbQBupm/q8qLAbQBupm.md +0 -0
  43. md/train/r1lZgyBYwS/r1lZgyBYwS.md +301 -0
  44. md/train/rJe4_xSFDB/rJe4_xSFDB.md +419 -0
  45. md/train/rJqFGTslg/rJqFGTslg.md +236 -0
  46. md/train/rJxt0JHKvS/rJxt0JHKvS.md +475 -0
  47. md/train/rkEFLFqee/rkEFLFqee.md +299 -0
  48. md/train/ryloogSKDS/ryloogSKDS.md +272 -0
  49. md/train/yvQKLaqNE6M/yvQKLaqNE6M.md +488 -0
  50. md/train/zv-typ1gPxA/zv-typ1gPxA.md +393 -0
md/dev/MSBDFwGYwwt/MSBDFwGYwwt.md ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TANKBind: Trigonometry-Aware Neural NetworKs for Drug-Protein Binding Structure Prediction
2
+
3
+ Wei Lu∗† Galixir Technologies
4
+
5
+ Qifeng Wu† Fudan University
6
+
7
+ Jixian Zhang† Galixir Technologies
8
+
9
+ Jiahua Rao Sun Yat-sen University
10
+
11
+ Chengtao Li Galixir Technologies
12
+
13
+ Shuangjia Zheng∗† Galixir Technologies Sun Yat-sen University
14
+
15
+ # Abstract
16
+
17
+ Illuminating interactions between proteins and small drug molecules is a longstanding challenge in the field of drug discovery. Despite the importance of understanding these interactions, most previous works are limited by hand-designed scoring functions and insufficient conformation sampling. The recently-proposed graph neural network-based methods provides alternatives to predict protein-ligand complex conformation in a one-shot manner. However, these methods neglect the geometric constraints of the complex structure and weaken the role of local functional regions. As a result, they might produce unreasonable conformations for challenging targets and generalize poorly to novel proteins. In this paper, we propose Trigonometry-Aware Neural networKs for binding structure prediction, TANKBind, that builds trigonometry constraint as a vigorous inductive bias into the model and explicitly attends to all possible binding sites for each protein by segmenting the whole protein into functional blocks. We construct novel contrastive losses with local region negative sampling to jointly optimize the binding interaction and affinity. Extensive experiments show substantial performance gains in comparison to state-of-the-art physics-based and deep learning-based methods on commonly-used benchmark datasets for both binding structure and affinity predictions with variant settings.
18
+
19
+ # 1 Introduction
20
+
21
+ Proteins are the workhorses of human bodies. They have a wide range of interaction partners, small molecules, other proteins, and DNA/RNA, for example. In this paper, we focus on drug-like small molecules as the interaction partners for proteins. The words ligands, drugs, small molecules and compounds are used interchangeably throughout the paper. Small molecules activate or inhibit activities of target proteins through mostly non-covalent interactions. In 2021, FDA approved 60 new drugs, among which 36 were small molecules Kinch et al. [2022]. Understanding the mechanismof-actions and off-target effects of drug molecules typically requires analyzing the structures of the related protein-ligand complexes Boopathi et al. [2021], Xie et al. [2011], but solving the complex structure experimentally is a an extremely challenging task. Despite tremendous effort spent on this topic over the last 50 years, only about 19,000 protein-ligand complex structures have been solved experimentally using $\mathbf { X }$ -ray, Cryo-EM or NMR Liu et al. [2015]. On the other hand, the estimated chemical space of drug is $\mathrm { 1 0 ^ { 6 \bar { 0 } } }$ and estimated number of unique proteins in human body is at least 20, 000, making the number of possible protein-ligand complex far exceeding the number of experimentally solved structures Reymond et al. [2010], Ponomarenko et al. [2016].
22
+
23
+ On the computational side, molecular docking is a commonly-used method for predicting the proteinligand complex structures the corresponding binding affinities Trott and Olson [2010], Friesner et al. [2004], Ackloo et al. [2022], Gentile et al. [2022]. Generally, the docking process involves three main stages: (1) locating favorable binding sites given a protein target; (2) sampling the ligand conformation as well as its position and orientation within these sites; (3) scoring and ranking the conformations of the complex using physics-inspired empirical energy functions to refine the structures and assess protein-ligand binding affinity. Due to its good interpretability and usability, docking has been integrated in drug development process for a long time and a number of successful cases have been reported Anderson [2003]. However, most open-source docking packages use atomlevel pairwise scoring functions, limiting the capacity to model the many-body effects. Moreover, they need to sample a large range of possible ligand poses and protein side-chain conformations, which leads to relatively high computational cost Trott and Olson [2010], Jain [2006].
24
+
25
+ To overcome these challenges, we propose a two-stage deep learning framework to neuralize the molecular docking process and predict the binding structures with better accuracy and lower computational cost. In the first stage, we segment the whole protein into functional blocks and predict their interactions with the ligand, creating an protein-ligand interaction energy landscape using a novel trigonometry-aware architecture. The trigonometry module has enough model capacity to capture many-body effects. In the second stage, we prioritize the crystallized binding structures by constrastively ensuring a weaker binding affinity for non-native interactions. In particular, our model improves the drug-protein binding structure predictions with a combination of (i) a novel trigonometry-aware architecture that jointly infuses trigonometry constraints and excluded-volume effects as inductive biases, (ii) a new divide-and-conquer strategy that constructs the protein-ligand local functional binding pairs in a contrastive manner. By doing so, we create a funnel-shape energy landscape for the inter-molecular interaction, removing the need of extensive sampling Jumper et al. [2021], Jain [2006], Chen et al. [2020a], Onuchic et al. [1997].
26
+
27
+ Our novel method is well-motivated by leveraging prior knowledge from physics and biology. Physically, the inter-molecular trigonometry module, inspired by the intra-molecular Evoformer module used in AlphaFold2 Jumper et al. [2021], ensures that our energy landscape disfavors configurations of protein-ligand complexes that are prohibited by laws of nature, for instance, no two atoms could overlap and the distances between atoms have to satisfy triangle inequality theorem in euclidean geometry. More details on these constraints is shown in section 3.3. Biologically, the functional regions of proteins tend to be more conserved and closely associated with binding De Juan et al. [2013], Glaser et al. [2003], allowing the model to learn critical information and generalize better to unseen proteins.
28
+
29
+ We evaluate our algorithm against several state-of-the-art deep learning and physics-based docking methods on task of binding structure prediction under multiple settings. Compared with baselines, our model increase the fraction of predictions with ligand root-mean-square deviation (RMSD) less than $5 \mathring \mathrm { A }$ by $16 \%$ in re-docking setting, $22 \%$ in self-docking setting, and $42 \%$ in the more difficult newprotein setting. Our model is also capable of predicting binding affinities, achieving better correlations with experimentally-measured values than sequence-based, structure-based and even complex-based methods. We also show that TankBind has the potential to discover novel mechanism-of-actions of drug molecules by identifying unseen protein binding sites.
30
+
31
+ # 2 Related Work
32
+
33
+ Geometric Deep Learning for drug discovery. There has been a surge of interest in integrating geometric priors for representation learning in the domain of drug discovery Jumper et al. [2021], Baek et al. [2021], Jing et al. [2021], Ganea et al. [2021], Jin et al. [2021], Ingraham et al. [2019], AlQuraishi [2019], Schütt et al. [2017], Somnath et al. [2021]. Recent researches have incorporated geometric information and symmetry properties of the input signals to improve the spatial perception of the learned representations. These works have been shown great potential in various applications like protein structure modeling Jumper et al. [2021], Baek et al. [2021], Jing et al. [2021], Ganea et al. [2021], molecular low-energy generation prediction Shi et al. [2021], Xu et al. [2022], Méndez-Lucio et al. [2021], property/function prediction Schütt et al. [2017], Somnath et al. [2021] and molecule design Jin et al. [2021], Ingraham et al. [2019]. Among which, AlphaFold 2 achieved outstanding performance in protein structure prediction Jumper et al. [2021], representing the state-of-the-art geometry-aware method. Our work is inspired from this groundbreaking work, adapting it from the intra-molecular structure prediction to the field of predicting the inter-molecular binding structure and binding affinity.
34
+
35
+ ![](images/f16b1a41aa648df27ad37860bf43f1e981fa6c499b9aab1a8677e5a27f44dd2b.jpg)
36
+ Figure 1: Overview of TankBind Model. The whole protein is divided into blocks of radius $2 0 \mathring \mathrm { A }$ , each block is going through the TankBind model along with the drug compound. Both protein blocks and drug compound are modeled as graphs. The block-compound interaction matrix evolved multiple times with additional input based on the distance maps of the protein block and the compound through trigonometry module. Based on the updated interaction embedding, the model predicts the binding affinity of the compound to the blocks and the block-ligand distance maps. A constrastive loss function is used to ensure the native block binds stronger to the compound than decoys.
37
+
38
+ Drug-protein Interaction (DPI) prediction. The goal of DPI prediction is to illustrate the binding structure and binding affinity between protein and ligand. Apart from docking-based approaches Trott and Olson [2010], Friesner et al. [2004], prior machine learning-based works either use complex-free models to predict the binding affinity directly from protein-ligand pairs Wang and Dokholyan [2021], Li et al. [2020], Tsubaki et al. [2019], Gao et al. [2018], Karimi et al. [2019], Zheng et al. [2020] or make predictions through complex structure that has been previously obtained by experimental or docking approaches Jiménez et al. [2018], Lim et al. [2019], Morrone et al. [2020]. The former ones are less interpretable while the latter requires data involved in vast experimental costs and labour. More recently, EquiBind Stärk et al. [2022] takes a new approach by directly predicting the key points on both the protein and the compound, and aligning their key points through the ingeniously designed optimal transport loss. However, this method may generate compound structures clashing with the protein structures and currently lacks the capability to predict the binding affinity, limiting its use in drug discovery. In contrast, our approach has a trigonometry module imposing geometry constraints and a state-of-the-art binding affinity prediction capability.
39
+
40
+ # 3 TankBind Model
41
+
42
+ # 3.1 Overview of TankBind model
43
+
44
+ The general protocol of our model is shown in figure 1. The encoding of protein and compound is described in section 3.2. The rationale and implementation of trigonometry module is detailed in section 3.3. The design of loss functions for training is described in section 3.4. The generation of atom coordinates from predicted inter-molecular distance map is introduced in section 3.5.
45
+
46
+ # 3.2 Structural encoders of protein and drug
47
+
48
+ Our model input is the separate structures of a protein and a drug compound, both encoded as graphs. Indices $i , k$ always operate on the residue dimension, $j , k ^ { \prime }$ always on the compound dimension. $n$ is the number of protein nodes and $m$ is the number of compound nodes.
49
+
50
+ Protein. The protein is represented as a proximity 3D graph following Jing et al. [2020]. We denote the protein graph as $\mathcal G ^ { p } = \mathsf { \bar { ( } } \mathcal V ^ { p } , \mathcal E ^ { p } )$ , where each node $\bar { \mathfrak { v } } _ { i } ^ { p } \in \mathcal { V } ^ { p }$ corresponds to an amino acid, and has feature $\mathbf { h } _ { \mathfrak { v } ^ { p } } ^ { ( i ) }$ with both scalar and vector features. Each node also has a position $\mathbf { x } _ { i } ^ { p } \in \mathbb { R } ^ { 3 }$ equal to the Cartesian coordinate of $C _ { \alpha _ { i } }$ . An edge $\mathfrak { e } _ { i k } ^ { p }$ exists if $\mathfrak { v } _ { k } ^ { p }$ is among the 30 nearest neighbors of $\mathfrak { v } _ { i } ^ { p }$ . Each edge ${ \mathfrak { e } } _ { i k } ^ { p } \in { \mathcal { E } } ^ { p }$ also encodes both the scalar and the vector features. We then apply the geometric vector perceptrons (GVP) Jing et al. [2020, 2021] to embed the protein and arrive at feature $\mathbf { h } ^ { p } \in \mathbb { R } ^ { n \times s }$ after graph propagation, where $n$ is the number of nodes and $s$ is the embedding size.
51
+
52
+ To implicitly model side-chain flexibility, we choose a residue-level representation ignoring the finer details of protein structure, separating our method from other methods that use all-atoms or surface vertexes representation Jiang et al. [2021], Gainza et al. [2020]. Also, as shown by Jumper et al. [2021, 2018], residue-level embedding is enough to infer the side-chain conformation.
53
+
54
+ Motivated by protein co-evolution De Juan et al. [2013] and divide-and-conquer theory, the protein graph, $\mathcal G ^ { p }$ , is further divided into subgraphs $\mathcal { G } ^ { p ^ { \prime } }$ . Each subgraph $\mathcal G ^ { p ^ { \prime } }$ includes all the $\mathfrak { v } _ { i } ^ { p }$ and $\mathfrak { e } _ { i j } ^ { p }$ inside the functional block. The subgraph is denoted as $\mathcal { G } ^ { p ^ { \prime } } = ( \{ \mathfrak { v } _ { i } ^ { p } , \mathfrak { e } _ { i k } ^ { p } \} \ | \| \mathbf { x } _ { i } ^ { p } - \mathbf { x } _ { o } \| \leq 2 0 \mathring { \mathrm { A } }$ , $\| \mathbf { x } _ { k } ^ { p } - \mathbf { x } _ { o } \| \leq$ $2 0 \mathring \mathrm { A } )$ , where $\mathbf { x } _ { o }$ is the center of the functional block predicted by a widely-used ligand-agnostic method, P2rank (published in 2018)Krivák and Hoksza [2018]. Justification for the size of radius and use of P2rank is described in appendix G.
55
+
56
+ Drug compound. The drug compound is represented as a graph using TorchDrug toolkit Zhu et al. [2022]. The compound graph is denoted as $\mathcal G ^ { c } = ( \mathcal V ^ { c } , \mathcal E ^ { c } )$ where each node ${ \mathfrak { v } } _ { j } ^ { c } \in \mathcal { V } ^ { c }$ corresponds to a heavy atom (non-hydrogen atom), and has feature $\mathbf { h } _ { \mathfrak { v } ^ { c } } ^ { ( j ) }$ and each edge ${ \mathfrak { e } } _ { j k ^ { \prime } } ^ { c }$ has feature $\mathbf { h } _ { \mathfrak { e } ^ { c } } ^ { ( j k ^ { \prime } ) }$ . We use Graph Isomorphism Network (GIN) $\mathrm { X u }$ et al. [2018] to embed the compound and arrive at feature $\mathbf { h } ^ { c } \in \mathbb { R } ^ { m \times s }$ after graph propagation, where $m$ is the number of heavy atoms and $s$ is the embedding size.
57
+
58
+ # 3.3 Details of trigonometry module
59
+
60
+ The compound feature, $\mathbf { h } ^ { c }$ , and the protein block feature, $\mathbf { h } ^ { p }$ , are used to form the initial interaction embedding $\mathbf { z } ^ { ( 0 ) } \in \mathbb { R } ^ { n \times m \times s }$ , ${ \bf z } _ { i j } ^ { ( 0 ) } = { \bf h } _ { i } ^ { p } \odot { \bf h } _ { j } ^ { c }$ . The interaction embedding will be further updated with pair distance map of protein nodes, $D _ { i k } ^ { p } = \| \dot { \mathbf { x } } _ { i } ^ { p } - \mathbf { x } _ { k } ^ { p } \|$ and pair distance map of compound nodes, $D _ { j k ^ { \prime } } ^ { c } = \left\| \mathbf { x } _ { j } ^ { c } - \mathbf { x } _ { k ^ { \prime } } ^ { c } \right\|$ .
61
+
62
+ The rationale for including both the pair distance map of the protein nodes and the pair distance map of the compound nodes in updating the protein-compound interaction embedding is explained with two simplified examples. As shown in the upper part of figure 2, if a protein node A is in close proximity with compound node B, then compound node C will not be in contact with node A due to the large distance constraint between node B and C. Distance constraint between compound nodes B and D could also force a node $\mathrm { D }$ to be in close contact with protein node A.
63
+
64
+ To build this observation of trigonometry constraints into our model, we design the following module to update the interaction embedding, in layer $\ell .$ , $\bar { \forall } ( i , j )$ :
65
+
66
+ ![](images/1e5c49815114f48a1860fda80030b01e5e0711a29a132c0141bf683ed5540bbd.jpg)
67
+ Figure 2: Rationale for including trigonometry module. Upper: Protein node in square, compound nodes in circles. Lower: Trigonometry module ensures that the interaction between protein node $i$ and compound node $j$ depends on all protein and compound nodes $k , k ^ { \prime }$ .
68
+
69
+ $$
70
+ \widetilde { \mathbf { z } } _ { i j } ^ { ( \ell ) } = \mathbf { z } _ { i j } ^ { ( \ell ) } + \Phi \big ( \sum _ { k = 1 } ^ { n } \mathbf { p } _ { i k } \mathbf { t } _ { k j } ^ { ( \ell ) } + \sum _ { k ^ { \prime } = 1 } ^ { m } \mathbf { t } _ { i k ^ { \prime } } ^ { \prime ( \ell ) } \mathbf { c } _ { k ^ { \prime } j } \big ) \odot \mathbf { g } \big ( \mathbf { z } _ { i j } ^ { ( \ell ) } \big )
71
+ $$
72
+
73
+ where $\mathbf { p } _ { i k } = \phi ( D _ { i k } ^ { p } )$ is the linear embedding of encoded pair distance between protein nodes. $\mathbf { p } \in$ $\mathbb { R } ^ { n \times n \times s }$ , $n$ is the number of nodes in protein block, $s$ is the embedding size. ${ \bf c } _ { j k ^ { \prime } } = \phi ( D _ { j k ^ { \prime } } ^ { c } )$ is the linear embedding of encoded pair distance between compound nodes. $\mathbf { c } \in \mathbb { R } ^ { m \times m \times s }$ , $m$ is the number of compound nodes. t(ℓ)ij and t′(ℓ)ij are the same gated linear transformations of $\mathbf { z } _ { i j } ^ { ( \ell ) }$ but with nonared parameters, $\mathbf t _ { i j } ^ { ( \ell ) } = \mathrm { L i n e a r } ( \mathbf z _ { i j } ^ { ( \ell ) } ) \odot \mathbf { g } ( \mathbf z _ { i j } ^ { ( \ell ) } ) , \mathbf t ^ { ( \ell ) } \in \mathbb { R } ^ { n \times m \times s } , \mathbf { g } ( \mathbf z _ { i j } ^ { ( \ell ) } ) = \mathrm { s i g m o i d } ( \mathrm { L i n e a r } ( \mathbf z _ { i j } ^ { ( \ell ) } ) ) ,$ $\Phi$ is a layernorm function followed by a linear transformation.
74
+
75
+ Another type of physical constraint need to be take into consideration is the excluded-volume (Van Der Waals) and saturation effect. As shown in the upper figure 2, if protein node A forms a strong interaction, hydrogen bonding for example, with compound node B, then node $\mathbf { D }$ is unlikely to form the same type of interaction with node A because node A has limited number of hydrogen donors or acceptors. To account for these effects, we designed a self-attention module to modulate the interaction between a protein node and all compound nodes by taking the whole interaction between this protein node and all compound nodes into consideration.
76
+
77
+ $$
78
+ \begin{array} { r l } & { \dot { \mathbf { z } } _ { i j } ^ { ( \ell ) } = \tilde { \mathbf { z } } _ { i j } ^ { ( \ell ) } + \Phi ( \mathrm { c o n c a t } _ { h } \big ( \displaystyle \sum _ { k ^ { \prime } = 1 } ^ { m } ( w _ { i j k ^ { \prime } } ^ { ( \ell ) h } \mathbf { v } _ { i k ^ { \prime } } ^ { ( \ell ) h } ) \odot \mathbf { g } ^ { h } ( \tilde { \mathbf { z } } _ { i j } ^ { ( \ell ) } ) \big ) ) } \\ & { w _ { i j k ^ { \prime } } ^ { ( \ell ) h } = \mathrm { s o f t m a x } _ { k ^ { \prime } } ( \mathbf { q } _ { i j } ^ { ( \ell ) h ^ { \top } } \mathbf { k } _ { i k ^ { \prime } } ^ { ( \ell ) h } ) } \end{array}
79
+ $$
80
+
81
+ , where q(ℓ)ij $\mathbf { q } _ { i j } ^ { ( \ell ) h } , \mathbf { k } _ { i j } ^ { ( \ell ) h } , \mathbf { v } _ { i j } ^ { ( \ell ) h }$ are linear transformation of $\tilde { \mathbf { z } } _ { i j } ^ { ( \ell ) }$ , $h$ is number of attention heads. Function $\mathbf { g } ^ { h }$ is the standard $\mathbf { g }$ with reshaping the embedding into heads at the end, is a linear transformation.
82
+
83
+ Lastly, a non-linear transition module is added to transit the interaction embedding to the next layer through multilayer perceptron, z(ℓij $\mathbf z _ { i j } ^ { ( \ell + 1 ) } = \mathbf { M L P } ( \dot { \mathbf z } _ { i j } ^ { ( \ell ) } )$ . The whole trigonometry module is composed of three consecutive parts, the trigonometry update, the self-attention modulation, and the non-linear transition module. Layernorm is applied on every input $\mathbf { z } _ { i j } ^ { ( \ell ) }$ and a $25 \%$ dropout is applied to the trigonometry update and self-attention modulation during training. The final outputs, drug-protein binding affinity, $\begin{array} { r } { \hat { a } = \sum _ { i = 1 } ^ { n } \sum _ { j = 1 } ^ { m } } \end{array}$ Linear $( \mathbf { z } _ { i j } ^ { ( L ) } )$ , and inter-molecular distance map, Dpredij = $D _ { i j } ^ { p r e d } = \mathbf { g } ( \mathbf { z } _ { i j } ^ { ( L ) } ) \mathrm { L i n e a r } ( \mathbf { z } _ { i j } ^ { ( L ) } )$ , are predicted directly based on the last layer embedding $\mathbf { z } _ { i j } ^ { ( L ) }$ , where $L$ is the number of module stacks.
84
+
85
+ # 3.4 Design of binding interaction and affinity loss functions
86
+
87
+ Many previous works model the interaction between compound and protein by only preserving the interaction region, residues that far away are ignored Townshend et al. [2020], Méndez-Lucio et al. [2021]. On the positive side, the computation and memory demand for characterize the interaction between protein and the drug compound is greatly reduced by focusing on regional interaction. But the fact of not binding to alternative binding sites is also a valuable information. By the nature of crystallization, if a protein-compound complex could be successfully crystallized, other possible binding sites on this protein definitely bind less strongly than the native binding site to the compound, therefore, those other binding sites could be used as high-valued decoys. Based on this observation, we designed a max-margin constrastive affinity loss, equation 4, following the idea of Hadsell et al. [2006]. Such that the compound’s predicted affinity, $\hat { a }$ , to the decoys is less than the experimentally measured affinity, $a$ , by a margin value, $\epsilon$ .
88
+
89
+ $$
90
+ \mathcal { L } _ { \mathrm { a f f i n i t y } } ( \hat { a } _ { \zeta } , a ) = \mathbb { 1 } ( \zeta ) ( \hat { a } _ { \zeta } - a ) ^ { 2 } + ( 1 - \mathbb { 1 } ( \zeta ) ) \operatorname* { m a x } ( 0 , \hat { a } _ { \zeta } - ( a - \epsilon ) ) ^ { 2 }
91
+ $$
92
+
93
+ where $\hat { a } _ { \zeta }$ is the predicted affinity to block $\zeta$ , and indicator function $\mathbb { 1 } ( \zeta ) = 1$ when block $\zeta$ encloses the native ligand, and $\mathbb { 1 } ( \zeta ) = 0$ otherwise. We, therefore, take full use of information stored in the whole protein instead of only the native binding region. We also include a mean squared erorr (MSE) loss for native interaction distance map, $\begin{array} { r } { \mathcal { L } _ { \mathrm { d i s t a n c e } } = \mathbb { 1 } ( \zeta ) \frac { 1 } { n m } \sum _ { i = 1 } ^ { n } \sum _ { j = 1 } ^ { m } ( D _ { i j } ^ { p r e d } - D _ { i j } ) ^ { 2 } } \end{array}$ . The overall training objective of TankBind is: $\mathcal { L } = \mathcal { L } _ { \mathrm { a f f u n i t y } } + \mathcal { L } _ { \mathrm { d i s t a n c t } }$ e .
94
+
95
+ # 3.5 Generation of drug coordinates based on predicted inter-molecular distance map.
96
+
97
+ The Cartesian coordinates, $\big \{ \hat { \mathbf { x } } _ { j } ^ { c } \big \}$ , of the heavy atoms of a drug compound could be deduced analytically based on the predicted inter-molecular distance matrix, $D _ { i j } ^ { p r e d }$ , the coordinates of protein nodes, $\{ \mathbf { x } _ { i } ^ { p } \}$ , and the pair distance matrix of compound nodes, $D _ { j k ^ { \prime } } ^ { c }$ Masters et al. [2022], Hoffmann and Noé [2019]. But since predicted distance matrix contains noise, we take a numerical approach Masters et al. [2022], Zsoldos et al. [2007]. By minimizing the total loss, $\mathcal { L } _ { \mathrm { g e n e r a t i o n } }$ , which consists of two parts, the interaction loss and the compound configuration loss, we could derive the coordinates
98
+
99
+ Table 1: Blind self-docking. All models take a pair of ligand structure (generated by RDKit) and protein structure as input, trying to predict the atom coordinates of the ligand after binding. In blind docking, the protein binding site is assumed unknown. Test set is composed of 363 protein-ligand structure crystallized after 2019 curated by PDBbind database. Details about model runtime and the number of model parameters are in appendix C
100
+
101
+ <table><tr><td></td><td colspan="4">Ligand RMSD Percentiles ↓</td><td colspan="2">% Below Threshold</td><td colspan="4">Centroid Distance Percentiles↓</td><td colspan="2">% Below Threshold 个</td></tr><tr><td>Methods</td><td>25%</td><td>50%</td><td>75%</td><td>Mean</td><td>2A</td><td>个 5A</td><td>25%</td><td>50%</td><td>75%</td><td>Mean</td><td>2A</td><td>5A</td></tr><tr><td>QVINA-W</td><td>2.5</td><td>7.7</td><td>23.7</td><td>13.6</td><td>20.9</td><td>40.2</td><td>0.9</td><td>3.7</td><td>22.9</td><td>11.9</td><td>41.0</td><td>54.6</td></tr><tr><td>GNINA</td><td>2.8</td><td>8.7</td><td>22.1</td><td>13.3</td><td>21.2</td><td>37.1</td><td>1.0</td><td>4.5</td><td>21.2</td><td>11.5</td><td>36.0</td><td>52.0</td></tr><tr><td>SMINA</td><td>3.8</td><td>8.1</td><td>17.9</td><td>12.1</td><td>13.5</td><td>33.9</td><td>1.3</td><td>3.7</td><td>16.2</td><td>9.8</td><td>38.0</td><td>55.9</td></tr><tr><td>GLIDE(c.)</td><td>2.6</td><td>9.3</td><td>28.1</td><td>16.2</td><td>21.8</td><td>33.6</td><td>0.8</td><td>5.6</td><td>26.9</td><td>14.4</td><td>36.1</td><td>48.7</td></tr><tr><td>VINA</td><td>5.7</td><td>10.7</td><td>21.4</td><td>14.7</td><td>5.5</td><td>21.2</td><td>1.9</td><td>6.2</td><td>20.1</td><td>12.1</td><td>26.5</td><td>47.1</td></tr><tr><td>EQUIBIND-U</td><td>3.3</td><td>5.7</td><td>9.7</td><td>7.8</td><td>7.2</td><td>42.4</td><td>1.3</td><td>2.6</td><td>7.4</td><td>5.6</td><td>40.0</td><td>67.5</td></tr><tr><td>EQUIBIND</td><td>3.8</td><td>6.2</td><td>10.3</td><td>8.2</td><td>5.5</td><td>39.1</td><td>1.3</td><td>2.6</td><td>7.4</td><td>5.6</td><td>40.0</td><td>67.5</td></tr><tr><td>TANKBind-R</td><td>2.8</td><td>5.2</td><td>11.2</td><td>9.4</td><td>16.0</td><td>47.9</td><td>1.0</td><td>2.3</td><td>7.7</td><td>7.3</td><td>44.9</td><td>69.4</td></tr><tr><td>TANKBind-C</td><td>2.4</td><td>4.5</td><td>8.4</td><td>8.2</td><td>19.6</td><td>54.8</td><td>0.9</td><td>1.9</td><td>5.4</td><td>6.3</td><td>53.2</td><td>73.3</td></tr><tr><td>TANKBind-P</td><td>2.6</td><td>4.5</td><td>8.1</td><td>8.5</td><td>16.3</td><td>54.0</td><td>0.9</td><td>1.9</td><td>5.2</td><td>6.4</td><td>53.2</td><td>74.4</td></tr><tr><td>TANKBind</td><td>2.4</td><td>4.0</td><td>7.7</td><td>7.4</td><td>19.3</td><td>61.7</td><td>0.9</td><td>1.7</td><td>4.2</td><td>5.5</td><td>56.5</td><td>77.4</td></tr></table>
102
+
103
+ of the docked drug coordinates, $\big \{ \hat { \mathbf { x } } _ { j } ^ { c } \big \}$
104
+
105
+ $$
106
+ \mathcal { L } _ { \mathrm { g e n e r a t i o n } } = \mathcal { L } _ { \mathrm { i n t e r a c i o n } } + \mathcal { L } _ { \mathrm { c o n f i g u r a t i o n } } = \sum _ { i } ^ { n } \sum _ { j } ^ { m } ( | \hat { D } _ { i j } - D _ { i j } ^ { p r e d } | ) + \sum _ { j } ^ { m } \sum _ { k ^ { \prime } } ^ { m } ( | \hat { D } _ { j k ^ { \prime } } ^ { c } - D _ { j k ^ { \prime } } ^ { c } | )
107
+ $$
108
+
109
+ $$
110
+ \hat { D } _ { i j } = \big \| \mathbf x _ { i } ^ { p } - \hat { \mathbf x } _ { j } ^ { c } \big \| , \hat { D } _ { j k ^ { \prime } } ^ { c } = \big \| \hat { \mathbf x } _ { j } ^ { c } - \hat { \mathbf x } _ { k ^ { \prime } } ^ { c } \big \|
111
+ $$
112
+
113
+ where $n$ is the number of protein nodes, and $m$ is number of compound nodes, and $\{ \mathbf { x } _ { j } ^ { p } \}$ are the Cartesian coordinates of protein nodes. All inter-molecular distances are clamped to have an upper bound of $1 0 \mathring \mathrm { A }$ to focus on the direct interaction. In self-docking setting, when the compound configuration is unknown, we add a local atomic structures (LAS) maskflexibility while enforcing basic geometric constraint, $\begin{array} { r } { \mathcal { L } _ { \mathrm { c o n f i g u r a t i o n } } = \sum _ { j } ^ { m } \sum _ { k ^ { \prime } } ^ { m } \mathbb { 1 } ( j , k ^ { \prime } ) ( | \hat { D } _ { j k ^ { \prime } } ^ { c } - D _ { j k ^ { \prime } } ^ { c } | ) } \end{array}$ where $\mathbb { 1 } ( j , k ^ { \prime } ) = 1$ when compound atom $j$ and are connected by connected by a bond, or 2-hop away, or in the same ring structure, and $\mathbb { 1 } ( j , k ^ { \prime } ) = 0$ otherwise Stärk et al. [2022], Trott and Olson [2010]. For every test protein-ligand pair, TankBind predicts the binding affinity of the ligand to all segmented functional blocks and chooses the one with strongest affinity to generate the binding structures.
114
+
115
+ # 4 Evaluation
116
+
117
+ # 4.1 Protein-ligand binding structure prediction
118
+
119
+ Dataset. We used publicly available PDBbind v2020 dataset Liu et al. [2015] which has the structures of 19443 protein-ligand complexes along with their experimentally measured binding affinity. PDBbind is a database curated based on the Protein Data Bank (PDB) Burley et al. [2021]. We followed the same time split as defined in EquiBind paper Stärk et al. [2022] in which the training and validation data are the protein-ligand complex structures deposited before 2019 and the test set is the structures deposited after 2019. After removing a few structures that unable to process using RDKit from the training set, we had 17787 structures for training, 968 for validation and 363 for testingLandrum et al. [2013]. We also reduced the possibility of encountering equally valid binding sites by removing chains that have no atom within $1 0 \mathring \mathrm { A }$ from any atom of the ligand following the protocol described in Stärk et al. [2022].
120
+
121
+ Baselines. We compared TankBind with the most widely-used docking method AutoDock VinaTrott and Olson [2010] and the recent proposed geometry-based DL method EquiBind Stärk et al. [2022]. We also included four popular docking methods QVina-W, GINAMcNutt et al. [2021], SMINAKoes et al. [2013] and GLIDEFriesner et al. [2004] as listed in Stärk et al. [2022].
122
+
123
+ Table 2: Blind self-docking for unseen receptors. All models evaluated on 142 crystallized proteincompound structures where the proteins have not been observed in training set.
124
+
125
+ <table><tr><td rowspan="3"></td><td colspan="4">Ligand RMSD Percentiles ↓</td><td colspan="2">%Below</td><td colspan="4">Centroid Distance Percentiles ↓</td><td rowspan="2" colspan="2">% Below Threshold</td></tr><tr><td colspan="4"></td><td colspan="2">个 Threshold</td><td colspan="4"></td></tr><tr><td>25%</td><td>50%</td><td>75%</td><td>Mean</td><td>2A</td><td>5A</td><td>25%</td><td>50%</td><td>75%</td><td>Mean</td><td>2A</td><td>5A</td></tr><tr><td>QVINA-W</td><td>3.4</td><td>10.3</td><td>28.1</td><td>16.9</td><td>15.3</td><td>31.9</td><td>1.3</td><td>6.5</td><td>26.8</td><td>15.2</td><td>35.4</td><td>47.9</td></tr><tr><td>GNINA</td><td>4.5</td><td>13.4</td><td>27.8</td><td>16.7</td><td>13.9</td><td>27.8</td><td>2.0</td><td>10.1</td><td>27.0</td><td>15.1</td><td>25.7</td><td>39.5</td></tr><tr><td>SMINA</td><td>4.8</td><td>10.9</td><td>26.0</td><td>15.7</td><td>9.0</td><td>25.7</td><td>1.6</td><td>6.5</td><td>25.7</td><td>13.6</td><td>29.9</td><td>41.7</td></tr><tr><td>GLIDE</td><td>3.4</td><td>18.0</td><td>31.4</td><td>19.6</td><td>19.6</td><td>28.7</td><td>1.1</td><td>17.6</td><td>29.1</td><td>18.1</td><td>29.4</td><td>40.6</td></tr><tr><td>VINA</td><td>7.9</td><td>16.6</td><td>27.1</td><td>18.7</td><td>1.4</td><td>12.0</td><td>2.4</td><td>15.7</td><td>26.2</td><td>16.1</td><td>20.4</td><td>37.3</td></tr><tr><td>EQUIBIND-U</td><td>5.7</td><td>8.8</td><td>14.1</td><td>11.0</td><td>1.4</td><td>21.5</td><td>2.6</td><td>6.3</td><td>12.9</td><td>8.9</td><td>16.7</td><td>43.8</td></tr><tr><td>EQUIBIND</td><td>5.9</td><td>9.1</td><td>14.3</td><td>11.3</td><td>0.7</td><td>18.8</td><td>2.6</td><td>6.3</td><td>12.9</td><td>8.9</td><td>16.7</td><td>43.8</td></tr><tr><td>TANKBind-R</td><td>3.6</td><td>6.9</td><td>17.0</td><td>12.6</td><td>5.6</td><td>35.2</td><td>1.3</td><td>3.6</td><td>15.7</td><td>10.3</td><td>35.2</td><td>58.5</td></tr><tr><td>TANKBind-C</td><td>3.4</td><td>5.5</td><td>9.8</td><td>9.9</td><td>9.2</td><td>43.0</td><td>1.1</td><td>2.6</td><td>8.1</td><td>7.9</td><td>46.5</td><td>65.5</td></tr><tr><td>TANKBind-P</td><td>3.3</td><td>5.5</td><td>10.9</td><td>11.2</td><td>5.6</td><td>45.1</td><td>1.3</td><td>2.3</td><td>7.9</td><td>9.1</td><td>47.9</td><td>66.9</td></tr><tr><td>TANKBind</td><td>2.9</td><td>4.7</td><td>8.8</td><td>9.1</td><td>4.9</td><td>55.6</td><td>1.3</td><td>2.3</td><td>4.8</td><td>7.0</td><td>45.1</td><td>75.4</td></tr></table>
126
+
127
+ Evaluation metrics. We follow prior work Stärk et al. [2022] and use ligand root-mean-square deviation (RMSD) of atomic positions and centroid distance to compare predicted binding structures with ground-truths. The Ligand RMSD calculates the normalized Frobenius norm of the two corresponding matrices of ligand coordinates. The centroid distance is defined as the the distance between the averaged 3D coordinates of the predicted and ground-truth bound ligand atoms, indicating the model capability of identifying correct binding region. Hydrogens are not involved in the calculation.
128
+
129
+ Performance in blind flexible self-docking We start with a real-world blind self-docking experiment, in which the ligand conformation is not fixed, and the result of re-docking experiment, in which the native ligand conformation is given, is reported in Appendix A. As shown in the table 1, TankBind achieves state-of-the-art performance, outperforming geometry DL-based model EquiBind. This advantage is particularly evident in the top $2 5 \%$ and top $50 \%$ ligand RMSD, which allows our method to predict $22 \%$ more qualified (below Threshold $5 \mathring \mathrm { A }$ ) binding poses than EquiBind. This results are also consistent in the metrics of centroid distance, demonstrating that our method also has a clear advantage in the identification of binding region. Even though GLIDE (commercial) and Autodock Vina are established docking software with more than a decade of continuous development, our model remarkably frequently outperforms them. At the same time, we are orders of magnitude faster than them, and on the same level as EquiBind (Appendix C). In addition, we explore the possible of TankBind-R, where we randomly segment the protein, TankBind-P, where we only doing the summation over protein nodes in equation 1, and TankBind-C, where we only sum over compound nodes. The performance reduction on the these variants supports our view that trigonometry message passing between proteins and ligand and segmentation choice are critical to the prediction of binding structures.
130
+
131
+ Performance in self-docking unseen protein We next focus on the new protein setting, in which the tested proteins have not been observed in the training set. Table 2 shows that Tankbind leads to larger improvements over EquiBind and docking methods with regard to ligand-RMSD and centriod distance.This is in line with our expectation that TankBind has better generalization ability due to the physical-inspired trigonometry module and explicit consideration of conservative functional blocks. In this setting, as shown in Figure 3 and table 2, for fractions smaller than $2 \mathring \mathrm { A }$ , 5Å and $1 5 \mathring \mathrm { A }$ , the performance between EquiBind and other docking method are comparable, while TankBind is always better by a large margin, further confirming the effectiveness of our method and indicating that the proposed strategy has practical values for the virtual screening of new proteins.
132
+
133
+ ![](images/433506758c93192d844b3ef47d777cc94fd12a2a093fa8cc235eab2d96c11c16.jpg)
134
+ Figure 3: Estimator of the Cumulative Distribution Function (ECDF) plot for ligand RMSD (left) and Centroid Distance (right) from result evaluated on new receptors subset. The x axis of the figure stops at $1 5 \mathring \mathrm { A }$ because comparison for larger RMSD is less meaningful when the predicted location of the ligand is away from the true binding site, a RMSD of $1 5 \mathring \mathrm { A }$ is not better than RMSD of $5 0 \mathring \mathrm { A }$ .
135
+
136
+ <table><tr><td>Methods</td><td colspan="3">Ligand↓Centroid↓Below2A↑Below5A↑</td></tr><tr><td>w/o P2Rank</td><td>9.37</td><td>7.30 44.90</td><td>69.42</td></tr><tr><td>w/o Trig</td><td>8.73</td><td>6.44 44.08</td><td>74.93</td></tr><tr><td>TAPE</td><td>8.81</td><td>6.89 50.69</td><td>73.00</td></tr><tr><td>GAT</td><td>8.27</td><td>6.23 56.47</td><td>78.51</td></tr><tr><td>TankBind-P</td><td>8.47</td><td>6.44 53.17</td><td>74.38</td></tr><tr><td>TankBind-C</td><td>8.20 6.27</td><td>53.17</td><td>73.28</td></tr><tr><td>Origin</td><td>7.43</td><td>5.51 56.47</td><td>77.41</td></tr></table>
137
+
138
+ Table 4: Ablation results. We listed four main metrics here, a complete table is in appendix E
139
+
140
+ <table><tr><td>Methods</td><td colspan="3">RMSE↓Pearson↑Spearman↑MAE↓</td></tr><tr><td>TransCPI</td><td>1.741 0.576</td><td>0.540</td><td>1.404</td></tr><tr><td>MONN</td><td>1.438 0.624</td><td>0.589</td><td>1.143</td></tr><tr><td>PIGNet※</td><td>2.640 0.511</td><td>0.489</td><td>2.110</td></tr><tr><td>IGN</td><td>1.433 0.698</td><td>0.641</td><td>1.169</td></tr><tr><td>HOLOPROT</td><td>1.546 0.602</td><td>0.571</td><td>1.208</td></tr><tr><td>STAMPDPI</td><td>1.658 0.545</td><td>0.411</td><td>1.325</td></tr><tr><td>TANKBind</td><td>1.346 0.726</td><td>0.703</td><td>1.070</td></tr></table>
141
+
142
+ Table 3: Binding affinity prediction. TankBind achieves SOTA on all four metrics.
143
+
144
+ # 4.2 Protein-ligand binding affinity prediction
145
+
146
+ TankBind is also capable of predicting protein-ligand binding affinity because of the constrastive affinity loss function. Since we segmented the whole protein into protein blocks, the predicted binding affinity of ligand to the whole protein is equal to the binding affinity to the one protein block that predicted to bind strongest with the ligand. To demonstrate the ability, we compared TankBind with the state-of-the-art binding affinity prediction models.
147
+
148
+ Dataset. We split the dataset into training, test and validation splits based on the same time split described earlier. The experimentally measured affinity data in PDBbind dataset has three different names, depending on the exact experiment setups, $50 \%$ inhibiting concentration (IC50), inhibition constant $( K _ { i } )$ , and dissociation constant $( K _ { D } )$ , all converted to the unit of molar concentration. Similar to previous methods Somnath et al. [2021], Townshend et al. [2020], we predict negative log-transformed binding affinity.
149
+
150
+ Baselines and evaluation metrics. We compare TankBind against two state-of-the-art sequencebased methods, TransformerCPI Chen et al. [2020b] and MONN Li et al. [2020], two complex-based methods, IGN Jiang et al. [2021] and PIGNet Moon et al. [2022] both requiring prior knowledge of the inter-molecular structure to predict affinity, and two structure-based methods, HOLOPTOT Somnath et al. [2021] and STAMPDPI Wang et al. [2022]. For evaluating various methods, we use four metrics – root mean squared error (RMSE), Pearson correlation coefficient, Spearman correlation coefficient and mean absolute error (MAE). We also include the mean and standard deviation across 3 experimental runs in appendix D.
151
+
152
+ ![](images/eff82a8928b58a7d62890bdc17d1250163e22dccc27770dfac1bde99f15855f3.jpg)
153
+ Figure 4: (a) An example of TankBind identifying an unseen binding site. The protein is shown in white, co-crystallized compounds of three PDBs in the training set is shown in purple. The ligand of 6K1S is shown in green. TankBind is able to find this correct pose for the compound, shown in red, while the other two, Vina in orange, and Equibind in cyan, place the compound away from the true binding site. (b) For PDB 6QRG, both protein and compound have not been seen in the training set. But TankBind still find the correct pose. Crystallized ligand colored in green, TankBind prediction in red, EquiBind in cyan and Vina result in organ.
154
+
155
+ Result As shown in Table 3, our model obtains the best performance in PDBbind test set, consistently outperforms SOTA binding affinity prediction methods. Note that even without the prior interaction information, TankBind also achieves better result than complex-based methods (PIGNET and IGN), proving that the predicted binding structural information provided considerable gain to the affinity prediction task.
156
+
157
+ # 4.3 Ablation study
158
+
159
+ We conducted ablation studies to investigate factors that influence the performance of proposed TankBind framework. As shown in Table 4, the original version of TankBind with the trigonometry message passing between protein and ligand shows the best performance among all architectures. Replacing the P2rank with a randomly split of blocks performed the worst, which verifies our hypothesis that functional block segmentation can improve generalization. Simple architecture substitutions for protein (TAPE) Rao et al. [2019] and molecular representation (GAT) Velickovi ˇ c´ et al. [2017] decrease slightly the model performance. Replacing the intra-trigonometry module with the uni-modal variants (TankBind-P and TankBind-C) both caused noticeable decreases in performances.
160
+
161
+ # 4.4 Case studies
162
+
163
+ TankBind correctly identifies an unseen binding site for a new drug compound. As a representative case, in PDB 6K1S, a seen protein binds to a new drug compound at a site that has not been observed before. This protein has three co-crystallized complex structures in the training set, PDB 4X60, 4X61, 4X63. As shown in the left of figure 4, our method, shown in red, aligns well with the true ligand, shown in green, despite our method has never seen any compound locates at this site before. While other two methods, EquiBind in cyan, Vina in orange identify an incorrect site for this compound. Packages Kalign, Biopython, and Smith-Waterman library are used to systematically analyze the results Lassmann [2020], Cock et al. [2009], Li et al. [2020], Zhao et al. [2013] (see Appendix H).
164
+
165
+ TankBind finds the correct pose when both compound and protein are unseen. We picked two representative examples with both compound and protein are unseen, one, PDB 6QRG, in the right of figure 4 and another, PDB 6KQI, in appendix B. Both PDB 6QRG and PDB 6KQI have max protein similarity below 0.8 (6QRG 0.78, 6KQI 0.57), and max compound similarity below 0.4 (6QRG 0.36, 6KQI 0.27).
166
+
167
+ # 5 Conclusion
168
+
169
+ In this work, we propose a novel binding structure and affinity prediction model, TankBind, that builds trigonometry constraints into the model and explicitly attends to all possible binding sites by segmenting the whole protein into functional blocks. We observe significant improvements on task of binding structure prediction over existing deep learning methods: a $22 \%$ increase in the fraction of prediction below $\bar { 5 } \mathring { \mathrm { A } }$ in ligand RMSD, and a $42 \%$ increase when the proteins have not been observed in the training set. Moreover, we demonstrate that the model is able to predict affinity and outperform SOTA methods on PDBbind. This work opens a new direction for modelling the inter-molecular interaction between protein and drug molecule. Numerous directions for further exploration include incorporating a ligand conformer generation module, enhancing the dataset with AlphaFold-predicted structure and public available SAR data, integrating the segmentation of functional block in an end-to-end manner, and combining the model with protein backbone dynamics modeling to handle larger scale conformation changes induced by drug-protein interactions.
170
+
171
+ # Acknowledgments and Disclosure of Funding
172
+
173
+ We thank Prof.Yuedong Yang, Dr.Leilei Shi, Dr. Jiahui Tong for their helpful discussions; Penglei Wang for his support in binding affinity experiments; Meihui Song for her support in figure drawing. We thank the Guangzhou National Supercomputer Center for providing computational source. S. $\textsf { Z }$ acknowledges support from the National Key R&D Program of China (2020YFB0204803) and National Natural Science Foundation of China (21773313 and 61772566).
174
+
175
+ # References
176
+
177
+ Michael S Kinch, Zachary Kraft, and Tyler Schwartz. 2021 in review: Fda approvals of new medicines. Drug discovery today, 2022.
178
+
179
+ Subramanian Boopathi, Adolfo B Poma, and Ponmalai Kolandaivel. Novel 2019 coronavirus structure, mechanism of action, antiviral drug promises and rule out against its treatment. Journal of Biomolecular Structure and Dynamics, 39(9):3409–3418, 2021.
180
+
181
+ Lei Xie, Li Xie, and Philip E Bourne. Structure-based systems biology for analyzing off-target binding. Current opinion in structural biology, 21(2):189–199, 2011.
182
+
183
+ Zhihai Liu, Yan Li, Li Han, Jie Li, Jie Liu, Zhixiong Zhao, Wei Nie, Yuchen Liu, and Renxiao Wang. Pdb-wide collection of binding data: current status of the pdbbind database. Bioinformatics, 31(3): 405–412, 2015.
184
+
185
+ Jean-Louis Reymond, Ruud Van Deursen, Lorenz C Blum, and Lars Ruddigkeit. Chemical space as a source for new drugs. MedChemComm, 1(1):30–38, 2010.
186
+
187
+ Elena A Ponomarenko, Ekaterina V Poverennaya, Ekaterina V Ilgisonis, Mikhail A Pyatnitskiy, Arthur T Kopylov, Victor G Zgoda, Andrey V Lisitsa, and Alexander I Archakov. The size of the human proteome: the width and depth. International journal of analytical chemistry, 2016, 2016.
188
+
189
+ Oleg Trott and Arthur J Olson. Autodock vina: improving the speed and accuracy of docking with a new scoring function, efficient optimization, and multithreading. Journal of computational chemistry, 31(2):455–461, 2010.
190
+
191
+ Richard A Friesner, Jay L Banks, Robert B Murphy, Thomas A Halgren, Jasna J Klicic, Daniel T Mainz, Matthew P Repasky, Eric H Knoll, Mee Shelley, Jason K Perry, et al. Glide: a new approach for rapid, accurate docking and scoring. 1. method and assessment of docking accuracy. Journal of medicinal chemistry, 47(7):1739–1749, 2004.
192
+
193
+ Suzanne Ackloo, Rima Al-awar, Rommie E Amaro, Cheryl H Arrowsmith, Hatylas Azevedo, Robert A Batey, Yoshua Bengio, Ulrich AK Betz, Cristian G Bologa, John D Chodera, et al. Cache (critical assessment of computational hit-finding experiments): A public–private partnership benchmarking initiative to enable the development of computational methods for hit-finding. Nature Reviews Chemistry, pages 1–9, 2022.
194
+
195
+ Francesco Gentile, Jean Charle Yaacoub, James Gleave, Michael Fernandez, Anh-Tien Ton, Fuqiang Ban, Abraham Stern, and Artem Cherkasov. Artificial intelligence–enabled virtual screening of ultra-large chemical libraries with deep docking. Nature Protocols, pages 1–26, 2022.
196
+
197
+ Amy C Anderson. The process of structure-based drug design. Chemistry & biology, 10(9):787–797, 2003.
198
+
199
+ Ajay N Jain. Scoring functions for protein-ligand docking. Current Protein and Peptide Science, 7 (5):407–420, 2006.
200
+
201
+ John Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Žídek, Anna Potapenko, et al. Highly accurate protein structure prediction with alphafold. Nature, 596(7873):583–589, 2021.
202
+
203
+ Mingchen Chen, Xun Chen, Nicholas P Schafer, Cecilia Clementi, Elizabeth A Komives, Diego U Ferreiro, and Peter G Wolynes. Surveying biomolecular frustration at atomic resolution. Nature communications, 11(1):1–9, 2020a.
204
+
205
+ José Nelson Onuchic, Zaida Luthey-Schulten, and Peter G Wolynes. Theory of protein folding: the energy landscape perspective. Annual review of physical chemistry, 48(1):545–600, 1997.
206
+
207
+ David De Juan, Florencio Pazos, and Alfonso Valencia. Emerging methods in protein co-evolution. Nature Reviews Genetics, 14(4):249–261, 2013.
208
+
209
+ Fabian Glaser, Tal Pupko, Inbal Paz, Rachel E Bell, Dalit Bechor-Shental, Eric Martz, and Nir BenTal. Consurf: identification of functional regions in proteins by surface-mapping of phylogenetic information. Bioinformatics, 19(1):163–164, 2003.
210
+
211
+ Minkyung Baek, Frank DiMaio, Ivan Anishchenko, Justas Dauparas, Sergey Ovchinnikov, Gyu Rie Lee, Jue Wang, Qian Cong, Lisa N Kinch, R Dustin Schaeffer, et al. Accurate prediction of protein structures and interactions using a three-track neural network. Science, 373(6557):871–876, 2021.
212
+
213
+ Bowen Jing, Stephan Eismann, Pratham N Soni, and Ron O Dror. Equivariant graph neural networks for 3d macromolecular structure. arXiv preprint arXiv:2106.03843, 2021.
214
+
215
+ Octavian-Eugen Ganea, Xinyuan Huang, Charlotte Bunne, Yatao Bian, Regina Barzilay, Tommi Jaakkola, and Andreas Krause. Independent se (3)-equivariant models for end-to-end rigid protein docking. arXiv preprint arXiv:2111.07786, 2021.
216
+
217
+ Wengong Jin, Jeremy Wohlwend, Regina Barzilay, and Tommi Jaakkola. Iterative refinement graph neural network for antibody sequence-structure co-design. arXiv preprint arXiv:2110.04624, 2021.
218
+
219
+ John Ingraham, Vikas Garg, Regina Barzilay, and Tommi Jaakkola. Generative models for graphbased protein design. Advances in Neural Information Processing Systems, 32, 2019.
220
+
221
+ Mohammed AlQuraishi. End-to-end differentiable learning of protein structure. Cell systems, 8(4): 292–301, 2019.
222
+
223
+ Kristof Schütt, Pieter-Jan Kindermans, Huziel Enoc Sauceda Felix, Stefan Chmiela, Alexandre Tkatchenko, and Klaus-Robert Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. Advances in neural information processing systems, 30, 2017.
224
+
225
+ Vignesh Ram Somnath, Charlotte Bunne, and Andreas Krause. Multi-scale representation learning on proteins. Advances in Neural Information Processing Systems, 34, 2021.
226
+
227
+ Chence Shi, Shitong Luo, Minkai Xu, and Jian Tang. Learning gradient fields for molecular conformation generation. In International Conference on Machine Learning, pages 9558–9568. PMLR, 2021.
228
+
229
+ Minkai Xu, Lantao Yu, Yang Song, Chence Shi, Stefano Ermon, and Jian Tang. Geodiff: A geometric diffusion model for molecular conformation generation. arXiv preprint arXiv:2203.02923, 2022.
230
+
231
+ Oscar Méndez-Lucio, Mazen Ahmad, Ehecatl Antonio del Rio-Chanona, and Jörg Kurt Wegner. A geometric deep learning approach to predict binding conformations of bioactive molecules. Nature Machine Intelligence, 3(12):1033–1039, 2021.
232
+
233
+ Jian Wang and Nikolay V Dokholyan. Yuel: Compound-protein interaction prediction with high generalizability. bioRxiv, 2021.
234
+
235
+ Shuya Li, Fangping Wan, Hantao Shu, Tao Jiang, Dan Zhao, and Jianyang Zeng. Monn: a multiobjective neural network for predicting compound-protein interactions and affinities. Cell Systems, 10(4):308–322, 2020.
236
+
237
+ Masashi Tsubaki, Kentaro Tomii, and Jun Sese. Compound–protein interaction prediction with end-to-end learning of neural networks for graphs and sequences. Bioinformatics, 35(2):309–318, 2019.
238
+
239
+ Kyle Yingkai Gao, Achille Fokoue, Heng Luo, Arun Iyengar, Sanjoy Dey, and Ping Zhang. Interpretable drug target prediction using deep neural representation. In IJCAI, volume 2018, pages 3371–3377, 2018.
240
+
241
+ Mostafa Karimi, Di Wu, Zhangyang Wang, and Yang Shen. Deepaffinity: interpretable deep learning of compound–protein affinity through unified recurrent and convolutional neural networks. Bioinformatics, 35(18):3329–3338, 2019.
242
+
243
+ Shuangjia Zheng, Yongjian Li, Sheng Chen, Jun Xu, and Yuedong Yang. Predicting drug–protein interaction using quasi-visual question answering system. Nature Machine Intelligence, 2(2): 134–140, 2020.
244
+
245
+ José Jiménez, Miha Skalic, Gerard Martinez-Rosell, and Gianni De Fabritiis. K deep: protein–ligand absolute binding affinity prediction via 3d-convolutional neural networks. Journal of chemical information and modeling, 58(2):287–296, 2018.
246
+
247
+ Jaechang Lim, Seongok Ryu, Kyubyong Park, Yo Joong Choe, Jiyeon Ham, and Woo Youn Kim. Predicting drug–target interaction using a novel graph neural network with 3d structure-embedded graph representation. Journal of chemical information and modeling, 59(9):3981–3988, 2019.
248
+
249
+ Joseph A Morrone, Jeffrey K Weber, Tien Huynh, Heng Luo, and Wendy D Cornell. Combining docking pose rank and structure with deep learning improves protein–ligand binding mode prediction over a baseline docking approach. Journal of chemical information and modeling, 60(9): 4170–4179, 2020.
250
+
251
+ Hannes Stärk, Octavian-Eugen Ganea, Lagnajit Pattanaik, Regina Barzilay, and Tommi Jaakkola. Equibind: Geometric deep learning for drug binding structure prediction. arXiv preprint arXiv:2202.05146, 2022.
252
+
253
+ Bowen Jing, Stephan Eismann, Patricia Suriana, Raphael JL Townshend, and Ron Dror. Learning from protein structure with geometric vector perceptrons. arXiv preprint arXiv:2009.01411, 2020.
254
+
255
+ Dejun Jiang, Chang-Yu Hsieh, Zhenxing Wu, Yu Kang, Jike Wang, Ercheng Wang, Ben Liao, Chao Shen, Lei Xu, Jian Wu, et al. Interactiongraphnet: A novel and efficient deep graph representation learning framework for accurate protein–ligand interaction predictions. Journal of medicinal chemistry, 64(24):18209–18232, 2021.
256
+
257
+ Pablo Gainza, Freyr Sverrisson, Frederico Monti, Emanuele Rodola, D Boscaini, MM Bronstein, and BE Correia. Deciphering interaction fingerprints from protein molecular surfaces using geometric deep learning. Nature Methods, 17(2):184–192, 2020.
258
+
259
+ John M Jumper, Nabil F Faruk, Karl F Freed, and Tobin R Sosnick. Accurate calculation of side chain packing and free energy with applications to protein molecular dynamics. PLoS computational biology, 14(12):e1006342, 2018.
260
+
261
+ Radoslav Krivák and David Hoksza. P2rank: machine learning based tool for rapid and accurate prediction of ligand binding sites from protein structure. Journal of cheminformatics, 10(1):1–12, 2018.
262
+
263
+ Zhaocheng Zhu, Chence Shi, Zuobai Zhang, Shengchao Liu, Minghao Xu, Xinyu Yuan, Yangtian Zhang, Junkun Chen, Huiyu Cai, Jiarui Lu, et al. Torchdrug: A powerful and flexible machine learning platform for drug discovery. arXiv preprint arXiv:2202.08320, 2022.
264
+
265
+ Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
266
+
267
+ Raphael JL Townshend, Martin Vögele, Patricia Suriana, Alexander Derry, Alexander Powers, Yianni Laloudakis, Sidhika Balachandar, Bowen Jing, Brandon Anderson, Stephan Eismann, et al. Atom3d: Tasks on molecules in three dimensions. arXiv preprint arXiv:2012.04035, 2020.
268
+
269
+ Raia Hadsell, Sumit Chopra, and Yann LeCun. Dimensionality reduction by learning an invariant mapping. In 2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR’06), volume 2, pages 1735–1742. IEEE, 2006.
270
+
271
+ Matthew Masters, Amr H Mahmoud, Yao Wei, and Markus Lill. Deep learning model for flexible and efficient protein-ligand docking. In ICLR2022 Machine Learning for Drug Discovery, 2022.
272
+
273
+ Moritz Hoffmann and Frank Noé. Generating valid euclidean distance matrices. arXiv preprint arXiv:1910.03131, 2019.
274
+
275
+ Zsolt Zsoldos, Darryl Reid, Aniko Simon, Sayyed Bashir Sadjad, and A Peter Johnson. ehits: a new fast, exhaustive flexible ligand docking system. Journal of Molecular Graphics and Modelling, 26 (1):198–212, 2007.
276
+
277
+ Stephen K Burley, Charmi Bhikadiya, Chunxiao Bi, Sebastian Bittrich, Li Chen, Gregg V Crichlow, Cole H Christie, Kenneth Dalenberg, Luigi Di Costanzo, Jose M Duarte, et al. Rcsb protein data bank: powerful new tools for exploring 3d structures of biological macromolecules for basic and applied research and education in fundamental biology, biomedicine, biotechnology, bioengineering and energy sciences. Nucleic acids research, 49(D1):D437–D451, 2021.
278
+
279
+ Greg Landrum et al. Rdkit: A software suite for cheminformatics, computational chemistry, and predictive modeling, 2013.
280
+
281
+ Andrew T McNutt, Paul Francoeur, Rishal Aggarwal, Tomohide Masuda, Rocco Meli, Matthew Ragoza, Jocelyn Sunseri, and David Ryan Koes. Gnina 1.0: molecular docking with deep learning. Journal of cheminformatics, 13(1):1–20, 2021.
282
+
283
+ David Ryan Koes, Matthew P Baumgartner, and Carlos J Camacho. Lessons learned in empirical scoring with smina from the csar 2011 benchmarking exercise. Journal of chemical information and modeling, 53(8):1893–1904, 2013.
284
+
285
+ Lifan Chen, Xiaoqin Tan, Dingyan Wang, Feisheng Zhong, Xiaohong Liu, Tianbiao Yang, Xiaomin Luo, Kaixian Chen, Hualiang Jiang, and Mingyue Zheng. Transformercpi: improving compound– protein interaction prediction by sequence-based deep learning with self-attention mechanism and label reversal experiments. Bioinformatics, 36(16):4406–4414, 2020b.
286
+
287
+ Seokhyun Moon, Wonho Zhung, Soojung Yang, Jaechang Lim, and Woo Youn Kim. Pignet: a physics-informed deep learning model toward generalized drug–target interaction predictions. Chemical Science, 13(13):3661–3673, 2022.
288
+
289
+ Penglei Wang, Shuangjia Zheng, Yize Jiang, Chengtao Li, Junhong Liu, Chang Wen, Atanas Patronov, Dahong Qian, Hongming Chen, and Yuedong Yang. Structure-aware multimodal deep learning for drug–protein interaction prediction. Journal of Chemical Information and Modeling, 62(5): 1308–1317, 2022.
290
+
291
+ Roshan Rao, Nicholas Bhattacharya, Neil Thomas, Yan Duan, Peter Chen, John Canny, Pieter Abbeel, and Yun Song. Evaluating protein transfer learning with tape. Advances in neural information processing systems, 32, 2019.
292
+
293
+ Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017.
294
+
295
+ Timo Lassmann. Kalign 3: multiple sequence alignment of large datasets, 2020.
296
+
297
+ Peter JA Cock, Tiago Antao, Jeffrey T Chang, Brad A Chapman, Cymon J Cox, Andrew Dalke, Iddo Friedberg, Thomas Hamelryck, Frank Kauff, Bartek Wilczynski, et al. Biopython: freely available python tools for computational molecular biology and bioinformatics. Bioinformatics, 25(11): 1422–1423, 2009.
md/dev/ZlCpRiZN7n/ZlCpRiZN7n.md ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Attracting and Dispersing: A Simple Approach for Source-free Domain Adaptation
2
+
3
+ Shiqi Yang1, Yaxing Wang2∗, Kai Wang1, Shangling $\mathbf { J u \mathbf { i } ^ { 3 } }$ , Joost van de Weijer1
4
+
5
+ 1 Computer Vision Center, Universitat Autonoma de Barcelona, Barcelona, Spain 2 Nankai University, Tianjin, China 3 Huawei Kirin Solution, Shanghai, China {syang,kwang,joost}@cvc.uab.es, yaxing@nankai.edu.cn, jui.shangling@huawei.com
6
+
7
+ # Abstract
8
+
9
+ We propose a simple but effective source-free domain adaptation (SFDA) method. Treating SFDA as an unsupervised clustering problem and following the intuition that local neighbors in feature space should have more similar predictions than other features, we propose to optimize an objective of prediction consistency. This objective encourages local neighborhood features in feature space to have similar predictions while features farther away in feature space have dissimilar predictions, leading to efficient feature clustering and cluster assignment simultaneously. For efficient training, we seek to optimize an upper-bound of the objective resulting in two simple terms. Furthermore, we relate popular existing methods in domain adaptation, source-free domain adaptation and contrastive learning via the perspective of discriminability and diversity. The experimental results prove the superiority of our method, and our method can be adopted as a simple but strong baseline for future research in SFDA. Our method can be also adapted to source-free open-set and partial-set DA which further shows the generalization ability of our method. Code is available in https://github.com/Albert0147/AaD_SFDA.
10
+
11
+ # 1 Introduction
12
+
13
+ Supervised learning methods which are based on training with huge amounts of labeled data are advancing almost all fields of computer vision. However, the learned models typically perform decently on test data which have a similar distribution with the training set. Significant performance degradation will occur if directly applying those models to a new domain different from the training set, where the data distribution (such as variation of background, styles or camera parameter) is considerably different. This kind of distribution shift is formally denoted as domain/distribution shift. It limits the generalization of the model to unseen domains which is important in real-world applications. There are several research fields trying to tackle this problem. One of them is Domain Adaptation (DA), which aims to reduce the domain shift between the labeled source domain and unlabeled target domain. Typical works [12, 38] resort to learn domain-invariant features, thus improving generalization ability of the model between different domains. And in the past few years, the main research line of domain adaptation is either trying to minimize the distribution discrepancy between two domains [32, 33, 35], or deploying adversarial training on features to learn domain invariant representation [52, 68, 4, 36]. Some methods also tackle domain shift from the view of semi-supervised learning [67, 27] or clustering [7, 50, 5].
14
+
15
+ Many recent methods [24, 29, 64, 66, 55, 15, 61] focus on source-free domain adaptation (SFDA), where source data are unavailable during target adaptation, due to data privacy and intellectual property concerns of both users and businesses. Some SFDA methods resort to neighborhood clustering and pseudo labeling. However, pseudo labeling methods [29] may suffer from negative impact from noisy labels [28], and neighborhood clustering methods [66, 64] fail to investigate the potential information from dissimilar samples. Other methods either demand complex extra modules/processing [24, 61] or the storing of historical models for contrastive learning [15].
16
+
17
+ Table 1: Detailed comparison of SFDA methods on VisDA. ’ODA/PDA’ means whether the method reports the results for open-set or partial-set DA. $| { \mathcal { L } } |$ means number of training objective terms.
18
+
19
+ <table><tr><td>Method</td><td>Extra Modules/Processing</td><td>ODA/PDA</td><td>[C|</td><td>Per-class</td></tr><tr><td>SHOT[26] 3C-GAN [24]</td><td>Access all target data for pseudo labeling</td><td>×</td><td>3</td><td>82.9</td></tr><tr><td>A²Net [61]</td><td>Data generation by conditional GAN</td><td></td><td>5 5</td><td>81.6 84.3</td></tr><tr><td>G-SFDA [66]</td><td>Self-supervised learning with extra classifiers</td><td>X</td><td></td><td></td></tr><tr><td>NRC[64]</td><td>Store features for nearest neighbor retrieval</td><td>X</td><td>2</td><td>85.4</td></tr><tr><td>HCL [15]</td><td>Store features for 2-hop nearest neighbor retrieval Store historical models</td><td>X √</td><td>4 2</td><td>85.9 83.5</td></tr><tr><td>Ours</td><td></td><td>√</td><td>2</td><td>88.0</td></tr><tr><td></td><td>Store features for nearest neighbor retrieval</td><td></td><td></td><td></td></tr></table>
20
+
21
+ Based on the fact that target features from the source model already form some semantic structure and following the intuition that for a target feature from a (source-pretrained) model, similar features should have closer predictions than dissimilar ones, we propose a new objective dubbed as Attractingand-Dispersing (AaD) to achieve it. we upperbound this objective, resulting in a simple final objective which only contains two types of terms, which encourage discriminability and diversity respectively. Further, we unify several popular domain adaptation, source-free domain adaptation and contrastive learning methods from the perspective of discriminability and diversity. Experimental results on several benchmarks prove the superiority of our proposed method. Our simple method improves the state-of-the-art on the challenging VisDA with $2 . 1 \%$ to $8 8 . 0 \%$ . Additionally, extra experiments on open-set and partial-set DA further prove the effectiveness of our method. A preliminary comparison between different SFDA method is shown in Tab. 1, which shows the simplicity and generalization ability of our method: it only requires the storing of features and a few nearest neighbors searches without any additional module like a generator [24] or a classifier [61].
22
+
23
+ We summary our contributions as follows:
24
+
25
+ • We propose to tackle source-free domain adaptation by optimizing an upperbound of the proposed clustering objective, which is surprisingly simple.
26
+ • We relate several popular existing methods in domain adaptation, source-free domain adaptation and contrastive learning via the perspective of discriminability and diversity, which is helpful to understand existing methods and beneficial for future improvement.
27
+ • The experimental results prove the efficacy of our method, especially we achieve new state-of-theart on the challenging VisDA, and the method can be also extended to source-free open-set and partial-set domain adaptation.
28
+
29
+ # 2 Related Work
30
+
31
+ Domain Adaptation. Early DA methods such as [33, 49, 53] adopt moment matching to align feature distributions. For adversarial learning methods, DANN [9] formulates domain adaptation as an adversarial two-player game. The adversarial training of CDAN [34] is conditioned on several sources of information. DIRT-T [47] performs domain adversarial training with an added term that penalizes violations of the cluster assumption. Additionally, [22, 36, 44] adopts prediction diversity between multiple learnable classifiers to achieve local or category-level feature alignment between source and target domains. SRDC [50] proposes to directly uncover the intrinsic target discrimination via discriminative clustering to achieve adaptation. CST [31] proposes a simple self-training strategy to improve the rough pseudo label under domain shift.
32
+
33
+ Source-free Domain Adaptation. The above-mentioned normal domain adaptation methods need to access source domain data at all time during adaptation. In recent years plenty of methods emerge trying to tackle source-free domain adaptation. USFDA [20] and FS [21] resort to synthesize extra training samples in order to get compact decision boundaries, which is beneficial for both
34
+
35
+ # Algorithm 1 Attracting and Dispersing for SFDA
36
+
37
+ <table><tr><td colspan="2">Require: Source-pretrained model and target data Dt</td></tr><tr><td colspan="2">1:Build memory bank storing all target features and predictions</td></tr><tr><td>2: while Adaptation do</td><td></td></tr><tr><td>3:</td><td>Sample batch T from Dt and Update memory bank</td></tr><tr><td>4:</td><td>For each feature zi in T,retrieve K-nearest neighbors (Ci)and their predictions from memory bank</td></tr><tr><td>5:</td><td>Update model by minimizing Eq. 5</td></tr><tr><td colspan="2">6: end while</td></tr></table>
38
+
39
+ the detection of open classes and also target adaptation. SHOT [26] proposes to freeze the source classifier and it clusters target features by maximizing mutual information along with pseudo labeling for extra supervision. 3C-GAN [24] synthesizes labeled target-style training images. It is based on a conditional GAN to provide supervision for adaptation. BAIT [65] extends MCD [44] to source-free setting. $A ^ { 2 } \mathrm { { N e t } }$ [61] proposes to learn an additional target-specific classifier for hard samples and adopts a contrastive category-wise matching module to cluster target features. HCL [15] adopts Instance Discrimination [60] for features from current and historical models to cluster features, along with a generated pseudo label conditioned on historical consistency. G-SFDA [66] and NRC [64] propose neighborhood clustering which enforces prediction consistency between local neighbors.
40
+
41
+ Deep Clustering and Contrastive Learning. Recent Deep Clustering methods can be roughly divided into two groups, they the differ in how they learn the feature representation and cluster assignments, either simultaneously or alternatively. For example, DAC [2] and DCCM [58] alternately update cluster assignments and between-sample similarity. Simultaneous clustering methods IIC [18] and ISMAT [14] are based on mutual information maximizing between samples and theirs augmentations. LA [70] depends on a huge amount of nearest neighbor searches and multiple extra runs of $k$ -means clustering to aggregate features. Recent unsupervised clustering works [25, 51, 46] start to rely on contrastive learning, where InfoNCE [37] is typically deployed. And recently NNCLR [8] proposes to use nearest neighbors in the latent space as positives in contrastive learning to cover more semantic variations than pre-defined transformations. However an inevitable problem of normal contrastive learning is class collision where negative samples are from the same class. To tackle this issue, recent works [23, 16] propose to estimate cluster prototypes and integrate them into contrastive learning.
42
+
43
+ # 3 Method
44
+
45
+ For source-free domain adaptation (SFDA), we are given source-pretrained model in the beginning and an unlabeled target domain with $N _ { t }$ samples as $\mathcal { D } _ { t } = \{ x _ { i } ^ { t } \} _ { i = 1 } ^ { \bar { N } _ { t } }$ . Target domain have same $C$ classes as source domain in this paper (known as the closed-set setting). The goal of SFDA is to adapt the model to target domain without source data. We divide the model into two parts: the feature extractor $f$ , and the classifier $g$ . The output of the feature extractor is denoted as feature $( z _ { i } = f \left( x \right) \in \mathbb { R } ^ { \bar { h } } )$ , where $h$ is dimension of the feature space. The output of classifier is denoted as $( p _ { i } = \delta ( g ( z _ { i } ) ) \in \mathbb { R } ^ { C }$ ) where $\delta$ is the softmax function. We denote $\boldsymbol { P } \in \mathbb { R } ^ { b s \times C }$ as the prediction matrix in a mini-batch. Regarding the SFDA as an unsupervised clustering problem, we address SFDA problem by clustering target features based on the proposed AaD. In additionally, we relate our method with several existing DA, SFDA and contrastive learning methods.
46
+
47
+ # 3.1 Attracting and Dispersing for Source-free Domain Adaptation
48
+
49
+ Since the source-pretrained model already learns a good feature representation, it can provides a decent initialization for target adaptation. We propose to achieve SFDA by attracting predictions for features that are located close in feature space, while dispersing predictions of those features farther away in feature space.
50
+
51
+ We define $p _ { i j }$ as the probability that the feature $z _ { i } \in \mathbb { R } ^ { h }$ has similar (or the same) prediction to feature $\begin{array} { r } { z _ { j } \colon p _ { i j } = \frac { e ^ { p _ { i } ^ { T } p _ { j } } } { \sum _ { k = 1 } ^ { N _ { t } } e ^ { p _ { i } ^ { t } p _ { k } } } } \end{array}$ It can be interpreted as the possibility that $p _ { j }$ is selected as the neighbor of $p _ { i }$ in the output space [10].
52
+
53
+ We then define two sets for each feature $z _ { i }$ : close neighbor set $\mathcal { C } _ { i }$ containing $K$ -nearest neighbors of $z _ { i }$ (with distances as cosine similarity), and background set $B _ { i }$ which contains the features that are not in $\mathcal { C } _ { i }$ (features potentially from different classes). To retrieve nearest neighbors for training, we build two memory banks to store all target features along with their predictions just like former works [27, 66, 64, 42], which is efficient in both memory and computation, since only the features along with their predictions computed in each mini-batch are used to update the memory bank.
54
+
55
+ Intuitively, for each feature $z _ { i }$ , the features in $B _ { i }$ should have less similar predictions than those in $ { { \mathcal { C } } } _ { i } { } ^ { 2 }$ . To achieve this, we first define two likelihood functions:
56
+
57
+ $$
58
+ P ( \mathcal C _ { i } | \boldsymbol \theta ) = \prod _ { j \in \mathcal C _ { i } } p _ { i j } = \prod _ { j \in \mathcal C _ { i } } \frac { e ^ { p _ { i } ^ { T } p _ { j } } } { \sum _ { k = 1 } ^ { N _ { t } } e ^ { p _ { i } ^ { T } p _ { k } } } , P ( \mathcal B _ { i } | \boldsymbol \theta ) = \prod _ { j \in \mathcal B _ { i } } p _ { i j } = \prod _ { j \in \mathcal B _ { i } } \frac { e ^ { p _ { i } ^ { T } p _ { j } } } { \sum _ { k = 1 } ^ { N _ { t } } e ^ { p _ { i } ^ { T } p _ { k } } }
59
+ $$
60
+
61
+ where $\theta$ denotes parameters of the model, for readability we omit $\theta$ in following equations. The probability $p _ { j }$ in Eq. 1 is the stored prediction for neighborhood feature $z _ { j }$ , which is retrieved from the memory bank.
62
+
63
+ We then propose to achieve target features clustering by minimizing the following negative loglikelihood, denoted as $A a D$ (Attracting-and-Dispersing):
64
+
65
+ $$
66
+ \tilde { L } _ { i } ( \mathcal { C } _ { i } , \mathcal { B } _ { i } ) = - \log \frac { P ( \mathcal { C } _ { i } ) } { P ( \mathcal { B } _ { i } ) }
67
+ $$
68
+
69
+ Noting that, if we only have $P ( \mathcal { C } _ { i } )$ , it will be similar to Instance Discrimination [60], but we also consider $P ( B _ { i } )$ and we operate on predictions instead of features. If regarding weights of the classifier $g$ as classes prototypes, optimizing Eq. 2 is not only pulling features towards their closest neighbors and pushing them away from background features, but also towards (or away from) corresponding class prototypes. Therefore, we can achieve feature clustering and cluster assignment simultaneously.
70
+
71
+ To simplify the training, instead of manually and carefully sampling background features, we use all other features except $z _ { i }$ in the mini-batch as $B _ { i }$ , which can be regarded as an estimation of the distribution of the whole dataset. We can reasonably believe that overall similarity of features in $\mathcal { C } _ { i }$ is potentially higher than that of $B _ { i }$ , even if $B _ { i }$ has intersection with $\mathcal { C } _ { i }$ since features in $\mathcal { C } _ { i }$ are the closest ones to feature $z _ { i }$ . By optimizing Eq. 2, we are encouraging features in $\mathcal { C } _ { i }$ , which have a higher chance of belonging to the same class, to have more similar predictions to $z _ { i }$ than those features in $B _ { i }$ , which have a lower chance of belonging to the same class. Note all features will show up in both the first and second term; intra-cluster alignment and inter-cluster separability are expected to be achieved after training.
72
+
73
+ One problem optimizing Eq. 2 is that all target data are needed to compute Eq. 1, which is infeasible in real-world situation. Here we resort to get an upper-bound of Eq. 2:
74
+
75
+ $$
76
+ \begin{array} { l } { \tilde { L } _ { i } ( \mathcal { C } _ { i } , \mathcal { B } _ { i } ) = - \log \displaystyle \frac { P ( \mathcal { C } _ { i } ) } { P ( \mathcal { B } _ { i } ) } = - \sum _ { j \in \mathcal { C } _ { i } } [ p _ { i } ^ { T } p _ { j } - \log ( \displaystyle \sum _ { k = 1 } ^ { N _ { t } } e ^ { p _ { i } ^ { T } p _ { k } } ) ] + \sum _ { m \in \mathcal { B } _ { i } } [ p _ { i } ^ { T } p _ { m } - \log ( \displaystyle \sum _ { k = 1 } ^ { N _ { t } } e ^ { p _ { i } ^ { T } p _ { k } } ) ] } \\ { \displaystyle = - \sum _ { j \in \mathcal { C } _ { i } } p _ { i } ^ { T } p _ { j } + \sum _ { m \in \mathcal { B } _ { i } } p _ { i } ^ { T } p _ { m } + ( N _ { \mathcal { C } _ { i } } - N _ { \mathcal { B } _ { i } } ) \log ( \displaystyle \sum _ { k = 1 } ^ { N _ { t } } e ^ { p _ { i } ^ { T } p _ { k } } ) } \end{array}
77
+ $$
78
+
79
+ Since we set $N _ { \mathcal { C } _ { i } } < N _ { B _ { i } }$ , with Jensen’s inequality:
80
+
81
+ $$
82
+ \begin{array} { r l } & { \tilde { L } _ { i } ( \mathcal { C } _ { i } , \mathcal { B } _ { i } ) \leq - \displaystyle \sum _ { j \in \mathcal { C } _ { i } } p _ { i } ^ { T } p _ { j } + \displaystyle \sum _ { m \in \mathcal { B } _ { i } } p _ { i } ^ { T } p _ { m } + ( N _ { \mathcal { C } _ { i } } - N _ { \mathcal { B } _ { i } } ) ( \displaystyle \sum _ { k = 1 } ^ { N _ { t } } \frac { 1 } { N _ { t } } p _ { i } ^ { T } p _ { k } + \log N _ { t } ) } \\ & { \qquad \quad \simeq \displaystyle \sum _ { m \in \mathcal { B } _ { i } } p _ { i } ^ { T } p _ { m } - \displaystyle \sum _ { j \in \mathcal { C } _ { i } } p _ { i } ^ { T } p _ { j } + ( N _ { \mathcal { C } _ { i } } - N _ { \mathcal { B } _ { i } } ) ( \displaystyle \sum _ { k \in \mathcal { B } _ { i } } \frac { p _ { i } ^ { T } p _ { k } } { N _ { \mathcal { B } _ { i } } } + \log N _ { t } ) } \\ & { \qquad \quad = - \displaystyle \sum _ { j \in \mathcal { C } _ { i } } p _ { i } ^ { T } p _ { j } + \displaystyle \frac { N _ { \mathcal { C } _ { i } } } { N _ { \mathcal { B } _ { i } } } \displaystyle \sum _ { m \in \mathcal { B } _ { i } } p _ { i } ^ { T } p _ { m } + ( N _ { \mathcal { C } _ { i } } - N _ { \mathcal { B } _ { i } } ) \log N _ { t } } \end{array}
83
+ $$
84
+
85
+ Table 2: Decomposition of methods into two terms: discriminability $( d i s )$ and diversity $( d i \nu )$ , which will be minimized for training.
86
+
87
+ <table><tr><td>Method</td><td>Task</td><td>disterm</td><td>div term</td></tr><tr><td>MI</td><td>SFDA&amp;Clustering</td><td>H(Y|X)</td><td>-H(Y)</td></tr><tr><td>BNM</td><td>DA&amp;SFDA</td><td>-|PIlF</td><td>-rank(P)</td></tr><tr><td>NC</td><td>SFDA</td><td>-g(WijpTpj)</td><td>∑KL(llge))</td></tr><tr><td>InfoNCE</td><td>Contrastive</td><td>-f(x)Tf(y)/T</td><td>log(+∑ef(x)f(x)/T)</td></tr><tr><td>Ours</td><td>SFDA</td><td>-∑jecppj</td><td>∑meB:pTPm</td></tr></table>
88
+
89
+ where $N _ { { \mathcal { C } } _ { i } }$ and $N _ { B _ { i } }$ is the number of features in $\mathcal { C } _ { i }$ and $B _ { i }$ . Note that we cannot get this upper-bound without $\dot { P ( B _ { i } ) }$ . The approximation above in the penultimate line is to estimate the average dot product using the mini-batch data. This leads to the surprisingly simple final objective for unsupervised domain adaptation:
90
+
91
+ $$
92
+ L = \mathbb { E } [ L _ { i } ( \mathcal { C } _ { i } , \mathcal { B } _ { i } ) ] , \mathrm { w i t h ~ } L _ { i } ( \mathcal { C } _ { i } , \mathcal { B } _ { i } ) = - \sum _ { j \in \mathcal { C } _ { i } } p _ { i } ^ { T } p _ { j } + \lambda \sum _ { m \in \mathcal { B } _ { i } } p _ { i } ^ { T } p _ { m }
93
+ $$
94
+
95
+ Note the gradient will come from both $p _ { i }$ and $p _ { m }$ . The first term aims to enforce prediction consistency between local neighbors, and the naive interpretation of second term is to disperse the prediction of potential dissimilar features, which are all other features in the mini-batch. Note that the dot product between two softmaxed predictions will be maximal when two predictions have the same predicted class and are close to one-hot vector. Our algorithm is illustrated in Algorithm. 1.
96
+
97
+ Unlike using a constant for the second term in Eq. 4 we empirically found that using a hyperparameter $\lambda$ to decay second term (starting from 1) works better, we will adopt SND [43] to tune this hyperparameter unsupervisedly. One reason may be that the approximation inside Eq. 3.1 is not necessarily accurate. And as training goes on, features are gradually clustering, the role of the second term for dispersing should be weakened. Additionally, considering the current mini-batch with the correctly predicted features $z _ { i }$ and $z _ { m }$ belonging to the same class. In this case the second term in both $L _ { i } ( \mathcal { C } _ { i } , B _ { i } )$ and $L _ { m } ( \mathcal { C } _ { m } , B _ { m } )$ tends to push $p _ { m }$ to the wrong direction, while the first term in $L _ { m } ( \mathcal { C } _ { m } , B _ { m } )$ can potentially keep current (correct) prediction unchanged. Hence, this will suppress the negative impact of the second term. We will further deepen the understanding of these two terms in the next subsection.
98
+
99
+ # 3.2 Relation to Existing Works
100
+
101
+ In this section, we will relate several popular DA, SFDA and contrastive learning methods through two objectives, discriminability and diversity. This can improve our understanding of domain adaptation methods, as well as improve the understanding of our method.
102
+
103
+ Mutual Information maximizing (MI). SHOT-IM [26] proposes to achieve source-free domain adaptation by maximizing the mutual information, which is actually widely used in unsupervised clustering [11, 40, 14]:
104
+
105
+ $$
106
+ { \cal L } _ { M I } = H ( Y | X ) - H ( Y )
107
+ $$
108
+
109
+ which contains two terms: conditional entropy term $H ( Y | X )$ to encourages unambiguous cluster assignments, and marginal entropy term $H ( Y )$ to encourage cluster sizes to be uniform to avoid degeneracy. In practice, $H ( Y )$ is approximated by the current mini-batch instead of using whole dataset [48, 14].
110
+
111
+ Batch Nuclear-norm Maximization (BNM). BNM [5, 6] aims to increase prediction discriminability and diversity to tackle domain shift. It is originally achieved by maximizing $F$ -norm (for discriminability) and rank of prediction matrix (for diversity) respectively:
112
+
113
+ $$
114
+ L = - \| P \| _ { F } - r a n k ( P )
115
+ $$
116
+
117
+ In their paper, they further prove merely maximizing the nuclear norm $\| P \| _ { * }$ can achieve these two goals simultaneously. In relation to our method, if target features are well clustering during training, we can presume the K-nearest neighbors of feature $z _ { i }$ have the same prediction, the first term in Eq. 5 can be seen as the summation of diagonal elements of matrix $P P ^ { T }$ , which is actually the square of $F$ -norm $( \| P \| _ { F } = { \sqrt { t r a c e ( P P ^ { T } ) } } )$ , then it is actually minimizing prediction entropy [5]. As for second term, we can regard it as the summation of non-diagonal element of $P P ^ { T }$ , it encourages all these non-diagonal elements to be 0 thus the $r a n k ( P P ^ { T } ) = r a n k ( P )$ is supposed to increase, which indicates larger prediction diversity [5]. In a nutshell, compared to SHOT and BNM our method first considers local feature structure to cluster target features, which can be treated as an alternative way to increase discriminability at the late training stage, meanwhile as discussed above our method is also encouraging diversity.
118
+
119
+ Neighborhood Clustering (NC). G-SFDA [66] and NRC [64] are based on neighborhood clustering to tackle SFDA problem. Those works basically contain two major terms in their optimizing objective: a neighborhood clustering term for prediction consistency and a marginal entropy term $H ( Y )$ for prediction diversity. NRC [64] further introduces neighborhood reciprocity to weight the different neighbors. Their loss objective can be written as:
120
+
121
+ $$
122
+ L _ { i } = - \sum _ { j \in \mathcal { C } _ { i } } g ( W _ { i j } p _ { i } ^ { T } p _ { j } ) + \sum _ { c = 1 } ^ { C } \mathbf { K L } ( \bar { p } _ { c } | | q _ { c } ) , \mathrm { ~ w i t h ~ } \bar { p } _ { c } = \frac { 1 } { n _ { t } } \sum _ { i } p _ { i } ^ { ( c ) } , \mathrm { ~ a n d ~ } q _ { \{ c = 1 , . . . , C \} } = \frac { 1 } { C }
123
+ $$
124
+
125
+ where $W _ { i j }$ will weight the importance of neighbor and $g ( \cdot )$ is log or identity function. Although the first term of G-SFDA and NRC is the same as that of our final loss objective Eq. 5, note that our motivation is different as we simultaneously consider similar and dissimilar features, and Eq. 5 is deduced as an approximated upper-bound of our original objective Eq. 2.
126
+
127
+ And note actually the marginal entropy termAlthough the second term of those metho $\begin{array} { r } { - H ( Y ) = \sum _ { c = 1 } ^ { C } \bar { p } _ { c } \log \bar { p } _ { c } = \sum _ { c = 1 } ^ { C } { \bf K } { \bf L } \left( \bar { p } _ { c } | | q _ { c } \right) - \log C . } \end{array}$ solution where all images are only assigned to some certain classes, the margin entropy term presumes the prior that whole dataset or the mini-batch is class balance/uniformly distributed, which is barely true for current benchmarks or in real-world environment. In conclusion, the above three types of methods are actually all to increase discriminability and meanwhile maximize diversity of the prediction, but through different ways.
128
+
129
+ Contrastive Learning. Here we also link our method to InfoNCE [37]), which is widely used in contrastive learning. As a recent paper [56] points out that InfoNCE loss can be decomposed into 2 terms:
130
+
131
+ $$
132
+ \chi _ { i n f o N C E } = \mathbb { E } _ { ( x , y ) \sim p _ { p o s } } [ - f ( x ) ^ { T } f ( y ) / \tau ] \ + \underset { x \sim p _ { d a t a } } { \mathbb { E } } ~ \underset { \substack { i = 1 \sim { p _ { d a t a } } \ \{ x _ { i } ^ { - } \} _ { i = 1 } ^ { M } \sim p _ { d a t a } } } [ \log ( e ^ { 1 / \tau } + \sum _ { i } e ^ { f ( x _ { i } ^ { - } ) ^ { T } f ( x ) / \tau } ) ]
133
+ $$
134
+
135
+ The first term is denoted as alignment term (with positive pairs) is to make positive pairs of features similar, and the second term denoted as uniformity term with negative pairs encouraging all features to roughly uniformly distributed in the feature space.
136
+
137
+ The Eq. 8 shares some similarity with all the above domain adaptation methods in that the first term is for the alignment with positive pairs and the second term is to encourage diversity. But note that the remarkable difference is that the above domain adaptation methods operate in the output (prediction) space while contrastive learning is conducted in the (spherical) feature space. Therefore, simultaneously feature representation learning and cluster assignment can be achieved for those domain adaptation methods. Note in normal contrastive learning methods, extra KNN or a linear learnable classifier needs to be deployed for final classification, while our model can directly give predictions.
138
+
139
+ We list all above methods in Tab. 2. Finally, returning to Eq. 5, we can also regard the second term as a variant of diversity loss to avoid degeneration solution, but without making any category prior assumption. Intuitively, with target features forming groups during training, the second term should play less and less important role, otherwise it may destabilize the training. This is similar to the class collision issue in contrastive learning. If our second term contains too many features belonging to the same class. Thus it is reasonable to decay the second term.
140
+
141
+ # 4 Experiments
142
+
143
+ Datasets. We conduct experiments on three benchmark datasets for image classification: Office-31, Office-Home and VisDA-C 2017. Office-31 [41] contains 3 domains (Amazon, Webcam, DSLR)
144
+
145
+ Table 3: Accuracies $( \% )$ on Office-Home for ResNet50-based methods. We highlight the best result and underline the second best one.
146
+
147
+ <table><tr><td>Method</td><td></td><td>SFAr→CIAr-→PrAr-→RwCl-→ArCl-→PrCl-→RwPr-→ArPr-&gt;CIPr-→RwRw→ArRw→CIRw→PrAvg</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ResNet-50[13]</td><td></td><td>X 34.9</td><td>50.0</td><td>58.0</td><td>37.4</td><td>41.9</td><td>46.2</td><td>38.5</td><td>31.2</td><td>60.4</td><td>53.9</td><td>41.2 59.9</td><td>46.1</td></tr><tr><td>MCD [44]</td><td></td><td>xxx 48.9</td><td>68.3</td><td>74.6</td><td>61.3</td><td>67.6</td><td>68.8</td><td>57.0</td><td>47.1</td><td>75.1</td><td>69.1</td><td>52.2 79.6</td><td>64.1</td></tr><tr><td>CDAN[34]</td><td></td><td>50.7</td><td>70.6</td><td>76.0</td><td>57.6</td><td>70.0</td><td>70.0</td><td>57.4</td><td>50.9</td><td>77.3 70.9</td><td>56.7</td><td>81.6</td><td>65.8</td></tr><tr><td>SAFN[63]</td><td></td><td>52.0</td><td>71.7</td><td>76.3</td><td>64.2</td><td>69.9</td><td>71.9</td><td>63.7</td><td>51.4</td><td>77.1 70.9</td><td>57.1</td><td>81.5</td><td>67.3</td></tr><tr><td>MDD [69]</td><td></td><td>X 54.9</td><td>73.7</td><td>77.8</td><td>60.0</td><td>71.4</td><td>71.8</td><td>61.2</td><td>53.6</td><td>78.1 72.5</td><td>60.2</td><td>82.3</td><td>68.1</td></tr><tr><td>TADA [57]</td><td></td><td>×x 53.1</td><td>72.3</td><td>77.2</td><td>59.1</td><td>71.2</td><td>72.1</td><td>59.7</td><td>53.1</td><td>78.4</td><td>72.4</td><td>60.0 82.9</td><td>67.6</td></tr><tr><td>SRDC [50]</td><td></td><td>52.3</td><td>76.3</td><td>81.0</td><td>69.5</td><td>76.2</td><td>78.0</td><td>68.7</td><td>53.8</td><td>81.7</td><td>76.3</td><td>57.1 85.0</td><td>71.3</td></tr><tr><td>SHOT[26]</td><td></td><td>√ 57.1</td><td>78.1</td><td>81.5</td><td>68.0</td><td>78.2</td><td>78.1</td><td>67.4</td><td>54.9</td><td>82.2</td><td>73.3 58.8</td><td>84.3</td><td>71.8</td></tr><tr><td>A²Net [61]</td><td></td><td>58.4</td><td>79.0</td><td>82.4</td><td>67.5</td><td>79.3</td><td>78.9</td><td>68.0</td><td>56.2</td><td>82.9 74.1</td><td>60.5</td><td>85.0</td><td>72.8</td></tr><tr><td>G-SFDA [66]</td><td></td><td>√ 57.9</td><td>78.6</td><td>81.0</td><td>66.7</td><td>77.2</td><td>77.2</td><td>65.6</td><td>56.0</td><td>82.2</td><td>72.0</td><td>57.8 83.4</td><td>71.3</td></tr><tr><td>NRC [64]</td><td></td><td>√ 57.7</td><td>80.3</td><td>82.0</td><td>68.1</td><td>79.8</td><td>78.6</td><td>65.3</td><td>56.4</td><td>83.0</td><td>71.0</td><td>58.6 85.6</td><td>72.2</td></tr><tr><td>BNM-S [6]</td><td></td><td>√ 57.4</td><td>77.8</td><td>81.7</td><td>67.8</td><td>77.6</td><td>79.3</td><td>67.6</td><td>55.7</td><td>82.2</td><td>73.5</td><td>59.5 84.7</td><td>72.1</td></tr><tr><td>Ours</td><td></td><td>59.3</td><td>79.3</td><td>82.1</td><td>68.9</td><td>79.8</td><td>79.5</td><td>67.2</td><td>57.4</td><td>83.1</td><td>72.1</td><td>58.5 85.4</td><td>72.7</td></tr></table>
148
+
149
+ Table 4: Accuracies $( \% )$ on VisDA-C (Synthesis $ \mathrm { R e a l }$ ) for ResNet101-based methods. We highlight the best result and underline the second best one.
150
+
151
+ <table><tr><td>Method</td><td>[SF</td><td>plane</td><td>bcycl bus</td><td>car</td><td>horse</td><td>knifemcycl</td><td></td><td>person</td><td></td><td></td><td></td><td>plant sktbrd train truck Per-class</td></tr><tr><td>ResNet-101[13]</td><td></td><td>55.1</td><td>53.3 61.9</td><td>59.1</td><td>80.6</td><td>17.9</td><td>79.7 31.2</td><td>81.0</td><td>26.5</td><td>73.5</td><td>8.5</td><td>52.4</td></tr><tr><td>CDAN+BSP[3]</td><td></td><td>92.4</td><td>61.0</td><td>81.0 57.5</td><td>89.0</td><td>80.6</td><td>90.1</td><td>77.0 84.2</td><td>77.9</td><td>82.1</td><td>38.4</td><td>75.9</td></tr><tr><td>MCC[19]</td><td></td><td>88.7</td><td>80.3</td><td>80.5 71.5</td><td>90.1</td><td>93.2</td><td>85.0</td><td>71.6 89.4</td><td>73.8</td><td>85.0</td><td>36.9</td><td>78.8</td></tr><tr><td>STAR[36]</td><td></td><td>95.0</td><td>84.0</td><td>84.6 73.0</td><td>91.6</td><td>91.8</td><td>85.9 78.4</td><td>94.4</td><td>84.7</td><td>87.0</td><td>42.2</td><td>82.7</td></tr><tr><td>RWOT[62]</td><td>xxxxx</td><td>95.1 80.3</td><td>83.7</td><td>90.0</td><td>92.4</td><td>68.0</td><td>92.5 82.2</td><td>87.9</td><td>78.4</td><td>90.4</td><td>68.2</td><td>84.0</td></tr><tr><td>3C-GAN [24]</td><td></td><td>94.8 73.4</td><td>68.8</td><td>74.8</td><td>93.1</td><td>95.4</td><td>88.6 84.7</td><td>89.1</td><td>84.7</td><td>83.5</td><td>48.1</td><td>81.6</td></tr><tr><td>SHOT[26]</td><td>v√</td><td>94.3 88.5</td><td></td><td>80.1 57.3</td><td>93.1</td><td>94.9</td><td>80.7</td><td>80.3 91.5</td><td>89.1</td><td>86.3</td><td>58.2</td><td>82.9</td></tr><tr><td>A²Net [61]</td><td></td><td>94.0 87.8</td><td>85.6</td><td>66.8</td><td>93.7</td><td>95.1</td><td>85.8</td><td>81.2 91.6</td><td>88.2</td><td>86.5</td><td>56.0</td><td>84.3</td></tr><tr><td>G-SFDA [66]</td><td></td><td>96.1 88.3</td><td>85.5</td><td>74.1</td><td>97.1</td><td>95.4</td><td>89.5</td><td>79.4 95.4</td><td>92.9</td><td>89.1</td><td>42.6</td><td>85.4</td></tr><tr><td>NRC [64]</td><td></td><td>96.8 91.3</td><td>82.4</td><td>62.4</td><td>96.2</td><td>95.9</td><td>86.1</td><td>80.6 94.8</td><td>94.1</td><td>90.4</td><td>59.7</td><td>85.9</td></tr><tr><td>HCL [15]</td><td>vvv√</td><td>93.3</td><td>85.4</td><td>80.7 68.5</td><td>91.0</td><td>88.1</td><td>86.0</td><td>78.6 86.6</td><td>88.8</td><td>80.0</td><td>74.7</td><td>83.5</td></tr><tr><td>Ours</td><td>√</td><td>97.4</td><td>90.5</td><td>80.8 76.2</td><td>97.3</td><td>96.1</td><td>89.8</td><td>82.9 95.5</td><td>93.0</td><td>92.0</td><td>64.7</td><td>88.0</td></tr></table>
152
+
153
+ with 31 classes and 4,652 images. Office-Home [54] contains 4 domains (Real, Clipart, Art, Product) with 65 classes and a total of 15,500 images. VisDA (VisDA-C 2017) [39] is a more challenging dataset, with 12-class synthetic-to-real object recognition tasks, its source domain contains of 152k synthetic images while the target domain has $5 5 \mathrm { k }$ real object images.
154
+
155
+ Evaluation. The column SF in the tables denotes source-free. For Office-31 and Office-Home, we show the results of each task and the average accuracy over all tasks ${ \it A } \nu g$ in the tables). For VisDA, we show accuracy for all classes and average over those classes (Per-class in the table). All results are the average of three random runs for target adaptation.
156
+
157
+ Model details. To ensure fair comparison with related methods, we adopt the backbone of a ResNet-50 [13] for Office-Home and ResNet-101 for VisDA. Specifically, we use the same network architecture as SHOT [26], BNM-S [6], G-SFDA [66] and NRC [64], i.e., the final part of the network is: fully connected layer - Batch Normalization $I I 7 J$ - fully connected layer with weight normalization $I 4 5 J$ . We adopt SGD with momentum 0.9 and batch size of 64 for all datasets. The learning rate for Office-31 and Office-Home is set to 1e-3 for all layers, except for the last two newly added fc layers, where we apply 1e-2. Learning rates are set 10 times smaller for VisDA. We train 40 epochs for Office-31 and Office-Home while 15 epochs for VisDA.
158
+
159
+ There are two hyperparameters $N _ { { \mathcal { C } } _ { i } }$ (number of nearest neighbors) and $\lambda$ , to ensure fair comparison we set $N _ { { \mathcal { C } } _ { i } }$ to the same number as previous works G-SFDA [66] and NRC [64], which also resort to nearest neighbors. That is, we set $N _ { { \mathcal { C } } _ { i } }$ to 3 on Office-31 and Office-Home, 5 on VisDA. For $\lambda$ , we set it as $\begin{array} { r } { \lambda = ( 1 + 1 0 * \frac { i t e r } { m a x \_ i t e r } ) ^ { - \beta } } \end{array}$ , where the decay factor $\beta$ controls the decaying speed. We directly apply SND $I 4 3 J$ to select $\beta$ unsupervisedly. Based on SND we set $\beta$ to 0 on Office-Home, 2 on Office-31 and 5 on VisDA.
160
+
161
+ # 4.1 Results and Analysis
162
+
163
+ Quantitative Results. As shown in Tables $3 { - } 5 ( L e f t )$ , where the top part shows results for the source-present methods that use source data during adaptation, and the bottom part shows results for the source-free DA methods. On Office-31 and VisDA, our method gets state-of-the-art performance compared to existing source-free domain adaptation methods, especially on VisDA our method outperforms others by a large margin $2 . 1 \%$ compared to NRC). And our method achieves similar results on Office-Home compared to the more complex $A ^ { \mathrm { 2 } } \mathrm { N e t }$ method (which combines three classifiers and five objective functions). The reported results clearly demonstrate the efficiency of the proposed method for source-free domain adaptation. It also achieves similar or better results compared to domain adaptation methods with access to source data on both Office-Home and VisDA. Note the extension of SHOT called $\mathrm { S H O T + + }$ [30] deploys extra self-supervised training and semisupervised learning, which are general to improve the results (an evidence is that the source model after these 2 tricks gets huge improvement, e.g., $6 0 . 2 \%$ improves to $6 6 . 6 \%$ on Office-Home.), we do not list it here for fair comparison.
164
+
165
+ Table 5: (Left) Accuracies $( \% )$ on Office-31 for ResNet50-based methods. We highlight the best result and underline the second best one. (Right) Ablation study on number of nearest neighbors $N _ { { \mathcal { C } } _ { i } }$ . We highlight the best score and underline the second best one.
166
+
167
+ <table><tr><td>Method</td><td></td><td colspan="3">JSFA→DA→WD-→WW-→DD-→AW→AAvg</td></tr><tr><td>MCD [44] CDAN [34] MDD[69]] DMRL[59] MCC[19]</td><td>X .xxxxx</td><td>92.2 88.6 92.9 94.1 90.4 90.4 93.4 90.8 95.6 95.4</td><td>98.5 98.6 100.0 98.7 99.9 99.0 100.0 98.6 100.0</td><td>100.0 69.5 69.7 86.5 71.0 75.0 73.0 71.2 72.6</td><td>69.3 87.7 73.7 88.0 87.9</td></tr><tr><td>SRDC [50] SHOT[26] 3C-GAN [24] NRC[64] HCL [15] BNM-S [6]</td><td></td><td>95.8 95.7 94.0 90.1 92.7 93.7 96.0 90.8 94.7 92.5 93.0 92.9</td><td>99.2 98.4 98.5 99.0 98.2 98.2</td><td>100.0 76.7 77.1 99.9 74.7 74.3 99.8 75.3 77.8 100.0 75.3 75.0 100.0 75.9 77.7 99.9 75.4 75.0</td><td>73.9 89.4 90.8 88.6 89.6 89.4 89.8 89.1</td></tr></table>
168
+
169
+ <table><tr><td>Nc</td><td>Avg</td><td colspan="2"></td></tr><tr><td>Office-31</td><td></td><td>Nc</td><td>Per-class</td></tr><tr><td>1</td><td>89.1</td><td>VisDA</td><td></td></tr><tr><td>2</td><td>89.5</td><td>3</td><td>86.7</td></tr><tr><td>3</td><td>89.9</td><td>4</td><td>87.4</td></tr><tr><td>Office-Home</td><td></td><td>5</td><td>88.0</td></tr><tr><td>1</td><td>72.2</td><td>6</td><td>88.0</td></tr><tr><td>2</td><td>72.6</td><td>7</td><td>88.0</td></tr><tr><td>3</td><td>72.7</td><td></td><td></td></tr></table>
170
+
171
+ ![](images/d5938c64280d6d34169a787c675d830390dd3f7d9107b41f341c64d6c1e9c21e.jpg)
172
+ Figure 1: Visualization of decision boundary on target data with different training objective.
173
+
174
+ Toy dataset. We carry out an experiment on the twinning moona dataset to ablate the influence of two terms in our objective Eq. 5. For the twinning moons dataset, the data from the source domain are represented by two inter-twinning moons, which contain 300 samples each. Data in the target domain are generated through rotating source data by $3 0 ^ { \circ }$ . The domain shift here is instantiated as the rotation degree. First we train the model with 3 linear layers only on the source domain, and test the model on all domains. As shown in the first image in Fig. 1, the source model performs badly on target data. Then we conduct several variants of our method to train the model. The visualization of the decision boundary in Fig. 1 indicates that both terms in Eq. 5 are necessary, and decay of second term is shown to be important.
175
+
176
+ Table 6: Unsupervised hyperparameter selection of $\beta$ with SND [43], larger SND should correspond to better target model.
177
+
178
+ <table><tr><td colspan="2">VisDA</td></tr><tr><td>β</td><td>SND个 Per-class</td></tr><tr><td>0 1</td><td>8.1823 77.5 8.2584 83.8</td></tr><tr><td>2 8.3214</td><td>86.7</td></tr><tr><td>3 8.3311</td><td>87.6</td></tr><tr><td>4</td><td>8.3540 88.0</td></tr><tr><td>5 8.3543</td><td>88.0</td></tr><tr><td>7 8.3530</td><td>88.1</td></tr></table>
179
+
180
+ <table><tr><td colspan="2">Office-31</td></tr><tr><td>β</td><td>SND↑ Avg</td></tr><tr><td>0</td><td>4.1366 88.0</td></tr><tr><td>0.25 4.3016</td><td>89.7</td></tr><tr><td>1 4.4494</td><td>89.9</td></tr><tr><td>2 4.4501</td><td>89.9</td></tr></table>
181
+
182
+ <table><tr><td colspan="2">Office-Home</td></tr><tr><td>β</td><td>SND个 Avg</td></tr><tr><td>0</td><td>3.7515 72.7</td></tr><tr><td>0.25</td><td>3.7402 72.6</td></tr><tr><td>0.5 3.7252</td><td>72.0</td></tr><tr><td>1 3.6923</td><td>70.6</td></tr></table>
183
+
184
+ ![](images/1cf6b003e9c6d20751c2aa0c45c9569c74226a20fb875407d84e6d762e676b95.jpg)
185
+ Figure 2: (Left) Ratio of features which have 3 nearest neighbor features sharing the same predicted label. (Right) Ratio among above features which have 3 nearest neighbor features sharing the same and correct predicted label.
186
+
187
+ Table 7: Runtime analysis on SHOT and our method. For SHOT, pseudo labels are computed at each epoch. $10 \%$ and $5 \%$ denote the percentage of target features which are stored in the memory bank.
188
+
189
+ <table><tr><td>VisDA</td><td>Runtime (s/epoch)Per-class (%)</td><td></td></tr><tr><td>SHOT</td><td>618.82</td><td>82.9</td></tr><tr><td>Ours</td><td>520.13</td><td>88.0</td></tr><tr><td>Ours(10% for memory bank)</td><td>490.21</td><td>87.6</td></tr><tr><td>Ours(5% for memory bank)</td><td>482.77</td><td>87.5</td></tr></table>
190
+
191
+ Number of nearest neighbors $( N _ { C _ { i } } )$ . For the number of nearest neighbors used for the first term in Eq. 5, we show in Tab. 5 $( R i g h t )$ our method is robust to the choice of $N _ { { \mathcal { C } } _ { i } }$ , as the results imply that a reasonable choice of $N _ { { \mathcal { C } } _ { i } }$ (such as 3) works quite well on all datasets, since only considering few neighbors (such as $1 / 2$ ) may be too noisy if all of them are misclassified, while setting $N _ { { \mathcal { C } } _ { i } }$ too larger may also potentially include samples of other categories. For larger dataset such as VisDA we can choose a relatively larger $N _ { { \mathcal { C } } _ { i } }$ . Note the reason why we choose $N _ { { \mathcal { C } } _ { i } }$ as 5 in main experiments is to compare fairly with G-SFDA [66] and NRC [64].
192
+
193
+ Decay factor $\beta$ . According to the analysis in Sec. 3.2, the second term acts like a diversity term to avoid that all target features collapse to a limited set of categories. The role of the second term should be weakened during the training, but how to decay the second term is non-trivial. We directly adopt SND [43] which computes Soft Neighborhood Density for unsupervised hyperparameter selection of $\beta$ . The method is unsupervised and larger SND predicts a better target models. The results of $S N D$ with different $\beta$ are shown in Tab. 6, the results prove that SND works well to choose optimal $\beta$ .
194
+
195
+ Runtime analysis. Instead of storing all features in the memory bank, we can only stores a limited number of target features, by updating the memory bank at the end of each iteration by taking the $n$ (batch size) embeddings from the current training iteration and concatenating them at the end of the memory bank, and discard the oldest $n$ elements from the memory bank. We report the results with this type of memory bank of different buffer size in the Table 7. The results show that indeed this could be an efficient way to reduce computation on very large datasets.
196
+
197
+ Degree of clustering during training. We also plot how features are clustered with different decaying factors $\beta$ on VisDA in Fig. 2. The left one shows the ratio of features which have 3-nearest neighbors all sharing the same prediction, which indicates the degree of clustering during training, and the right one shows the ratio among above features which have 3-nearest neighbor features sharing the same and correct predicted label. Those curves in Fig. 2 left show that the target features are clustering, and those in Fig. 2 right indicate that clear category boundaries are emerging. The numbers in the legends denote the deployed $\beta$ and the corresponding final accuracy. From the figures we can draw the conclusion that with a larger decay factor $\beta$ on VisDA, features are quickly clustering and forming inter-class boundaries, since the ratio of features which share the same and correct prediction with neighbors are increasing faster. When decaying factor $\beta$ is too small, meaning training signal from the second term is strong, the clustering process is actually impeded. The curves in Fig. 2 (left) signify that this ratio can also be used to choose $\beta$ with higher performance unsupervisedly.
198
+
199
+ Table 8: Accuracy on Office-Home using ResNet-50 as backbone for Source-free open-set DA. $O S ^ { * }$ , UNK and $H O S$ mean average per-class accuracy across known classes, unknown accuracy and harmonic mean between known and unknown accuracy respectively.
200
+
201
+ <table><tr><td colspan="3">Ar→Cl</td><td colspan="2">Ar→Pr</td><td colspan="2"></td><td colspan="2">Ar→Rw</td><td colspan="2">Cl→Ar</td><td colspan="2">Cl→Pr</td><td colspan="4">Cl→Rw</td></tr><tr><td></td><td colspan="2">OS*UNK HOS</td><td colspan="2">OS*UNK HOS</td><td colspan="2"></td><td colspan="2">OS*UNK HOS</td><td colspan="2">OS*UNK HOS</td><td colspan="2">OS*UNK HOS</td><td colspan="2">OS*UNK HOS</td><td colspan="2"></td></tr><tr><td>SHOT 67.0 28.0 39.5</td><td></td><td></td><td></td><td>81.8 26.339.8</td><td></td><td></td><td>87.532.1 47.0</td><td></td><td>66.846.2 54.6</td><td></td><td>77.527.240.2</td><td></td><td>80.025.939.1</td><td colspan="2"></td></tr><tr><td>AaD 50.7 66.4 57.6</td><td></td><td></td><td></td><td>64.6 69.4 66.9</td><td></td><td></td><td>73.166.9 69.9</td><td></td><td>48.2 81.1 60.5</td><td></td><td>59.5 63.5 61.4</td><td></td><td>67.4 68.3 67.8</td><td></td><td></td></tr><tr><td></td><td>Pr→Ar</td><td></td><td></td><td>Pr→Cl</td><td></td><td>Pr→Rw</td><td></td><td></td><td>Rw→Ar</td><td></td><td>Rw→Cl</td><td></td><td>Rw→Pr</td><td></td><td>Avg</td></tr><tr><td></td><td>OS* UNK HOS</td><td></td><td></td><td>OS*UNK HOS</td><td></td><td></td><td>OS*UNK HOS</td><td></td><td>OS*UNKHOS</td><td></td><td>OS*UNK HOS</td><td>OS*UNK HOS</td><td></td><td>OS* UNK HOS</td><td></td></tr><tr><td>SHOT 66.3 51.1 57.7</td><td></td><td></td><td></td><td>59.331.040.8</td><td></td><td></td><td>85.8 31.6 46.2</td><td></td><td>73.550.6 59.9</td><td></td><td>65.328.940.1</td><td></td><td>84.4 28.2 42.3</td><td></td><td>74.633.9 45.6</td></tr><tr><td>AaD 47.3 82.4 60.1</td><td></td><td></td><td></td><td>45.4 72.8 55.9</td><td></td><td></td><td>68.472.8 70.6</td><td></td><td>54.579.0 64.6</td><td></td><td>49.069.6 57.5</td><td></td><td>69.770.6 70.1</td><td>58.271.9</td><td>63.6</td></tr></table>
202
+
203
+ Table 9: Accuracy on Office-Home using ResNet-50 as backbone for Source-free partial-set DA.
204
+
205
+ <table><tr><td colspan="10">Partial-set DA Ar-&gt;C1Ar-→Pr Ar-→Re Cl→ArCl-→PrCl-→RePr→ArPr-→ClPr→Re Re→ArRe-→Cl Re-→Pr Avg.</td></tr><tr><td></td><td>83.6</td><td></td><td>88.8</td><td>72.4</td><td>74.0</td><td>79.0</td><td>76.1</td><td>60.6</td><td>90.1</td><td>81.9</td><td>88.5</td><td>76.8</td></tr><tr><td>SHOT-IM SHOT</td><td>57.9 64.8</td><td>85.2</td><td>92.7</td><td>76.3</td><td>77.6</td><td>88.8</td><td>79.7</td><td>64.3 89.5</td><td>80.6</td><td>68.3 66.4</td><td>85.8</td><td>79.3</td></tr><tr><td>AaD</td><td>67.0</td><td>83.5</td><td>93.1</td><td>80.5</td><td>76.0</td><td>87.6</td><td>78.1 65.6</td><td>90.2</td><td>83.5</td><td>64.3</td><td>87.3</td><td>79.7</td></tr></table>
206
+
207
+ Source-free partial-set and open-set DA. We provide additional results under source-free partialset and open-set DA (PDA and ODA) setting in Tab. 8 and Tab. 9 respectively, where the open-set detection in ODA follows the same protocol to detect unseen categories as SHOT. On ODA, instead of reporting average per-class accuracy OS = |Cs|×OS∗|C |+1 $\begin{array} { r } { O S = \frac { | \mathcal { C } _ { s } | \times O S ^ { * } } { | \mathcal { C } _ { s } | + 1 } + \frac { 1 \times \bar { U } N K } { | \mathcal { C } _ { s } | + 1 } } \end{array}$ + 1×UNK|C |+1 where |Cs| is the number of known categories on source domain, we report results of HOS = 2×OS∗×UNKOS∗+UNK , which is harmonic mean between known categories accuracy $O S ^ { * }$ and unknown accuracy UNK. As pointed out by [1], $O S$ is problematic since this metric can be quite high even when unknown class accuracy UNK is 0, while unknown category detection is the key part in open-set DA. We reproduce SHOT under open-set DA and report results of $O S ^ { * }$ , UNK and $H O S$ in Tab. 8, which shows our method gets much better balance between known and unknown accuracy.
208
+
209
+ # 5 Conclusion
210
+
211
+ We proposed to tackle source-free domain adaptation by encouraging similar features in feature space to have similar predictions while dispersing predictions of dissimilar features in feature space, to achieve simultaneously feature clustering and cluster assignment. We introduced an upper bound to our proposed objective, resulting in two simple terms. Further we showed that we can unify several popular domain adaptation, source-free domain adaptation and contrastive learning methods from the perspective of discriminability and diversity. The approach is simple but achieves state-of-the-art performance on several benchmarks, and can be also adapted to source-free open-set and partial-set domain adaptation.
212
+
213
+ # Acknowledgement
214
+
215
+ We acknowledge the support from Huawei Kirin Solution, and the project PID2019-104174GBI00/AEI/10.13039/501100011033 (MINECO, Spain), and the CERCA Programme of Generalitat de Catalunya.
216
+
217
+ # References
218
+
219
+ [1] Silvia Bucci, Mohammad Reza Loghmani, and Tatiana Tommasi. On the effectiveness of image rotation for open set domain adaptation. In European Conference on Computer Vision, pages 422–438. Springer, 2020.
220
+ [2] Jianlong Chang, Lingfeng Wang, Gaofeng Meng, Shiming Xiang, and Chunhong Pan. Deep adaptive image clustering. In ICCV, pages 5879–5887, 2017. [3] Xinyang Chen, Sinan Wang, Mingsheng Long, and Jianmin Wang. Transferability vs. discriminability: Batch spectral penalization for adversarial domain adaptation. In ICML, pages 1081–1090, 2019. [4] Safa Cicek and Stefano Soatto. Unsupervised domain adaptation via regularized conditional alignment. In ICCV, pages 1416–1425, 2019. [5] Shuhao Cui, Shuhui Wang, Junbao Zhuo, Liang Li, Qingming Huang, and Qi Tian. Towards discriminability and diversity: Batch nuclear-norm maximization under label insufficient situations. CVPR, 2020. [6] Shuhao Cui, Shuhui Wang, Junbao Zhuo, Liang Li, Qingming Huang, and Qi Tian. Fast batch nuclear-norm maximization and minimization for robust domain adaptation. arXiv preprint arXiv:2107.06154, 2021. [7] Zhijie Deng, Yucen Luo, and Jun Zhu. Cluster alignment with a teacher for unsupervised domain adaptation. In ICCV, pages 9944–9953, 2019. [8] Debidatta Dwibedi, Yusuf Aytar, Jonathan Tompson, Pierre Sermanet, and Andrew Zisserman. With a little help from my friends: Nearest-neighbor contrastive learning of visual representations. ICCV, 2021. [9] Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. JMLR, 17(1):2096–2030, 2016.
221
+ [10] Jacob Goldberger, Geoffrey E Hinton, Sam Roweis, and Russ R Salakhutdinov. Neighbourhood components analysis. NIPS, 17, 2004.
222
+ [11] Ryan Gomes, Andreas Krause, and Pietro Perona. Discriminative clustering by regularized information maximization. In NIPS, 2010.
223
+ [12] Boqing Gong, Yuan Shi, Fei Sha, and Kristen Grauman. Geodesic flow kernel for unsupervised domain adaptation. In CVPR, pages 2066–2073. IEEE, 2012.
224
+ [13] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, pages 770–778, 2016.
225
+ [14] Weihua Hu, Takeru Miyato, Seiya Tokui, Eiichi Matsumoto, and Masashi Sugiyama. Learning discrete representations via information maximizing self-augmented training. In ICML, pages 1558–1567, 2017.
226
+ [15] Jiaxing Huang, Dayan Guan, Aoran Xiao, and Shijian Lu. Model adaptation: Historical contrastive learning for unsupervised domain adaptation without source data. NeurIPS, 34, 2021.
227
+ [16] Zhizhong Huang, Jie Chen, Junping Zhang, and Hongming Shan. Exploring non-contrastive representation learning for deep clustering. arXiv preprint arXiv:2111.11821, 2021.
228
+ [17] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. arXiv preprint arXiv:1502.03167, 2015.
229
+ [18] Xu Ji, Joao F Henriques, and Andrea Vedaldi. Invariant information clustering for unsupervised image classification and segmentation. In ICCV, pages 9865–9874, 2019.
230
+ [19] Ying Jin, Ximei Wang, Mingsheng Long, and Jianmin Wang. Minimum class confusion for versatile domain adaptation. ECCV, 2020.
231
+ [20] Jogendra Nath Kundu, Naveen Venkat, and R Venkatesh Babu. Universal source-free domain adaptation. CVPR, 2020.
232
+ [21] Jogendra Nath Kundu, Naveen Venkat, Ambareesh Revanur, R Venkatesh Babu, et al. Towards inheritable models for open-set domain adaptation. In CVPR, pages 12376–12385, 2020.
233
+ [22] Chen-Yu Lee, Tanmay Batra, Mohammad Haris Baig, and Daniel Ulbricht. Sliced wasserstein discrepancy for unsupervised domain adaptation. In CVPR, pages 10285–10295, 2019.
234
+ [23] Junnan Li, Pan Zhou, Caiming Xiong, and Steven Hoi. Prototypical contrastive learning of unsupervised representations. In ICLR, 2021.
235
+ [24] Rui Li, Qianfen Jiao, Wenming Cao, Hau-San Wong, and Si Wu. Model adaptation: Unsupervised domain adaptation without source data. In CVPR, pages 9641–9650, 2020.
236
+ [25] Yunfan Li, Peng Hu, Zitao Liu, Dezhong Peng, Joey Tianyi Zhou, and Xi Peng. Contrastive clustering. In AAAI, 2021.
237
+ [26] Jian Liang, Dapeng Hu, and Jiashi Feng. Do we really need to access the source data? source hypothesis transfer for unsupervised domain adaptation. ICML, 2020.
238
+ [27] Jian Liang, Dapeng Hu, and Jiashi Feng. Domain adaptation with auxiliary target domain-oriented classifier. In CVPR, pages 16632–16642, 2021.
239
+ [28] Jian Liang, Dapeng Hu, Ran He, and Jiashi Feng. Distill and fine-tune: Effective adaptation from a black-box source model. CVPR, 2022.
240
+ [29] Jian Liang, Dapeng Hu, Yunbo Wang, Ran He, and Jiashi Feng. Source data-absent unsupervised domain adaptation through hypothesis transfer and labeling transfer. arXiv preprint arXiv:2012.07297, 2020.
241
+ [30] Jian Liang, Dapeng Hu, Yunbo Wang, Ran He, and Jiashi Feng. Source data-absent unsupervised domain adaptation through hypothesis transfer and labeling transfer. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
242
+ [31] Hong Liu, Jianmin Wang, and Mingsheng Long. Cycle self-training for domain adaptation. In NeurIPS, 2021.
243
+ [32] Mingsheng Long, Yue Cao, Zhangjie Cao, Jianmin Wang, and Michael I Jordan. Transferable representation learning with deep adaptation networks. TPAMI, 41(12):3071–3085, 2018.
244
+ [33] Mingsheng Long, Yue Cao, Jianmin Wang, and Michael I Jordan. Learning transferable features with deep adaptation networks. ICML, 2015.
245
+ [34] Mingsheng Long, Zhangjie Cao, Jianmin Wang, and Michael I Jordan. Conditional adversarial domain adaptation. In NIPS, pages 1647–1657, 2018.
246
+ [35] Mingsheng Long, Han Zhu, Jianmin Wang, and Michael I Jordan. Unsupervised domain adaptation with residual transfer networks. In NIPS, pages 136–144, 2016.
247
+ [36] Zhihe Lu, Yongxin Yang, Xiatian Zhu, Cong Liu, Yi-Zhe Song, and Tao Xiang. Stochastic classifiers for unsupervised domain adaptation. In CVPR, pages 9111–9120, 2020.
248
+ [37] Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
249
+ [38] Sinno Jialin Pan and Qiang Yang. A survey on transfer learning. TKDE, 22(10):1345–1359, 2009.
250
+ [39] Xingchao Peng, Ben Usman, Neela Kaushik, Judy Hoffman, Dequan Wang, and Kate Saenko. Visda: The visual domain adaptation challenge. arXiv preprint arXiv:1710.06924, 2017.
251
+ [40] Simone Romano, James Bailey, Vinh Nguyen, and Karin Verspoor. Standardized mutual information for clustering comparisons: one step further in adjustment for chance. In ICML, pages 1143–1151, 2014.
252
+ [41] Kate Saenko, Brian Kulis, Mario Fritz, and Trevor Darrell. Adapting visual category models to new domains. In ECCV, pages 213–226. Springer, 2010.
253
+ [42] Kuniaki Saito, Donghyun Kim, Stan Sclaroff, and Kate Saenko. Universal domain adaptation through self supervision. NeurIPS, 33, 2020.
254
+ [43] Kuniaki Saito, Donghyun Kim, Piotr Teterwak, Stan Sclaroff, Trevor Darrell, and Kate Saenko. Tune it the right way: Unsupervised validation of domain adaptation via soft neighborhood density. In ICCV, pages 9184–9193, 2021.
255
+ [44] Kuniaki Saito, Kohei Watanabe, Yoshitaka Ushiku, and Tatsuya Harada. Maximum classifier discrepancy for unsupervised domain adaptation. In CVPR, pages 3723–3732, 2018.
256
+ [45] Tim Salimans and Diederik P Kingma. Weight normalization: A simple reparameterization to accelerate training of deep neural networks. arXiv preprint arXiv:1602.07868, 2016.
257
+ [46] Yuming Shen, Ziyi Shen, Menghan Wang, Jie Qin, Philip HS Torr, and Ling Shao. You never cluster alone. In NeurIPS, 2021.
258
+ [47] Rui Shu, Hung H Bui, Hirokazu Narui, and Stefano Ermon. A dirt-t approach to unsupervised domain adaptation. ICLR, 2018.
259
+ [48] Jost Tobias Springenberg. Unsupervised and semi-supervised learning with categorical generative adversarial networks. In ICLR, 2015.
260
+ [49] Baochen Sun, Jiashi Feng, and Kate Saenko. Return of frustratingly easy domain adaptation. In AAAI, 2016.
261
+ [50] Hui Tang, Ke Chen, and Kui Jia. Unsupervised domain adaptation via structurally regularized deep clustering. In CVPR, pages 8725–8735, 2020.
262
+ [51] Tsung Wei Tsai, Chongxuan Li, and Jun Zhu. Mice: Mixture of contrastive experts for unsupervised image clustering. In ICLR, 2021.
263
+ [52] Eric Tzeng, Judy Hoffman, Kate Saenko, and Trevor Darrell. Adversarial discriminative domain adaptation. In CVPR, pages 7167–7176, 2017.
264
+ [53] Eric Tzeng, Judy Hoffman, Ning Zhang, Kate Saenko, and Trevor Darrell. Deep domain confusion: Maximizing for domain invariance. arXiv preprint arXiv:1412.3474, 2014.
265
+ [54] Hemanth Venkateswara, Jose Eusebio, Shayok Chakraborty, and Sethuraman Panchanathan. Deep hashing network for unsupervised domain adaptation. In CVPR, pages 5018–5027, 2017.
266
+ [55] Qin Wang, Olga Fink, Luc Van Gool, and Dengxin Dai. Continual test-time domain adaptation. CVPR, 2022.
267
+ [56] Tongzhou Wang and Phillip Isola. Understanding contrastive representation learning through alignment and uniformity on the hypersphere. In ICML, pages 9929–9939. PMLR, 2020.
268
+ [57] Ximei Wang, Liang Li, Weirui Ye, Mingsheng Long, and Jianmin Wang. Transferable attention for domain adaptation. In AAAI, volume 33, pages 5345–5352, 2019.
269
+ [58] Jianlong Wu, Keyu Long, Fei Wang, Chen Qian, Cheng Li, Zhouchen Lin, and Hongbin Zha. Deep comprehensive correlation mining for image clustering. In ICCV, pages 8150–8159, 2019.
270
+ [59] Yuan Wu, Diana Inkpen, and Ahmed El-Roby. Dual mixup regularized learning for adversarial domain adaptation. ECCV, 2020.
271
+ [60] Zhirong Wu, Yuanjun Xiong, Stella X Yu, and Dahua Lin. Unsupervised feature learning via non-parametric instance discrimination. In CVPR, pages 3733–3742, 2018.
272
+ [61] Haifeng Xia, Handong Zhao, and Zhengming Ding. Adaptive adversarial network for source-free domain adaptation. In ICCV, pages 9010–9019, 2021.
273
+ [62] Renjun Xu, Pelen Liu, Liyan Wang, Chao Chen, and Jindong Wang. Reliable weighted optimal transport for unsupervised domain adaptation. In CVPR, pages 4394–4403, 2020.
274
+ [63] Ruijia Xu, Guanbin Li, Jihan Yang, and Liang Lin. Larger norm more transferable: An adaptive feature norm approach for unsupervised domain adaptation. In ICCV, October 2019.
275
+ [64] Shiqi Yang, Joost van de Weijer, Luis Herranz, Shangling Jui, et al. Exploiting the intrinsic neighborhood structure for source-free domain adaptation. NeurIPS, 34, 2021.
276
+ [65] Shiqi Yang, Yaxing Wang, Joost van de Weijer, Luis Herranz, and Shangling Jui. Unsupervised domain adaptation without source data by casting a bait. arXiv preprint arXiv:2010.12427, 2020.
277
+ [66] Shiqi Yang, Yaxing Wang, Joost van de Weijer, Luis Herranz, and Shangling Jui. Generalized source-free domain adaptation. In ICCV, pages 8978–8987, 2021.
278
+ [67] Yabin Zhang, Bin Deng, Kui Jia, and Lei Zhang. Label propagation with augmented anchors: A simple semi-supervised learning baseline for unsupervised domain adaptation. In ECCV, pages 781–797, 2020.
279
+ [68] Yabin Zhang, Hui Tang, Kui Jia, and Mingkui Tan. Domain-symmetric networks for adversarial domain adaptation. In CVPR, pages 5031–5040, 2019.
280
+ [69] Yuchen Zhang, Tianle Liu, Mingsheng Long, and Michael Jordan. Bridging theory and algorithm for domain adaptation. In ICML, pages 7404–7413, 2019.
281
+ [70] Chengxu Zhuang, Alex Lin Zhai, and Daniel Yamins. Local aggregation for unsupervised learning of visual embeddings. In ICCV, pages 6002–6012, 2019.
282
+
283
+ # Checklist
284
+
285
+ 1. For all authors...
286
+
287
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
288
+ (b) Did you describe the limitations of your work? [No]
289
+ (c) Did you discuss any potential negative societal impacts of your work? [No]
290
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
291
+
292
+ 2. If you are including theoretical results...
293
+
294
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
295
+
296
+ 3. If you ran experiments...
297
+
298
+ (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]
299
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
300
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
301
+ (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)? [No]
302
+
303
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
304
+
305
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
306
+ (b) Did you mention the license of the assets? [No]
307
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
308
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
309
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
310
+
311
+ 5. If you used crowdsourcing or conducted research with human subjects...
312
+
313
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
314
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
315
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/nrksGSRT7kX/nrksGSRT7kX.md ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RAMBO-RL: Robust Adversarial Model-Based Offline Reinforcement Learning
2
+
3
+ Marc Rigter, Bruno Lacerda, Nick Hawes Oxford Robotics Institute University of Oxford {mrigter, bruno, nickh}@robots.ox.ac.uk
4
+
5
+ # Abstract
6
+
7
+ Offline reinforcement learning (RL) aims to find performant policies from logged data without further environment interaction. Model-based algorithms, which learn a model of the environment from the dataset and perform conservative policy optimisation within that model, have emerged as a promising approach to this problem. In this work, we present Robust Adversarial Model-Based Offline RL (RAMBO), a novel approach to model-based offline RL. We formulate the problem as a two-player zero sum game against an adversarial environment model. The model is trained to minimise the value function while still accurately predicting the transitions in the dataset, forcing the policy to act conservatively in areas not covered by the dataset. To approximately solve the two-player game, we alternate between optimising the policy and adversarially optimising the model. The problem formulation that we address is theoretically grounded, resulting in a probably approximately correct (PAC) performance guarantee and a pessimistic value function which lower bounds the value function in the true environment. We evaluate our approach on widely studied offline RL benchmarks, and demonstrate that it outperforms existing state-of-the-art baselines.
8
+
9
+ # 1 Introduction
10
+
11
+ Reinforcement learning (RL) [61] has achieved state-of-the-art performance on many sequential decision-making problems [40, 45, 59]. However, the need for extensive exploration prohibits the application of RL to many real world domains where such exploration is costly or dangerous. Offline RL [33, 35] overcomes this limitation by learning policies from static, pre-recorded datasets.
12
+
13
+ Online RL algorithms perform poorly in the offline setting due to the distributional shift between the state-action pairs in the dataset and those taken by the learnt policy. Thus, an important aspect of offline RL is to introduce conservatism to prevent the learnt policy from executing state-action pairs which are out of distribution. Model-free offline RL algorithms [15, 23, 27, 29, 31, 72] train a policy from only the data present in the fixed dataset, and incorporate conservatism either into the value function or by directly constraining the policy.
14
+
15
+ On the other hand, model-based offline RL algorithms [76, 75, 25, 63, 39] use the dataset to learn a model of the environment, and train a policy using additional synthetic data generated from that model. By training on additional synthetic data, model-based algorithms can potentially generalise better to states not present in the dataset, or to solving new tasks. Previous approaches to model-based offline RL incorporate conservatism by estimating the uncertainty in the model and applying reward penalties for state-action pairs that have high uncertainty [76, 25]. However, uncertainty estimation can be unreliable for neural network models [75, 37]. Like recent work [75], we propose an approach for offline model-based RL which does not require uncertainty estimation.
16
+
17
+ In this work we present Robust Adversarial Model-Based Offline (RAMBO) RL, a new algorithm for model-based offline RL. RAMBO incorporates conservatism by modifying the transition dynamics of the learnt Markov decision process (MDP) model in an adversarial manner. We formulate the problem of offline RL as a zero-sum game against an adversarial environment. To solve the resulting maximin optimisation problem, we alternate between optimising the agent and optimising the adversary in the style of Robust Adversarial RL (RARL) [50]. Unlike existing RARL approaches, our modelbased approach forgoes the need to define and train an adversary policy, and instead only learns an adversarial model of the MDP. We train the agent policy with an actor-critic algorithm using synthetic data generated from the model in addition to data sampled from the dataset, similar to Dyna [60] and a number of recent methods [22, 76, 25, 75]. We update the environment model so that it reduces the value function for the agent policy, while still accurately predicting the transitions in the dataset. As a result, our approach introduces conservatism by generating pessimistic synthetic transitions for state-action pairs which are out-of-distribution. The theoretical formulation of offline RL that our algorithm addresses yields a PAC bound for the performance gap with respect to any policy covered by the dataset, and a pessimistic value function that lower bounds the value function in the true environment.
18
+
19
+ In summary, the main contributions of this work are:
20
+
21
+ • RAMBO, a novel and theoretically-grounded model-based offline RL algorithm which enforces conservatism by training an adversarial dynamics model.
22
+ • Adapting the Robust Adversarial RL approach to model-based offline RL by proposing a new formulation of RARL, where instead of defining and training an adversary policy, we directly train the model adversarially.
23
+
24
+ In our experiments we demonstrate that RAMBO outperforms current state-of-the-art algorithms on the D4RL benchmarks [14]. Furthermore, we provide ablation results which show that training the model adversarially is crucial to the strong performance of RAMBO.
25
+
26
+ # 2 Related Work
27
+
28
+ Offline RL: Offline RL addresses the problem of learning policies from fixed datasets, and has been applied to domains such as healthcare [42, 57], natural language processing [24, 23], and robotics [30, 38, 51]. Model-free offline RL algorithms do not require a learnt model. Approaches for model-free offline RL include importance sampling algorithms [36, 41], constraining the learnt policy to be similar to the behaviour policy [16, 28, 72, 23, 58, 15], incorporating conservatism into the value function during training [9, 27, 31, 73], using uncertainty quantification to generate more robust value estimates [1, 2, 29], or applying only a single iteration of policy iteration [7, 49]. In contrast, modelbased approaches learn a model of the environment and generate synthetic data from that model [60] to optimise a policy using either planning [4] or RL algorithms [25, 76, 75]. By training a policy on additional synthetic data, model-based approaches have the potential for broader generalisation and for solving new tasks [6, 76]. A simple approach to ensuring conservatism is to constrain the policy to be similar to the behaviour policy in the same fashion as some model-free approaches [8, 39, 63]. Another approach is to apply reward penalties for executing state-action pairs with high uncertainty in the environment model [25, 74, 76]. However, this requires explicit uncertainty estimates which may be unreliable for neural network models [17, 37, 46, 75]. COMBO [75] obviates the need for uncertainty estimation in model-based offline RL by adapting model-free techniques [31] to regularise the value function for out-of-distribution samples. Like COMBO, our approach does not require uncertainty estimation.
29
+
30
+ Most approaches to model-based offline RL use maximum likelihood estimates (MLE) of the MDP trained using standard supervised learning [4, 39, 63, 76, 75]. However, other methods have been proposed to learn models which are more suitable for offline policy optimisation. One approach is to reweight the loss function to ensure the model is accurate under the state-action distribution generated by the policy [34, 53, 20]. In contrast, our approach produces pessimistic synthetic transitions when out-of-distribution.
31
+
32
+ Most related to our work is a recent paper [66] which introduces the maximin formulation of offline RL that we address. This existing work motivates our approach theoretically by showing that the problem formulation obtains probably approximately correct (PAC) guarantees. However, [66] only addresses the theoretical aspects of the problem formulation and does not propose a practical algorithm. In this work, we propose a practical RL algorithm to solve the maximin formulation of model-based offline RL.
33
+
34
+ Robust RL: Algorithms for Robust MDPs [5, 12, 21, 43, 54, 64, 70] find the policy with the best worst-case performance over a set of possible MDPs. Typically, it is assumed that the uncertainty set of MDPs is specified a priori. To eliminate the need to specify the set of possible MDPs, model-free approaches to Robust MDPs [68, 55] instead assume that samples can be drawn from a misspecified MDP which is similar to the true MDP. As our work addresses offline RL, we assume that we have a fixed dataset from the true MDP.
35
+
36
+ Our approach is conceptually similar to Robust Adversarial RL (RARL) [50], a method proposed to improve the robustness of RL policies in the online setting. RARL is posed as a two-player zero-sum game where the agent plays against an adversary which perturbs the environment. Formulations of model-free RARL differ in how they define the action space of the adversary. Options include allowing the adversary to apply perturbation forces to the simulator [50], add noise to the agent’s actions [65], or periodically take over control [48]. A model-based approach to RARL is proposed in [13], which learns an optimistic and pessimistic model to encourage online exploration. However, this existing approach requires uncertainty estimation as well as an adversarial policy to be learnt in addition to the model. Our work follows the paradigm of RARL and alternates between agent and adversarial updates in a maximin formulation. We adapt model-based RARL to the offline setting and propose an alternative formulation: we eliminate the need to learn an adversary policy and instead directly modify the MDP model adversarially.
37
+
38
+ # 3 Preliminaries
39
+
40
+ MDPs and Offline RL: An MDP is defined by the tuple, $M = ( S , A , T , R , \mu _ { 0 } , \gamma )$ . $S$ and $A$ denote the state and action spaces respectively, $R ( s , a )$ is the reward function, $T ( s ^ { \prime } | s , a )$ is the transition function, $\mu _ { 0 }$ is the initial state distribution, and $\gamma \in \mathsf { \Gamma } ( 0 , 1 )$ is the discount factor. In this work we consider Markovian policies, $\pi \in \Pi$ , which map from each state to a distribution over actions. We denote the (improper) discounted state visitation distribution of a policy by $\begin{array} { r } { d _ { M } ^ { \pi } ( s ) : = \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } \operatorname* { P r } ( s _ { t } = s | \pi , \bar { M } ) } \end{array}$ , where $\mathrm { P r } ( s _ { t } = s | \pi , M )$ is the probability of reaching state $s$ at time $t$ by executing policy $\pi$ in $M$ . The improper state-action visitation distribution is $d _ { M } ^ { \pi } \bar { ( } s , a ) =$ $\pi ( a | s ) \cdot d _ { M } ^ { \pi } ( s )$ . We also denote the normalised state-action visitation distribution by $\tilde { d } _ { M } ^ { \pi } ( s , a ) =$ $( 1 - \gamma ) \cdot d _ { M } ^ { \pi } ( s , a )$ .
41
+
42
+ The value function, $V _ { M } ^ { \pi } ( s )$ , represents the expected discounted return from executing $\pi$ from state $s$ in $\begin{array} { r } { M \colon V _ { M } ^ { \pi } ( s ) = \mathbb { E } _ { \pi , M } \bigl [ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } R ( s _ { t } , a _ { t } ) \bigr ] } \end{array}$ . We write $V _ { M } ^ { \pi }$ to indicate the value function under the initial state distribution, i.e. $\begin{array} { r } { V _ { M } ^ { \pi } = \sum _ { s \in S } \mu _ { 0 } ( s ) V _ { M } ^ { \pi } ( s ) } \end{array}$ . The standard objective for MDPs is to find the policy which maximises $V _ { M } ^ { \pi }$ . The state-action value function, $Q _ { M } ^ { \pi } ( s , a )$ , is the expected discounted cumulative reward from taking action $a$ at state $s$ and then executing $\pi$ thereafter.
43
+
44
+ In offline RL we only have access to a fixed dataset of transitions from the MDP, $\begin{array} { r l } { \mathcal { D } } & { { } = } \end{array}$ $\{ ( s _ { i } , a _ { i } , r _ { i } , s _ { i } ^ { \prime } ) \} _ { i = 1 } ^ { | \mathcal { D } | }$ . The goal of offline RL is to find the best possible policy using the fixed dataset.
45
+
46
+ Model-Based Offline RL Algorithms: Model-based approaches to offline RL use a model of the MDP to help train a policy. The dataset is used to learn a dynamics model, $\widehat { T }$ , which is typically trained via maximum likelihood estimation: $\begin{array} { r } { \operatorname* { m i n } _ { \widehat { T } } \mathbb { E } _ { ( s , a , s ^ { \prime } ) \sim \mathcal { D } } \big [ - \log \widehat { T } ( s ^ { \prime } | s , a ) \big ] } \end{array}$ . A model of the reward function, $\widehat { R } ( s , a )$ , can also be learnt if it is unknown. The estimated MDP, $\widehat { M } = ( S , A , \widehat { T } , \widehat { R } , \mu _ { 0 } , \gamma )$ , has the same state and action space as the true MDP but uses the learnt transition and reward functions. Thereafter, any planning or RL algorithm can be used to recover optimal policy in the learnt model, $\widehat { \pi } = \arg \operatorname* { m a x } _ { \pi \in \Pi } V _ { \widehat { M } } ^ { \pi } .$ ·
47
+
48
+ Unfortunately, directly applying this approach to the offline RL setting does not perform well due to distributional shift. In particular, if the dataset does not cover the entire state-action space, the model will inevitably be inaccurate for some state-action pairs. Thus, naive policy optimisation on a learnt model in the offline setting can result in model exploitation [22, 32, 53]. To mitigate this issue, we propose the novel approach of enforcing conservatism by adversarially modifying the transition dynamics of $\widehat { M }$ .
49
+
50
+ In line with existing works [76, 75, 8], we use model-based policy optimisation (MBPO) [22] to learn the optimal policy for $\widehat { M }$ . MBPO utilises a standard actor-critic RL algorithm. However, the value function is trained using an augmented dataset ${ \mathcal { D } } \cup { \mathcal { D } } _ { \widehat { M } }$ , where $\mathcal { D } _ { \widehat { M } }$ is synthetic data generated c cby simulating rollouts in the learnt model. To generate the synthetic data, MBPO performs $k$ -step rollouts in $\widehat { M }$ starting from states $s \in \mathcal { D }$ , and adds this data to $\mathcal { D } _ { \widehat { M } }$ . To train the policy, minibatches of data are drawn from $\mathcal { D } \cup \mathcal { D } _ { \widehat { M } }$ c, where each datapoint is sampled from the real data, $\mathcal { D }$ , with probability $f$ , and from $\mathcal { D } _ { \widehat { M } }$ cwith probability $1 - f$ .
51
+
52
+ Robust Adversarial Reinforcement Learning: RARL addresses the problem of finding a robust agent policy, $\pi$ , in the online RL setting by posing the problem as a two-player zero sum game against adversary policy, $\bar { \pi }$ :
53
+
54
+ $$
55
+ \pi = \arg \operatorname* { m a x } _ { \pi \in \Pi } \operatorname* { m i n } _ { \bar { \pi } \in \bar { \Pi } } V _ { M } ^ { \pi , \bar { \pi } }
56
+ $$
57
+
58
+ wher e V π,π¯ is the expected value from executing $\pi$ and $\bar { \pi }$ in environment $M$ . Different approaches define the action space for $\bar { \pi }$ in different ways, as discussed in Section 2. For a scalable approximation to the optimisation problem in Equation 1, algorithms for RARL alternate between applying steps of stochastic gradient ascent to the agent’s policy to increase the expected value, and stochastic gradient descent to the adversary’s policy to decrease the expected value. In our work, we follow the RARL paradigm of alternating between agent and adversarial updates and adapt it to the model-based offline setting. Instead of defining a separate adversary policy, we treat the model itself as the policy to be adversarially trained.
59
+
60
+ # 4 Problem Formulation
61
+
62
+ For the sake of generality, we assume that both the transition function and reward function are unknown. Hereafter, we write $\widehat { T }$ to denote both the learnt dynamics and reward function, where $\widehat { T } ( s ^ { \prime } , r | s , a )$ is the probability of receiving reward $r$ and transitioning to $s ^ { \prime }$ after executing $( s , a )$ . We address the maximin formulation of offline RL recently proposed by [66]:
63
+
64
+ Problem 1. For some dataset, $\mathcal { D }$ , and some fixed constant $\xi > 0$ , find the policy $\pi$ defined by
65
+
66
+ $$
67
+ \begin{array} { r } { \mathcal { M } _ { \mathcal { D } } = \Big \{ \widehat { T } \ : | \mathbb { E } _ { \mathcal { D } } \big [ \mathbf { T V } ( \widehat { T } _ { \mathrm { M L E } } ( \cdot | s , a ) , \widehat { T } ( \cdot | s , a ) ) ^ { 2 } \big ] \leq \xi \Big \} , } \end{array}
68
+ $$
69
+
70
+ where $\mathrm { T V } ( P _ { 1 } , P _ { 2 } )$ is the total variation distance between distributions $P _ { 1 }$ and $P _ { 2 }$ , and $\widehat { T } _ { \mathrm { M L E } }$ denotes the maximum likelihood estimate of the MDP given the offline dataset, $\mathcal { D }$ .
71
+
72
+ Thus, the set defined in Equation 3 contains MDPs which are similar to the maximum likelihood estimate under state-action pairs in $\mathcal { D }$ . However, because the expectation in Equation 3 is taken under $\mathcal { D }$ , there is no restriction on $\widehat { T }$ for regions of the state-action space not covered by $\mathcal { D }$ . We present a brief overview of the theoretical guarantees from [66] in the following subsection.
73
+
74
+ Remark 1. Note that Problem 1 differs from the pessimistic MDP formulations introduced by MOPO [76] and MOReL [25]. Problem 1 considers the worst-case transition dynamics, while the pessimistic MDPs constructed by MOPO and MOReL only modify the reward function by applying reward penalties for state-action pairs with high uncertainty.
75
+
76
+ # 4.1 Theoretical Motivation
77
+
78
+ The theoretical analysis from [66] shows that solving Problem 1 outputs a policy that with high probability is approximately as good as any policy with a state-action distribution that is covered by the dataset. This is formally stated in the following theorem.
79
+
80
+ Theorem 1 (PAC guarantee from [66], Theorem 5). Denote the true MDP transition function by $T$ and let $\mathcal { M }$ denote a hypothesis class of MDP models such that $T \in { \mathcal { M } }$ . Let $\pi$ denote the solution to Problem 1 for dataset $\mathcal { D }$ . Then with probability $1 - \delta$ for any policy, $\pi ^ { * } \in \Pi$ , we have
81
+
82
+ $$
83
+ { V _ { T } ^ { \pi ^ { * } } } - { V _ { T } ^ { \pi } } \leq ( 1 - \gamma ) ^ { - 2 } c _ { 1 } \sqrt { C _ { \pi ^ { * } } } \sqrt { G _ { \mathcal M _ { 1 } } + G _ { \mathcal M _ { 2 } } + \xi _ { n } ^ { 2 } + \frac { \ln ( c / \delta ) } { | \mathcal D | } } , \ w h e r e
84
+ $$
85
+
86
+ $$
87
+ C _ { \pi ^ { * } } = \operatorname* { m a x } _ { T ^ { \prime } \in \mathcal { M } } \frac { \mathbb { E } _ { ( s , a ) \sim \tilde { d } _ { T } ^ { \pi ^ { * } } } \left[ \mathrm { T V } ( T ^ { \prime } ( \cdot | s , a ) , T ( \cdot | s , a ) ) ^ { 2 } \right] } { \mathbb { E } _ { ( s , a ) \sim \rho } \left[ \mathrm { T V } ( T ^ { \prime } ( \cdot | s , a ) , T ( \cdot | s , a ) ) ^ { 2 } \right] } ,
88
+ $$
89
+
90
+ where $\rho$ is the state-action distribution from which $\mathcal { D }$ was sampled, and c and $c _ { 1 }$ are universal constants. We refer the reader to Appendix $A$ of [66] for the definitions of $G _ { \mathcal { M } _ { 1 } }$ , $G _ { \mathcal { M } _ { 2 } }$ , and $\xi _ { n }$ .
91
+
92
+ The quantity $C _ { \pi ^ { * } }$ is upper bounded by the maximum density ratio between the comparator policy, $\pi ^ { * }$ , and the offline distribution, i.e. $C _ { \pi ^ { * } } ^ { \mathrm { ~ \bar { ~ } } } \le \operatorname* { m a x } _ { ( s , a ) } \tilde { d } _ { T } ^ { \pi ^ { * } } ( s , a ) / \rho ( s , a )$ . It represents the discrepancy between the distribution of data in the dataset compared to the visitation distribution of policy $\pi ^ { * }$ . Theorem 1 shows that if we find a policy by solving Problem 1, the performance gap of that policy is bounded with respect to any other policy $\pi ^ { * }$ that has a state-action distribution which is covered by the dataset.
93
+
94
+ Furthermore, the value function under the worst-case model in the set defined by Problem 1 is a lower bound on the value function in the true environment, as stated by Proposition 1.
95
+
96
+ Proposition 1 (Pessimistic value function). Let $T$ denote the true transition function for some MDP, and let $\mathcal { M } _ { \mathcal { D } }$ be the set of MDP models defined in Equation 3. Then for any policy $\pi$ , with probability $1 - \delta$ we have that
97
+
98
+ $$
99
+ \operatorname* { m i n } _ { \widehat { T } \in \mathcal { M } _ { \mathcal { D } } } V _ { \widehat { T } } ^ { \pi } \leq V _ { T } ^ { \pi } .
100
+ $$
101
+
102
+ Proposition 1 follows from the fact that $T \in \mathcal { M } _ { \mathcal { D } }$ with high probability, which is proven in [66] (Appendix E.2). Proposition 1 shows that we can expect the performance of any policy in the true MDP to be at least as good as the value in the worst-case model defined in Problem 1.
103
+
104
+ While [66] provides the theoretical motivation for solving Problem 1, it does not propose a practical algorithm. In this work, we focus on developing a practical approach to solving Problem 1.
105
+
106
+ # 5 RAMBO-RL
107
+
108
+ In this section, we present Robust Adversarial Model-Based Offline RL (RAMBO), our algorithm for solving Problem 1. The main difficulty with solving Problem 1 is that it is unclear how to find the worst-case MDP in the set defined in Equation 3. To arrive at a scalable solution, we propose a novel approach which is in the spirit of RARL. We alternate between optimising the agent policy to increase the expected value, and adversarially optimising the model to decrease the expected value. In this section, we first describe how we compute the gradient to adversarially train the model. Then, we discuss how to ensure that the model remains approximately within the constraint set defined in Problem 1. Finally, we present our overall algorithm.
109
+
110
+ # 5.1 Model Gradient
111
+
112
+ We propose a policy gradient-inspired approach to adversarially optimise the model. Typically, policy gradient algorithms are used to modify the distribution over actions taken by a policy at each state [62, 71]. In contrast, the update that we propose modifies the likelihood of the successor states and rewards in the MDP model.
113
+
114
+ We assume that the MDP model is defined by parameters, $\phi$ , and we write $\widehat { T } _ { \phi }$ to indicate this. We denote by V πφ the value function for policy π in model Tbφ. To approximately find minTφ∈MD as required by Problem 1 via gradient descent, we wish to compute the gradient of the model parameters that reduces the value of the policy within the model, i.e. $\nabla _ { \phi } V _ { \phi } ^ { \pi }$ .
115
+
116
+ Proposition 2 (Model Gradient). Let $\phi$ denote the parameters of a parametric MDP model $\widehat { T } _ { \phi }$ , and let $V _ { \phi } ^ { \pi }$ denote the value function for policy $\pi$ in $\widehat { T } _ { \phi }$ . Then:
117
+
118
+ $$
119
+ \nabla _ { \phi } V _ { \phi } ^ { \pi } = \mathbb { E } _ { s \sim d _ { \phi } ^ { \pi } , a \sim \pi , ( s ^ { \prime } , r ) \sim \widehat { T } _ { \phi } } \left[ ( r + \gamma V _ { \phi } ^ { \pi } ( s ^ { \prime } ) ) \cdot \nabla _ { \phi } \log \widehat { T } _ { \phi } ( s ^ { \prime } , r | s , a ) \right]
120
+ $$
121
+
122
+ The proof of Proposition 2 is given in Appendix A. We can subtract the baseline $Q _ { \phi } ^ { \pi } ( s , a )$ without biasing the gradient estimate (see Appendix A.1 for details):
123
+
124
+ $$
125
+ \begin{array} { r } { \nabla _ { \phi } V _ { \phi } ^ { \pi } = \mathbb { E } _ { s \sim d _ { \phi } ^ { \pi } , a \sim \pi , ( s ^ { \prime } , r ) \sim \widehat { T } _ { \phi } } \left[ \left( r + \gamma V _ { \phi } ^ { \pi } ( s ^ { \prime } ) - Q _ { \phi } ^ { \pi } ( s , a ) \right) \cdot \nabla _ { \phi } \log \widehat { T } _ { \phi } ( s ^ { \prime } , r | s , a ) \right] } \end{array}
126
+ $$
127
+
128
+ The Model Gradient differs from the standard policy gradient in that a) it is used to update the likelihood of successor states in the model, rather than actions in a policy, and b) the “advantage” term $r + \gamma V _ { \phi } ^ { \pi } ( s ^ { \prime } ) - Q _ { \phi } ^ { \pi } ( s , a )$ compares the utility of receiving reward $r$ and transitioning to $s ^ { \prime }$ to the expected value of state action pair $( s , a )$ . In contrast, the standard advantage term, $Q ( s , a ) - V ( s )$ [56], compares the value of executing state-action pair $( s , a )$ to the value at $s$ . To estimate $V _ { \phi } ^ { \pi }$ and $Q _ { \phi } ^ { \pi }$ , we use the critic learnt by the actor-critic algorithm used for policy optimisation. Thus, we use the critic both for training the policy and adversarially training the model.
129
+
130
+ Remark 2. The Model Gradient can be thought of as a specific instantiation of the policy gradient if we view $\widehat { T } _ { \phi }$ as a adversarial “policy” on an augmented MDP, $M ^ { + }$ , i.e. $\widehat { T } _ { \phi } : S ^ { + } \to \operatorname { D i s t } ( A ^ { + } )$ . The augmented state space, $S ^ { + } = \bar { S } \times \bar { A }$ includes the state in the original MDP augmented by the action taken by the agent. The augmented action space consists of the reward applied and the successor state, $A ^ { + } = S \times [ R _ { \operatorname* { m i n } } , R _ { \operatorname* { m a x } } ]$ . Thus, we can think of this approach as an instantiation of RARL in which the adversary policy $\bar { \pi }$ in Equation 1) that we train is the model itself.
131
+
132
+ # 5.2 Adversarial Model Training
133
+
134
+ If we were to update the model using Equation 5 alone, this would allow the model to be modified arbitrarily such that the value function in the model is reduced. However, the set of plausible MDPs given by Equation 3 states that over the dataset, $\mathcal { D }$ , the model $\widehat { T } _ { \phi }$ should be close to the maximum likelihood estimate, $\widehat { T } _ { \mathrm { M L E } }$ . Specifically, in the inner optimisation of Problem 1 we wish to find a solution to the constrained optimisation problem
135
+
136
+ $$
137
+ \operatorname* { m i n } _ { \widehat { T } _ { \phi } } V _ { \phi } ^ { \pi } , \quad s . t . \mathbb { E } _ { \mathcal { D } } \big [ \mathbf { T V } ( \widehat { T } _ { \mathrm { M L E } } ( \cdot | s , a ) , \widehat { T } _ { \phi } ( \cdot | s , a ) ) ^ { 2 } \big ] \leq \xi .
138
+ $$
139
+
140
+ The Lagrangian relaxation leads to the unconstrained problem
141
+
142
+ $$
143
+ \operatorname* { m a x } _ { \lambda \geq 0 } \operatorname* { m i n } _ { \hat { T } _ { \phi } } \Big ( L ( \hat { T } , \lambda ) : = V _ { \phi } ^ { \pi } + \lambda \big ( \mathbb { E } _ { \mathcal { D } } \big [ \mathrm { T V } ( \hat { T } _ { \mathrm { M L E } } ( \cdot \vert s , a ) , \hat { T } _ { \phi } ( \cdot \vert s , a ) ) ^ { 2 } \big ] - \xi \big ) \Big ) ,
144
+ $$
145
+
146
+ where $\lambda$ is the Lagrange multiplier. Rather than optimising the Lagrange multiplier, we find that in practice fixing $\lambda$ to apply a constant weighting between the two terms works well with minimal tuning. To facilitate easier tuning of the learning rate, in our implementation we apply the weighting constant to the value function term rather than the model term, which is equivalent up to a scaling factor. This leads to
147
+
148
+ $$
149
+ \begin{array} { r } { \underset { \widehat { T } _ { \phi } } { \operatorname* { m i n } } \left( \lambda V _ { \phi } ^ { \pi } + \mathbb { E } _ { \mathcal { D } } \left[ \Gamma \mathbf { V } ( \widehat { T } _ { \mathrm { M L E } } ( \cdot | s , a ) , \widehat { T } _ { \phi } ( \cdot | s , a ) ) ^ { 2 } \right] \right) . } \end{array}
150
+ $$
151
+
152
+ We aim to make our algorithm efficient and simple to implement. Therefore, rather than minimising the TV distance between the model and MLE model as prescribed by Equation 8, we directly optimise the standard MLE loss. This leads to the final loss function:
153
+
154
+ $$
155
+ \begin{array} { r } { \mathcal { L } _ { \phi } = \lambda V _ { \phi } ^ { \pi } - \mathbb { E } _ { ( s , a , r , s ^ { \prime } ) \sim \mathcal { D } } \left[ \log \widehat { T } _ { \phi } ( s ^ { \prime } , r | s , a ) \right] . } \end{array}
156
+ $$
157
+
158
+ Thus, the loss function for the model in Equation 9 simply adds the adversarial term to the standard MLE loss. By minimising the loss function in Equation 9, the model is trained to a) predict the transitions within the dataset, and b) reduce the value function of the policy, with $\lambda$ determining the tradeoff between these two objectives. Choosing $\lambda$ to be small ensures that the MLE term dominates for transitions within $\mathcal { D }$ , ensuring that the model fits the dataset accurately. Because the MLE term is only computed over $\mathcal { D }$ , the adversarial term dominates outside of the dataset meaning that the model is modified adversarially for transitions outside of the dataset.
159
+
160
+ To estimate the gradient of the loss function in Equation 9 for stochastic gradient descent, we sample a minibatch of transitions from $\mathcal { D }$ to estimate the MLE term. The gradient for the value function term is computed using the Model Gradient. The transitions used to compute the Model Gradient term must be sampled under the current policy and model (Equation 5). Therefore, to estimate the Model Gradient term, we generate a minibatch of transitions by simulating the current policy in $\widehat { T } _ { \phi }$ .
161
+
162
+ Like previous works [10, 76, 75, 8], we represent the dynamics model using an ensemble of neural networks. Each neural network produces a Gaussian distribution over the next state and reward:
163
+
164
+ $\widehat { T } _ { \phi } ( s ^ { \prime } , r | s , a ) = \mathcal { N } ( \mu _ { \phi } ( s , a ) , \Sigma _ { \phi } ( s , a ) )$ . A visualisation of the result of adversarially training the dynamics model can be found in Appendix C.3.
165
+
166
+ Normalisation The composite loss function in Equation 9 comprises two terms which may have different magnitudes across domains depending on the scale of the states and rewards. To enable easier tuning of the adversarial loss weighting, $\lambda$ , across different domains we perform the following normalisation procedure. Prior to training, we normalise the states in $\mathcal { D }$ in the manner proposed in [15], by subtracting the mean and dividing by the standard deviation of each state dimension in the dataset. Additionally, when computing the gradient in Equation 5 we normalise the advantage terms, $r + \gamma V _ { \phi } ^ { \pi } ( s ^ { \prime } ) - \dot { Q _ { \phi } ^ { \pi } } ( s , a )$ , according to the mean and standard deviation across each minibatch. Advantage normalisation is common practice in policy gradient RL implementations [3, 52].
167
+
168
+ # 5.3 Algorithm
169
+
170
+ We are now ready to present our overall approach in Algorithm 1. The first step of RAMBO is to pretrain the environment dynamics model using standard MLE (Line 1). Thereafter, the algorithm follows the format of RARL. At each iteration, we apply gradient updates to the agent to increase the expected value, followed by gradient updates to the model to decrease the expected value.
171
+
172
+ Prior to each agent update, we generate synthetic $k$ -step rollouts starting from states in $\mathcal { D }$ by simulating rollouts in the current MDP model $\widehat { T } _ { \phi }$ . This data is added to the synthetic dataset $\mathcal { D } _ { \widehat { T } _ { \phi } }$ (Line 3). Following previous approaches [76, 75, 22] we only store data from recent iterations in $\mathcal { D } _ { \widehat { T } _ { \phi } }$ . The agent’s policy and value functions are trained with an off-policy actor-critic algorithm using samples from $\mathcal { D } \cup \mathcal { D } _ { \widehat { T } _ { \phi } }$ (Line 4). In our implementation, we use soft actor-critic (SAC) [19] for agent training. To update the model to minimise the loss in Equation 9 (Line 5), we sample data from $\mathcal { D }$ to estimate the gradient for the MLE component. To compute the adversarial component we generate samples by simulating the current policy and model, and utilise the value function learnt by the agent to compute the gradient according to Equation 5.
173
+
174
+ # Algorithm 1 RAMBO-RL
175
+
176
+ Require: Normalised dataset, $\mathcal { D }$ ;
177
+ 1: $\widehat { T } _ { \phi } \gets \mathrm { M L E }$ dynamics model.
178
+ 2: for $i = 1 , 2 , \dots , n _ { \mathrm { i t e r } } ,$ do
179
+ 3: Generate synthetic $k$ -step rollouts. Add transition data to $\mathcal { D } _ { \widehat { T } _ { \phi } }$ .
180
+ 4: Agent update: Update $\pi$ and $Q _ { \phi } ^ { \pi }$ Tbφwith an actor critic algorithm, using samples from $\mathcal { D } \cup \mathcal { D } _ { \widehat { T } _ { \phi } }$ .
181
+ 5: Adversarial model update: Update $\widehat { T } _ { \phi }$ according to Eq. 9, using samples from $\mathcal { D }$ for the MLE component, and the current critic $Q _ { \phi } ^ { \pi }$ and synthetic data sampled from $\pi$ and $\widehat { T } _ { \phi }$ for the adversarial component.
182
+
183
+ # 6 Experiments
184
+
185
+ In our experiments, we aim to: a) evaluate how well RAMBO performs compared to state-ofthe-art baselines, b) examine whether RAMBO can be tuned offline, c) determine the impact of adversarial training on the performance of the algorithm, and d) investigate the difference between RAMBO and COMBO, the most similar prior algorithm. The code for our experiments is available at github.com/marc-rigter/rambo. We evaluate our approach on the following domains.
186
+
187
+ MuJoCo There are three different environments representing different robots (HalfCheetah, Hopper, Walker2D), each with 4 datasets (Random, Medium, Medium-Replay, Medium-Expert). Random contains transitions collected by a random policy. Medium contains transitions collected by an early-stopped SAC policy. Medium-Replay consists of the replay buffer generated while training the Medium policy. The Medium-Expert dataset contains a mixture of suboptimal and expert data.
188
+
189
+ AntMaze The agent controls a robot and navigates to reach a goal, receiving a sparse reward only if the goal is reached. There are three different layouts of maze (Umaze, Medium, Large), and different dataset types (Fixed, Play, Diverse) which differ in terms of the variety of start and goal locations used to collect the dataset. The MuJoCo and AntMaze benchmarks are from D4RL [14].
190
+
191
+ Hyperparameter Details The base hyperparameters that we use for RAMBO mostly follow those used in SAC [19] and COMBO [75]. We find that the performance of RAMBO is sensitive to the choice of rollout length, $k$ , consistent with findings in previous works [22, 37]. The other critical parameter for RAMBO is the choice of the adversarial weighting, $\lambda$ .
192
+
193
+ For each dataset, we choose the rollout length and the adversarial weighting from one of three possible configurations: $( k , \lambda ) \in \{ ( 2 , 3 { \mathrm { e } } { - } 4 ) , ( 5 , 3 { \bar { \mathrm { e } } } { - } 4 ) , ( 5 , 0 ) \}$ . We included $\bar { ( k , \lambda ) } = ( 5 , 0 )$ as we found that an adversarial weighting of 0 worked well for some datasets. For the MuJoCo datasets we performed model rollouts using the current policy, and initialised the policy using behaviour cloning (BC) which is a common practice in offline RL [25, 74]. Ablation results in Appendix C.4 indicate that the BC initialisation results in a small improvement. For the AntMaze datasets we used a random rollout policy and a randomly initialised policy as we found that this performed better. Further details about the hyperparameters are in Appendix B.
194
+
195
+ Evaluation We present two different evaluations of our approach: RAMBO and RAMBOOFF. For RAMBO, we ran each of the three hyperparameter configurations for five seeds each, and report the best performance across the three configurations. Thus, our evaluation of RAMBO utilises limited online tuning which is the most common practice among existing model-based offline RL algorithms [25, 37, 39, 76]. The performance obtained for each of the hyperparameter configurations is included in Appendix C.2.
196
+
197
+ Offline hyperparameter selection is an important topic in offline RL [47, 77]. Therefore, we present additional results for RAMBOOFF where we select between the three choices of hyperparameters offline using a simple heuristic (details in Appendix B.5) based on the magnitude and stability of the $Q$ -values during offline training. We first select the hyperparameters using the heuristic, and then rerun each dataset for 5 seeds to generate the results for RAMBOOFF.
198
+
199
+ Baselines We compare RAMBO against state-of-the-art model-based (COMBO [75], RepBSDE [34], MOReL [25], and MOPO [76]) and model-free (CQL [31], IQL [28], and $\mathrm { T D } 3 { + } \mathrm { B C }$ [15]) offline RL algorithms. We provide results for all algorithms for the MuJoCo-v2 D4RL datasets and the AntMaze-v0 datasets (details in Appendix B.7).
200
+
201
+ # 6.1 Results
202
+
203
+ D4RL Performance The results in Table 1 show that RAMBO achieves the best total score for the MuJoCo locomotion domains, outperforming existing state-of-the-art methods. Furthermore, RAMBO obtains the best overall score on both the Medium and Medium-Replay dataset types. For the random datasets, RAMBO is outperformed only by MOReL. This shows that RAMBO performs very well for datasets that are either noisy or consist of suboptimal data.
204
+
205
+ For the Medium-Expert datasets, RAMBO is outperformed by most of the baseline algorithms, suggesting that RAMBO is less suitable for high-quality datasets. However, for the Medium-Expert datasets, simpler approaches such as performing behaviour cloning on the best $10 \%$ of trajectories can be used to achieve stronger performance than offline RL methods [28]. Therefore, the suboptimal performance of RAMBO on the Medium-Expert datasets is less of a concern, as applying offline RL algorithms may not be the most suitable approach for these high-quality datasets.
206
+
207
+ For AntMaze, the model-based algorithms perform considerably less well than the model-free approaches. Unlike the other model-based approaches, RAMBO at least scores greater than zero for most of the datasets. Our results echo previous findings that model-based approaches struggle to perform well in the AntMaze domains, potentially because model-based algorithms are too aggressive and collide with walls [67]. Recent work [67] showed that reverse rollouts can lead to stronger performance for model-based methods in these domains. In future work, we wish to investigate whether combining RAMBO with reverse rollouts improves the performance for AntMaze.
208
+
209
+ Offline Tuning In Table 1, we also present results for RAMBOOFF where the final hyperparameters are chosen using the heuristic described in Appendix B.5. We see that there is a slight degradation in the performance relative to RAMBO, which uses online tuning. However, RAMBOOFF still achieves comparable performance to the best existing approaches on the MuJoCo datasets. This suggests that suitable hyperparameters for RAMBO can reliably be chosen using our offline heuristic.
210
+
211
+ Table 1: Results for the D4RL benchmark using the normalisation procedure proposed by [14]. We report the normalised performance during the last 10 iterations of training averaged over 5 seeds. $\pm$ captures the standard deviation over seeds. Highlighted numbers indicate results within $2 \%$ of the most performant algorithm. \* indicates the total without random datasets.
212
+
213
+ <table><tr><td colspan="2"></td><td colspan="2">Ours</td><td colspan="4">Model-based baselines</td><td colspan="3">Model-free baselines</td><td></td></tr><tr><td colspan="2"></td><td>RAMBO</td><td>RAMBOOFF|</td><td>RepB-SDE COMBO MOPO MOReL</td><td></td><td></td><td></td><td>CQL</td><td>IQL</td><td>TD3+BC</td><td>BC</td></tr><tr><td rowspan="3">aapaem</td><td>HalfCheetah</td><td>40.0 ± 2.3</td><td>33.5 ± 2.6</td><td>32.9</td><td>38.8</td><td>35.4</td><td>25.6</td><td>19.6</td><td>1</td><td>11.0</td><td>2.1</td></tr><tr><td>Hopper</td><td>21.6 ± 8.0</td><td>15.5± 9.4</td><td>8.6</td><td>17.9</td><td>4.1</td><td>53.6</td><td>6.7</td><td>-</td><td>8.5</td><td>9.8</td></tr><tr><td>Walker2D</td><td>11.5 ± 10.5</td><td>0.2±0.6</td><td>21.1</td><td>7.0</td><td>4.2</td><td>37.3</td><td>2.4</td><td>-</td><td>1.6</td><td>1.6</td></tr><tr><td rowspan="3">Waiea</td><td>HalfCheetah</td><td>77.6 ± 1.5</td><td>71.0 ± 3.0</td><td>49.1</td><td>54.2</td><td>69.5</td><td>42.1</td><td>49.0</td><td>47.4</td><td>48.3</td><td>36.1</td></tr><tr><td>Hopper</td><td>92.8± 6.0</td><td>91.2 ± 16.3</td><td>34.0</td><td>94.9</td><td>48.0</td><td>95.4</td><td>66.6</td><td>66.3</td><td>59.3</td><td>29.0</td></tr><tr><td>Walker2D</td><td>86.9 ± 2.7</td><td>89.1 ± 2.7</td><td>72.1</td><td>75.5</td><td>-0.2</td><td>77.8</td><td>83.8</td><td>78.3</td><td>83.7</td><td>6.6</td></tr><tr><td rowspan="3">nipea Aerder</td><td>HalfCheetah</td><td>68.9 ± 2.3</td><td>67.0 ± 1.5</td><td>57.5</td><td>55.1</td><td>68.2</td><td>40.2</td><td>47.1</td><td>44.2</td><td>44.6</td><td>38.4</td></tr><tr><td>Hopper</td><td>96.6± 7.0</td><td>97.6± 3.4</td><td>62.2</td><td>73.1</td><td>39.1</td><td>93.6</td><td>97.0</td><td>94.7</td><td>60.9</td><td>11.8</td></tr><tr><td>Walker2D</td><td>85.0 ± 15.0</td><td>88.5± 4.0</td><td>49.8</td><td>56.0</td><td>69.4</td><td>49.8</td><td>88.2</td><td>73.9</td><td>81.8</td><td>11.3</td></tr><tr><td rowspan="3">wnipen dx</td><td>HalfCheetah</td><td>93.7± 10.5</td><td>79.3 ± 2.9</td><td>55.4</td><td>90.0</td><td>72.7</td><td>53.3</td><td>90.8</td><td>86.7</td><td>90.7</td><td>35.8</td></tr><tr><td>Hopper</td><td>83.3± 9.1</td><td>89.5 ± 11.1</td><td>82.6</td><td>111.1</td><td>3.3</td><td>108.7</td><td>106.8</td><td>91.5</td><td>98.0</td><td>111.9</td></tr><tr><td>Walker2D</td><td>68.3± 20.6</td><td>63.1± 31.3</td><td>88.8</td><td>96.1</td><td>-0.3</td><td>95.6</td><td>109.4</td><td>109.6</td><td>110.1</td><td>6.4</td></tr><tr><td colspan="2">MuJoCo-v2 Total:</td><td>826.2 ± 33.8</td><td>785.5± 40.4</td><td>614.1</td><td>769.7</td><td>413.4</td><td>773.0</td><td>767.4</td><td>692.6*</td><td>698.5</td><td>300.8</td></tr><tr><td colspan="2">Umaze</td><td>25.0±12.0</td><td>23.8± 15.0</td><td>0.0</td><td>80.3</td><td>0.0</td><td>0.0</td><td>74.0</td><td>87.5</td><td>78.6</td><td>65.0</td></tr><tr><td colspan="2"></td><td>16.4 ± 17.9</td><td>5.6± 10.9</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>61.2</td><td>71.2</td><td>3.0</td><td>0.0</td></tr><tr><td colspan="2">Large-Play</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>15.8</td><td>39.6</td><td>0.0</td><td>0.0</td></tr><tr><td colspan="2"></td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0</td><td>57.3</td><td>0.0</td><td>0.0</td><td>84.0</td><td>62.2</td><td>71.4</td><td>55.0</td></tr><tr><td colspan="2">Medium-Diverse</td><td>23.2 ± 14.2</td><td>8.4±9.9</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>53.7</td><td>70.0</td><td>10.6</td><td>0.0</td></tr><tr><td colspan="2">Large-Diverse</td><td>2.4± 3.3</td><td>0.0±0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>14.9</td><td>47.5</td><td>0.2</td><td>0.0</td></tr><tr><td colspan="2">AntMaze-v0 Total:</td><td>67.0 ± 14.9</td><td>37.8± 12.4</td><td>0.0</td><td>137.6</td><td>0.0</td><td>0.0</td><td>303.6</td><td>378.0</td><td>163.8</td><td>120.0</td></tr></table>
214
+
215
+ Table 2: Ablation of the adversarial updates for RAMBO. These results use the same rollout length for each dataset as RAMBO but with no adversarial updates (i.e. $\lambda = 0$ ). The scores are averaged over 5 seeds.
216
+
217
+ <table><tr><td>RAMBO (No Adversarial Training)</td></tr><tr><td>MuJoCo-v2 Total: 694.4 ± 56.5|AntMaze-v0 Total: 45.8 ± 21.8</td></tr></table>
218
+
219
+ Table 3: Comparison between RAMBO and COMBO for the Single Transition Example. We use 20 seeds and $\pm$ captures the standard deviation over seeds. RAMBO outperforms COMBO $( p = 0 . 0 0 5 )$ .
220
+
221
+ <table><tr><td>RAMBO:</td><td></td></tr></table>
222
+
223
+ Ablation of Adversarial Training In Table 2 we present results for RAMBO with no adversarial updates. These results demonstrate that overall performance degrades if the adversarial training is removed. This parallels previous findings that mitigating the issue of model exploitation is crucial to obtaining strong performance in model-based offline RL. Interestingly however, for some specific datasets we obtain the best performance with no adversarial training (Appendix C.2). This suggests that a potential direction for future work could be trying to identify which types of problems do not require regularisation for a successful policy to be trained offline with model-based RL.
224
+
225
+ Comparison to COMBO We focus especially on comparing our approach to COMBO, as it is the most similar existing algorithm. We compare RAMBO and COMBO on the Single Transition toy example which is described in detail in Appendix C.1. This domain has a one-dimensional state and action space, and several distinct regions of the action space are covered by the dataset. We use this domain to investigate whether the policies optimised by RAMBO and COMBO tend to become stuck in local optima.
226
+
227
+ Table 3 compares the performance of RAMBO and COMBO on the Single Transition Example. Further analysis in Appendix C.1 shows that for this problem, the pessimistic value function updates used by COMBO create local maxima in the $Q$ -function which are present throughout training. Policy optimisation can become stuck in these local maxima. On the other hand, the value function produced by RAMBO is initially optimistic, and pessimism is introduced into the value function gradually as the transition function is modified adversarially. Adversarial modification of the transition function is visualised in Appendix C.3. As a result of this gradual introduction of pessimism, we observe that the policy produced by RAMBO is less likely to become stuck in poor local maxima, and better overall performance is obtained in Table 3. This observation may help to explain why RAMBO is able to achieve consistently strong performance relative to existing algorithms in the MuJoCo domains. Gradually increasing the level of pessimism could be a useful modification for existing offline RL algorithms to be investigated in future work.
228
+
229
+ # 7 Conclusion and Future Directions
230
+
231
+ RAMBO is a promising new approach to offline RL which imposes conservatism by adversarially modifying the transition dynamics of a learnt model. Our approach is theoretically justified, and achieves state-of-the-art performance on standard benchmarks.
232
+
233
+ There are a number of possible extensions to RAMBO, some of which we have already discussed. In addition, we would like to apply RAMBO to image-space domains by using deep latent variable models to compress the state space [18, 51] and adversarially perturbing the transition dynamics in the latent space representation. Another direction that we would like to investigate is the use of adversarially trained models to aid interpretability in deep RL [44] by generating imagined worst-case trajectories. Finally, we wish to investigate applying the ideas developed in this work to the online RL setting to improve robustness.
234
+
235
+ # Acknowledgements
236
+
237
+ This work was supported by a Programme Grant from the Engineering and Physical Sciences Research Council (EP/V000748/1), the Clarendon Fund at the University of Oxford, and a gift from Amazon Web Services. Additionally, this project made use of time on Tier 2 HPC facility JADE2, funded by the Engineering and Physical Sciences Research Council (EP/T022205/1).
238
+
239
+ The authors would like to thank Raunak Bhattacharyya, Paul Duckworth, and Matthew Budd for their feedback on an earlier draft of this work.
240
+
241
+ # References
242
+
243
+ [1] Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. An optimistic perspective on offline reinforcement learning. In International Conference on Machine Learning, pages 104–114. PMLR, 2020.
244
+ [2] Gaon An, Seungyong Moon, Jang-Hyun Kim, and Hyun Oh Song. Uncertainty-based offline reinforcement learning with diversified Q-ensemble. Advances in Neural Information Processing Systems, 34:7436–7447, 2021.
245
+ [3] Marcin Andrychowicz, Anton Raichuk, Piotr Stanczyk, Manu Orsini, Sertan Girgin, Raphaël ´ Marinier, Leonard Hussenot, Matthieu Geist, Olivier Pietquin, Marcin Michalski, Sylvain Gelly, and Olivier Bachem. What matters for on-policy deep actor-critic methods? A large-scale study. In International Conference on Learning Representations, 2021.
246
+ [4] Arthur Argenson and Gabriel Dulac-Arnold. Model-based offline planning. In International Conference on Learning Representations, 2021.
247
+ [5] J Andrew Bagnell, Andrew $\mathrm { ~ Y ~ N ~ g ~ }$ , and Jeff G Schneider. Solving uncertain Markov decision processes. Technical report, 2001.
248
+ [6] Philip J Ball, Cong Lu, Jack Parker-Holder, and Stephen Roberts. Augmented world models facilitate zero-shot dynamics generalization from a single offline environment. In International Conference on Machine Learning, pages 619–629. PMLR, 2021.
249
+ [7] David Brandfonbrener, Will Whitney, Rajesh Ranganath, and Joan Bruna. Offline RL without off-policy evaluation. Advances in Neural Information Processing Systems, 34:4933–4946, 2021.
250
+ [8] Catherine Cang, Aravind Rajeswaran, Pieter Abbeel, and Michael Laskin. Behavioral priors and dynamics models: Improving performance and domain transfer in offline RL. In Deep RL Workshop NeurIPS 2021, 2021.
251
+ [9] Ching-An Cheng, Tengyang Xie, Nan Jiang, and Alekh Agarwal. Adversarially trained actor critic for offline reinforcement learning. 2022.
252
+ [10] Kurtland Chua, Roberto Calandra, Rowan McAllister, and Sergey Levine. Deep reinforcement learning in a handful of trials using probabilistic dynamics models. Advances in Neural Information Processing Systems, 31, 2018.
253
+ [11] Ignasi Clavera, Violet Fu, and Pieter Abbeel. Model-augmented actor-critic: Backpropagating through paths. International Conference on Learning Representations, 2020.
254
+ [12] Michael K Cohen and Marcus Hutter. Pessimism about unknown unknowns inspires conservatism. In Conference on Learning Theory, pages 1344–1373. PMLR, 2020.
255
+ [13] Sebastian Curi, Ilija Bogunovic, and Andreas Krause. Combining pessimism with optimism for robust and efficient model-based deep reinforcement learning. In International Conference on Machine Learning, pages 2254–2264. PMLR, 2021.
256
+ [14] Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4RL: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
257
+ [15] Scott Fujimoto and Shixiang Shane Gu. A minimalist approach to offline reinforcement learning. Advances in Neural Information Processing Systems, 34, 2021.
258
+ [16] Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pages 2052–2062. PMLR, 2019.
259
+ [17] Jakob Gawlikowski, Cedrique Rovile Njieutcheu Tassi, Mohsin Ali, Jongseok Lee, Matthias Humt, Jianxiang Feng, Anna Kruspe, Rudolph Triebel, Peter Jung, Ribana Roscher, et al. A survey of uncertainty in deep neural networks. arXiv preprint arXiv:2107.03342, 2021.
260
+ [18] David Ha and Jürgen Schmidhuber. Recurrent world models facilitate policy evolution. Advances in Neural Information Processing Systems, 31, 2018.
261
+ [19] Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Offpolicy maximum entropy deep reinforcement learning with a stochastic actor. In International Conference on Machine Learning, pages 1861–1870. PMLR, 2018.
262
+ [20] Toru Hishinuma and Kei Senda. Weighted model estimation for offline model-based reinforcement learning. Advances in Neural Information Processing Systems, 34, 2021.
263
+ [21] Garud N Iyengar. Robust dynamic programming. Mathematics of Operations Research, 30(2):257–280, 2005.
264
+ [22] Michael Janner, Justin Fu, Marvin Zhang, and Sergey Levine. When to trust your model: Model-based policy optimization. Advances in Neural Information Processing Systems, 32, 2019.
265
+ [23] Natasha Jaques, Asma Ghandeharioun, Judy Hanwen Shen, Craig Ferguson, Agata Lapedriza, Noah Jones, Shixiang Gu, and Rosalind Picard. Way off-policy batch deep reinforcement learning of implicit human preferences in dialog. arXiv preprint arXiv:1907.00456, 2019.
266
+ [24] Kirthevasan Kandasamy, Yoram Bachrach, Ryota Tomioka, Daniel Tarlow, and David Carter. Batch policy gradient methods for improving neural conversation models. International Conference on Learning Representations, 2017.
267
+ [25] Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. MOReL: Model-based offline reinforcement learning. Advances in neural information processing systems, 33:21810–21823, 2020.
268
+ [26] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. International Conference on Learning Representations, 2015.
269
+ [27] Ilya Kostrikov, Rob Fergus, Jonathan Tompson, and Ofir Nachum. Offline reinforcement learning with Fisher divergence critic regularization. In International Conference on Machine Learning, pages 5774–5783. PMLR, 2021.
270
+ [28] Ilya Kostrikov, Ashvin Nair, and Sergey Levine. Offline reinforcement learning with implicit Q-learning. In International Conference on Learning Representations, 2022.
271
+ [29] Aviral Kumar, Justin Fu, Matthew Soh, George Tucker, and Sergey Levine. Stabilizing offpolicy Q-learning via bootstrapping error reduction. Advances in Neural Information Processing Systems, 32, 2019.
272
+ [30] Aviral Kumar, Anikait Singh, Stephen Tian, Chelsea Finn, and Sergey Levine. A workflow for offline model-free robotic reinforcement learning. Conference on Robot Learning, 2021.
273
+ [31] Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative Q-learning for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:1179– 1191, 2020.
274
+ [32] Thanard Kurutach, Ignasi Clavera, Yan Duan, Aviv Tamar, and Pieter Abbeel. Model-ensemble trust-region policy optimization. In International Conference on Learning Representations, 2018.
275
+ [33] Sascha Lange, Thomas Gabel, and Martin Riedmiller. Batch reinforcement learning. In Reinforcement learning, pages 45–73. Springer, 2012.
276
+ [34] Byung-Jun Lee, Jongmin Lee, and Kee-Eung Kim. Representation balancing offline modelbased reinforcement learning. In International Conference on Learning Representations, 2020.
277
+ [35] Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. arXiv preprint arXiv:2005.01643, 2020.
278
+ [36] Yao Liu, Adith Swaminathan, Alekh Agarwal, and Emma Brunskill. Off-policy policy gradient with state distribution correction. International Conference on Machine Learning RL4RealLife Workshop, 2019.
279
+ [37] Cong Lu, Philip Ball, Jack Parker-Holder, Michael Osborne, and Stephen J Roberts. Revisiting design choices in offline model based reinforcement learning. In International Conference on Learning Representations, 2022.
280
+ [38] Ajay Mandlekar, Fabio Ramos, Byron Boots, Silvio Savarese, Li Fei-Fei, Animesh Garg, and Dieter Fox. Iris: Implicit reinforcement without interaction at scale for learning control from offline robot manipulation data. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 4414–4420. IEEE, 2020.
281
+ [39] Tatsuya Matsushima, Hiroki Furuta, Yutaka Matsuo, Ofir Nachum, and Shixiang Gu. Deployment-efficient reinforcement learning via model-based offline optimization. In International Conference on Learning Representations, 2021.
282
+ [40] Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. Nature, 518(7540):529–533, 2015.
283
+ [41] Ofir Nachum, Bo Dai, Ilya Kostrikov, Yinlam Chow, Lihong Li, and Dale Schuurmans. AlgaeDICE: Policy gradient from arbitrary experience. arXiv preprint arXiv:1912.02074, 2019.
284
+ [42] Xinkun Nie, Emma Brunskill, and Stefan Wager. Learning when-to-treat policies. Journal of the American Statistical Association, 116(533):392–409, 2021.
285
+ [43] Arnab Nilim and Laurent El Ghaoui. Robust control of Markov decision processes with uncertain transition matrices. Operations Research, 53(5):780–798, 2005.
286
+ [44] Michael Oberst and David Sontag. Counterfactual off-policy evaluation with gumbel-max structural causal models. In International Conference on Machine Learning, pages 4881–4890. PMLR, 2019.
287
+ [45] OpenAI, Ilge Akkaya, Marcin Andrychowicz, Maciek Chociej, Mateusz Litwin, Bob McGrew, Arthur Petron, Alex Paino, Matthias Plappert, Glenn Powell, Raphael Ribas, Jonas Schneider, Nikolas Tezak, Jerry Tworek, Peter Welinder, Lilian Weng, Qiming Yuan, Wojciech Zaremba, and Lei Zhang. Solving rubik’s cube with a robot hand. arXiv preprint, 2019.
288
+ [46] Yaniv Ovadia, Emily Fertig, Jie Ren, Zachary Nado, David Sculley, Sebastian Nowozin, Joshua Dillon, Balaji Lakshminarayanan, and Jasper Snoek. Can you trust your model’s uncertainty? Evaluating predictive uncertainty under dataset shift. Advances in Neural Information Processing Systems, 32, 2019.
289
+ [47] Tom Le Paine, Cosmin Paduraru, Andrea Michi, Caglar Gulcehre, Konrad Zolna, Alexander Novikov, Ziyu Wang, and Nando de Freitas. Hyperparameter selection for offline reinforcement learning. arXiv preprint arXiv:2007.09055, 2020.
290
+ [48] Xinlei Pan, Daniel Seita, Yang Gao, and John Canny. Risk averse robust adversarial reinforcement learning. In 2019 International Conference on Robotics and Automation (ICRA), pages 8522–8528. IEEE, 2019.
291
+ [49] Xue Bin Peng, Aviral Kumar, Grace Zhang, and Sergey Levine. Advantage-weighted regression: Simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177, 2019.
292
+ [50] Lerrel Pinto, James Davidson, Rahul Sukthankar, and Abhinav Gupta. Robust adversarial reinforcement learning. In International Conference on Machine Learning, pages 2817–2826. PMLR, 2017.
293
+ [51] Rafael Rafailov, Tianhe Yu, Aravind Rajeswaran, and Chelsea Finn. Offline reinforcement learning from images with latent space models. In Learning for Dynamics and Control, pages 1154–1168. PMLR, 2021.
294
+ [52] Antonin Raffin, Ashley Hill, Adam Gleave, Anssi Kanervisto, Maximilian Ernestus, and Noah Dormann. Stable-baselines3: Reliable reinforcement learning implementations. Journal of Machine Learning Research, 2021.
295
+ [53] Aravind Rajeswaran, Igor Mordatch, and Vikash Kumar. A game theoretic framework for model based reinforcement learning. In International Conference on Machine Learning, pages 7953–7963. PMLR, 2020.
296
+ [54] Marc Rigter, Bruno Lacerda, and Nick Hawes. Minimax regret optimisation for robust planning in uncertain Markov decision processes. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 11930–11938. Association for the Advancement of Artificial Intelligence, 2021.
297
+ [55] Aurko Roy, Huan Xu, and Sebastian Pokutta. Reinforcement learning under model mismatch. Advances in Neural Information Processing Systems, 30, 2017.
298
+ [56] John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel. Highdimensional continuous control using generalized advantage estimation. International Conference on Learning Representations, 2016.
299
+ [57] Susan M Shortreed, Eric Laber, Daniel J Lizotte, T Scott Stroup, Joelle Pineau, and Susan A Murphy. Informing sequential clinical decision-making through reinforcement learning: an empirical study. Machine learning, 84(1):109–136, 2011.
300
+ [58] Noah Siegel, Jost Tobias Springenberg, Felix Berkenkamp, Abbas Abdolmaleki, Michael Neunert, Thomas Lampe, Roland Hafner, Nicolas Heess, and Martin Riedmiller. Keep doing what worked: Behavior modelling priors for offline reinforcement learning. In International Conference on Learning Representations, 2020.
301
+ [59] David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, et al. Mastering the game of Go without human knowledge. Nature, 550(7676):354–359, 2017.
302
+ [60] Richard S Sutton. Dyna, an integrated architecture for learning, planning, and reacting. ACM Sigart Bulletin, 2(4):160–163, 1991.
303
+ [61] Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018.
304
+ [62] Richard S Sutton, David McAllester, Satinder Singh, and Yishay Mansour. Policy gradient methods for reinforcement learning with function approximation. Advances in Neural Information Processing Systems, 12, 1999.
305
+ [63] Phillip Swazinna, Steffen Udluft, and Thomas Runkler. Overcoming model bias for robust offline deep reinforcement learning. Engineering Applications of Artificial Intelligence, 104:104366, 2021.
306
+ [64] Aviv Tamar, Shie Mannor, and Huan Xu. Scaling up robust MDPs using function approximation. In International Conference on Machine Learning, pages 181–189. PMLR, 2014.
307
+ [65] Chen Tessler, Yonathan Efroni, and Shie Mannor. Action robust reinforcement learning and applications in continuous control. In International Conference on Machine Learning, pages 6215–6224. PMLR, 2019.
308
+ [66] Masatoshi Uehara and Wen Sun. Pessimistic model-based offline reinforcement learning under partial coverage. International Conference on Learning Representations, 2022.
309
+ [67] Jianhao Wang, Wenzhe Li, Haozhe Jiang, Guangxiang Zhu, Siyuan Li, and Chongjie Zhang. Offline reinforcement learning with reverse model-based imagination. Advances in Neural Information Processing Systems, 34, 2021.
310
+ [68] Yue Wang and Shaofeng Zou. Online robust reinforcement learning with model uncertainty. Advances in Neural Information Processing Systems, 34, 2021.
311
+ [69] Paul J Werbos. Backpropagation through time: what it does and how to do it. Proceedings of the IEEE, 78(10):1550–1560, 1990.
312
+ [70] Wolfram Wiesemann, Daniel Kuhn, and Berç Rustem. Robust Markov decision processes. Mathematics of Operations Research, 38(1):153–183, 2013.
313
+ [71] Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3):229–256, 1992.
314
+ [72] Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019.
315
+ [73] Tengyang Xie, Ching-An Cheng, Nan Jiang, Paul Mineiro, and Alekh Agarwal. Bellmanconsistent pessimism for offline reinforcement learning. Advances in Neural Information Processing Systems, 34, 2021.
316
+ [74] Yijun Yang, Jing Jiang, Tianyi Zhou, Jie Ma, and Yuhui Shi. Pareto policy pool for model-based offline reinforcement learning. In International Conference on Learning Representations, 2021.
317
+ [75] Tianhe Yu, Aviral Kumar, Rafael Rafailov, Aravind Rajeswaran, Sergey Levine, and Chelsea Finn. COMBO: Conservative offline model-based policy optimization. Advances in Neural Information Processing Systems, 34, 2021.
318
+ [76] Tianhe Yu, Garrett Thomas, Lantao Yu, Stefano Ermon, James Y Zou, Sergey Levine, Chelsea Finn, and Tengyu Ma. MOPO: Model-based offline policy optimization. Advances in Neural Information Processing Systems, 33:14129–14142, 2020.
319
+ [77] Siyuan Zhang and Nan Jiang. Towards hyperparameter-free policy selection for offline reinforcement learning. Advances in Neural Information Processing Systems, 34, 2021.
320
+
321
+ # Checklist
322
+
323
+ The checklist follows the references. Please read the checklist guidelines carefully for information on how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or [N/A] . You are strongly encouraged to include a justification to your answer, either by referencing the appropriate section of your paper or providing a brief inline description. For example:
324
+
325
+ • Did you include the license to the code and datasets? [Yes] See Section ??.
326
+ • Did you include the license to the code and datasets? [No] The code and the data are proprietary.
327
+ • Did you include the license to the code and datasets? [N/A]
328
+
329
+ Please do not modify the questions and only use the provided macros for your answers. Note that the Checklist section does not count towards the page limit. In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
330
+
331
+ 1. For all authors...
332
+
333
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
334
+ (b) Did you describe the limitations of your work? [Yes] We included results for the AntMaze datasets where our approach performs less well than model-free methods.
335
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A]
336
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
337
+
338
+ 2. If you are including theoretical results...
339
+
340
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes]
341
+ (b) Did you include complete proofs of all theoretical results? [Yes] We include a complete proof of Proposition 2. For the theoretical results from [66], we provide references to the appropriate parts of that paper.
342
+
343
+ 3. If you ran experiments...
344
+
345
+ (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] A URL to the code is provided.
346
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Detailed information about implementation details and hyperparameters is in the appendix.
347
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Standard deviation with respect to seeds is reported for all results.
348
+ (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] Details of compute used per run and total compute used for full evaluation is in Appendix B.8.
349
+
350
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
351
+
352
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We cite the D4RL benchmark datasets [14].
353
+ (b) Did you mention the license of the assets? [Yes] In Appendix B.7.
354
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] Code for our work is in included via a URL.
355
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
356
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
357
+
358
+ 5. If you used crowdsourcing or conducted research with human subjects...
359
+
360
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
361
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
362
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/train/0lz69oI5iZP/0lz69oI5iZP.md ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Per-Pixel Classification is Not All You Need for Semantic Segmentation
2
+
3
+ Bowen Cheng1,2∗ Alexander G. Schwing2 Alexander Kirillov1
4
+
5
+ 1Facebook AI Research (FAIR)
6
+
7
+ 2University of Illinois at Urbana-Champaign (UIUC)
8
+
9
+ # Abstract
10
+
11
+ Modern approaches typically formulate semantic segmentation as a per-pixel classification task, while instance-level segmentation is handled with an alternative mask classification. Our key insight: mask classification is sufficiently general to solve both semantic- and instance-level segmentation tasks in a unified manner using the exact same model, loss, and training procedure. Following this observation, we propose MaskFormer, a simple mask classification model which predicts a set of binary masks, each associated with a single global class label prediction. Overall, the proposed mask classification-based method simplifies the landscape of effective approaches to semantic and panoptic segmentation tasks and shows excellent empirical results. In particular, we observe that MaskFormer outperforms per-pixel classification baselines when the number of classes is large. Our mask classification-based method outperforms both current state-of-the-art semantic (55.6 mIoU on ADE20K) and panoptic segmentation (52.7 PQ on COCO) models.1
12
+
13
+ # 1 Introduction
14
+
15
+ The goal of semantic segmentation is to partition an image into regions with different semantic categories. Starting from Fully Convolutional Networks (FCNs) work of Long et al. [28], most deep learning-based semantic segmentation approaches formulate semantic segmentation as per-pixel classification (Figure 1 left), applying a classification loss to each output pixel [8, 46]. Per-pixel predictions in this formulation naturally partition an image into regions of different classes.
16
+
17
+ Mask classification is an alternative paradigm that disentangles the image partitioning and classification aspects of segmentation. Instead of classifying each pixel, mask classification-based methods predict a set of binary masks, each associated with a single class prediction (Figure 1 right). The more flexible mask classification dominates the field of instance-level segmentation. Both Mask R-CNN [19] and DETR [3] yield a single class prediction per segment for instance and panoptic segmentation. In contrast, per-pixel classification assumes a static number of outputs and cannot return a variable number of predicted regions/segments, which is required for instance-level tasks.
18
+
19
+ Our key observation: mask classification is sufficiently general to solve both semantic- and instancelevel segmentation tasks. In fact, before FCN [28], the best performing semantic segmentation methods like O2P [4] and SDS [18] used a mask classification formulation. Given this perspective, a natural question emerges: can a single mask classification model simplify the landscape of effective approaches to semantic- and instance-level segmentation tasks? And can such a mask classification model outperform existing per-pixel classification methods for semantic segmentation?
20
+
21
+ To address both questions we propose a simple MaskFormer approach that seamlessly converts any existing per-pixel classification model into a mask classification. Using the set prediction mechanism proposed in DETR [3], MaskFormer employs a Transformer decoder [37] to compute a set of pairs, each consisting of a class prediction and a mask embedding vector. The mask embedding vector is used to get the binary mask prediction via a dot product with the per-pixel embedding obtained from an underlying fully-convolutional network. The new model solves both semantic- and instance-level segmentation tasks in a unified manner: no changes to the model, losses, and training procedure are required. Specifically, for semantic and panoptic segmentation tasks alike, MaskFormer is supervised with the same per-pixel binary mask loss and a single classification loss per mask. Finally, we design a simple inference strategy to blend MaskFormer outputs into a task-dependent prediction format.
22
+
23
+ ![](images/6c865ff89e1ebcc297bb1742e7ca52ffcee661225a78ea093cb69da114208a3b.jpg)
24
+ Figure 1: Per-pixel classification vs. mask classification. (left) Semantic segmentation with perpixel classification applies the same classification loss to each location. (right) Mask classification predicts a set of binary masks and assigns a single class to each mask. Each prediction is supervised with a per-pixel binary mask loss and a classification loss. Matching between the set of predictions and ground truth segments can be done either via bipartite matching similarly to DETR [3] or by fixed matching via direct indexing if the number of predictions and classes match, i.e., if $N = K$ .
25
+
26
+ We evaluate MaskFormer on five semantic segmentation datasets with various numbers of categories: Cityscapes [13] (19 classes), Mapillary Vistas [31] (65 classes), ADE20K [49] (150 classes), COCOStuff-10K [2] (171 classes), and ADE20K-Full [49] (847 classes). While MaskFormer performs on par with per-pixel classification models for Cityscapes, which has a few diverse classes, the new model demonstrates superior performance for datasets with larger vocabulary. We hypothesize that a single class prediction per mask models fine-grained recognition better than per-pixel class predictions. MaskFormer achieves the new state-of-the-art on ADE20K $\mathbf { \left( 5 5 . 6 \ m I o U \right) }$ ) with Swin-Transformer [27] backbone, outperforming a per-pixel classification model [27] with the same backbone by 2.1 mIoU, while being more efficient ( $10 \%$ reduction in parameters and $40 \%$ reduction in FLOPs).
27
+
28
+ Finally, we study MaskFormer’s ability to solve instance-level tasks using two panoptic segmentation datasets: COCO [26, 22] and ADE20K [49]. MaskFormer outperforms a more complex DETR model [3] with the same backbone and the same post-processing. Moreover, MaskFormer achieves the new state-of-the-art on COCO (52.7 PQ), outperforming prior state-of-the-art [38] by 1.6 PQ. Our experiments highlight MaskFormer’s ability to unify instance- and semantic-level segmentation.
29
+
30
+ # 2 Related Works
31
+
32
+ Both per-pixel classification and mask classification have been extensively studied for semantic segmentation. In early work, Konishi and Yuille [23] apply per-pixel Bayesian classifiers based on local image statistics. Then, inspired by early works on non-semantic groupings [11, 33], mask classification-based methods became popular demonstrating the best performance in PASCAL VOC challenges [16]. Methods like O2P [4] and CFM [14] have achieved state-of-the-art results by classifying mask proposals [5, 36, 1]. In 2015, FCN [28] extended the idea of per-pixel classification to deep nets, significantly outperforming all prior methods on mIoU (a per-pixel evaluation metric which particularly suits the per-pixel classification formulation of segmentation).
33
+
34
+ Per-pixel classification became the dominant way for deep-net-based semantic segmentation since the seminal work of Fully Convolutional Networks (FCNs) [28]. Modern semantic segmentation models focus on aggregating long-range context in the final feature map: ASPP [6, 7] uses atrous convolutions with different atrous rates; PPM [46] uses pooling operators with different kernel sizes; DANet [17], OCNet [45], and CCNet [21] use different variants of non-local blocks [39]. Recently, SETR [47] and Segmenter [34] replace traditional convolutional backbones with Vision Transformers (ViT) [15] that capture long-range context starting from the very first layer. However, these concurrent Transformer-based [37] semantic segmentation approaches still use a per-pixel classification formulation. Note, that our MaskFormer module can convert any per-pixel classification model to the mask classification setting, allowing seamless adoption of advances in per-pixel classification.
35
+
36
+ Mask classification is commonly used for instance-level segmentation tasks [18, 22]. These tasks require a dynamic number of predictions, making application of per-pixel classification challenging as it assumes a static number of outputs. Omnipresent Mask R-CNN [19] uses a global classifier to classify mask proposals for instance segmentation. DETR [3] further incorporates a Transformer [37] design to handle thing and stuff segmentation simultaneously for panoptic segmentation [22]. However, these mask classification methods require predictions of bounding boxes, which may limit their usage in semantic segmentation. The recently proposed Max-DeepLab [38] removes the dependence on box predictions for panoptic segmentation with conditional convolutions [35, 40]. However, in addition to the main mask classification losses it requires multiple auxiliary losses (i.e., instance discrimination loss, mask-ID cross entropy loss, and the standard per-pixel classification loss).
37
+
38
+ # 3 From Per-Pixel to Mask Classification
39
+
40
+ In this section, we first describe how semantic segmentation can be formulated as either a per-pixel classification or a mask classification problem. Then, we introduce our instantiation of the mask classification model with the help of a Transformer decoder [37]. Finally, we describe simple inference strategies to transform mask classification outputs into task-dependent prediction formats.
41
+
42
+ # 3.1 Per-pixel classification formulation
43
+
44
+ For per-pixel classification, a segmentation model aims to predict the probability distribution over all possible K categories for every pixel of an H×W image: y = {pi|pi ∈ ∆K }H·Wi=1 . Here ∆K is the Kdimensional probability simplex. Training a per-pixel classification model is straight-forward: given ground truth category labels $y ^ { \mathrm { g t } } = \{ y _ { i } ^ { \mathrm { g t } } | y _ { i } ^ { \mathrm { g t } } \in \{ 1 , \dots , K \} \} _ { i = 1 } ^ { H \cdot W }$ for every pixel, a per-pixel crossentropy (negative log-likelihood) loss is usually applied, i.e., $\begin{array} { r } { \dot { \mathcal { L } } _ { \mathrm { p i x e l - c l s } } ( y , y ^ { \mathrm { g t } } ) = \sum _ { i = 1 } ^ { H \cdot W } - \log p _ { i } ( y _ { i } ^ { \mathrm { g t } } ) } \end{array}$ .
45
+
46
+ # 3.2 Mask classification formulation
47
+
48
+ Mask classification splits the segmentation task into 1) partitioning/grouping the image into $N$ regions $N$ does not need to equal $K$ ), represented with binary masks $\{ m _ { i } | \bar { m } _ { i } \in [ 0 , 1 ] ^ { \bar { H } \times W } \} _ { i = 1 } ^ { N }$ }Ni=1; and 2) associating each region as a whole with some distribution over $K$ categories. To jointly group and classify a segment, i.e., to perform mask classification, we define the desired output $z$ as a set of $N$ probability-mask pairs, i.e., $z = \{ ( p _ { i } , m _ { i } ) \} _ { i = 1 } ^ { N }$ . In contrast to per-pixel class probability prediction, for mask classification the probability distribution $p _ { i } \in \Delta ^ { K + 1 }$ contains an auxiliary “no object” label $( \emptyset )$ in addition to the $K$ category labels. The $\mathcal { D }$ label is predicted for masks that do not correspond to any of the $K$ categories. Note, mask classification allows multiple mask predictions with the same associated class, making it applicable to both semantic- and instance-level segmentation tasks.
49
+
50
+ To train a mask classification model, a matching $\sigma$ between the set of predictions $z$ and the set of $N ^ { \mathrm { g t } }$ ground truth segments zgt = {(cgti , mgti )|cgti ∈ {1, . . . , K }, mgti ∈ {0, 1}H×W }N gti=1 i s required.2 Here $c _ { i } ^ { \mathrm { g t } }$ is the ground truth class of the $i ^ { \mathrm { { t h } } }$ ground truth segment. Since the size of prediction set $| z | = N$ and ground truth set $| z ^ { \mathrm { g t } } | = N ^ { \mathrm { g t } }$ generally differ, we assume $N \geq N ^ { \mathrm { g t } }$ and pad the set of ground truth labels with “no object” tokens $\mathcal { D }$ to allow one-to-one matching.
51
+
52
+ For semantic segmentation, a trivial fixed matching is possible if the number of predictions $N$ matches the number of category labels $K$ . In this case, the $i ^ { \mathrm { { t h } } }$ prediction is matched to a ground truth region with class label $i$ and to $\mathcal { D }$ if a region with class label $i$ is not present in the ground truth. In our experiments, we found that a bipartite matching-based assignment demonstrates better results than the fixed matching. Unlike DETR [3] that uses bounding boxes to compute the assignment costs between prediction $z _ { i }$ and ground truth $z _ { j } ^ { \mathrm { g t } }$ for the matching problem, we directly use class and mask predictions, i.e., $- p _ { i } ( c _ { j } ^ { \mathrm { g t } } ) + \mathcal { L } _ { \mathrm { m a s k } } ( m _ { i } , m _ { j } ^ { \mathrm { g t } } )$ , where ${ \mathcal { L } } _ { \mathrm { m a s k } }$ is a binary mask loss.
53
+
54
+ To train model parameters, given a matching, the main mask classification loss $\mathcal { L } _ { \mathrm { m a s k - c l s } }$ is composed of a cross-entropy classification loss and a binary mask loss $\mathcal { L } _ { \mathrm { m a s k } }$ for each predicted segment:
55
+
56
+ $$
57
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { m a s k - c l s } } ( z , z ^ { \mathsf { g t } } ) = \sum _ { j = 1 } ^ { N } \left[ - \log p _ { \sigma ( j ) } ( c _ { j } ^ { \mathsf { g t } } ) + \mathbb { 1 } _ { c _ { j } ^ { \mathsf { g t } } \neq \sigma } \mathcal { L } _ { \mathrm { m a s k } } ( m _ { \sigma ( j ) } , m _ { j } ^ { \mathsf { g t } } ) \right] . } \end{array}
58
+ $$
59
+
60
+ ![](images/80d5cbaf1d83eaec5aa6fc1a91131a3b51bc0a3d769578d338e903483120c65b.jpg)
61
+ Figure 2: MaskFormer overview. We use a backbone to extract image features $\mathcal { F }$ . A pixel decoder gradually upsamples image features to extract per-pixel embeddings $\mathcal { E } _ { \mathrm { p i x e l } }$ . A transformer decoder attends to image features and produces $N$ per-segment embeddings $\mathcal { Q }$ . The embeddings independently generate $N$ class predictions with $N$ corresponding mask embeddings ${ \mathcal { E } } _ { \mathrm { m a s k } }$ . Then, the model predicts $N$ possibly overlapping binary mask predictions via a dot product between pixel embeddings $\mathcal { E } _ { \mathrm { p i x e l } }$ and mask embeddings ${ \mathcal { E } } _ { \mathrm { m a s k } }$ followed by a sigmoid activation. For semantic segmentation task we can get the final prediction by combining $N$ binary masks with their class predictions using a simple matrix multiplication (see Section 3.4). Note, the dimensions for multiplication $\otimes$ are shown in gray.
62
+
63
+ Note, that most existing mask classification models use auxiliary losses (e.g., a bounding box loss [19, 3] or an instance discrimination loss [38]) in addition to $\mathcal { L } _ { \mathrm { m a s k - c l s } }$ . In the next section we present a simple mask classification model that allows end-to-end training with $\mathcal { L } _ { \mathrm { m a s k - c l s } }$ alone.
64
+
65
+ # 3.3 MaskFormer
66
+
67
+ We now introduce MaskFormer, the new mask classification model, which computes $N$ probabilitymask pairs $z = \{ ( p _ { i } , m _ { i } ) \} _ { i = 1 } ^ { N }$ . The model contains three modules (see Fig. 2): 1) a pixel-level module that extracts per-pixel embeddings used to generate binary mask predictions; 2) a transformer module, where a stack of Transformer decoder layers [37] computes $N$ per-segment embeddings; and 3) a segmentation module, which generates predictions $\{ ( p _ { i } , m _ { i } ) \} _ { i = 1 } ^ { N ^ { \ast } }$ from these embeddings. During inference, discussed in Sec. 3.4, $p _ { i }$ and $m _ { i }$ are assembled into the final prediction.
68
+
69
+ Pixel-level module takes an image of size $H \times W$ as input. A backbone generates a (typically) low-resolution image feature map $\mathcal { F } \in \mathbb { R } ^ { C _ { \mathcal { F } } \times \frac { H } { S } \times \frac { W } { S } }$ , where $C _ { \mathcal { F } }$ is the number of channels and $S$ is the stride of the feature map ( $C _ { \mathcal { F } }$ depends on the specific backbone and we use $S = 3 2$ in this work). Then, a pixel decoder gradually upsamples the features to generate per-pixel embeddings $\mathcal { E } _ { \mathrm { p i x e l } } \in \mathbb { R } ^ { C _ { \varepsilon } \times H \stackrel { \cdot } { \times } W }$ , where $C _ { \mathcal { E } }$ is the embedding dimension. Note, that any per-pixel classificationbased segmentation model fits the pixel-level module design including recent Transformer-based models [34, 47, 27]. MaskFormer seamlessly converts such a model to mask classification.
70
+
71
+ Transformer module uses the standard Transformer decoder [37] to compute from image features $\mathcal { F }$ and $N$ learnable positional embeddings (i.e., queries) its output, i.e., $N$ per-segment embeddings $\mathcal { Q } \in \mathbb { R } ^ { C _ { \mathcal { Q } } \times N }$ of dimension $C _ { \mathcal { Q } }$ that encode global information about each segment MaskFormer predicts. Similarly to [3], the decoder yields all predictions in parallel.
72
+
73
+ Segmentation module applies a linear classifier, followed by a softmax activation, on top of the per-segment embeddings Note, that the classifier p $\mathcal { Q }$ to yield class probability predictions dicts an additional “no object” categ $\{ p _ { i } \in \Delta ^ { K + 1 } \} _ { i = 1 } ^ { N }$ for each segment. embedding does $( \emptyset )$ not correspond to any region. For mask prediction, a Multi-Layer Perceptron (MLP) with 2 hidden layers converts the per-segment embeddings $\mathcal { Q }$ to $N$ mask embeddings $\bar { \mathcal { E } _ { \mathrm { m a s k } } } \in \mathbb { R } ^ { C \varepsilon \times N }$ of dimension $C _ { \mathcal { E } }$ . Finally, we obtain each binary mask prediction $m _ { i } \in [ 0 , 1 ] ^ { H \times \widecheck W }$ via a dot product between the $i ^ { \mathrm { { t h } } }$ mask embedding and per-pixel embeddings $\mathcal { E } _ { \mathrm { p i x e l } }$ computed by the pixel-level module. The dot product is followed by a sigmoid activation, i.e., $\begin{array} { r } { \dot { m } _ { i } [ h , w ] = \mathrm { s i g m o i d } ( \mathcal { E } _ { \mathrm { m a s k } } [ : , i ] ^ { \mathrm { T } } \cdot \mathcal { E } _ { \mathrm { p i x e l } } [ : , h , w ] ) } \end{array}$ .
74
+
75
+ Note, we empirically find it is beneficial to not enforce mask predictions to be mutually exclusive to each other by using a softmax activation. During training, the $\mathcal { L } _ { \mathrm { m a s k - c l s } }$ loss combines a cross entropy classification loss and a binary mask loss $\mathcal { L } _ { \mathrm { m a s k } }$ for each predicted segment. For simplicity we use the same $\mathcal { L } _ { \mathrm { m a s k } }$ as DETR [3], i.e., a linear combination of a focal loss [25] and a dice loss [30] multiplied by hyper-parameters $\lambda _ { \mathrm { f o c a l } }$ and $\lambda _ { \mathrm { d i c e } }$ respectively.
76
+
77
+ # 3.4 Mask-classification inference
78
+
79
+ First, we present a simple general inference procedure that converts mask classification outputs $\{ ( p _ { i } , m _ { i } ) \bar \} _ { i = 1 } ^ { N }$ to either panoptic or semantic segmentation output formats. Then, we describe a semantic inference procedure specifically designed for semantic segmentation. We note, that the specific choice of inference strategy largely depends on the evaluation metric rather than the task.
80
+
81
+ General inference partitions an image into segments by assigning each pixel $[ h , w ]$ to one of the $N$ predicted probability-mask pairs via arg $\mathrm { m a x } _ { i : c _ { i } \neq \emptyset } p _ { i } ( c _ { i } ) \cdot m _ { i } [ h , w ]$ . Here $c _ { i }$ is the most likely class label $c _ { i } = \arg \operatorname* { m a x } _ { c \in \{ 1 , \ldots , K , \infty \} } p _ { i } ( c )$ for each probability-mask pair $i$ . Intuitively, this procedure assigns a pixel at location $[ h , w ]$ to probability-mask pair $i$ only if both the most likely class probability $p _ { i } ( c _ { i } )$ and the mask prediction probability $m _ { i } [ h , w ]$ are high. Pixels assigned to the same probabilitymask pair $i$ form a segment where each pixel is labelled with $c _ { i }$ . For semantic segmentation, segments sharing the same category label are merged; whereas for instance-level segmentation tasks, the index $i$ of the probability-mask pair helps to distinguish different instances of the same class. Finally, to reduce false positive rates in panoptic segmentation we follow previous inference strategies [3, 22]. Specifically, we filter out low-confidence predictions prior to inference and remove predicted segments that have large parts of their binary masks $( m _ { i } > 0 . 5 )$ occluded by other predictions.
82
+
83
+ Semantic inference is designed specifically for semantic segmentation and is done via a simple matrix multiplication. We empirically find that marginalization over probability-mask pairs, i.e., arg $\begin{array} { r } { \operatorname* { m a x } _ { c \in \{ 1 , \ldots , K \} } \sum _ { i = 1 } ^ { N } p _ { i } ( c ) \cdot m _ { i } [ h , w ] } \end{array}$ , yields better results than the hard assignment of each pixel to a probability-mask pair $i$ used in the general inference strategy. The argmax does not include the “no object” category $( \emptyset )$ as standard semantic segmentation requires each output pixel to take a label. Note, this strategy returns a per-pixel class probability $\begin{array} { r } { \sum _ { i = 1 } ^ { N } p _ { i } ( c ) \cdot m _ { i } [ h , w ] } \end{array}$ . However, we observe that directly maximizing per-pixel class likelihood leads to poor performance. We hypothesize, that gradients are evenly distributed to every query, which complicates training.
84
+
85
+ # 4 Experiments
86
+
87
+ We demonstrate that MaskFormer seamlessly unifies semantic- and instance-level segmentation tasks by showing state-of-the-art results on both semantic segmentation and panoptic segmentation datasets. Then, we ablate the MaskFormer design confirming that observed improvements in semantic segmentation indeed stem from the shift from per-pixel classification to mask classification.
88
+
89
+ Datasets. We study MaskFormer using four widely used semantic segmentation datasets: ADE20K [49] (150 classes) from the SceneParse150 challenge [48], COCO-Stuff-10K [2] (171 classes), Cityscapes [13] (19 classes), and Mapillary Vistas [31] (65 classes). In addition, we use the ADE20K-Full [49] dataset annotated in an open vocabulary setting (we keep 874 classes that are present in both train and validation sets). For panotic segmenation evaluation we use COCO [26, 2, 22] (80 “things” and 53 “stuff” categories) and ADE20K-Panoptic [49, 22] (100 “things” and 50 “stuff” categories). Please see the appendix for detailed descriptions of all used datasets.
90
+
91
+ Evaluation metrics. For semantic segmentation the standard metric is mIoU (mean Intersection-overUnion) [16], a per-pixel metric that directly corresponds to the per-pixel classification formulation. To better illustrate the difference between segmentation approaches, in our ablations we supplement mIoU with $\mathbf { P Q } ^ { \mathbf { S t } }$ (PQ stuff) [22], a per-region metric that treats all classes as “stuff” and evaluates each segment equally, irrespective of its size. We report the median of 3 runs for all datasets, except for Cityscapes where we report the median of 5 runs. For panoptic segmentation, we use the standard PQ (panoptic quality) metric [22] and report single run results due to prohibitive training costs.
92
+
93
+ Baseline models. On the right we sketch the used per-pixel classification baselines. The PerPixelBaseline uses the pixel-level module of MaskFormer and directly outputs per-pixel class scores. For a fair comparison, we design PerPixelBaseline+ which adds the transformer module and mask em
94
+
95
+ ![](images/b57ad823f8fc97519af6d2b349e90c0278692fb8d303fd19f3e9b2c5cf677508.jpg)
96
+
97
+ bedding MLP to the PerPixelBaseline. Thus, PerPixelBaseline+ and MaskFormer differ only in the formulation: per-pixel vs. mask classification. Note that these baselines are for ablation and we compare MaskFormer with state-of-the-art per-pixel classification models as well.
98
+
99
+ # 4.1 Implementation details
100
+
101
+ Backbone. MaskFormer is compatible with any backbone architecture. In our work we use the standard convolution-based ResNet [20] backbones (R50 and R101 with 50 and 101 layers respectively) and recently proposed Transformer-based Swin-Transformer [27] backbones. In addition, we use the R101c model [6] which replaces the first $7 \times 7$ convolution layer of R101 with 3 consecutive $3 \times 3$ convolutions and which is popular in the semantic segmentation community [46, 7, 8, 21, 44, 10].
102
+
103
+ Pixel decoder. The pixel decoder in Figure 2 can be implemented using any semantic segmentation decoder (e.g., [8–10]). Many per-pixel classification methods use modules like ASPP [6] or PSP [46] to collect and distribute context across locations. The Transformer module attends to all image features, collecting global information to generate class predictions. This setup reduces the need of the per-pixel module for heavy context aggregation. Therefore, for MaskFormer, we design a light-weight pixel decoder based on the popular FPN [24] architecture.
104
+
105
+ Following FPN, we $2 \times$ upsample the low-resolution feature map in the decoder and sum it with the projected feature map of corresponding resolution from the backbone; Projection is done to match channel dimensions of the feature maps with a $1 \times 1$ convolution layer followed by GroupNorm (GN) [41]. Next, we fuse the summed features with an additional $3 \times 3$ convolution layer followed by GN and ReLU activation. We repeat this process starting with the stride 32 feature map until we obtain a final feature map of stride 4. Finally, we apply a single $1 \times 1$ convolution layer to get the per-pixel embeddings. All feature maps in the pixel decoder have a dimension of 256 channels.
106
+
107
+ Transformer decoder. We use the same Transformer decoder design as DETR [3]. The $N$ query embeddings are initialized as zero vectors, and we associate each query with a learnable positional encoding. We use 6 Transformer decoder layers with 100 queries by default, and, following DETR, we apply the same loss after each decoder. In our experiments we observe that MaskFormer is competitive for semantic segmentation with a single decoder layer too, whereas for instance-level segmentation multiple layers are necessary to remove duplicates from the final predictions.
108
+
109
+ Segmentation module. The multi-layer perceptron (MLP) in Figure 2 has 2 hidden layers of 256 channels to predict the mask embeddings $\mathcal { E } _ { \mathrm { m a s k } }$ , analogously to the box head in DETR. Both per-pixel $\mathcal { E } _ { \mathrm { p i x e l } }$ and mask ${ \mathcal { E } } _ { \mathrm { m a s k } }$ embeddings have 256 channels.
110
+
111
+ Loss weights. We use focal loss [25] and dice loss [30] for our mask loss: ${ \mathcal { L } } _ { \mathrm { m a s k } } ( m , m ^ { \mathrm { g t } } ) =$ $\lambda _ { \mathrm { f o c a l } } \mathcal { L } _ { \mathrm { f o c a l } } ( m , m ^ { \mathrm { g t } } ) + \lambda _ { \mathrm { d i c e } } \mathcal { L } _ { \mathrm { d i c e } } ( m , m ^ { \mathrm { g t } } )$ , and set the hyper-parameters to $\lambda _ { \mathrm { f o c a l } } = 2 0 . 0$ and $\lambda _ { \mathrm { d i c e } } =$ 1.0. Following DETR [3], the weight for the “no object” $( \emptyset )$ in the classification loss is set to 0.1.
112
+
113
+ # 4.2 Training settings
114
+
115
+ Semantic segmentation. We use Detectron2 [42] and follow the commonly used training settings for each dataset. More specifically, we use AdamW [29] and the poly [6] learning rate schedule with an initial learning rate of $1 0 ^ { - \bar { 4 } }$ and a weight decay of $1 0 ^ { - 4 }$ for ResNet [20] backbones, and an initial learning rate of $6 \cdot 1 0 ^ { - 5 }$ and a weight decay of $1 0 ^ { - 2 }$ for Swin-Transformer [27] backbones. Backbones are pre-trained on ImageNet-1K [32] if not stated otherwise. A learning rate multiplier of 0.1 is applied to CNN backbones and 1.0 is applied to Transformer backbones. The standard random scale jittering between 0.5 and 2.0, random horizontal flipping, random cropping as well as random color jittering are used as data augmentation [12]. For the ADE20K dataset, if not stated otherwise, we use a crop size of $5 1 2 \times 5 1 2$ , a batch size of 16 and train all models for $1 6 0 \mathrm { k }$ iterations. For the ADE20K-Full dataset, we use the same setting as ADE20K except that we train all models for $2 0 0 \mathrm { k }$ iterations. For the COCO-Stuff-10k dataset, we use a crop size of $6 4 0 \times 6 4 0$ , a batch size of 32 and train all models for $6 0 \mathrm { k }$ iterations. All models are trained with 8 V100 GPUs. We report both performance of single scale (s.s.) inference and multi-scale (m.s.) inference with horizontal flip and scales of 0.5, 0.75, 1.0, 1.25, 1.5, 1.75. See appendix for Cityscapes and Mapillary Vistas settings.
116
+
117
+ Panoptic segmentation. We follow exactly the same architecture, loss, and training procedure as we use for semantic segmentation. The only difference is supervision: i.e., category region masks in semantic segmentation vs. object instance masks in panoptic segmentation. We strictly follow the DETR [3] setting to train our model on the COCO panoptic segmentation dataset [22] for a fair comparison. On the ADE20K panoptic segmentation dataset, we follow the semantic segmentation setting but train for longer (720k iterations) and use a larger crop size $6 4 0 \times 6 4 0 )$ ). COCO models are trained using 64 V100 GPUs and ADE20K experiments are trained with 8 V100 GPUs. We use the general inference (Section 3.4) with the following parameters: we filter out masks with class confidence below 0.8 and set masks whose contribution to the final panoptic segmentation is less than $80 \%$ of its mask area to VOID. We report performance of single scale inference.
118
+
119
+ Table 1: Semantic segmentation on ADE20K val with 150 categories. Mask classification-based MaskFormer outperforms the best per-pixel classification approaches while using fewer parameters and less computation. We report both single-scale (s.s.) and multi-scale (m.s.) inference results with ±std. FLOPs are computed for the given crop size. Frames-per-second (fps) is measured on a V100 GPU with a batch size of 1.3 Backbones pre-trained on ImageNet-22K are marked with †.
120
+
121
+ <table><tr><td></td><td>method</td><td>backbone</td><td>crop size</td><td>mIoU (s.s.)</td><td>mloU (m.s.)</td><td>#params.</td><td>FLOPs</td><td>fps</td></tr><tr><td rowspan="5">GN egeess</td><td rowspan="2">OCRNet [44]</td><td>R101c</td><td>520×520</td><td>1</td><td>45.3</td><td>-</td><td>-</td><td>-</td></tr><tr><td>R50c</td><td>512×512</td><td>44.0</td><td>44.9</td><td>44M</td><td>177G</td><td>21.0</td></tr><tr><td rowspan="2">DeepLabV3+ [8]</td><td>R101c</td><td>512×512</td><td>45.5</td><td>46.4</td><td>63M</td><td>255G</td><td>14.2</td></tr><tr><td>R50</td><td>512×512</td><td>44.5 ±0.5</td><td>46.7 ±0.6</td><td>41M</td><td>53G</td><td>24.5</td></tr><tr><td rowspan="2">MaskFormer (ours)</td><td>R101</td><td>512 × 512</td><td>45.5 ±0.5</td><td>47.2 ±0.2</td><td>60M</td><td>73G</td><td>19.5</td></tr><tr><td>R101c</td><td>512 × 512</td><td>46.0 ±0.1</td><td>48.1 ±0.2</td><td>60M</td><td>80G</td><td>19.0</td></tr><tr><td rowspan="10">Trrirrrrrgrreloreors</td><td>SETR[47]</td><td>ViT-L</td><td>512×512</td><td>-</td><td>50.3</td><td>308M</td><td>-</td><td>-</td></tr><tr><td rowspan="4">Swin-UperNet [27,43]</td><td>Swin-T</td><td>512×512</td><td>1</td><td>46.1</td><td>60M</td><td>236G</td><td>18.5</td></tr><tr><td>Swin-S</td><td>512× 512</td><td>1</td><td>49.3</td><td>81M</td><td>259G</td><td>15.2</td></tr><tr><td>Swin-B</td><td>640 × 640</td><td>1</td><td>51.6</td><td>121M</td><td>471G</td><td>8.7</td></tr><tr><td>Swin-L</td><td>640× 640</td><td>-</td><td>53.5</td><td>234M</td><td>647G</td><td>6.2</td></tr><tr><td rowspan="5">MaskFormer (ours)</td><td>Swin-T</td><td>512×512</td><td>46.7 ±0.7</td><td>48.8 ±0.6</td><td>42M</td><td>55G</td><td>22.1</td></tr><tr><td>Swin-S</td><td>512× 512</td><td>49.8 ±0.4</td><td>51.0 ±0.4</td><td>63M</td><td>79G</td><td>19.6</td></tr><tr><td>Swin-B</td><td>640× 640</td><td>51.1 ±0.2</td><td>52.3 ±0.4</td><td>102M</td><td>195G</td><td>12.6</td></tr><tr><td>Swin-B</td><td>640×640</td><td>52.7 ±0.4</td><td>53.9 ±0.2</td><td>102M</td><td>195G</td><td>12.6</td></tr><tr><td>Swin-L†</td><td>640 × 640</td><td>54.1 ±0.2</td><td>55.6 ±0.1</td><td>212M</td><td>375G</td><td>7.9</td></tr></table>
122
+
123
+ Table 2: MaskFormer vs. per-pixel classification baselines on 4 semantic segmentation datasets. MaskFormer improvement is larger when the number of classes is larger. We use a ResNet-50 backbone and report single scale mIoU and $\mathrm { P Q } ^ { \mathrm { S t } }$ for ADE20K, COCO-Stuff and ADE20K-Full, whereas for higher-resolution Cityscapes we use a deeper ResNet-101 backbone following [7, 8].
124
+
125
+ <table><tr><td></td><td>Cityscapes (19 classes) mIoU</td><td>PQS</td><td>ADE20K(150 classes) mIoU</td><td>PQS</td><td>COCO-Stuff (171 classes) mIoU</td><td>PQSt</td><td>ADE20K-Full(847 classes) mIoU</td><td>PQSt</td></tr><tr><td>PerPixelBaseline</td><td>77.4</td><td>58.9</td><td>39.2</td><td>21.6</td><td>32.4</td><td>15.5</td><td>12.4</td><td>5.8</td></tr><tr><td>PerPixelBaseline+</td><td>78.5</td><td>60.2</td><td>41.9</td><td>28.3</td><td>34.2</td><td>24.6</td><td>13.9</td><td>9.0</td></tr><tr><td>MaskFormer(ours)</td><td>78.5(+0.0)</td><td>63.1 (+2.9)</td><td>44.5 (+2.6)</td><td>33.4 (+5.1)</td><td>37.1 (+2.9)</td><td>28.9 (+4.3)</td><td>17.4 (+3.5)</td><td>11.9 (+2.9)</td></tr></table>
126
+
127
+ # 4.3 Main results
128
+
129
+ Semantic segmentation. In Table 1, we compare MaskFormer with state-of-the-art per-pixel classification models for semantic segmentation on the ADE20K val set. With the same standard CNN backbones (e.g., ResNet [20]), MaskFormer outperforms DeepLab ${ \mathrm { V } } 3 +$ [8] by 1.7 mIoU. MaskFormer is also compatible with recent Vision Transformer [15] backbones (e.g., the Swin Transformer [27]), achieving a new state-of-the-art of $5 5 . 6 \mathrm { m I o U }$ , which is 2.1 mIoU better than the prior state-of-theart [27]. Observe that MaskFormer outperforms the best per-pixel classification-based models while having fewer parameters and faster inference time. This result suggests that the mask classification formulation has significant potential for semantic segmentation. See appendix for results on test set.
130
+
131
+ Beyond ADE20K, we further compare MaskFormer with our baselines on COCO-Stuff-10K, ADE20K-Full as well as Cityscapes in Table 2 and we refer to the appendix for comparison with state-of-the-art methods on these datasets. The improvement of MaskFormer over PerPixelBaseline $^ +$ is larger when the number of classes is larger: For Cityscapes, which has only 19 categories, MaskFormer performs similarly well as PerPixelBaseline $^ +$ ; While for ADE20K-Full, which has 847 classes, MaskFormer outperforms PerPixelBaseline $^ +$ by 3.5 mIoU.
132
+
133
+ Although MaskFormer shows no improvement in mIoU for Cityscapes, the $\mathrm { P Q } ^ { \mathrm { S t } }$ metric increases by $2 . 9 \mathrm { \bar { P Q } ^ { S t } }$ . We find MaskFormer performs better in terms of recognition quality $( \mathsf { R Q } ^ { \mathsf { S t } } )$ while lagging in per-pixel segmentation quality $( \mathrm { S Q } ^ { \mathrm { S t } } )$ (we refer to the appendix for detailed numbers). This observation suggests that on datasets where class recognition is relatively easy to solve, the main challenge for mask classification-based approaches is pixel-level accuracy (i.e., mask quality).
134
+
135
+ Table 3: Panoptic segmentation on COCO panoptic val with 133 categories. MaskFormer seamlessly unifies semantic- and instance-level segmentation without modifying the model architecture or loss. Our model, which achieves better results, can be regarded as a box-free simplification of DETR [3]. The major improvement comes from “stuff” classes $( \mathrm { P Q } ^ { \mathrm { S t } } )$ which are ambiguous to represent with bounding boxes. For MaskFormer (DETR) we use the exact same post-processing as DETR. Note, that in this setting MaskFormer performance is still better than DETR $( + 2 . 2 \ : \mathrm { P Q } )$ . Our model also outperforms recently proposed Max-DeepLab [38] without the need of sophisticated auxiliary losses, while being more efficient. FLOPs are computed as the average FLOPs over 100 validation images (COCO images have varying sizes). Frames-per-second (fps) is measured on a V100 GPU with a batch size of 1 by taking the average runtime on the entire val set including post-processing time. Backbones pre-trained on ImageNet-22K are marked with †.
136
+
137
+ <table><tr><td></td><td>method</td><td>backbone</td><td>PQ</td><td>PQTh</td><td>PQSt</td><td>SQ</td><td>RQ</td><td>#params.</td><td>FLOPs</td><td>fps</td></tr><tr><td></td><td>DETR [3]</td><td>R50+6Enc</td><td>43.4</td><td>48.2</td><td>36.3</td><td>79.3</td><td>53.8</td><td>-</td><td>-</td><td>-</td></tr><tr><td></td><td>MaskFormer (DETR)</td><td>R50 +6Enc</td><td>45.6</td><td>50.0 (+1.8)</td><td>39.0 (+2.7)</td><td>80.2</td><td>55.8</td><td>-</td><td>-</td><td>-</td></tr><tr><td></td><td>MaskFormer (ours)</td><td>R50 +6Enc</td><td>46.5</td><td>51.0 (+2.8)</td><td>39.8 (+3.5)</td><td>80.4</td><td>56.8</td><td>45M</td><td>181G</td><td>17.6</td></tr><tr><td>Ceee</td><td>DETR [3]</td><td>R101+6Enc</td><td>45.1</td><td>50.5</td><td>37.0</td><td>79.9</td><td>55.5</td><td>-</td><td>1</td><td>-</td></tr><tr><td></td><td>MaskFormer (ours)</td><td>R101 +6Enc</td><td>47.6</td><td>52.5 (+2.0)</td><td>40.3 (+3.3)</td><td>80.7</td><td>58.0</td><td>64M</td><td>248G</td><td>14.0</td></tr><tr><td></td><td>Max-DeepLab [38]</td><td>Max-S</td><td>48.4</td><td>53.0</td><td>41.5</td><td>-</td><td>·</td><td>62M</td><td>324G</td><td>7.6</td></tr><tr><td>rirrerigarrrseers</td><td></td><td>Max-L</td><td>51.1</td><td>57.0</td><td>42.2</td><td>-</td><td>1</td><td>451M</td><td>3692G</td><td>-</td></tr><tr><td></td><td></td><td>Swin-T</td><td>47.7</td><td>51.7</td><td>41.7</td><td>80.4</td><td>58.3</td><td>42M</td><td>179G</td><td>17.0</td></tr><tr><td></td><td></td><td>Swin-S</td><td>49.7</td><td>54.4</td><td>42.6</td><td>80.9</td><td>60.4</td><td>63M</td><td>259G</td><td>12.4</td></tr><tr><td></td><td>MaskFormer (ours)</td><td>Swin-B</td><td>51.1</td><td>56.3</td><td>43.2</td><td>81.4</td><td>61.8</td><td>102M</td><td>411G</td><td>8.4</td></tr><tr><td></td><td></td><td>Swin-B</td><td>51.8</td><td>56.9</td><td>44.1</td><td>81.4</td><td>62.6</td><td>102M</td><td>411G</td><td>8.4</td></tr><tr><td></td><td></td><td>Swin-L</td><td>52.7</td><td>58.5</td><td>44.0</td><td>81.8</td><td>63.5</td><td>212M</td><td>792G</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>5.2</td></tr></table>
138
+
139
+ Panoptic segmentation. In Table 3, we compare the same exact MaskFormer model with DETR [3] on the COCO panoptic val set. To match the standard DETR design, we add 6 additional Transformer encoder layers after the CNN backbone. Unlike DETR, our model does not predict bounding boxes but instead predicts masks directly. MaskFormer achieves better results while being simpler than DETR. To disentangle the improvements from the model itself and our post-processing inference strategy we run our model following DETR post-processing (MaskFormer (DETR)) and observe that this setup outperforms DETR by 2.2 PQ. Overall, we observe a larger improvement in $\mathrm { P Q } ^ { \mathrm { S t } }$ compared to $\mathrm { P Q } ^ { \mathrm { T h } }$ . This suggests that detecting “stuff” with bounding boxes is suboptimal, and therefore, boxbased segmentation models (e.g., Mask R-CNN [19]) do not suit semantic segmentation. MaskFormer also outperforms recently proposed Max-DeepLab [38] without the need of special network design as well as sophisticated auxiliary losses (i.e., instance discrimination loss, mask-ID cross entropy loss, and per-pixel classification loss in [38]). MaskFormer, for the first time, unifies semantic- and instance-level segmentation with the exact same model, loss, and training pipeline.
140
+
141
+ We further evaluate our model on the panoptic segmentation version of the ADE20K dataset. Our model also achieves state-of-the-art performance. We refer to the appendix for detailed results.
142
+
143
+ # 4.4 Ablation studies
144
+
145
+ We perform a series of ablation studies of MaskFormer using a single ResNet-50 backbone [20].
146
+
147
+ Per-pixel vs. mask classification. In Table 4, we verify that the gains demonstrated by MaskFromer come from shifting the paradigm to mask classification. We start by comparing PerPixelBaseline+ and MaskFormer. The models are very similar and there are only 3 differences: 1) per-pixel vs. mask classification used by the models, 2) MaskFormer uses bipartite matching, and 3) the new model uses a combination of focal and dice losses as a mask loss, whereas PerPixelBaseline+ utilizes per-pixel cross entropy loss. First, we rule out the influence of loss differences by training PerPixelBaseline $^ +$ with exactly the same losses and observing no improvement. Next, in Table 4a, we compare PerPixelBaseline $^ +$ with MaskFormer trained using a fixed matching (MaskFormer-fixed), i.e., $N = K$ and assignment done based on category label indices identically to the per-pixel classification setup. We observe that MaskFormer-fixed is 1.8 mIoU better than the baseline, suggesting that shifting from per-pixel classification to mask classification is indeed the main reason for the gains of MaskFormer. In Table 4b, we further compare MaskFormer-fixed with MaskFormer trained with bipartite matching (MaskFormer-bipartite) and find bipartite matching is not only more flexible (allowing to predict less masks than the total number of categories) but also produces better results.
148
+
149
+ Table 4: Per-pixel vs. mask classification for semantic segmentation. All models use 150 queries for a fair comparison. We evaluate the models on ADE20K val with 150 categories. 4a: PerPixelBaseline $^ +$ and MaskFormer-fixed use similar fixed matching (i.e., matching by category index), this result confirms that the shift from per-pixel to mask classification is the key. 4b: bipartite matching is not only more flexible (can make less prediction than total class count) but also gives better results.
150
+
151
+ (a) Per-pixel vs. mask classification.
152
+
153
+ (b) Fixed vs. bipartite matching assignment.
154
+
155
+ <table><tr><td></td><td>mIoU</td><td>PQSt</td></tr><tr><td>PerPixelBaseline+</td><td>41.9</td><td>28.3</td></tr><tr><td>MaskFormer-fixed</td><td>43.7 (+1.8)</td><td>30.3 (+2.0)</td></tr></table>
156
+
157
+ <table><tr><td></td><td>mIoU</td><td>PQSt</td></tr><tr><td>MaskFormer-fixed</td><td>43.7</td><td>30.3</td></tr><tr><td>MaskFormer-bipartite (ours)</td><td>44.2 (+0.5)</td><td>33.4 (+3.1)</td></tr></table>
158
+
159
+ Number of queries. The table to the right shows results of MaskFormer trained with a varying number of queries on datasets with different number of categories. The model with 100 queries consistently performs the best across the studied datasets. This suggest we may not need to adjust the number of queries w.r.t. the number of categories or datasets much. Interestingly, even with 20 queries MaskFormer outperforms our per-pixel classification baseline.
160
+
161
+ <table><tr><td># of queries</td><td>ADE20K mIoU PQS</td><td>mIoU</td><td>COCO-Stuff PQS</td><td>ADE20K-Full mIoU</td><td>PQS</td></tr><tr><td>PerPixelBaseline+</td><td>41.9</td><td>28.3</td><td>34.2</td><td>24.6 13.9</td><td>9.0</td></tr><tr><td>20</td><td>42.9</td><td>32.6</td><td>35.0 27.6</td><td>14.1</td><td>10.8</td></tr><tr><td>50</td><td>43.9</td><td>32.7</td><td>35.5 27.9</td><td>15.4</td><td>11.1</td></tr><tr><td>100</td><td> 44.5</td><td>33.4</td><td> 37.1</td><td>28.9 16.0</td><td>11.9</td></tr><tr><td>150</td><td>44.2</td><td>33.4</td><td>37.0</td><td>28.9 15.5</td><td>11.5</td></tr><tr><td>300</td><td>43.5</td><td>32.3</td><td>36.1</td><td>29.1 14.2</td><td>10.3</td></tr><tr><td>1000</td><td>35.4</td><td>26.7</td><td>34.4</td><td>27.6</td><td>8.0 5.8</td></tr></table>
162
+
163
+ We further calculate the number of classes which are on average present in a training set image. We find these statistics to be similar across datasets despite the fact that the datasets have different number of total categories: 8.2 classes per image for ADE20K (150 classes), 6.6 classes per image for COCO-Stuff-10K (171 classes) and 9.1 classes per image for ADE20K-Full (847 classes). We hypothesize that each query is able to capture masks from multiple categories.
164
+
165
+ The figure to the right shows the number of unique categories predicted by each query (sorted in descending order) of our MaskFormer model on the validation sets of the corresponding datasets. Interestingly, the number of unique categories per query does not follow a uniform distribution: some queries capture more classes than others. We try to analyze how MaskFormer queries group categories, but we do not observe any obvious pattern: there are queries capturing categories with similar semantics or shapes (e.g., “house” and “building”), but there are also queries capturing completely different categories (e.g., “water” and “sofa”).
166
+
167
+ ![](images/ae89dfd9e70e3e0680496b42fc9d272c5369941d71040c6cb96f485bff205fd8.jpg)
168
+
169
+ Number of Transformer decoder layers. Interestingly, MaskFormer with even a single Transformer decoder layer already performs well for semantic segmentation and achieves better performance than our 6-layer-decoder PerPixelBaseline+. For panoptic segmentation, however, multiple decoder layers are required to achieve competitive performance. Please see the appendix for a detailed discussion.
170
+
171
+ # 5 Discussion
172
+
173
+ Our main goal is to show that mask classification is a general segmentation paradigm that could be a competitive alternative to per-pixel classification for semantic segmentation. To better understand its potential for segmentation tasks, we focus on exploring mask classification independently of other factors like architecture, loss design, or augmentation strategy. We pick the DETR [3] architecture as our baseline for its simplicity and deliberately make as few architectural changes as possible. Therefore, MaskFormer can be viewed as a “box-free” version of DETR.
174
+
175
+ Table 5: Matching with masks vs. boxes. We compare DETR [3] which uses box-based matching with two MaskFormer models trained with box- and mask-based matching respectively. To use box-based matching in MaskFormer we add to the model an additional box prediction head as in DETR. Note, that with box-based matching MaskFormer performs on par with DETR, whereas with mask-based matching it shows better results. The evaluation is done on COCO panoptic val set.
176
+
177
+ <table><tr><td>method</td><td>backbone</td><td>matching</td><td>PQ</td><td>PQTh</td><td>PQSt</td></tr><tr><td>DETR [3]</td><td>R50 +6Enc</td><td>by box</td><td>43.4</td><td>48.2</td><td>36.3</td></tr><tr><td rowspan="2">MaskFormer (ours)</td><td>R50 +6Enc</td><td>by box</td><td>43.7</td><td>49.2</td><td>35.3</td></tr><tr><td>R50+6Enc</td><td>by mask</td><td>46.5</td><td>51.0</td><td>39.8</td></tr></table>
178
+
179
+ In this section, we discuss in detail the differences between MaskFormer and DETR and show how these changes are required to ensure that mask classification performs well. First, to achieve a pure mask classification setting we remove the box prediction head and perform matching between prediction and ground truth segments with masks instead of boxes. Secondly, we replace the computeheavy per-query mask head used in DETR with a more efficient per-image FPN-based head to make end-to-end training without box supervision feasible.
180
+
181
+ Matching with masks is superior to matching with boxes. We compare MaskFormer models trained using matching with boxes or masks in Table 5. To do box-based matching, we add to MaskFormer an additional box prediction head as in DETR [3]. Observe that MaskFormer, which directly matches with mask predictions, has a clear advantage. We hypothesize that matching with boxes is more ambiguous than matching with masks, especially for stuff categories where completely different masks can have similar boxes as stuff regions often spread over a large area in an image.
182
+
183
+ MaskFormer mask head reduces computation. Results in Table 5 also show that MaskFormer performs on par with DETR when the same matching strategy is used. This suggests that the difference in mask head designs between the models does not significantly influence the prediction quality. The new head, however, has significantly lower computational and memory costs in comparison with the original mask head used in DETR. In MaskFormer, we first upsample image features to get highresolution per-pixel embeddings and directly generate binary mask predictions at a high-resolution. Note, that the per-pixel embeddings from the upsampling module (i.e., pixel decoder) are shared among all queries. In contrast, DETR first generates low-resolution attention maps and applies an independent upsampling module to each query. Thus, the mask head in DETR is $N$ times more computationally expensive than the mask head in MaskFormer (where $N$ is the number of queries).
184
+
185
+ # 6 Conclusion
186
+
187
+ The paradigm discrepancy between semantic- and instance-level segmentation results in entirely different models for each task, hindering development of image segmentation as a whole. We show that a simple mask classification model can outperform state-of-the-art per-pixel classification models, especially in the presence of large number of categories. Our model also remains competitive for panoptic segmentation, without a need to change model architecture, losses, or training procedure. We hope this unification spurs a joint effort across semantic- and instance-level segmentation tasks.
188
+
189
+ # Acknowledgments and Disclosure of Funding
190
+
191
+ We thank Ross Girshick for insightful comments and suggestions. Work of UIUC authors Bowen Cheng and Alexander G. Schwing was supported in part by NSF under Grant #1718221, 2008387, 2045586, 2106825, MRI #1725729, NIFA award 2020-67021-32799 and Cisco Systems Inc. (Gift Award CG 1377144 - thanks for access to Arcetri).
192
+
193
+ # References
194
+
195
+ [1] Pablo Arbeláez, Jordi Pont-Tuset, Jonathan T Barron, Ferran Marques, and Jitendra Malik. Multiscale combinatorial grouping. In CVPR, 2014. 2
196
+ [2] Holger Caesar, Jasper Uijlings, and Vittorio Ferrari. COCO-Stuff: Thing and stuff classes in context. In CVPR, 2018. 2, 5
197
+ [3] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In ECCV, 2020. 1, 2, 3, 4, 5, 6, 8, 9, 10 second-order pooling. In ECCV, 2012. 1, 2
198
+ [5] Joao Carreira and Cristian Sminchisescu. CPMC: Automatic object segmentation using constrained parametric min-cuts. PAMI, 2011. 2
199
+ [6] Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. DeepLab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected CRFs. PAMI, 2018. 2, 6
200
+ [7] Liang-Chieh Chen, George Papandreou, Florian Schroff, and Hartwig Adam. Rethinking atrous convolution for semantic image segmentation. arXiv:1706.05587, 2017. 2, 6, 7 [8] Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam. Encoder-decoder with atrous separable convolution for semantic image segmentation. In ECCV, 2018. 1, 6, 7
201
+ [9] Bowen Cheng, Liang-Chieh Chen, Yunchao Wei, Yukun Zhu, Zilong Huang, Jinjun Xiong, Thomas S Huang, Wen-Mei Hwu, and Honghui Shi. SPGNet: Semantic prediction guidance for scene parsing. In ICCV, 2019.
202
+ [10] Bowen Cheng, Maxwell D Collins, Yukun Zhu, Ting Liu, Thomas S Huang, Hartwig Adam, and LiangChieh Chen. Panoptic-DeepLab: A simple, strong, and fast baseline for bottom-up panoptic segmentation. In CVPR, 2020. 6
203
+ [11] Dorin Comaniciu and Peter Meer. Robust Analysis of Feature Spaces: Color Image Segmentation. In CVPR, 1997. 2
204
+ [12] MMSegmentation Contributors. MMSegmentation: OpenMMLab semantic segmentation toolbox and benchmark. https://github.com/open-mmlab/mmsegmentation, 2020. 6, 7
205
+ [13] Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Rehfeld, Markus Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, and Bernt Schiele. The Cityscapes dataset for semantic urban scene understanding. In CVPR, 2016. 2, 5
206
+ [14] Jifeng Dai, Kaiming He, and Jian Sun. Convolutional feature masking for joint object and stuff segmentation. In CVPR, 2015. 2
207
+ [15] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021. 2, 7
208
+ [16] Mark Everingham, SM Ali Eslami, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman. The PASCAL visual object classes challenge: A retrospective. IJCV, 2015. 2, 5
209
+ [17] Jun Fu, Jing Liu, Haijie Tian, Yong Li, Yongjun Bao, Zhiwei Fang, and Hanqing Lu. Dual attention network for scene segmentation. In CVPR, 2019. 2
210
+ [18] Bharath Hariharan, Pablo Arbeláez, Ross Girshick, and Jitendra Malik. Simultaneous detection and segmentation. In ECCV, 2014. 1, 3
211
+ [19] Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask R-CNN. In ICCV, 2017. 1, 3, 4, 8
212
+ [20] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016. 6, 7, 8
213
+ [21] Zilong Huang, Xinggang Wang, Lichao Huang, Chang Huang, Yunchao Wei, and Wenyu Liu. CCNet: Criss-cross attention for semantic segmentation. In ICCV, 2019. 2, 6
214
+ [22] Alexander Kirillov, Kaiming He, Ross Girshick, Carsten Rother, and Piotr Dollár. Panoptic segmentation. In CVPR, 2019. 2, 3, 5, 6
215
+ [23] Scott Konishi and Alan Yuille. Statistical Cues for Domain Specific Image Segmentation with Performance Analysis. In CVPR, 2000. 2
216
+ [24] Tsung-Yi Lin, Piotr Dollár, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature pyramid networks for object detection. In CVPR, 2017. 6
217
+ [25] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. Focal loss for dense object detection. In ICCV, 2017. 4, 6
218
+ [26] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft COCO: Common objects in context. In ECCV, 2014. 2, 5
219
+ [27] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv:2103.14030, 2021. 2, 4, 6, 7
220
+ [28] Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In CVPR, 2015. 1, 2
221
+ [29] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR, 2019. 6
222
+ [30] Fausto Milletari, Nassir Navab, and Seyed-Ahmad Ahmadi. V-Net: Fully convolutional neural networks for volumetric medical image segmentation. In 3DV, 2016. 4, 6
223
+ [31] Gerhard Neuhold, Tobias Ollmann, Samuel Rota Bulò, and Peter Kontschieder. The mapillary vistas dataset for semantic understanding of street scenes. In CVPR, 2017. 2, 5
224
+ [32] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. IJCV, 2015. 6
225
+ [33] Jianbo Shi and Jitendra Malik. Normalized Cuts and Image Segmentation. PAMI, 2000. 2
226
+ [34] Robin Strudel, Ricardo Garcia, Ivan Laptev, and Cordelia Schmid. Segmenter: Transformer for semantic segmentation. arXiv:2105.05633, 2021. 2, 4
227
+ [35] Zhi Tian, Chunhua Shen, and Hao Chen. Conditional convolutions for instance segmentation. In ECCV, 2020. 3
228
+ [36] Jasper RR Uijlings, Koen EA Van De Sande, Theo Gevers, and Arnold WM Smeulders. Selective search for object recognition. IJCV, 2013. 2
229
+ [37] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017. 1, 2, 3, 4
230
+ [38] Huiyu Wang, Yukun Zhu, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen. MaX-DeepLab: End-to-end panoptic segmentation with mask transformers. In CVPR, 2021. 2, 3, 4, 8
231
+ [39] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In CVPR, 2018. 2
232
+ [40] Xinlong Wang, Rufeng Zhang, Tao Kong, Lei Li, and Chunhua Shen. SOLOv2: Dynamic and fast instance segmentation. NeurIPS, 2020. 3
233
+ [41] Yuxin Wu and Kaiming He. Group normalization. In ECCV, 2018. 6
234
+ [42] Yuxin Wu, Alexander Kirillov, Francisco Massa, Wan-Yen Lo, and Ross Girshick. Detectron2. https: //github.com/facebookresearch/detectron2, 2019. 6
235
+ [43] Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In ECCV, 2018. 7
236
+ [44] Yuhui Yuan, Xilin Chen, and Jingdong Wang. Object-contextual representations for semantic segmentation. In ECCV, 2020. 6, 7
237
+ [45] Yuhui Yuan, Lang Huang, Jianyuan Guo, Chao Zhang, Xilin Chen, and Jingdong Wang. OCNet: Object context for semantic segmentation. IJCV, 2021. 2
238
+ [46] Hengshuang Zhao, Jianping Shi, Xiaojuan Qi, Xiaogang Wang, and Jiaya Jia. Pyramid scene parsing network. In CVPR, 2017. 1, 2, 6
239
+ [47] Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip HS Torr, et al. Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers. In CVPR, 2021. 2, 4, 7
240
+ [48] Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing challenge 2016. http://sceneparsing.csail.mit.edu/index_challenge.html, 2016. 5
241
+ [49] Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ADE20K dataset. In CVPR, 2017. 2, 5
md/train/B1IzH7cxl/B1IzH7cxl.md ADDED
@@ -0,0 +1,401 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A NEURAL STOCHASTIC VOLATILITY MODEL
2
+
3
+ Rui Luo†, Xiaojun $\mathbf { X } \mathbf { u } ^ { \ddag }$ , Weinan Zhang‡, Jun Wang†
4
+ †University College London, $^ \ddag$ Shanghai Jiao Tong University
5
+ {r.luo,j.wang}@cs.ucl.ac.uk, {xuxj,wnzhang}@apex.sjtu.edu.cn
6
+
7
+ # ABSTRACT
8
+
9
+ In this paper, we show that the recent integration of statistical models with recurrent neural networks provides a new way of formulating volatility models that have been popular in time series analysis and prediction. The model comprises a pair of complementary stochastic recurrent neural networks: the generative network models the joint distribution of the stochastic volatility process; the inference network approximates the conditional distribution of the latent variables given the observable ones. Our focus in this paper is on the formulation of temporal dynamics of volatility over time under a stochastic recurrent neural network framework. Our derivations show that some popular volatility models are a special case of our proposed neural stochastic volatility model. Experiments demonstrate that the proposed model generates a smoother volatility estimation, and outperforms standard econometric models GARCH, EGARCH, GJR-GARCH and some other GARCH variants as well as MCMC-based model stochvol and a recent Gaussian processes based volatility model GPVOL on several metrics about the fitness of the volatility modelling and the accuracy of the prediction.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ The volatility of the price movements reflects the ubiquitous uncertainty within financial markets. It is critical that the level of risk, indicated by volatility, is taken into consideration before investment decisions are made and portfolio are optimised (Hull, 2006); volatility is substantially a key variable in the pricing of derivative securities. Hence, estimating and forecasting volatility is of great importance in branches of financial studies, including investment, risk management, security valuation and monetary policy making (Poon & Granger, 2003).
14
+
15
+ Volatility is measured typically by using the standard deviation of price change in a fixed time interval, such as a day, a month or a year. The higher the volatility, the riskier the asset. One of the primary challenges in designing volatility models is to identify the existence of latent (stochastic) variables or processes and to characterise the underlying dependences or interactions between variables within a certain time span. A classic approach has been to handcraft the characteristic features of volatility models by imposing assumptions and constraints, given prior knowledge and observations. Notable examples include autoregressive conditional heteroskedasticity (ARCH) model (Engle, 1982) and its generalisation GARCH (Bollerslev, 1986), which makes use of autoregression to capture the properties of time-variant volatility within many time series. Heston (1993) assumed that the volatility follows a Cox-Ingersoll-Ross (CIR) process (Cox et al., 1985) and derived a closed-form solution for options pricing. While theoretically sound, those approaches require strong assumptions which might involve complex probability distributions and non-linear dynamics that drive the process, and in practice, one may have to impose less prior knowledge and rectify a solution under the worst-case volatility case (Avellaneda & Paras, 1996).
16
+
17
+ In this paper, we take a fully data driven approach and determine the configurations with as few exogenous input as possible, or even purely from the historical data. We propose a neural network re-formulation of stochastic volatility by leveraging stochastic models and recurrent neural networks (RNNs). We are inspired by the recent development on variational approaches of stochastic (deep) neural networks (Kingma & Welling, 2013; Rezende et al., 2014) to a recurrent case (Chung et al., 2015; Fabius & van Amersfoort, 2014; Bayer & Osendorfer, 2014), and our formulation shows that existing volatility models such as the GARCH (Bollerslev, 1986) and the Heston model (Heston, 1993) are the special cases of our neural stochastic volatility formulation. With the hidden latent variables in the neural networks we naturally uncover the underlying stochastic process formulated from the models.
18
+
19
+ Experiments with synthetic data and real-world financial data are performed, showing that the proposed model outperforms the widely-used GARCH model on several metrics of the fitness and the accuracy of time series modelling and prediction: it verifies our model’s high flexibility and rich expressive power.
20
+
21
+ # 2 RELATED WORK
22
+
23
+ A notable volatility method is autoregressive conditional heteroskedasticity (ARCH) model (Engle, 1982): it can accurately capture the properties of time-variant volatility within many types of time series. Inspired by ARCH model, a large body of diverse work based on stochastic process for volatility modelling has emerged. Bollerslev (1986) generalised ARCH model to the generalised autoregressive conditional heteroskedasticity (GARCH) model in a manner analogous to the extension from autoregressive (AR) model to autoregressive moving average (ARMA) model by introducing the past conditional variances in the current conditional variance estimation. Engle & Kroner (1995) presented theoretical results on the formulation and estimation of multivariate GARCH model within simultaneous equations systems. The extension to multivariate model allows the covariances to present and depend on the historical information, which are particularly useful in multivariate financial models. Heston (1993) derived a closed-form solution for option pricing with stochastic volatility where the volatility process is a CIR process driven by a latent Wiener process such that the current volatility is no longer a deterministic function even if the historical information is provided. Notably, empirical evidences have confirmed that volatility models provide accurate forecasts (Andersen & Bollerslev, 1998) and models such as ARCH and its descendants/variants have become indispensable tools in asset pricing and risk evaluation.
24
+
25
+ On the other hand, deep learning (LeCun et al., 2015; Schmidhuber, 2015) that utilises nonlinear structures known as deep neural networks, powers various applications. It has triumph over pattern recognition challenges, such as image recognition (Krizhevsky et al., 2012; He et al., 2015; van den Oord et al., 2016), speech recognition (Hinton et al., 2012; Graves et al., 2013; Chorowski et al., 2015), machine translation (Sutskever et al., 2014; Cho et al., 2014; Bahdanau et al., 2014; Luong et al., 2015) to name a few.
26
+
27
+ Time-dependent neural networks models include RNNs with advanced neuron structure such as long short-term memory (LSTM) (Hochreiter & Schmidhuber, 1997), gated recurrent unit (GRU) (Cho et al., 2014), and bidirectional RNN (BRNN) (Schuster & Paliwal, 1997). Recent results show that RNNs excel for sequence modelling and generation in various applications (Graves, 2013; Gregor et al., 2015). However, despite its capability as non-linear universal approximator, one of the drawbacks of neural networks is its deterministic nature. Adding latent variables and their processes into neural networks would easily make the posterori computationally intractable. Recent work shows that efficient inference can be found by variational inference when hidden continuous variables are embedded into the neural networks structure (Kingma & Welling, 2013; Rezende et al., 2014). Some early work has started to explore the use of variational inference to make RNNs stochastic (Chung et al., 2015; Bayer & Osendorfer, 2014; Fabius & van Amersfoort, 2014). Bayer & Osendorfer (2014) and Fabius & van Amersfoort (2014) considered the hidden variables are independent between times, whereas (Fraccaro et al., 2016) utilised a backward propagating inference network according to its Markovian properties. Our work in this paper extends the work (Chung et al., 2015) with a focus on volatility modelling for time series. We assume that the hidden stochastic variables follow a Gaussian autoregression process, which is then used to model both the variance and the mean. We show that the neural network formulation is a general one, which covers two major financial stochastic volatility models as the special cases by defining the specific hidden variables and non-linear transforms.
28
+
29
+ # 3 PRELIMINARY: VOLATILITY MODELS
30
+
31
+ Stochastic processes are often defined by stochastic differential equations (SDEs), e.g. a (univariate) generalised Wiener process is $\mathrm { d } x _ { t } = \mu \mathrm { d } t + \sigma \mathrm { d } w _ { t }$ , where $\mu$ and $\sigma$ denote the time-invariant rates of drift and standard deviation (square root of variance) while $\mathrm { d } w _ { t } \sim \mathcal { N } ( 0 , \mathrm { d } t )$ is the increment of
32
+
33
+ standard Wiener process at time $t$ . In a small time interval between $t$ and $t + \Delta t$ , the change in the variable is $\varDelta x _ { t } = \mu \varDelta t + \sigma \varDelta w _ { t }$ . Let $\varDelta t = 1$ , we obtain the discrete-time version of basic volatility model:
34
+
35
+ $$
36
+ x _ { t } = x _ { t - 1 } + \mu + \sigma \epsilon _ { t } ,
37
+ $$
38
+
39
+ where $\epsilon _ { t } \sim \mathcal { N } ( 0 , 1 )$ is a sample drawn from standard normal distribution. In the multivariate case, $\pmb { \Sigma }$ represents the covariance matrix in place of $\sigma ^ { 2 }$ . As presumed that the variables are multidimensional, we will use $\pmb { \Sigma }$ to represent variance in general case except explicitly noted.
40
+
41
+ # 3.1 DETERMINISTIC VOLATILITY
42
+
43
+ The time-invariant variance $\pmb { \Sigma }$ can be extended to be a function $\pmb { \mathscr { D } } _ { t } = \pmb { \mathscr { D } } ( \pmb { \mathscr { x } } _ { < t } )$ relying on history of the (observable) underlying stochastic process $\{ { \pmb x } _ { < t } \}$ . The current variance $\Sigma _ { t }$ is therefore determined given the history $\{ { \pmb x } _ { < t } \}$ up to time $t$ . An example of such extensions is the univariate GARCH(1,1) model (Bollerslev, 1986):
44
+
45
+ $$
46
+ \sigma _ { t } ^ { 2 } = \alpha _ { 0 } + \alpha _ { 1 } ( x _ { t - 1 } - \mu _ { t - 1 } ) ^ { 2 } + \beta _ { 1 } \sigma _ { t - 1 } ^ { 2 } ,
47
+ $$
48
+
49
+ where $x _ { t - 1 }$ is the observation from $\mathcal { N } ( \mu _ { t - 1 } , \sigma _ { t - 1 } ^ { 2 } )$ at time $t - 1$ . Note that the determinism is in a conditional sense, which means that it only holds under the condition that the complete history $\{ \pmb { x } _ { < t } \}$ is presented, such as the case of 1-step-ahead forecast. otherwise the current volatility would still be stochastic as it is built on stochastic process $\{ \pmb { x } _ { t } \}$ . However, for multi-step-ahead forecast, we usually exploit the relation $\mathbb { E } _ { t - 1 } [ ( x _ { t } - \mu _ { t } ) ^ { 2 } ] = \sigma _ { t } ^ { 2 }$ to substitute the corresponding terms and calculate the forecasts with longer horizon in a recursive fashion, for example, $\bar { \sigma _ { t + 1 } ^ { 2 } } = \bar { \alpha } _ { 0 } + \alpha _ { 1 } \mathbb { E } _ { t - 1 } [ ( x _ { t } -$ $\mu _ { t } ) ^ { 2 } ] + \beta _ { 1 } \sigma _ { t } ^ { 2 } = \alpha _ { 0 } + ( \alpha _ { 1 } + \beta _ { 1 } ) \sigma _ { t } ^ { 2 }$ . For $\mathbf { n }$ -step-ahead forecast, there will be $n$ iterations and the procedure is hence also deterministic.
50
+
51
+ # 3.2 STOCHASTIC VOLATILITY
52
+
53
+ Another extension is applicable for $\Sigma _ { t }$ from being conditionally deterministic (i.e. deterministic given the complete history $\{ { \pmb x } _ { < t } \} )$ to fully stochastic: $\pmb { \mathscr { D } } _ { t } = \pmb { \mathscr { D } } ( \pmb { z } _ { \le t } )$ is driven by another latent stochastic process $\{ z _ { t } \}$ instead of the observable process $\{ x _ { t } \}$ . Heston (1993) model instantiates a continuous-time stochastic volatility model for univariate processes:
54
+
55
+ $$
56
+ \begin{array} { r l } & { \mathrm { d } x _ { t } = ( \mu - 0 . 5 \sigma _ { t } ^ { 2 } ) \mathrm { d } t + \sigma _ { t } \mathrm { d } w _ { t } ^ { \langle 1 \rangle } , } \\ & { \mathrm { d } \sigma _ { t } = a \sigma _ { t } \mathrm { d } t + b \mathrm { d } w _ { t } ^ { \langle 2 \rangle } , } \end{array}
57
+ $$
58
+
59
+ where the correlation between d wh1t i and d wh2it applies: $\mathbb { E } [ \mathrm { d } w _ { t } ^ { ( 1 ) } \cdot \mathrm { d } w _ { t } ^ { \langle 2 \rangle } ] = \rho \mathrm { d } t$ . We apply Euler’s scheme of quantisation (Stoer & Bulirsch, 2013) to obtain the discrete analogue to the continuoustime Heston model (Eqs. (3) and (4)):
60
+
61
+ $$
62
+ \begin{array}{c} \begin{array} { r l } & { x _ { t } = ( x _ { t - 1 } + \mu - 0 . 5 \sigma _ { t } ^ { 2 } ) + \sigma \epsilon _ { t } } \\ & { \sigma _ { t } = ( 1 + a ) \sigma _ { t - 1 } + b z _ { t } } \end{array} \quad \mathrm { w h e r e } \quad \begin{array} { l } { \Big [ \epsilon _ { t } } \\ { z _ { t } } \end{array} \Big ] = \mathcal { N } ( \mathbf { 0 } , \Big [ \begin{array} { l l } { 1 } & { \rho } \\ { \rho } & { 1 } \end{array} \Big ] ) . \end{array}
63
+ $$
64
+
65
+ # 3.3 VOLATILITY MODEL IN GENERAL
66
+
67
+ As discussed above, the observable variable $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ follows Gaussian distribution of which the mean and variance depend on the history of observable process $\{ x _ { t } \}$ and latent $\left\{ { z } _ { t } \right\}$ . We presume in addition that the latent process $\{ z _ { t } \}$ is an autoregressive model such that ${ \boldsymbol { z } } _ { t }$ is (conditionally) Gaussian distributed. Therefore, we formulate the volatility model in general as:
68
+
69
+ $$
70
+ \begin{array} { r l } & { z _ { t } \sim \mathcal { N } ( \pmb { \mu } ^ { z } ( \pmb { z } _ { < t } ) , \pmb { \Sigma } ^ { z } ( \pmb { z } _ { < t } ) ) , } \\ & { \pmb { x } _ { t } \sim \mathcal { N } ( \pmb { \mu } ^ { x } ( \pmb { x } _ { < t } , \pmb { z } _ { \leq t } ) , \pmb { \Sigma } ^ { x } ( \pmb { x } _ { < t } , \pmb { z } _ { \leq t } ) ) , } \end{array}
71
+ $$
72
+
73
+ where $\pmb { \mu } ^ { z } ( \pmb { x } _ { < t } , \pmb { z } _ { \leq t } )$ and $\begin{array} { r } { \pmb { \Sigma } ^ { z } ( \pmb { x } _ { < t } , z _ { \leq t } ) } \end{array}$ denote the autoregressive time-varying mean and variance of the latent variable ${ \boldsymbol { z } } _ { t }$ while $\pmb { \mu } ^ { x } ( \pmb { x } _ { < t } , \pmb { z } _ { \leq t } )$ and $\begin{array} { r } { \pmb { \Sigma ^ { x } } ( \pmb { x } _ { < t } , \pmb { z } _ { \leq t } ) } \end{array}$ represent the mean and variance of observable variable $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ , which depend on not only history of the observable process $\{ \pmb { x } _ { < t } \}$ but that of the latent process $\{ { z } _ { \leq t } \}$ .
74
+
75
+ These two formulas (Eqs. (6) and (7)) abstract the generalised formulation of volatility models. Together, they represents a broad family of volatility models with latent variables, where the Heston model for stochastic volatility is merely a special case of the family. Furthermore, it will degenerate to deterministic volatility models such as the well-studied GARCH model if we disable the latent process.
76
+
77
+ # 4 NEURAL STOCHASTIC VOLATILITY MODELS
78
+
79
+ In this section, we establish the neural stochastic volatility model (NSVM) for stochastic volatility estimation and forecast.
80
+
81
+ # 4.1 GENERATING OBSERVABLE SEQUENCE
82
+
83
+ Recall that the latent variable $z _ { t }$ (Eq. (6)) and the observable $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ (Eq. (7)) are described by autoregressive models ${ \bf \nabla } _ { { \bf \mathcal { X } } _ { t } }$ has the exogenous input $\{ { z } _ { \leq t } \}$ .) For the distributions of $\{ z _ { t } \}$ and $\{ x _ { t } \}$ , the following factorisation applies:
84
+
85
+ $$
86
+ \begin{array} { c } { { p _ { \Phi } ( Z ) = \displaystyle \prod _ { t } p _ { \Phi } ( z _ { t } | z _ { < t } ) = \displaystyle \prod _ { t } { \mathcal N } ( z _ { t } ; \mu _ { \Phi } ^ { z } ( z _ { < t } ) , \Sigma _ { \Phi } ^ { z } ( z _ { < t } ) ) , } } \\ { { p _ { \Phi } ( X | Z ) = \displaystyle \prod _ { t } p _ { \Phi } ( x _ { t } | x _ { < t } , z _ { \le t } ) = \displaystyle \prod _ { t } { \mathcal N } ( x _ { t } ; \mu _ { \Phi } ^ { x } ( x _ { < t } , z _ { \le t } ) , \Sigma _ { \Phi } ^ { x } ( x _ { < t } , z _ { \le t } ) ) , } } \end{array}
87
+ $$
88
+
89
+ where ${ \pmb X } = \{ { \pmb x } _ { t } \}$ and $Z = \{ z _ { t } \}$ are the sequences of observable and latent variables, respectively, while $\Phi$ represents the parameter set of the model. The full generative model is defined as the joint distribution:
90
+
91
+ $$
92
+ \begin{array} { l } { { \displaystyle p _ { \Phi } ( X , Z ) = \prod _ { t } p _ { \Phi } ( x _ { t } | x _ { < t } , z _ { \le t } ) p _ { \Phi } ( z _ { t } | z _ { < t } ) } } \\ { { \displaystyle \qquad = \prod _ { t } \mathcal { N } ( z _ { t } ; \mu _ { \Phi } ^ { z } ( z _ { < t } ) , \Sigma _ { \Phi } ^ { z } ( z _ { < t } ) ) \mathcal { N } ( x _ { t } ; \mu _ { \Phi } ^ { x } ( x _ { < t } , z _ { \le t } ) , \Sigma _ { \Phi } ^ { x } ( x _ { < t } , z _ { \le t } ) ) . } } \end{array}
93
+ $$
94
+
95
+ It is observed that the means and variances are conditionally deterministic: given the historical information $\{ z _ { < t } \}$ , the current mean $\mu _ { t } ^ { z } = \mu _ { \Phi } ^ { z } ( z _ { < t } )$ and variance $\begin{array} { r } { \pmb { \Sigma _ { t } ^ { z } } = \pmb { \Sigma _ { \Phi } ^ { z } } ( \pmb { z } _ { < t } ) } \end{array}$ of ${ \boldsymbol { z } } _ { t }$ is obtained and hence the distribution $\mathcal { N } ( z _ { t } ; \mu _ { t } ^ { z } , \Sigma _ { t } ^ { z } )$ of ${ \boldsymbol { z } } _ { t }$ is specified; after sampling ${ \boldsymbol { z } } _ { t }$ from the specified distribution, we incorporate $\{ \pmb { x } _ { < t } \}$ and calculate the current mean $\pmb { \mu } _ { t } ^ { x } = \pmb { \mu } _ { \Phi } ^ { x } ( \pmb { x } _ { < t } , \pmb { z } _ { \leq t } )$ and variance $\begin{array} { r } { \Sigma _ { t } ^ { x } = \Sigma _ { \Phi } ^ { x } ( \pmb { x } _ { < t } , \pmb { z } _ { \le t } ) } \end{array}$ of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ and determine its distribution $\mathcal { N } ( \pmb { x } _ { t } ; \pmb { \mu } _ { t } ^ { x } , \pmb { \Sigma } _ { t } ^ { x } )$ of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ . It is natural and convenient to present such a procedure in a recurrent fashion because of its autoregressive nature. As is known that RNNs can essentially approximate arbitrary function of recurrent form (Hammer, 2000), the means and variances, which may be driven by complex non-linear dynamics, can be efficiently computed using RNNs.
96
+
97
+ It is always a good practice to reparameterise the random variables before we go into RNN architecture. As the covariance matrix $\pmb { \Sigma }$ is symmetric and positive definite, it can be factorised as $\Sigma = U A U ^ { \top }$ , where $\pmb { A }$ is a full-rank diagonal matrix with positive diagonal elements. Let $A = U A ^ { \frac { 1 } { 2 } }$ , we have $\pmb { \Sigma } = \pmb { A } \pmb { A } ^ { \top }$ . Hence we can reparameterise the latent variable ${ \boldsymbol { z } } _ { t }$ (Eq. (6)) and observable $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ (Eq. (7)):
98
+
99
+ $$
100
+ \begin{array} { r } { z _ { t } = \pmb { \mu } _ { t } ^ { z } + \pmb { A } _ { t } ^ { z } \pmb { \epsilon } _ { t } ^ { z } , } \\ { \pmb { x } _ { t } = \pmb { \mu } _ { t } ^ { x } + \pmb { A } _ { t } ^ { x } \pmb { \epsilon } _ { t } ^ { x } , } \end{array}
101
+ $$
102
+
103
+ where $A _ { t } ^ { z } ( A _ { t } ^ { z } ) ^ { \top } = \Sigma _ { t } ^ { z }$ , $A _ { t } ^ { x } ( A _ { t } ^ { x } ) ^ { \top } = \Sigma _ { t } ^ { x }$ and $\epsilon _ { t } ^ { x } \sim \mathcal { N } ( \mathbf { 0 } , I _ { x } ) , \epsilon _ { t } ^ { z } \sim \mathcal { N } ( \mathbf { 0 } , I _ { z } )$ are auxiliary variables. Note that the randomness within the variables of interest (e.g. ${ \boldsymbol { z } } _ { t }$ ) is extracted by the auxiliary variables (e.g. $\epsilon _ { t . }$ ) which follow the standard distributions. Hence, the reparameterisation guarantees that gradient-based methods can be applied in learning phase (Kingma & Welling, 2013).
104
+
105
+ In this paper, the joint generative model is comprised of two sets of RNN and multilayer perceptron (MLP): $\mathrm { \bar { R N N } } _ { g } ^ { z } / \mathrm { \bar { M L P } } _ { g } ^ { z }$ for the latent variable, while $\mathrm { R N N } _ { g } ^ { x } / \mathrm { M L P } _ { g } ^ { z }$ for the observables. We stack these two RNN/MLP together according to the causal dependency between those variables. The joint generative model is implemented as the generative network:
106
+
107
+ $$
108
+ \begin{array} { r l } & { \{ \mu _ { t } ^ { z } , A _ { t } ^ { z } \} = \mathrm { M L P } _ { g } ^ { z } ( h _ { t } ^ { z } ; \Phi ) , } \\ & { \quad \quad h _ { t } ^ { z } = \mathrm { R N N } _ { g } ^ { z } ( h _ { t - 1 } ^ { z } , z _ { t - 1 } ; \Phi ) , } \\ & { \quad \quad z _ { t } = \mu _ { t } ^ { z } + A _ { t } ^ { z } \epsilon _ { t } ^ { z } , } \\ & { \{ \mu _ { t } ^ { x } , A _ { t } ^ { x } \} = \mathrm { M L P } _ { g } ^ { x } ( h _ { t } ^ { x } ; \Phi ) , } \\ & { \quad \quad h _ { t } ^ { x } = \mathrm { R N N } _ { g } ^ { x } ( h _ { t - 1 } ^ { x } , x _ { t - 1 } , z _ { t } ; \Phi ) , } \\ & { \quad \quad x _ { t } = \mu _ { t } ^ { x } + A _ { t } ^ { x } \epsilon _ { t } ^ { x } , } \end{array}
109
+ $$
110
+
111
+ where $ { \boldsymbol { h } } _ { t } ^ { z }$ and ${ h } _ { t } ^ { x }$ denote the hidden states of the corresponding RNNs. The MLPs map the hidden states of RNNs into the means and deviations of variables of interest. The parameter set $\Phi$ is comprised of the weights of RNNs and MLPs.
112
+
113
+ One should notice that when the latent variable $_ z$ is obtained, e.g. by inference (details in the next subsection), the conditional distribution $p _ { \Phi } ( \pmb { X } | Z )$ (Eq. (9)) will involve in generating the observable $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ instead of the joint distribution $p _ { \Phi } ( X , Z )$ (Eq. (10)). This is essentially the scenario of predicting future values of the observable variable given its history. We will use the term “generative model” and will not discriminate the joint generative model or the conditional one as it can be inferred in context.
114
+
115
+ # 4.2 INFERENCING THE LATENT PROCESS
116
+
117
+ As the generative model involves latent variable ${ \boldsymbol { z } } _ { t }$ , of which the true valus are unaccessible even we have observed $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ . Hence, the marginal likelihood $p _ { \Phi } ( X )$ becomes the key that bridges the model and the data. The calculation of marginal likelihood involves the posterior distribution $p _ { \Phi } ( Z | X )$ , which is often intractable as complex integrals are involved. We are unable to learn the paramters or to infer the latent variables. Therefore, we consider instead a restricted family of tractable distributions $q _ { \Psi } ( Z | X )$ , referred to as the approximate posterior family, as approximations to the true posterior $p _ { \Phi } ( Z | X )$ such that the family is sufficiently rich and flexible to provide good approximations (Bishop, 2006; Kingma & Welling, 2013; Rezende et al., 2014).
118
+
119
+ We define the inference model in accordance with the approximate posterior family we have presumed, in a similar fashion as (Chung et al., 2015), where the factorised distribution is formulated as follows:
120
+
121
+ $$
122
+ q _ { \Psi } ( Z | X ) = \prod _ { t } q _ { \Psi } ( z _ { t } | z _ { < t } , \pmb { x } _ { < t } ) = \prod _ { t } \mathcal { N } ( z _ { t } ; \tilde { \mu } _ { \Psi } ^ { z } ( z _ { < t } , \pmb { x } _ { < t } ) , \tilde { \Sigma } _ { \Psi } ^ { z } ( z _ { < t } , \pmb { x } _ { < t } ) ) ,
123
+ $$
124
+
125
+ where $\tilde { \mu } _ { \Psi } ^ { z } ( \boldsymbol { z } _ { < t } , \boldsymbol { x } _ { < t } )$ and $\tilde { \Sigma } _ { \Psi } ^ { z } ( z _ { < t } , \pmb { x } _ { < t } )$ are functions of the historical information $\{ { \boldsymbol { z } } _ { < t } \} , \{ { \boldsymbol { x } } _ { < t } \}$ , representing the approximated mean and variance of the latent variable ${ \boldsymbol { z } } _ { t }$ , respectively. Note that $\pmb { \psi }$ represents the parameter set of inference model.
126
+
127
+ The inference model essentially describes an autoregressive model on ${ \boldsymbol { z } } _ { t }$ with exogenous input $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ . Hence, in a similar fashion as the generative model, we implement the inference model as the inference network using RNN/MLP:
128
+
129
+ $$
130
+ \begin{array} { r l } & { \{ \tilde { \pmb { \mu } } _ { t } ^ { z } , \tilde { \pmb { A } } _ { t } ^ { z } \} = \mathrm { M L P } _ { i } ^ { z } ( \tilde { \pmb { h } } _ { t } ^ { z } ) , } \\ & { \quad \quad \quad \tilde { \pmb { h } } _ { t } ^ { z } = \mathrm { R N N } _ { i } ^ { z } ( \tilde { \pmb { h } } _ { t - 1 } ^ { z } , z _ { t - 1 } , { \pmb { x } } _ { t - 1 } ) , } \\ & { \quad \quad \quad z _ { t } = \tilde { \pmb { \mu } } _ { t } ^ { z } + \tilde { \pmb { A } } _ { t } ^ { z } \tilde { \epsilon } _ { t } ^ { z } , } \end{array}
131
+ $$
132
+
133
+ where $\tilde { A } _ { t } ^ { z } ( \tilde { A } _ { t } ^ { z } ) ^ { \top } = \tilde { \Sigma } _ { t } ^ { z } = \tilde { \Sigma } _ { \Psi } ^ { z } ( z _ { < t } , { \pmb x } _ { < t } )$ while $\tilde { h } _ { t } ^ { z }$ represents the hidden state of RNN and $\tilde { \epsilon } _ { t } ^ { z } \sim$ $\textstyle \mathcal { N } ( \mathbf { 0 } , \pmb { I } _ { z } )$ is an auxiliary variable to extract randomness. The inference mean $\tilde { \mu } _ { t } ^ { z }$ and deviation $\tilde { A } _ { t } ^ { z }$ is computed by an MLP from the hidden state $\tilde { h } _ { t } ^ { z }$ . We use the subscript $i$ instead of $g$ to distinguish the architecture used in inference model in contrast to generative model.
134
+
135
+ # 4.3 FORECASTING OBSERVATIONS IN FUTURE
136
+
137
+ In the realm of time series analysis, we usually pay more attention on forecasting over generating (Box et al., 2015). It means that we are essentially more interested in the generation procedure conditioning on the historical information rather than generation purely based on a priori belief since the observations in the past of $\scriptstyle { \mathbf { { \mathcal { x } } } } _ { < t }$ influences our belief of the latent variable ${ \boldsymbol { z } } _ { t }$ . Therefore, we apply the approximate posterior distribution of the latent variable ${ \boldsymbol { z } } _ { t }$ (Eq. (19)) as discussed in previous subsection, in place of the prior distribution (Eq. (8)) to build our predictive model.
138
+
139
+ ![](images/852dde43a7bb5c25766ead25232f56522d381c9a08a4e2765edea88184ee2287.jpg)
140
+ Figure 1: Forecasting the future using Neural Stochastic Volatility Model.
141
+
142
+ Given the historical observations $\scriptstyle { \mathbf { \mathcal { x } } } _ { < t }$ , the predictive model infers the current value of latent variable ${ \boldsymbol { z } } _ { t }$ using inference network and then generates the prediction of the current observation $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ using generative network. The procedure of forecasting is shown in Fig. 1.
143
+
144
+ NSVM is learned using Stochastic Gradient Variational Bayes following (Kingma & Welling, 2013;
145
+ Rezende et al., 2014). For readability, we provide the detailed derivation in Appendix A.
146
+
147
+ # 4.4 LINKS TO GARCH(1,1) AND HESTON MODEL
148
+
149
+ Although we refer to GARCH and Heston as volatility models, the purposes of them are quite different: GARCH is a predictive model used for volatility forecasting whereas Heston is more of a generative model of the underlying dynamics which facilitate closed-form solutions to SDEs in option pricing. The proposed NSVM has close relations to GARCH(1,1) and Heston model: both of them can be regarded as a special case of the neural network formulation. Recall Eq. (2), GARCH(1,1) is formulated as $\sigma _ { t } ^ { 2 } \stackrel { . } { = } \alpha _ { 0 } + \alpha _ { 1 } ( x _ { t - 1 } - \mu _ { t - 1 } ) ^ { 2 } + \beta _ { 1 } \sigma _ { t - 1 } ^ { 2 }$ , where $\mu _ { t - 1 }$ is the trend estimate of $\{ x _ { t } \}$ at time step $t$ calculated by some mean models. A common practice is to assume that $\mu _ { t }$ follows the ARMA family (Box et al., 2015), or even simpler, as a constant that $\mu _ { t } \equiv \mu$ . We adopt the constant trend for simplicity as our focus is on volatility estimation.
150
+
151
+ We define the hidden state as $h _ { t } ^ { x } = [ \mu , \sigma _ { t } ] ^ { \top }$ , and disable the latent variable $z _ { t } \equiv 0$ as the volatility modelled by GARCH(1,1) is conditionally deterministic. Hence, we instantiate the generative network (Eqs. (16), (17) and (18)) as follows:
152
+
153
+ $$
154
+ \begin{array} { r l r } { { \{ \mu , \sigma _ { t } \} = \mathrm { M L P } _ { g } ^ { x } ( h _ { t } ^ { x } ; \Phi ) = \{ [ 1 , 0 ] h _ { t } ^ { x } , [ 0 , 1 ] h _ { t } ^ { x } \} , } } \\ & { } & { h _ { t } ^ { x } = \mathrm { R N N } _ { g } ^ { x } ( h _ { t - 1 } ^ { x } , x _ { t - 1 } ; \Phi ) } \\ & { } & { = \sqrt { [ \begin{array} { l } { 0 } \\ { \alpha _ { 0 } } \end{array} ] + [ \begin{array} { l } { 0 } \\ { \alpha _ { 1 } } \end{array} ] ( x _ { t - 1 } - [ 1 , 0 ] h _ { t - 1 } ^ { x } ) ^ { 2 } + [ \begin{array} { l l } { 1 } & { 0 } \\ { 0 } & { \beta _ { 1 } } \end{array} ] ( h _ { t - 1 } ^ { x } ) ^ { 2 } } , } \\ & { } & { x _ { t } = \mu + \sigma _ { t } \epsilon _ { t } \qquad \mathrm { w h e r e } ~ \epsilon _ { t } \sim \mathcal { N } ( 0 , 1 ) . } \end{array}
155
+ $$
156
+
157
+ The set of generative parameters is $\Phi = \{ \mu , \alpha _ { 0 } , \alpha _ { 1 } , \beta _ { 1 } \}$ .
158
+
159
+ Next, we show the link between NSVM and (discrete-time) Heston model (Eq. (5)). Let $h _ { t } ^ { x } \ =$ $[ x _ { t - 1 } , \mu , \sigma _ { t } ] ^ { \top }$ be the hidden state and $z _ { t }$ be i.i.d. standard Gaussian instead of autoregressive vari
160
+
161
+ able, we represent the Heston model in the framework of NSVM as:
162
+
163
+ $$
164
+ \begin{array} { r l } & { \quad \left[ \epsilon _ { t } \right] = \mathcal { N } ( \mathbf { 0 } , \left[ \begin{array} { l l } { 1 } & { \rho } \\ { \rho } & { 1 } \end{array} \right] ) , } \\ & { \lbrace \mu _ { t } , \sigma _ { t } \rbrace = \mathrm { M L P } _ { g } ^ { x } ( h _ { t } ^ { x } ; \Phi ) = \lbrace [ 1 , 1 , 0 ] h _ { t } ^ { x } - [ 0 , 0 , 0 . 5 ] ( h _ { t } ^ { x } ) ^ { 2 } , [ 0 , 0 , 1 ] h _ { t } ^ { x } \rbrace , } \\ & { \quad \quad h _ { t } ^ { x } = \mathrm { R N N } _ { g } ^ { x } ( h _ { t - 1 } ^ { x } , x _ { t - 1 } , z _ { t } ; \Phi ) } \\ & { \quad \quad \quad = \left[ \begin{array} { l l l } { 0 } & { 0 } & { 0 } \\ { 0 } & { 1 } & { 0 } \\ { 0 } & { 0 } & { 1 + a } \end{array} \right] h _ { t - 1 } ^ { x } + \left[ \begin{array} { l } { 1 } \\ { 0 } \end{array} \right] x _ { t - 1 } + \left[ \begin{array} { l } { 0 } \\ { 0 } \end{array} \right] z _ { t } , } \\ & { \quad \quad x _ { t } = \mu _ { t } + \sigma _ { t } \epsilon _ { t } . } \end{array}
165
+ $$
166
+
167
+ The set of generative parameters is $\Phi = \{ \mu , a , b \}$
168
+
169
+ One should notice that, in practice, the formulation may change in accordance with the specific architecture of neural networks involved in building the model, and hence a closed-form representation may be absent.
170
+
171
+ # 5 EXPERIMENTS
172
+
173
+ In this section, we present our experiments1 both on the synthetic and real-world datasets to validate the effectiveness of NSVM.
174
+
175
+ # 5.1 BASELINES AND EVALUATION METRICS
176
+
177
+ To evaluate the performance of volatility modelling, we adopt the standard econometric model GARCH(1,1) Bollerslev (1986) as well as its variants EGARCH(1,1) Nelson (1991), GJR-GARCH(1,1,1) Glosten et al. (1993), ARCH(5), TARCH(1,1,1), APARCH(1,1,1), AGARCH(1,1,1), NAGARCH(1,1,1), IGARCH(1,1), IAVGARCH(1,1), FIGARCH(1,d,1) as baselines, which incorporate with the corresponding mean model AR(20). We would also compare our NSVM against a MCMC-based model “stochvol” and the recent Gaussian-processes-based model “GPVOL” Wu et al. (2014), which is a non-parametric model jointly learning the dynamics and hidden states via online inference algorithm. In addition, we setup a naive forecasting model as an alternative baseline referred to as NAIVE, which maintains a sliding window of size 20 on the most recent historical observations and forecasts the current values of mean and volatility by the average mean and variance of the window.
178
+
179
+ For synthetic data experiments, we take four metrics into consideration for performance evaluation: 1) the negative log-likelihood (NLL) of observing the test sequence with respect to the generative model parameters; 2) the mean-squared error (MSE) between the predicted mean and the ground truth ( $\mu$ -MSE), 3) MSE of the predicted variance against the true variance ( $\sigma$ -MSE); 4) smoothness of fit, which is the standard deviation of the differences of succesive variance estimates. As for the real-world scenarios, the trend and volatility are implicit such that no ground truth is accessible to compare with, we consider only NLL and smoothness as the metrics for evaluation on real-world data experiment.
180
+
181
+ # 5.2 MODEL IMPLEMENTATION
182
+
183
+ The implementation of NSVM in experiments is in accordance with the architecture illustrated in Fig. 1: it consists of two neural networks, namely inference network and generative network. Each network comprises a set of RNN/MLP as we have discussed above: the RNN is instantiated by stacked LSTM layers whereas the MLP is essentially a 1-layer fully-connected feedforward network which splits into two equal-sized sublayers with different activation functions – one sublayer applies exponential function to impose the non-negativity and prevents overshooting of variance estimates while the other uses linear function to calculate mean estimates. During experiment, the model is structured by cascading the inference network and generative network as depicted in Fig. 1. The input layer is of size 20, which is the same as the embedding dimension $D _ { E }$ ; the layer on the interface of inference network and generative network – we call it latent variable layer – represents the latent variable $z$ , where its dimension is 2. The output layer has the same structure as the input one, therefore the latent variable layer acts as a bottleneck of the entire architecture which helps to extract the key factor. The stacked layers between input layer, latent variable layer and output layer are the hidden layers of either inference network or generative network, it consists of 1 or 2 LSTM layers with size 10, which contains recurrent connection for temporal dependencies modelling.
184
+
185
+ State-of-the-art learning techniques have been applied: we introduce Dropout (Zaremba et al., 2014) into each LSTM recurrent layer and impose L2-norm on the weights of each fully-connected feedforward layer as regularistion; NADAM optimiser (Dozat, 2015) is exploited for fast convergence, which is a variant of ADAM optimiser (Kingma & Ba, 2014) incorporated with Nesterov momentum; stepwise exponential learning rate decay is adopted to anneal the variations of convergence as time goes.
186
+
187
+ For econometric models, we utilise several widely-used packages for time series analysis: statsmodels (http://statsmodels.sourceforge.net/), arch (https://pypi.python. org/pypi/arch/3.2), Oxford-MFE-toolbox (https://www.kevinsheppard. com/MFE_Toolbox), stochvol (https://cran.r-project.org/web/packages/ stochvol) and fGarch (https://cran.r-project.org/web/packages/fGarch). The implementation of GPVOL is retrived from http://jmhl.org and we adopt the same hyperparameter setting as in Wu et al. (2014).
188
+
189
+ # 5.3 SYNTHETIC DATA EXPERIMENT
190
+
191
+ We build up the synthetic dataset by generating 256 heteroskedastic univariate time series, each with 2000 data points i.e. 2000 time steps. At each time step, the observation is drawn from a Gaussian distribution with pre-determined mean and variance, where the tendency of mean and variance is synthesised as linear combinations of sine functions. Specifically, for the trend and variance, we synthesis each using 3 sine functions with randomly chosen amplitudes and frequencies; then the value of the synthesised signal at each timestep is drawn from a Gaussian distribution with the corresponding value of trend and variance at that timestep. A sampled sequence is shown in Fig. 2a. We expect that this limited dataset could well simulate the real-world scenarios: one usually has very limited chances to observe and collect a large amount of data from time-invariant distributions. In addition, it seems that every observable or latent quantity within time series varies from time to time and seldom repeats the old patterns. Hence, we presume that the tendency shows long-term patterns and the period of tendency is longer than observation. In the experiment, we take the former 1500 time steps as the training set whereas the latter 500 as the test set.
192
+
193
+ For the synthetic data experiment, we simplify the recurrent layers in both inference net and generative net as single LSTM layer of size 10. The actual input $\{ \vec { \pmb { x } } _ { t } \}$ fed to NSVM is $D _ { E }$ - dimensional time-delay embedding (Kennel et al., 1992) of raw univariate observation $\{ x _ { t } \}$ such that $\vec { \pmb { x } } _ { t } = [ x _ { t + 1 - D _ { E } } , \ldots , x _ { t } ]$ . 2-dimensional latent variable ${ \boldsymbol { z } } _ { t }$ is adopted to capture the latent process, and enforces an orthogonal representation of the process by using diagonal covariance matrix. At each time step, 30 samples of latent variable ${ \boldsymbol { z } } _ { t }$ are generated via reparameterisation (Eq. (22)).
194
+
195
+ # 5.4 REAL-WORLD DATA EXPERIMENT
196
+
197
+ We select 162 out of more than 1500 stocks from Chinese stock market and collect the time series of their daily closing prices from 3 institutions in China. We favour those with earlier listing date of trading (from 2006 or earlier) and fewer suspension days (at most 50 suspension days in total during the period of observation) so as to reduce the noise introduced by insufficient observation or missing values, which has significant influences on the performance but is essentially irrelevant to the purpose of volatility forecasting. More specifically, the dataset obtained contains 162 time series, each with 2552 data points (7 years). A sampled sequence is shown in Fig. 2b. We divide the whole dataset into two subsets: the training subset consists of the first 2000 data points while the test subset contains the rest 552 data points.
198
+
199
+ Similar model configuration is applied to the real-world data experiment: time-delay embedding of dimension $D _ { E }$ on the raw univariate time series; 2-dimensional latent variable with diagonal (a) Synthetic time series prediction. (up) The data and the predicted $\mu ^ { x }$ and bounds $\mu ^ { x } \pm \sigma ^ { x }$ . (down) The groundtruth data variance and the corresponding prediction from GARCH(1,1) and NSVM.
200
+
201
+ ![](images/4019d43352f97311d7c9fcf91d932c937cf2eef3ef065be2dfb5d2655247be46.jpg)
202
+
203
+ ![](images/0f4267086df87d704e935cf7b8baa2f7349e39f858a7ba0e54f10a6f3ad78001.jpg)
204
+ Figure 2: A case study of time series prediction.
205
+
206
+ (b) Real-world stock price prediction. (up) The data and the predicted $\mu ^ { x }$ and bounds $\mu ^ { x } \pm \sigma ^ { x }$ . (down) The variance prediction from GARCH(1,1) and NSVM. The prediction of NSVM is more smooth and stable than that of GARCH(1,1), also yielding smaller NLL.
207
+
208
+ covariance matrix; 30 sampling for the latent variable at each time step. Instead of single LSTM layers, here we adopt stacked LSTM layers composed of $2 \times 1 0$ LSTM cells.
209
+
210
+ # 5.5 RESULT AND DISCUSSION
211
+
212
+ The overall performance of NSVM and baselines is listed in details in Table 1 and case studies on synthetic data and real-world financial data are illustrated in Fig. 2. The results show that NSVM has higher accuracies for modelling heteroskedastic time series on various metrics: NLL shows the fitness of the model under likelihood measure; the smoothness indicates that NSVM obtains more robust representation of the latent volatility; $\mu$ -MSE and $\sigma$ -MSE in synthetic data experiment imply the ability of recognising the underlying patterns of both trend and volatility, which in fact verifies our claim of NSVM’s high flexibility and rich expressive power for volatility (as well as trend) modelling and forecasting compared with the baselines. Although the improvement comes at the cost of longer training time before convergence, it can be mitigated by applying parallel computing techniques as well as more advanced network architecture or training procedure.
213
+
214
+ Table 1: Results of the experiments.
215
+
216
+ <table><tr><td colspan="6">SYNTHETICDATA STOCKDATA</td></tr><tr><td></td><td>NLL</td><td>μ-MSE</td><td>σ-MSE</td><td>smoothness</td><td>NLL smoothness</td></tr><tr><td>NSVM</td><td>3.932e-2</td><td>2.393e-3</td><td>6.178e-4</td><td>4.322e-3</td><td>-2.184 3.505e-3</td></tr><tr><td>GARCH(1,1)</td><td>6.905e-2</td><td>7.594e-3*</td><td>8.408e-4</td><td>4.616e-3</td><td>-1.961 6.659e-3</td></tr><tr><td>GJRGARCH(1,1,1)</td><td>6.491e-2</td><td>7.594e-3*</td><td>7.172e-4</td><td>4.426e-3</td><td>-2.016 4.967e-3</td></tr><tr><td>EGARCH(1,1)</td><td>5.913e-2</td><td>7.594e-3*</td><td>8.332e-4</td><td>4.546e-3</td><td>-2.001 5.451e-3</td></tr><tr><td>ARCH(5)</td><td>7.577e-2</td><td>7.594e-3*</td><td>1.610e-3</td><td>5.880e-3</td><td>-1.955 7.917e-3</td></tr><tr><td>TARCH(1,1,1)</td><td>6.365e-2</td><td>7.594e-3*</td><td>7.284e-4</td><td>4.727e-3</td><td>-2.012 3.399e-3</td></tr><tr><td>APARCH(1,1,1)</td><td>6.187e-2</td><td>7.594e-3*</td><td>9.115e-4</td><td>4.531e-3</td><td>-2.014 4.214e-3</td></tr><tr><td>AGARCH(1,1)</td><td>6.311e-2</td><td>7.594e-3*</td><td>9.543e-4</td><td>4.999e-3</td><td>-2.008 5.847e-3</td></tr><tr><td>NAGARCH(1,1,1)</td><td>1.134e-1</td><td>7.594e-3*</td><td>9.516e-4</td><td>4.904e-3</td><td>-2.020 5.224e-3</td></tr><tr><td>IGARCH(1,1)</td><td>6.751e-2</td><td>7.594e-3*</td><td>9.322e-4</td><td>4.019e-3</td><td>-1.999 4.284e-3</td></tr><tr><td>IAVGARCH(1,1)</td><td>6.901e-2</td><td>7.594e-3*</td><td>7.174e-4</td><td>4.282e-3</td><td>-1.984 4.062e-3</td></tr><tr><td>FIGARCH(1,d,1)</td><td>6.666e-2</td><td>7.594e-3*</td><td>1.055e-3</td><td>5.045e-3</td><td>-2.002 5.604e-3</td></tr><tr><td>MCMC-stochvol</td><td>0.368</td><td>7.594e-3*</td><td>3.956e-2</td><td>6.421e-4</td><td>-0.909 1.511e-3</td></tr><tr><td>GPVOL</td><td>1.273</td><td>7.594e-3*</td><td>6.457e-1</td><td>4.142e-2</td><td>-2.052 5.739e-3</td></tr><tr><td>NAIVE</td><td>2.037e-1</td><td>8.423e-3</td><td>3.515e-3</td><td>2.708e-2</td><td>-0.918 7.459e-3</td></tr></table>
217
+
218
+ \*the same results obtained from AR(20) mean models
219
+
220
+ The newly proposed NSVM outperforms standard econometric models GARCH(1,1), EGARCH(1,1), GJR-GARCH(1,1,1) and some other variants as well as the MCMC-based model “stochvol” and the recent GP-based model “GPVOL”. Apart from the higher accuracy NSVM obtained, it provides us with the ability to simply generalise univariate time series analysis to multivariate cases by extending network dimensions and manipulating the covariance matrices. Furthermore, it allows us to implement and deploy a similar framework on other applications, for example signal processing and denoising. The shortcoming of NSVM comparing to GPVOL is that the training procedure is offline: for short-term prediction, the experiments have shown the accuracy, but for long-term forecasting, the parameters need retraining, which will be rather time consuming. The online algorithm for inference will be one of the work in the future.
221
+
222
+ Specifically, our NSVM outperforms GARCH(1,1) on 142 out of 162 stocks on the metric of NLL. In particular, NSVM obtains $- 2 . 1 1 1$ , $- 2 . 0 4 4$ , $- 2 . 6 0 9$ and $- 1 . 9 3 9$ on the stocks corresponding to Fig2(b), Fig 4(a), (b) and (c) respectively, each of which is better than the that of GARCH (0.3433, 0.589, 0.109 and 0.207 lower on NLL).
223
+
224
+ # 6 CONCLUSION
225
+
226
+ In this paper, a novel volatility model NSVM has been proposed for stochastic volatility estimation and forecast. We integrated statistical models and RNNs, leveraged the characteristics of each model, organised the dependences between random variables in the form of graphical models, implemented the mappings among variables and parameters through RNNs, and finally established a powerful stochastic recurrent model with universal approximation capability. The proposed architecture comprises a pair of complementary stochastic neural networks: the generative network and inference network. The former models the joint distribution of the stochastic volatility process with both observable and latent variables of interest; the latter provides with the approximate posterior i.e. an analytical approximation to the (intractable) conditional distribution of the latent variables given the observable ones. The parameters (and consequently the underlying distributions) are learned (and inferred) via variational inference, which maximises the lower bound for the marginal log-likelihood of the observable variables. Our NSVM has presented higher accuracy compared to GARCH(1,1), EGARCH(1,1) and GJR-GARCH(1,1,1) as well as GPVOL for volatility modelling and forecasting on synthetic data and real-world financial data. Future work on NSVM would be to incorporate well-established models such as ARMA/ARIMA and to investigate the modelling of seasonal time series and correlated sequences.
227
+
228
+ As we have known, for models that evolve explicitly in terms of the squares of the residuals $( e _ { t } ^ { 2 } =$ $( x _ { t } - \mu _ { t } ) ^ { 2 } )$ , e.g. GARCH, the multi-step-ahead forecasts have closed-form solutions, which means that those forecasts can be efficiently computed in a recursive fashion due to the linear formulation of the model and the exploitation of relation $E _ { t - 1 } [ e _ { t } ^ { 2 } ] = \sigma _ { t } ^ { 2 }$ .
229
+
230
+ On the other hand, for models that are not linear or do not explicitly evolve in terms of $e ^ { 2 }$ , e.g. EGARCH (linear but not evolve in terms of $e ^ { 2 }$ ), our NSVM (nonlinear and not evolve in terms of $e ^ { 2 }$ ), the closed-form solutions are absent and thus the analytical forecast is not available. We will instead use simulation-based forecast, which uses random number generator to simulate draws from the predicted distribution and build up a pre-specified number of paths of the variances at 1 step ahead. The draws are then averaged to produce the forecast of the next step. For n-step-ahead forecast, it requires n iterations of 1-step-ahead forecast to get there.
231
+
232
+ NSVM is designed as an end-to-end model for volatility estimation and forecast. It takes the price of stocks as input and outputs the distribution of the price at next step. It learns the dynamics using RNN, leading to an implicit, highly nonlinear formulation, where only simulation-based forecast is available. In order to obtain reasonably accurate forecasts, the number of draws should be relatively large, which will be very expensive for computation. Moreover, the number of draws will increase exponentially as the forecast horizon grows, so it will be infeasible to forecast several time steps ahead. We have planned to investigate the characteristics of NSVM’s long-horizontal forecasts and try to design a model specific sampling method for efficient evaluation in the future.
233
+
234
+ # REFERENCES
235
+
236
+ Torben G Andersen and Tim Bollerslev. Answering the skeptics: Yes, standard volatility models do provide accurate forecasts. International economic review, pp. 885–905, 1998.
237
+
238
+ Marco Avellaneda and Antonio Paras. Managing the volatility risk of portfolios of derivative securities: the lagrangian uncertain volatility model. Applied Mathematical Finance, 3(1):21–52, 1996.
239
+
240
+ Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014.
241
+
242
+ Justin Bayer and Christian Osendorfer. Learning stochastic recurrent networks. arXiv preprint arXiv:1411.7610, 2014.
243
+
244
+ Christopher M Bishop. Pattern recognition. Machine Learning, 128, 2006.
245
+
246
+ Tim Bollerslev. Generalized autoregressive conditional heteroskedasticity. Journal of econometrics, 31(3):307–327, 1986.
247
+
248
+ George EP Box, Gwilym M Jenkins, Gregory C Reinsel, and Greta M Ljung. Time series analysis: forecasting and control. John Wiley & Sons, 2015.
249
+
250
+ Kyunghyun Cho, Bart Van Merrienboer, Caglar Gulcehre, Dzmitry Bahdanau, Fethi Bougares, Hol- ¨ ger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical machine translation. arXiv preprint arXiv:1406.1078, 2014.
251
+
252
+ Jan K Chorowski, Dzmitry Bahdanau, Dmitriy Serdyuk, Kyunghyun Cho, and Yoshua Bengio. Attention-based models for speech recognition. In Advances in Neural Information Processing Systems, pp. 577–585, 2015.
253
+
254
+ Junyoung Chung, Kyle Kastner, Laurent Dinh, Kratarth Goel, Aaron C Courville, and Yoshua Bengio. A recurrent latent variable model for sequential data. In Advances in neural information processing systems, pp. 2980–2988, 2015.
255
+
256
+ John C Cox, Jonathan E Ingersoll Jr, and Stephen A Ross. A theory of the term structure of interest rates. Econometrica: Journal of the Econometric Society, pp. 385–407, 1985.
257
+
258
+ Timothy Dozat. Incorporating nesterov momentum into adam. 2015.
259
+
260
+ Robert F Engle. Autoregressive conditional heteroscedasticity with estimates of the variance of united kingdom inflation. Econometrica: Journal of the Econometric Society, pp. 987–1007, 1982.
261
+
262
+ Robert F Engle and Kenneth F Kroner. Multivariate simultaneous generalized arch. Econometric theory, 11(01):122–150, 1995.
263
+
264
+ Otto Fabius and Joost R van Amersfoort. Variational recurrent auto-encoders. arXiv preprint arXiv:1412.6581, 2014.
265
+
266
+ Marco Fraccaro, Søren Kaae Sønderby, Ulrich Paquet, and Ole Winther. Sequential neural models with stochastic layers. arXiv preprint arXiv:1605.07571, 2016.
267
+
268
+ Lawrence R Glosten, Ravi Jagannathan, and David E Runkle. On the relation between the expected value and the volatility of the nominal excess return on stocks. The journal of finance, 48(5): 1779–1801, 1993.
269
+
270
+ Alex Graves. Generating sequences with recurrent neural networks. arXiv preprint arXiv:1308.0850, 2013.
271
+
272
+ Alex Graves, Abdel-rahman Mohamed, and Geoffrey Hinton. Speech recognition with deep recurrent neural networks. In 2013 IEEE international conference on acoustics, speech and signal processing, pp. 6645–6649. IEEE, 2013.
273
+
274
+ Karol Gregor, Ivo Danihelka, Alex Graves, Danilo Jimenez Rezende, and Daan Wierstra. Draw: A recurrent neural network for image generation. arXiv preprint arXiv:1502.04623, 2015.
275
+
276
+ Barbara Hammer. On the approximation capability of recurrent neural networks. Neurocomputing, 31(1):107–123, 2000.
277
+
278
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. arXiv preprint arXiv:1512.03385, 2015.
279
+
280
+ Steven L Heston. A closed-form solution for options with stochastic volatility with applications to bond and currency options. Review of financial studies, 6(2):327–343, 1993.
281
+
282
+ Geoffrey Hinton, Li Deng, Dong Yu, George E Dahl, Abdel-rahman Mohamed, Navdeep Jaitly, Andrew Senior, Vincent Vanhoucke, Patrick Nguyen, Tara N 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.
283
+
284
+ Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997.
285
+
286
+ John C Hull. Options, futures, and other derivatives. Pearson Education India, 2006.
287
+
288
+ Matthew B Kennel, Reggie Brown, and Henry DI Abarbanel. Determining embedding dimension for phase-space reconstruction using a geometrical construction. Physical review A, 45(6):3403, 1992.
289
+
290
+ Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
291
+
292
+ Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
293
+
294
+ 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.
295
+
296
+ Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. Nature, 521(7553):436–444, 2015.
297
+
298
+ Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attentionbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015.
299
+
300
+ Daniel B Nelson. Conditional heteroskedasticity in asset returns: A new approach. Econometrica: Journal of the Econometric Society, pp. 347–370, 1991.
301
+
302
+ Ser-Huang Poon and Clive WJ Granger. Forecasting volatility in financial markets: A review. Journal of economic literature, 41(2):478–539, 2003.
303
+
304
+ Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. arXiv preprint arXiv:1401.4082, 2014.
305
+
306
+ Jurgen Schmidhuber. Deep learning in neural networks: An overview. ¨ Neural Networks, 61:85–117, 2015.
307
+
308
+ Mike Schuster and Kuldip K Paliwal. Bidirectional recurrent neural networks. IEEE Transactions on Signal Processing, 45(11):2673–2681, 1997.
309
+
310
+ Josef Stoer and Roland Bulirsch. Introduction to numerical analysis, volume 12. Springer Science & Business Media, 2013.
311
+
312
+ Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. In Advances in neural information processing systems, pp. 3104–3112, 2014.
313
+
314
+ Aaron van den Oord, Nal Kalchbrenner, and Koray Kavukcuoglu. Pixel recurrent neural networks. arXiv preprint arXiv:1601.06759, 2016.
315
+
316
+ Yue Wu, Jose Miguel Hern ´ andez-Lobato, and Zoubin Ghahramani. Gaussian process volatility ´ model. In Advances in Neural Information Processing Systems, pp. 1044–1052, 2014.
317
+
318
+ Wojciech Zaremba, Ilya Sutskever, and Oriol Vinyals. Recurrent neural network regularization. arXiv preprint arXiv:1409.2329, 2014.
319
+
320
+ # A COMPLEMENTARY DISCUSSIONS OF NSVM
321
+
322
+ In this appendix section we present detailed derivations of NSVM, specifically, the parameters learning and calibration, and covariance reparameterisation.
323
+
324
+ # A.1 LEARNING PARAMETERS / CALIBRATION
325
+
326
+ Given the observations $\boldsymbol { X }$ , the objective of learning is to maximise the marginal log-likelihood of $\boldsymbol { X }$ given $\Phi$ , where the posterior is involved. However, as we have discussed in the previous subsection, the true posterior is usually intractable, which means exact inference is difficult. Hence, approximate inference is applied instead of rather than exact inference by following (Kingma & Welling, 2013; Rezende et al., 2014). We represent the marginal log-likelihood of $\boldsymbol { X }$ in the following form:
327
+
328
+ $$
329
+ \begin{array} { r l } & { \displaystyle \ln p _ { \Phi } ( \pmb X ) = \mathbb { E } _ { q _ { \Psi } ( Z | \pmb X ) } \Big [ \ln \frac { p _ { \Phi } ( \pmb X , Z ) } { p _ { \Phi } ( Z | \pmb X ) } \Big ] = \mathbb { E } _ { q _ { \Psi } ( Z | \pmb X ) } \Big [ \ln \frac { p _ { \Phi } ( \pmb X , Z ) } { q _ { \Psi } ( Z | \pmb X ) } \frac { q _ { \Psi } ( Z | \pmb X ) } { p _ { \Phi } ( Z | \pmb X ) } \Big ] } \\ & { \quad \quad \quad \quad \quad = \mathbb { E } _ { q _ { \Psi } ( Z | \pmb X ) } [ \ln p _ { \Phi } ( \pmb X , Z ) - \ln q _ { \Psi } ( Z | \pmb X ) ] + K L [ q _ { \Psi } ( Z | \pmb X ) | | p _ { \Phi } ( Z | \pmb X ) ] } \\ & { \quad \quad \quad \quad \geq \mathbb { E } _ { q _ { \Psi } ( Z | \pmb X ) } [ \ln p _ { \Phi } ( \pmb X , Z ) - \ln q _ { \Psi } ( Z | \pmb X ) ] \qquad ( \mathrm { a s } K L \geq 0 ) , } \end{array}
330
+ $$
331
+
332
+ where the expectation term $\mathbb { E } _ { q _ { \Psi } ( Z | X ) } [ \ln p _ { \Phi } ( X , Z ) - \ln q _ { \Psi } ( Z | X ) ]$ is referred to as the variational lower bound $\mathcal { L } [ q ; X , \Phi , \Psi ]$ of the approximate posterior $q _ { \Psi } ( Z | X , \Psi )$ . The lower bound is essentially a functional with respect to distribution $q$ and parameterised by observations $\boldsymbol { X }$ and parameter sets $\Phi , \Psi$ of both generative and inference model. In theory, the marginal log-likelihood is maximised by optimisation on the lower bound $\mathcal { L } [ q ; X , \Phi , \Psi ]$ with respect to $\Phi$ and $\pmb { \psi }$ .
333
+
334
+ We apply the factorisations in Eqs. (10) and (19) to the integrand within expectation of Eq. (30):
335
+
336
+ $$
337
+ \begin{array} { l } { \displaystyle \ln p _ { \Phi } ( X , Z ) - \ln q _ { \Psi } ( Z | X ) = \sum _ { t } \Big [ \ln \mathcal { N } ( x _ { t } ; \mu _ { \Phi } ^ { x } ( x _ { < t } , z _ { \le t } ) , \Sigma _ { \Phi } ^ { x } ( x _ { < t } , z _ { \le t } ) ) } \\ { \displaystyle \qquad + \ln \mathcal { N } ( z _ { t } ; \mu _ { \Phi } ^ { z } ( z _ { < t } ) , \Sigma _ { \Phi } ^ { z } ( z _ { < t } ) ) - \ln \mathcal { N } ( z _ { t } ; \mu _ { \Psi } ^ { z } ( z _ { < t } , x _ { < t } ) , \tilde { \Sigma } _ { \Psi } ^ { z } ( z _ { < t } , x _ { < t } ) ) \Big ] . } \end{array}
338
+ $$
339
+
340
+ As there is usually no closed-form solution for the expecation (Eq. (30)), we have to estimate the expectation by applying sampling methods to latent variable ${ \boldsymbol { z } } _ { t }$ through time in accordance with the causal dependences. We utilise the reparameterisation of ${ \boldsymbol { z } } _ { t }$ as shown in Eq. (22) such that we sample the corresponding auxiliary standard variable $\tilde { \epsilon } _ { t }$ rather than ${ \boldsymbol { z } } _ { t }$ itself and compute the value of ${ \boldsymbol { z } } _ { t }$ on the fly. This ensures that the gradient-based optimisation techniques are applicable as the reparameterisation isolates the model parameters of interest from the sampling procedure. By sampling $N$ sample paths, the estimator of the lower bound is defined as the average of paths:
341
+
342
+ $$
343
+ \begin{array} { r l } & { \widehat { \mathcal { L } } = - \displaystyle \frac { 1 } { 2 N } \sum _ { t } \Big [ \ln \operatorname* { d e t } { \textstyle \Sigma _ { t } ^ { z } } + ( \tilde { \mu } _ { t } ^ { z } + \tilde { A } _ { t } ^ { z } \tilde { \epsilon } _ { t } ^ { z } - \mu _ { t } ^ { z } ) ^ { \top } ( { \textstyle \Sigma _ { t } ^ { z } } ) ^ { - 1 } ( \tilde { \mu } _ { t } ^ { z } + \tilde { A } _ { t } ^ { z } \tilde { \epsilon } _ { t } ^ { z } - \mu _ { t } ^ { z } ) } \\ & { \qquad + \ln \operatorname* { d e t } { \textstyle \Sigma _ { t } ^ { x } } + ( x _ { t } - \mu _ { t } ^ { x } ) ^ { \top } ( { \textstyle \Sigma _ { t } ^ { x } } ) ^ { - 1 } ( x _ { t } - \mu _ { t } ^ { x } ) - \ln \operatorname* { d e t } { \textstyle \tilde { \Sigma } _ { t } } \Big ] + \mathrm { c o n s t } , } \end{array}
344
+ $$
345
+
346
+ where $\tilde { A } _ { t } ^ { z } ( \tilde { A } _ { t } ^ { z } ) ^ { \top } = \tilde { \Sigma } _ { t } ^ { z }$ and $\tilde { \epsilon } _ { t } ^ { z } \sim \mathcal { N } ( \mathbf { 0 } , I _ { z } )$ is parameter-independent and considered as constant when calculating derivatives.
347
+
348
+ # A.2 COVARIANCE PARAMETERISATION
349
+
350
+ As is known, it entails a computational complexity of $\mathcal { O } ( M ^ { 3 } )$ to maintain and update the full-size covariance $\pmb { \Sigma }$ with $M$ dimensions (Rezende et al., 2014). In the case of very high dimensions, the full-size covariance matrix would be too computationally expensive to afford. Hence, we use instead the covariance matrices with much fewer parameters for efficiency. The simplest setting is to use diagonal precision matrix (i.e. the inverse of covariance matrix) $\overrightharpoon { \mathbfcal { Z } } ^ { - 1 } = \overrightharpoon { \cal D }$ . However, it draws very strong restrictions on representation of the random variable of interest as the diagonal precision matrix (and thus diagonal covariance matrix) indicates independence among the dimensions. Therefore, the tradeoff becomes low-rank perturbation on diagonal matrix: $\pmb { \Sigma } ^ { - 1 } = \pmb { D } + \pmb { V V } ^ { \top }$ , where $V = \{ \pmb { v } _ { 1 } , \dots , \pmb { v } _ { K } \}$ denotes the perturbation while each ${ \pmb v } _ { k }$ is a $M$ -dimensional column vector.
351
+
352
+ The corresponding covariance matrix and its determinant is obtained using Woodbury identity and matrix determinant lemma:
353
+
354
+ $$
355
+ { \begin{array} { r l } & { \qquad \Sigma = D ^ { - 1 } - D ^ { - 1 } V ( I + V ^ { \top } D ^ { - 1 } V ) ^ { - 1 } V ^ { \top } D ^ { - 1 } } \\ & { } \\ & { \ln \operatorname* { d e t } \Sigma = - \ln \operatorname* { d e t } { ( D + V V ^ { \top } ) } = - \ln \operatorname* { d e t } D - \ln \operatorname* { d e t } { ( I + V ^ { \top } D ^ { - 1 } V ) } } \end{array} }
356
+ $$
357
+
358
+ To calculate the deviation $\pmb { A }$ for the factorisation of covariance matrix $\pmb { \Sigma } = \pmb { A } \pmb { A } ^ { \top }$ , we first consider the rank-1 perturbation where $K \ = \ 1$ . It follows that $V ~ = ~ v$ is a column vector, and $I + V ^ { \top } D ^ { - 1 } V \stackrel { \cdot } { = } 1 + v ^ { \top } D ^ { - 1 } v$ is a real number. A particular solution of $\pmb { A }$ is obtain:
359
+
360
+ $$
361
+ A = D ^ { - \frac { 1 } { 2 } } - [ \gamma ^ { - 1 } ( 1 - \sqrt { \eta } ) ] D ^ { - 1 } v v ^ { \top } D ^ { - \frac { 1 } { 2 } }
362
+ $$
363
+
364
+ where $\gamma = v ^ { \top } D ^ { - 1 } v$ , $\eta = ( 1 + \gamma ) ^ { - 1 }$ . The computational complexity involved here is merely $\mathcal { O } ( M )$ .
365
+
366
+ bserve that $\begin{array} { r } { V V ^ { \top } = \sum _ { k = 1 } ^ { K } { v _ { k } v _ { k } ^ { \top } } } \end{array}$ , the perturbation of rank $K$ is es ntially the superposition of $K$ $\pmb { A }$
367
+ provided to demonstrate the procedure of calculation. The computational complexity for rank- $K$ perturbation remains to be $\mathcal { O } ( M )$ given $K \ll M$ .
368
+
369
+ Algorithm 1 gives the detailed calculation scheme.
370
+
371
+ <table><tr><td>Algorithm1 Calculation of rank-K perturbation of precision matrices</td></tr><tr><td>Input: The original diagonal matrix D; The rank-K perturbation V = {U1,..., Uk}</td></tr><tr><td>Output: A such that the factorisation AAT = ∑= (D + VVT)-1 holds</td></tr><tr><td>1: A(0) = D-¹</td></tr><tr><td>2:i=0</td></tr><tr><td>3:while i&lt;K_do 4: Y(i) =U)A(i))A)U(i)</td></tr><tr><td>5: n(i) = (1+Y())-1</td></tr><tr><td>6: A(i+1) =A(i)-[γ(i1(1-√n(a)]A(i)A)U(i)U(𝑖)A(𝑖) 7: A= A(K)</td></tr></table>
372
+
373
+ # B MORE CASE STUDIES
374
+
375
+ In this appendix section we add more case studies of NVSM performance on both synthetic data and real-world stock data.
376
+
377
+ NSVM obtains $- 2 . 0 4 4$ , $- 2 . 6 0 9$ and $- 1 . 9 3 9$ on the stocks corresponding to Fig 4(a), (b) and (c) respectively, each of which is better than the that of GARCH (0.589, 0.109 and 0.207 lower on NLL).
378
+
379
+ The reason of the drops in Fig 4(b) and (c) seems to be that NSVM has captured the jumps and drops of the stock price using its nonlinear dynamics and modelled the sudden changes as part of the trend: the estimated trend “mu” goes very close to the real observed price even around the jumps and drops (see the upper figure of Fig 4(b) and (c) around step 1300 and 1600). The residual (i.e. difference between the real value of observation and the trend of prediction) therefore becomes quite small, which lead to a lower volatility estimation.
380
+
381
+ On the other hand, for the baselines, we adopt AR as the trend model, which is a relatively simple linear model compared with the nonlinear NSVM. AR would not capture the sudden changes and leave those spikes in the residual; GARCH then took the residuals as input for volatility modelling, resulting in the spikes in volatility estimation.
382
+
383
+ ![](images/f43ff1bc495c169e73aa911c03a878aa3a393f55577ca834838d3698e86186d6.jpg)
384
+
385
+ (a) Synthetic time series prediction II. (up) The data and the predicted $\mu ^ { x }$ and bounds $\mu ^ { x } \pm \sigma ^ { x }$ . (down) The groundtruth data variance and the corresponding prediction from GARCH(1,1) and NSVM.
386
+
387
+ ![](images/1b651a01073939c302698d3354c49a9ab7c7b3941aa09e36a8f018842b56c5a5.jpg)
388
+ Figure 3: A case study of synthetic time series prediction.
389
+
390
+ (b) Synthetic time series prediction IV. (up) The data and the predicted $\mu ^ { x }$ and bounds $\mu ^ { x } \pm \sigma ^ { x }$ . (down) The groundtruth data variance and the corresponding prediction from GARCH(1,1) and NSVM.
391
+
392
+ ![](images/b0fe530281b1acc1169c13d45e343fa8a7c1e248898be60bf2cd72f86cf67b7b.jpg)
393
+ (a) Real-world stock price prediction II. (up) The data and the predicted $\mu ^ { x }$ and bounds $\mu ^ { x } \pm \sigma ^ { x }$ . (down) The variance prediction from GARCH(1,1) and NSVM. The prediction of NSVM is more smooth and stable than that of GARCH(1,1), also yielding smaller NLL.
394
+
395
+ ![](images/aaa3fb36f229f2934bd102fd6afebcd7437777c69d894aead7542c2c4c4d34e3.jpg)
396
+ (b) Real-world stock price prediction III. (up) The data and the predicted $\mu ^ { x }$ and bounds $\mu ^ { x } \pm \sigma ^ { x }$ . (down) The variance prediction from GARCH(1,1) and NSVM. The prediction of NSVM is more smooth and stable than that of GARCH(1,1), also yielding smaller NLL.
397
+
398
+ ![](images/6c59a9568d5de3de16d22ae651e0b90c39f62322077353e6665f93557889c043.jpg)
399
+ Figure 4: A case study of real-world stock time series prediction.
400
+
401
+ (c) Real-world stock price prediction IV. (up) The data and the predicted $\mu ^ { x }$ and bounds $\mu ^ { x } \pm \sigma ^ { x }$ . (down) The variance prediction from GARCH(1,1) and NSVM. The prediction of NSVM is more smooth and stable than that of GARCH(1,1), also yielding smaller NLL.
md/train/BJE-4xW0W/BJE-4xW0W.md ADDED
The diff for this file is too large to render. See raw diff
 
md/train/BJbD_Pqlg/BJbD_Pqlg.md ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HUMAN PERCEPTION IN COMPUTER VISION / CONFERENCE SUBMISSIONS
2
+
3
+ # Ron Dekel ∗
4
+
5
+ Department of Neurobiology Weizmann Institute of Science Rehovot, PA 7610001, Israel ron.dekel@weizmann.ac.il
6
+
7
+ # ABSTRACT
8
+
9
+ Computer vision has made remarkable progress in recent years. Deep neural network (DNN) models optimized to identify objects in images exhibit unprecedented task-trained accuracy and, remarkably, some generalization ability: new visual problems can now be solved more easily based on previous learning. Biological vision (learned in life and through evolution) is also accurate and generalpurpose. Is it possible that these different learning regimes converge to similar problem-dependent optimal computations? We therefore asked whether the human system-level computation of visual perception has DNN correlates and considered several anecdotal test cases. We found that perceptual sensitivity to image changes has DNN mid-computation correlates, while sensitivity to segmentation, crowding and shape has DNN end-computation correlates. Our results quantify the applicability of using DNN computation to estimate perceptual loss, and are consistent with the fascinating theoretical view that properties of human perception are a consequence of architecture-independent visual learning.
10
+
11
+ # 1 QUICK EXPERT SUMMARY
12
+
13
+ Considering the learned computation of ImageNet-trained DNNs, we find:
14
+
15
+ • Large computation changes for perceptually salient image changes (Figure 1).
16
+ • Gestalt: segmentation, crowding, and shape interactions in computation (Figure 2).
17
+ • Contrast constancy: bandpass transduction in first layers is later corrected (Figure 3).
18
+
19
+ These properties are reminiscent of human perception, perhaps because learned general-purpose classifiers (human and DNN) tend to converge.
20
+
21
+ # 2 INTRODUCTION
22
+
23
+ Deep neural networks (DNNs) are a class of computer learning algorithms that have become widely used in recent years (LeCun et al., 2015). By training with millions of examples, such models achieve unparalleled degrees of task-trained accuracy (Krizhevsky et al., 2012). This is not unprecedented on its own - steady progress has been made in computer vision for decades, and to some degree current designs are just scaled versions of long-known principles (Lecun et al., 1998). In previous models, however, only the design is general-purpose, while learning is mostly specific to the context of a trained task. Interestingly, for current DNNs trained to solve a large-scale image recognition problem (Russakovsky et al., 2014), the learned computation is useful as a building block for drastically different and untrained visual problems (Huh et al., 2016; Yosinski et al., 2014).
24
+
25
+ For example, orientation- and frequency-selective features (Gabor patches) can be considered general-purpose visual computations. Such features are routinely discovered by DNNs (Krizhevsky et al., 2012; Zeiler & Fergus, 2013), by other learning algorithms (Hinton & Salakhutdinov, 2006;
26
+
27
+ Lee et al., 2008; 2009; Olshausen & Field, 1997), and are extensively hard-coded in computer vision (Jain & Farrokhnia, 1991). Furthermore, a similar computation is believed to underlie the spatial response properties of visual neurons of diverse animal phyla (Carandini et al., 2005; DeAngelis et al., 1995; Hubel & Wiesel, 1968; Seelig & Jayaraman, 2013), and is evident in human visual perception (Campbell & Robson, 1968; Fogel & Sagi, 1989; Neri et al., 1999). This diversity culminates in satisfying theoretical arguments as to why Gabor-like features are so useful in general-purpose vision (Olshausen, 1996; Olshausen & Field, 1997).
28
+
29
+ As an extension, general-purpose computations are perhaps of universal use. For example, a dimensionality reduction transformation that optimally preserves recognition-relevant information may constitute an ideal computation for both DNN and animal. More formally, different learning algorithms with different physical implementations may converge to the same computation when similar (or sufficiently general) problems are solved near-optimally. Following this line of reasoning, DNN models with good general-purpose computations may be computationally similar to biological visual systems, even more so than less accurate and less general biologically plausible simulations (Kriegeskorte, 2015; Yamins & DiCarlo, 2016).
30
+
31
+ Related work seems to be consistent with computation convergence. First, different DNN training regimes seem to converge to a similar learned computation (Li et al., 2015; Zhou et al., 2014). Second, image representation may be similar in trained DNN and in biological visual systems. That is, when the same images are processed by DNN and by humans or monkeys, the final DNN computation stages are strong predictors of human fMRI and monkey electrophysiology data collected from visual areas V4 and IT (Cadieu et al., 2014; Khaligh-Razavi & Kriegeskorte, 2014; Yamins et al., 2014). Furthermore, more accurate DNN models exhibit stronger predictive power (Cadieu et al., 2014; Dubey & Agarwal, 2016; Yamins et al., 2014), and the final DNN computation stage is even a strong predictor of human-perceived shape discrimination (Kubilius et al., 2016). However, some caution is perhaps unavoidable, since measured similarity may be confounded with categorization consistency, view-invariance resilience, or similarity in the inherent difficulty of the tasks undergoing comparison. A complementary approach is to consider images that were produced by optimizing trained DNN-based perceptual metrics (Gatys et al., 2015a;b; Johnson et al., 2016; Ledig et al., 2016), which perhaps yields undeniable evidence of non-trivial computational similarity, although a more objective approach may be warranted.
32
+
33
+ Here, we quantify the similarity between human visual perception, as measured by psychophysical experiments, and individual computational stages (layers) in feed-forward DNNs trained on a large-scale image recognition problem (ImageNet LSVRC). Comparison is achieved by feeding the experimental image stimuli to the trained DNN and comparing a DNN metric (mean mutual information or mean absolute change) to perceptual data. The use of reduced (simplified and typically non-natural) stimuli ensures identical inherent task difficulty across compared categories and prevents confounding of categorization consistency with measured similarity. Perception, a systemlevel computation, may be influenced less by the architectural discrepancy (biology vs. DNN) than are neural recordings.
34
+
35
+ # 3 CORRELATE FOR IMAGE CHANGE SENSITIVITY
36
+
37
+ From a perceptual perspective, an image change of fixed size has different saliency depending on image context (Polat & Sagi, 1993). To investigate whether the computation in trained DNNs exhibits similar contextual modulation, we used the Local Image Masking Database (Alam et al., 2014), in which 1080 partially-overlapping images were subjected to different levels of the same random additive noise perturbation, and for each image, a psychophysical experiment determined the threshold noise level at which the added-noise image is discriminated from two noiseless copies at $7 5 \%$ (Figure 1a). Threshold is the objective function that is compared with an $L _ { 1 }$ -distance correlate in the DNN representation. The scale of measured threshold was:
38
+
39
+ $$
40
+ 2 0 \cdot \log _ { 1 0 } \left( \frac { \mathrm { s t d } \left( n o i s e \right) } { T } \right) ,
41
+ $$
42
+
43
+ where std $( n o i s e )$ is the standard deviation of the additive noise, and $T$ is the mean image pixel value calculated over the region where the noise is added (i.e. image center).
44
+
45
+ ![](images/790ed25adca1327d42ec60be5b4b6dbf2d30a4be4b78b863a68199a6c956a87c.jpg)
46
+ Figure 1: Predicting perturbation thresholds. a, For a fixed image perturbation, perceptual detection threshold (visualized by red arrow) depends on image context. b, Measured perceptual threshold is correlated with the average $L _ { 1 }$ change in DNN computation due to image perturbation (for DNN model VGG-19, image scale $= 1 0 0 \%$ ). c, Explained variability $( R ^ { 2 } )$ of perceptual threshold data when $L _ { 1 }$ change is based on isolated computational layers for different input image scales. Same VGG-19 model as in (b). X-axis labels: data refers to raw image pixel data, $\mathsf { c o n v ^ { * } } _ { - 1 }$ and ${ \mathsf { f c } } _ { - } *$ are the before-ReLU output of a convolution and a fully-connected operation, respectively, and prob is the output class label probabilities vector. d, Example images for whcih predicted threshold in b is much higher than perceptually measured (”Overshoot”, where perturbation saliency is better than predicted), or vise versa (”Undershoot”). Examples are considered from several perceptual threshold ranges $\pm 2 \mathrm { d B }$ of shown number).
47
+
48
+ The DNN correlate of perceptual threshold we used was the average $L _ { 1 }$ change in DNN computation between added-noise images and the original, noiseless image. Formally,
49
+
50
+ $$
51
+ L _ { 1 } ^ { i , n } ( I ) = \left| \overline { { { a _ { i } \left( I + n o i s e \left( n \right) \right) } } } - a _ { i } \left( I \right) \right| ,
52
+ $$
53
+
54
+ where $a _ { i } \left( X \right)$ is the activation value of neuron $i$ during the DNN feedforward pass for input image $X$ , and the inner average (denoted by bar) is taken over repetitions with random $n$ -sized noise (noise is introduced at random phase spectra in a fixed image location, an augmentation that follows the between-image randomization described by Alam et al., 2014; the number of repetitions was 10 or more). Unless otherwise specified, the final $L _ { 1 }$ prediction is $L _ { 1 } ^ { i , n }$ averaged across noise levels $( - 4 0$ to $2 5 { \mathrm { ~ d B } }$ with 5-dB intervals) and computational neurons (first within and then across computational stages). Using $L _ { 1 }$ averaged across noise levels as a correlate for the noise level of perceptual threshold is a simple approximation with minimal assumptions.
55
+
56
+ Results show that the $L _ { 1 }$ metric is correlated with the perceptual threshold for all tested DNN architectures (Figure 1b, 4a-c). In other words, higher values of the $L _ { 1 }$ metric (indicating larger changes in DNN computation due to image perturbation, consistent with higher perturbation saliency) are correlated with lower values of measured perceptual threshold (indicating that weaker noise levels are detectable, i.e. higher saliency once more).
57
+
58
+ Table 1: Prediction accuracy. Percent of linearly explained variability $( R ^ { 2 } )$ , absolute value of Spearman rank-order correlation coefficient (SROCC), and the root mean squared error of the linear prediction (RMSE) are presented for each prediction model. Note the measurement scale of the threshold data being predicted (Eq. 1). $( ^ { * } )$ Thresholds linearized through a logistic transform before prediction (see Larson & Chandler, 2010), possibly increasing but not decreasing measured predictive strength. $( ^ { * * } )$ Average of four similar alternatives.
59
+
60
+ <table><tr><td>Model</td><td>R²</td><td>SROCC</td><td>RMSE</td></tr><tr><td>Signal-noise ratio</td><td></td><td></td><td></td></tr><tr><td>Spectral change</td><td>.20 .25</td><td>.39</td><td>7.67</td></tr><tr><td>RMS contrast (Alam et al., 2014)</td><td>.27*</td><td>.61</td><td>7.42</td></tr><tr><td>L1 VGG-19 (50%)</td><td>.57</td><td>.46</td><td>1</td></tr><tr><td>L1 VGG-19 (66%)</td><td>.60</td><td>.77</td><td>5.57 5.42</td></tr><tr><td>L1 VGG-19 (100%)</td><td>.60</td><td>.79</td><td></td></tr><tr><td>Perceptual model** (Alam et al., 2014)</td><td>.60*</td><td>.79</td><td>5.40</td></tr><tr><td></td><td></td><td>.70</td><td>5.73</td></tr><tr><td>Inter-person (Alam et al., 2014)</td><td>.84*</td><td>.87</td><td>4.08</td></tr></table>
61
+
62
+ To quantify and compare predictive power, we considered the percent of linearly explained variability $( R ^ { 2 } )$ . For all tested DNN architectures, the prediction explains about $6 0 \%$ of the perceptual variability (Tables 1, 2; baselines at Tables 3-5), where inter-person similarity representing theoretical maximum is $84 \%$ (Alam et al., 2014). The DNN prediction is far more accurate than a prediction based on simple image statistical properties (e.g. RMS contrast), and is on par with a detailed perceptual model that relies on dozens of psychophysically collected parameters (Alam et al., 2014). The Spearmann correlation coefficient is much higher compared with the perceptual model (with an absolute SROCC value of about 0.79 compared with 0.70, Table 1), suggesting that the $L _ { 1 }$ metric gets the order right but not the scale. We did not compare these results with models that fit the experimental data (e.g. Alam et al., 2015; Liu & Allebach, 2016), since the $L _ { 1 }$ metric has no explicit parameters. Also, different DNN architectures exhibited high similarity in their predictions $\bar { R } ^ { 2 }$ of about 0.9, e.g. Figure 4d).
63
+
64
+ Prediction can also be made from isolated computational stages, instead of across all stages as before. This analysis shows that the predictive power peaks mid-computation across all tested image scales (Figure 1c). This peak is consistent with use of middle DNN layers to optimize perceptual metrics (Gatys et al., 2015a;b; Ledig et al., 2016), and is reminiscent of cases in which low- to mid-level vision is the performance limiting computation in the detection of at-threshold stimuli (Campbell & Robson, 1968; Del Cul et al., 2007).
65
+
66
+ Finally, considering the images for which the $L _ { 1 }$ -based prediction has a high error suggests a factor which causes a systematic inconsistency with perception (Figures 1d, 6). This factor may be related to the mean image luminance: by introducing noise perturbations according to the scale of Equation 1, a fixed noise size (in dB) corresponds to smaller pixel changes in dark compared with bright images. (Using this scales reflects an assumption of multiplicative rather than additive conservation; this assumption may be justified for the representation at the final but perhaps not the intermediate computational stages considering the log-linear contrast response discussed in Section 5). Another factor may the degree to which image content is identifiable.
67
+
68
+ The previous analysis suggested gross computational similarity between human perception and trained DNNs. Next, we aimed to extend the comparison to more interpretable properties of perception by considering more highly controlled designs. To this end, we considered cases in which a static background context modulates the difficulty of discriminating a foreground shape, despite no spatial overlap of foreground and background. This permits interpretation by considering the cause of the modulation.
69
+
70
+ We first consider segmentation, in which arrangement is better discriminated for arrays of consistently oriented lines compared with inconsistently oriented lines (Figure 2a) (Pinchuk-Yacobi et al., 2016). Crowding is considered next, where surround clutter that is similar to the discriminated target leads to deteriorated discrimination performance (Figure 2b) (Livne & Sagi, 2007). Last to be addressed is object superiority, in which a target line location is better discriminated when it is in a shape-forming layout (Figure 2c) (Weisstein & Harris, 1974). In this case, clutter is controlled by having the same fixed number of lines in context. To measure perceptual discrimination, these works introduced performance-limiting manipulations such as location jittering, brief presentation, and temporal masking. While different manipulations showed different measured values, order-of-difficulty was typically preserved. Here we changed all the original performance-limiting manipulations to location jittering (whole-shape or element-wise, see Section 8.4).
71
+
72
+ To quantify discrimination difficulty in DNNs, we measured the target-discriminative information of isolated neurons (where performance is limited by location jittering noise), then averaged across all neurons (first within and then across computational layer stages). Specifically, for each neuron, we measured the reduction in categorization uncertainty due to observation, termed mutual information (MI):
73
+
74
+ $$
75
+ M I \left( A _ { i } ; C \right) = H \left( C \right) - H \left( C \vert A _ { i } \right) ,
76
+ $$
77
+
78
+ where H stands for entropy, and $A _ { i }$ is a random variable for the value of neuron i when the DNN processes a random image from a category defined by the random variable C. For example, if a neuron gives a value in the range of 100.0 to 200.0 when the DNN processes images from category A, and 300.0 to 400.0 for category B, then the category is always known by observing the value, and so mutual information is high $\mathbf { M } \mathbf { I } { = } 1$ bits). On the other extreme, if the neuron has no discriminative task information, then ${ \bf M I } { = } 0$ bits. To measure MI, we quantized activations into eight equal-amount bins, and used 500 samples (repetitions having different location jittering noise) across categories. The motivation for this correlate is the assumption that the perceptual order-of-difficulty reflects the quantity of task-discriminative information in the representation.
79
+
80
+ Results show that, across hundreds of configurations (varying pattern element size, target location, jitter magnitude, and DNN architecture; see Section 8.4), the qualitative order of difficulty in terms of the DNN MI metric is consistent with the order of difficulty measured in human psychophysical experiments, for the conditions addressing segmentation and crowding (Figures 2d, 7; for baseline models see Figure 8). It is interesting to note that the increase in similarity develops gradually along different layer types in the DNN computation (i.e. not just pooling layers), and is accompanied by a gradual increase in the quantity of task-relevant information (Figure 2e-g). This indicates a link between task relevance and computational similarity for the tested conditions. Note that unlike the evident increase in isolated unit task information, the task information from all units combined decreases by definition along any computational hierarchy. An intuition for this result is that the total hidden information decreases, while more accessible per-unit information increases.
81
+
82
+ For shape formation, four out of six shapes consistently show order of difficulty like perception, and two shapes consistently do no (caricature at Figure 2h; actual data at Figure 9).
83
+
84
+ ![](images/facc45e6917a8622804e2ee023233bcc6bd542f3ced7648ea2c3f55e2650d3af.jpg)
85
+ Figure 2: Background context. a-c, Illustrations of reproduced discrimination stimuli for three psychophysical experiments (actual images used were white-on-black rather than black-on-white, and pattern size was smaller, see Figures 12-14). d, Number of configurations for which orderof-difficulty in discrimination is qualitatively consistency with perception according to a mutual information DNN metric. Configurations vary in pattern (element size, target location, and jitter magnitude; see Section 8.4) and in DNN architecture used (CaffeNet, GoogLeNet, VGG-19, and ResNet-152). DNN metric is the average across neurons of the isolated neuron target-discriminative information (averaged first within, and then across computational layer stages), where performance is limited by location jittering (e.g. evident jitter in illustrations). e-g, The value of the MI metric across computational layers of model VGG-19 for a typical pattern configuration. The six ”hard” (gray) lines in Shape MI correspond to six different layouts (see Section 8.4.3). Analysis shows that for isolated computation stages, similarity to perception is evident only at the final DNN computation stages. h, A caricature summarizing the similarity and discrepancy of perception and the MI-based DNN prediction for Shape (see Figure 9).
86
+
87
+ # 5 CORRELATE FOR CONTRAST SENSITIVITY
88
+
89
+ A cornerstone of biological vision research is the use of sine gratings at different frequencies, orientations, and contrasts (Campbell & Robson, 1968). Notable are results showing that the lowest perceivable contrast in human perception depends on frequency. Specifically, high spatial frequencies are attenuated by the optics of the eye, and low spatial frequencies are believed to be attenuated due to processing inefficiencies (Watson & Ahumada, 2008), so that the lowest perceivable contrast is found at intermediate frequencies. (To appreciate this yourself, examine Figure 3a). Thus, for low-contrast gratings, the physical quantity of contrast is not perceived correctly: it is not preserved across spatial frequencies. Interestingly, this is corrected for gratings of higher contrasts, for which perceived contrast is more constant across spatial frequencies (Georgeson & Sullivan, 1975).
90
+
91
+ The DNN correlate we considered is the mean absolute change in DNN representation between a gray image and sinusoidal gratings, at all combinations of spatial frequency and contrast. Formally, for neurons in a given layer, we measured:
92
+
93
+ $$
94
+ L _ { 1 } ( c o n t r a s t , f r e q u e n c y ) = \frac { 1 } { N _ { n e u r o n s } } \sum _ { i = 1 } ^ { N _ { n e u r o n s } } \left| \overline { { a _ { i } \left( c o n t r a s t , f r e q u e n c y \right) } } - a _ { i } \left( 0 , 0 \right) \right| ,
95
+ $$
96
+
97
+ where $a _ { i }$ (contrast, frequency) is the average activation value of neuron $i$ to 250 sine images (random orientation, random phase), $a _ { i } \left( 0 , 0 \right)$ is the response to a blank (gray) image, and $N _ { n }$ eurons is the number of neurons in the layer. This measure reflects the overall change in response vs. the gray image.
98
+
99
+ Results show a bandpass response for low-contrast gratings (blue lines strongly modulated by frequency, Figures 3, 10), and what appears to be a mostly constant response at high contrast for end-computation layers (red lines appear more invariant to frequency), in accordance with perception.
100
+
101
+ We next aimed to compare these results with perception. Data from human experiments is generally iso-output (i.e. for a pre-set output, such as $7 5 \%$ detection accuracy, the input is varied to find the value which produce the preset output). However, the DNN measurements here are iso-input (i.e. for a fixed input contrast the $L _ { 1 }$ is measured). As such, human data should be compared to the interpoalted inverse of DNN measurements. Specifically, for a set output value, the interpolated contrast value which produce the output is found for every frequency (Figure 11). This analysis permits quantifying the similarity of iso-output curves for human and DNN, measured here as the percent of log-Contrast variability in human measurements which is explained by the DNN predictions. This showed a high explained variability at the end computation stage (prob layer, $\mathbf { \dot { \mathit { R } } ^ { 2 } = 9 4 \% }$ , but importantly, a similarly high value at the first computational stage (conv1 1 layer, $R ^ { 2 } = 9 6 \%$ ). Intiutively, while the ”internal representation” variability in terms of $L _ { 1 }$ is small, the iso-output number-of-input-contrast-cahnges variability is still high. For example. for the prob layer, about the same $L _ { 1 }$ is measured for (Contrast $^ { - 1 }$ ,freq $= 7 5$ ) and for (Contras ${ = } 0 . 1 8$ ,freq $= 1 2$ ).
102
+
103
+ An interesting, unexpected observation is that the logarithmically spaced contrast inputs are linearly spaced at the end-computation layers. That is, the average change in DNN representation scales logarithmically with the size of input change. This can be quantified by the correlation of output $L _ { 1 }$ with log Contrast input, which showed $R ^ { 2 } = 9 8 \%$ (averaged across spatial frequencies) for prob, while much lower values were observed for early and middle layers (up to layer fc7). The same computation when scrambling the learned parameters of the model showed $R ^ { 2 } = 6 0 \%$ . Because the degree of log-linearity observed was extremely high, it may be an important emergent property of the learned DNN computation, which may deserve further investigation. However, this property is only reminiscent and not immediately consistent with the perceptual power-law scaling (Gottesman et al., 1981).
104
+
105
+ ![](images/129e93025def5a9cbbe9b8278b8c41324aea4c3845d014896910bb2486ca54c3.jpg)
106
+ Figure 3: Contrast sensitivity. a. Perceived contrast is strongly affected by spatial frequency at low contrast, but less so at high contrast (which preserves the physical quantity of contrast and thus termed constancy). b. The $L _ { 1 }$ change in VGG-19 representation between a gray image and images depicting sinusoidal gratings at each combination of sine spatial frequency $\mathbf { \dot { x } }$ -axis) and contrast (color) (random orientation, random phase), considering the raw image pixel data representation (data), the before-ReLU output of the first convolutional layer representation (conv1 1), the output of the last fully-connected layer representation (fc8), and the output class label probabilities representation (prob).
107
+
108
+ # 6 DISCUSSION
109
+
110
+ # 6.1 HUMAN PERCEPTION IN COMPUTER VISION
111
+
112
+ It may be tempting to believe that what we see is the result of a simple transformation of visual input. Centuries of psychophysics have, however, revealed complex properties in perception, by crafting stimuli that isolate different perceptual properties. In our study, we used the same stimuli to investigate the learned properties of deep neural networks (DNNs), which are the leading computer vision algorithms to date (LeCun et al., 2015).
113
+
114
+ The DNNs we used were trained in a supervised fashion to assign labels to input images. To some degree, this task resembles the simple verbal explanations given to children by their parents. Since human perception is obviously much richer than the simple external supervision provided, we were not surprised to find that the best correlate for perceptual saliency of image changes is a part of the DNN computation that is only supervised indirectly (i.e. the mid-computation stage). This similarity is so strong, that even with no fine-tuning to human perception, the DNN metric is competitively accurate, even compared with a direct model of perception.
115
+
116
+ This strong, quantifiable similarity to a gross aspect of perception may, however, reflect a mix of similarities and discrepancies in different perceptual properties. To address isolated perceptual effects, we considered experiments that manipulate a spatial interaction, where the difficulty of discriminating a foreground target is modulated by a background context. Results showed modulation of DNN target diagnostic, isolated unit information, consistent with the modulation found in perceptual discrimination. This was shown for contextual interactions reflecting grouping/segmentation (Harris et al., 2015), crowding/clutter (Livne & Sagi, 2007; Pelli et al., 2004), and shape superiority (Weisstein & Harris, 1974). DNN similarity to these groupings/gestalt phenomena appeared at the end-computation stages.
117
+
118
+ No less interesting, are the cases in which there is no similarity. For example, perceptual effects related to 3D (Erdogan & Jacobs, 2016) and symmetry (Pramod & Arun, 2016) do not appear to have a strong correlate in the DNN computation. Indeed, it may be interesting to investigate the influence of visual experience in these cases. And, equally important, similarity should be considered in terms of specific perceptual properties rather than as a general statement.
119
+
120
+ # 6.2 RECURRENT VS. FEEDFORWARD CONNECTIVITY
121
+
122
+ In the human hierarchy of visual processing areas, information is believed to be processed in a feedforward sweep, followed by recurrent processing loops (top-down and lateral) (Lamme & Roelfsema, 2000). Thus, for example, the early visual areas can perform deep computations. Since mapping from visual areas to DNN computational layers is not simple, it will not be considered here. (Note that ResNet connectivity is perhaps reminiscent of unrolled recurrent processing).
123
+
124
+ Interestingly, debate is ongoing about the degree to which visual perception is dependent on recurrent connectivity (Fabre-Thorpe et al., 1998; Hung et al., 2005): recurrent representations are obviously richer, but feedforward computations converge much faster. An implicit question here regarding the extent of feasible feed-forward representations is, perhaps: Can contour segmentation, contextual influences, and complex shapes be learned? Based on the results reported here for feedforward DNNs, a feedforward representation may seem sufficient. However, the extent to which this is true may be very limited. In this study we used small images with a small number of lines, while effects such as contour integration seem to take place even in very large configurations (Field et al., 1993). Such scaling seems more likely in a recurrent implementation. As such, a reasonable hypothesis may be that the full extent of contextual influence is only realizable with recurrence, while feedforward DNNs learn a limited version by converging towards a useful computation.
125
+
126
+ # 6.3 IMPLICATIONS AND FUTURE WORK
127
+
128
+ # 6.3.1 USE IN BRAIN MODELING
129
+
130
+ The use of DNNs in modeling of visual perception (or of biological visual systems in general) is subject to a tradeoff between accuracy and biological plausibility. In terms of architecture, other deep models better approximate our current understanding of the visual system (Riesenhuber &
131
+
132
+ Poggio, 1999; Serre, 2014). However, the computation in trained DNN models is quite generalpurpose (Huh et al., 2016; Yosinski et al., 2014) and offers unparalleled accuracy in recognition tasks (LeCun et al., 2015). Since visual computations are, to some degree, task- rather than architecturedependent, an accurate and general-purpose DNN model may better resemble biological processing than less accurate biologically plausible ones (Kriegeskorte, 2015; Yamins & DiCarlo, 2016). We support this view by considering a controlled condition in which similarity is not confounded with task difficulty or categorization consistency.
133
+
134
+ # 6.3.2 USE IN PSYCHOPHYSICS
135
+
136
+ Our results imply that trained DNN models have good predictive value for outcomes of psychophysical experiments, permitting a zero-cost first-order approximation. Note, however, that the scope of such simulations may be limited, since learning (Sagi, 2011) and adaptation (Webster, 2011) were not considered here.
137
+
138
+ Another fascinating option is the formation of hypotheses in terms of mathematically differentiable trained-DNN constraints, whereby it is possible to efficiently solve for the visual stimuli that optimally dissociate the hypotheses (see Gatys et al. 2015a;b; Mordvintsev et al. 2015 and note Goodfellow et al. 2014; Szegedy et al. 2013). The conclusions drawn from such stimuli can be independent of the theoretical assumptions about the generating process (for example, creating new visual illusions that can be seen regardless of how they were created).
139
+
140
+ # 6.3.3 USE IN ENGINEERING (A PERCEPTUAL LOSS METRIC)
141
+
142
+ As proposed previously (Dosovitskiy & Brox, 2016; Johnson et al., 2016; Ledig et al., 2016), the saliency of small image changes can be estimated as the representational distance in trained DNNs. Here, we quantified this approach by relying on data from a controlled psychophysical experiment (Alam et al., 2014). We found the metric to be far superior to simple image statistical properties, and on par with a detailed perceptual model (Alam et al., 2014). This metric can be useful in image compression, whereby optimizing degradation across image sub-patches by comparing perceptual loss may minimize visual artifacts and content loss.
143
+
144
+ # ACKNOWLEDGMENTS
145
+
146
+ We thank Yoram Bonneh for his valuable questions which led to much of this work.
147
+
148
+ # REFERENCES
149
+
150
+ Md Mushfiqul Alam, Kedarnath P Vilankar, David J Field, and Damon M Chandler. Local masking in natural images: A database and analysis. Journal of vision, 14(8):22–, jan 2014. ISSN 1534- 7362. doi: 10.1167/14.8.22.
151
+
152
+ Md Mushfiqul Alam, Pranita Patil, Martin T Hagan, and Damon M Chandler. A computational model for predicting local distortion visibility via convolutional neural network trainedon natural scenes. In Image Processing (ICIP), 2015 IEEE International Conference on, pp. 3967–3971. IEEE, 2015.
153
+
154
+ Charles F Cadieu, Ha Hong, Daniel L K Yamins, Nicolas Pinto, Diego Ardila, Ethan A Solomon, Najib J Majaj, and James J DiCarlo. Deep neural networks rival the representation of primate IT cortex for core visual object recognition. PLoS computational biology, 10(12):e1003963, dec 2014. ISSN 1553-7358. doi: 10.1371/journal.pcbi.1003963.
155
+
156
+ Fergus W Campbell and J G Robson. Application of Fourier analysis to the visibility of gratings. The Journal of physiology, 197(3):551, 1968.
157
+
158
+ Matteo Carandini, Jonathan B Demb, Valerio Mante, David J Tolhurst, Yang Dan, Bruno A Olshausen, Jack L Gallant, and Nicole C Rust. Do we know what the early visual system does? The Journal of Neuroscience, 25(46):10577–97, nov 2005. ISSN 1529-2401. doi: 10.1523/JNEUROSCI.3726-05.2005.
159
+
160
+ Gregory C DeAngelis, Izumi Ohzawa, and Ralph D Freeman. Receptive-field dynamics in the central visual pathways. Trends in neurosciences, 18(10):451–458, 1995. ISSN 0166-2236.
161
+
162
+ Antoine Del Cul, Sylvain Baillet, and Stanislas Dehaene. Brain dynamics underlying the nonlinear threshold for access to consciousness. PLoS Biol, 5(10):e260, 2007. ISSN 1545-7885.
163
+
164
+ Alexey Dosovitskiy and Thomas Brox. Generating images with perceptual similarity metrics based on deep networks. arXiv preprint arXiv:1602.02644, 2016.
165
+
166
+ Abhimanyu Dubey and Sumeet Agarwal. Examining Representational Similarity in ConvNets and the Primate Visual Cortex. arXiv preprint arXiv:1609.03529, 2016.
167
+
168
+ Goker Erdogan and Robert A Jacobs. A 3D shape inference model matches human visual object similarity judgments better than deep convolutional neural networks. In Proceedings of the 38th Annual Conference of the Cognitive Science Society. Cognitive Science Society Austin, TX, 2016.
169
+
170
+ Michele Fabre-Thorpe, Ghislaine Richard, and Simon J Thorpe. Rapid categorization of natural \` images by rhesus monkeys. Neuroreport, 9(2):303–308, 1998. ISSN 0959-4965.
171
+
172
+ David J Field, Anthony Hayes, and Robert F Hess. Contour integration by the human visual system: evidence for a local association field. Vision research, 33(2):173–193, 1993. ISSN 0042-6989.
173
+
174
+ Itzhak Fogel and Dov Sagi. Gabor filters as texture discriminator. Biological cybernetics, 61(2): 103–113, 1989. ISSN 0340-1200.
175
+
176
+ Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge. A Neural Algorithm of Artistic Style. aug 2015a.
177
+
178
+ Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge. Texture synthesis and the controlled generation of natural stimuli using convolutional neural networks. may 2015b.
179
+
180
+ M A Georgeson and G D Sullivan. Contrast constancy: deblurring in human vision by spatial frequency channels. The Journal of Physiology, 252(3):627–656, 1975. ISSN 1469-7793.
181
+
182
+ Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in Neural Information Processing Systems, pp. 2672–2680, 2014.
183
+
184
+ Jon Gottesman, Gary S Rubin, and Gordon E Legge. A power law for perceived contrast in human vision. Vision research, 21(6):791–799, 1981. ISSN 0042-6989.
185
+
186
+ Hila Harris, Noga Pinchuk-Yacobi, and Dov Sagi. Target selective tilt-after effect during texture learning. Journal of vision, 15(12):1134, 2015.
187
+
188
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep Residual Learning for Image Recognition. dec 2015.
189
+
190
+ Hinton and Salakhutdinov. Reducing the dimensionality of data with neural networks. Science (New York, N.Y.), 313(5786):504–7, jul 2006. ISSN 1095-9203. doi: 10.1126/science.1127647.
191
+
192
+ D. H. Hubel and T. N. Wiesel. Receptive fields and functional architecture of monkey striate cortex. The Journal of Physiology, 195(1):215–243, mar 1968. ISSN 00223751. doi: 10.1113/jphysiol. 1968.sp008455.
193
+
194
+ Minyoung Huh, Pulkit Agrawal, and Alexei A. Efros. What makes ImageNet good for transfer learning? aug 2016.
195
+
196
+ Chou P Hung, Gabriel Kreiman, Tomaso Poggio, and James J DiCarlo. Fast readout of object identity from macaque inferior temporal cortex. Science, 310(5749):863–866, 2005. ISSN 0036- 8075.
197
+
198
+ Anil K Jain and Farshid Farrokhnia. Unsupervised texture segmentation using Gabor filters. Pattern recognition, 24(12):1167–1186, 1991. ISSN 0031-3203.
199
+
200
+ Yangqing Jia, Evan Shelhamer, Jeff Donahue, Sergey Karayev, Jonathan Long, Ross Girshick, Sergio Guadarrama, and Trevor Darrell. Caffe. In Proceedings of the ACM International Conference on Multimedia - MM ’14, pp. 675–678, New York, New York, USA, nov 2014. ACM Press. ISBN 9781450330633. doi: 10.1145/2647868.2654889.
201
+
202
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. arXiv preprint arXiv:1603.08155, 2016.
203
+
204
+ A. Karni and D. Sagi. Where practice makes perfect in texture discrimination: evidence for primary visual cortex plasticity. Proceedings of the National Academy of Sciences, 88(11):4966–4970, jun 1991. ISSN 0027-8424. doi: 10.1073/pnas.88.11.4966.
205
+
206
+ Seyed-Mahdi Khaligh-Razavi and Nikolaus Kriegeskorte. Deep Supervised, but Not Unsupervised, Models May Explain IT Cortical Representation. PLoS Computational Biology, 10(11): e1003915, nov 2014. ISSN 1553-7358. doi: 10.1371/journal.pcbi.1003915.
207
+
208
+ Nikolaus Kriegeskorte. Deep neural networks: A new framework for modeling biological vision and brain information processing. Annual Review of Vision Science, 1:417–446, 2015. ISSN 2374-4642.
209
+
210
+ 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.
211
+
212
+ Jonas Kubilius, Stefania Bracci, and Hans P Op de Beeck. Deep Neural Networks as a Computational Model for Human Shape Sensitivity. PLoS Comput Biol, 12(4):e1004896, 2016. ISSN 1553-7358.
213
+
214
+ Victor A.F. Lamme and Pieter R. Roelfsema. The distinct modes of vision offered by feedforward and recurrent processing. Trends in Neurosciences, 23(11):571–579, nov 2000. ISSN 01662236. doi: 10.1016/S0166-2236(00)01657-X.
215
+
216
+ Eric C Larson and Damon M Chandler. Most apparent distortion: full-reference image quality assessment and the role of strategy. Journal of Electronic Imaging, 19(1):11006, 2010. ISSN 1017-9909.
217
+
218
+ Y. Lecun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998. ISSN 00189219. doi: 10.1109/5.726791.
219
+
220
+ Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. Nature, 521(7553):436–444, may 2015. ISSN 0028-0836. doi: 10.1038/nature14539.
221
+
222
+ Christian Ledig, Lucas Theis, Ferenc Huszar, Jose Caballero, Andrew Aitken, Alykhan Tejani, Johannes Totz, Zehan Wang, and Wenzhe Shi. Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network. sep 2016.
223
+
224
+ Honglak Lee, Chaitanya Ekanadham, and Andrew Y. Ng. Sparse deep belief net model for visual area V2. In Advances in Neural Information Processing Systems, pp. 873–880, 2008.
225
+
226
+ Honglak Lee, Roger Grosse, Rajesh Ranganath, and Andrew Y. Ng. Convolutional deep belief networks for scalable unsupervised learning of hierarchical representations. In Proceedings of the 26th Annual International Conference on Machine Learning - ICML ’09, pp. 1–8, New York, New York, USA, jun 2009. ACM Press. ISBN 9781605585161. doi: 10.1145/1553374.1553453.
227
+
228
+ Yixuan Li, Jason Yosinski, Jeff Clune, Hod Lipson, and John Hopcroft. Convergent Learning: Do different neural networks learn the same representations? arXiv preprint arXiv:1511.07543, 2015.
229
+
230
+ Yucheng Liu and Jan P. Allebach. Near-threshold perceptual distortion prediction based on optimal structure classification. In 2016 IEEE International Conference on Image Processing (ICIP), pp. 106–110. IEEE, sep 2016. ISBN 978-1-4673-9961-6. doi: 10.1109/ICIP.2016.7532328.
231
+
232
+ Tomer Livne and Dov Sagi. Configuration influence on crowding. Journal of Vision, 7(2):4, 2007. ISSN 1534-7362.
233
+
234
+ Alexander Mordvintsev, Christopher Olah, and Mike Tyka. Inceptionism: Going deeper into neural networks. Google Research Blog. Retrieved June, 20, 2015.
235
+
236
+ Peter Neri, Andrew J Parker, and Colin Blakemore. Probing the human stereoscopic system with reverse correlation. Nature, 401(6754):695–698, 1999. ISSN 0028-0836.
237
+
238
+ Bruno A Olshausen. Emergence of simple-cell receptive field properties by learning a sparse code for natural images. Nature, 381(6583):607–609, 1996. ISSN 0028-0836.
239
+
240
+ Bruno A. Olshausen and David J. Field. Sparse coding with an overcomplete basis set: A strategy employed by V1? Vision Research, 37(23):3311–3325, dec 1997. ISSN 00426989. doi: 10.1016/ S0042-6989(97)00169-7.
241
+
242
+ Denis G Pelli, Melanie Palomares, and Najib J Majaj. Crowding is unlike ordinary masking: Distinguishing feature integration from detection. Journal of vision, 4(12):12, 2004. ISSN 1534-7362.
243
+
244
+ Noga Pinchuk-Yacobi, Ron Dekel, and Dov Sagi. Expectation and the tilt aftereffect. Journal of vision, 15(12):39, sep 2015. ISSN 1534-7362. doi: 10.1167/15.12.39.
245
+
246
+ Noga Pinchuk-Yacobi, Hila Harris, and Dov Sagi. Target-selective tilt aftereffect during texture learning. Vision research, 124:44–51, 2016. ISSN 0042-6989.
247
+
248
+ U Polat and D Sagi. Lateral interactions between spatial channels: suppression and facilitation revealed by lateral masking experiments. Vision research, 33(7):993–9, may 1993. ISSN 0042- 6989.
249
+
250
+ R T Pramod and S P Arun. Do computational models differ systematically from human object perception? In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1601–1609, 2016.
251
+
252
+ Maximilian Riesenhuber and Tomaso Poggio. Hierarchical models of object recognition in cortex. Nature neuroscience, 2(11):1019–1025, 1999.
253
+
254
+ Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. sep 2014.
255
+
256
+ Dov Sagi. Perceptual learning in vision research. Vision research, 51(13):1552–1566, 2011. ISSN 0042-6989.
257
+
258
+ Johannes D Seelig and Vivek Jayaraman. Feature detection and orientation tuning in the Drosophila central complex. Nature, 503(7475):262–266, 2013. ISSN 0028-0836.
259
+
260
+ Thomas Serre. Hierarchical Models of the Visual System. In Encyclopedia of Computational Neuroscience, pp. 1–12. Springer, 2014. ISBN 1461473209.
261
+
262
+ Eero P Simoncelli and William T Freeman. The steerable pyramid: a flexible architecture for multiscale derivative computation. In ICIP (3), pp. 444–447, 1995.
263
+
264
+ Karen Simonyan and Andrew Zisserman. Very Deep Convolutional Networks for Large-Scale Image Recognition. sep 2014.
265
+
266
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
267
+
268
+ Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going Deeper with Convolutions. sep 2014.
269
+
270
+ Andrea Vedaldi and Karel Lenc. Matconvnet: Convolutional neural networks for matlab. In Proceedings of the 23rd ACM international conference on Multimedia, pp. 689–692. ACM, 2015. ISBN 1450334598.
271
+
272
+ Andrew B Watson and Albert J Ahumada. Predicting visual acuity from wavefront aberrations. Journal of vision, 8(4):17.1–19, jan 2008. ISSN 1534-7362. doi: 10.1167/8.4.17.
273
+
274
+ Michael A Webster. Adaptation and visual coding. Journal of vision, 11(5), jan 2011. ISSN 1534- 7362.
275
+
276
+ N. Weisstein and C. S. Harris. Visual Detection of Line Segments: An Object-Superiority Effect. Science, 186(4165):752–755, nov 1974. ISSN 0036-8075. doi: 10.1126/science.186.4165.752.
277
+
278
+ Daniel L K Yamins and James J DiCarlo. Using goal-driven deep learning models to understand sensory cortex. Nature neuroscience, 19(3):356–365, 2016. ISSN 1097-6256.
279
+
280
+ Daniel L K Yamins, Ha Hong, Charles F Cadieu, Ethan A Solomon, Darren Seibert, and James J DiCarlo. Performance-optimized hierarchical models predict neural responses in higher visual cortex. Proceedings of the National Academy of Sciences, 111(23):8619–8624, 2014. ISSN 0027-8424.
281
+
282
+ Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? In Advances in neural information processing systems, pp. 3320–3328, 2014.
283
+
284
+ Matthew D Zeiler and Rob Fergus. Visualizing and Understanding Convolutional Networks. nov 2013.
285
+
286
+ Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, and Antonio Torralba. Object Detectors Emerge in Deep Scene CNNs. pp. 12, dec 2014.
287
+
288
+ ![](images/7f5bbbcb223c1452fc1734ff68228fa0b27732812631743799d06e0300cc5f5e.jpg)
289
+ Figure 4: Predicting perceptual sensitivity to image changes (following Figure 1). a-c, The $L _ { 1 }$ change in CaffeNet, GoogLeNet, and ResNet-152 DNN architectures as a function of perceptual threshold. d, The $L _ { 1 }$ change in GoogLeNet as a function of the $L _ { 1 }$ change in VGG-19.
290
+
291
+ ![](images/5ebde87e3cc14d07e5e038829043986e2f1e92f89ee8c84f1c899d55e3377031.jpg)
292
+ Figure 5: Prediction accuracy as a function of computational stage. a, Predicting perceptual sensitivity for model VGG-19 using the best single kernel (i.e. using one fitting parameter, no cross validation), vs. the standard $L _ { 1 }$ metric (reproduced from Figure 1). b, For non-branch computational stages of model ResNet-152.
293
+
294
+ Table 2: Accuracy of perceptual sensitivity prediction and task-trained ImageNet center-crop top-1 validation accuracy for different DNN models (following Table 1 from which third row is reproduced; used scale: $100 \%$ ). The quality of prediction for ResNet-152 improves dramatically if only the first tens of layers are considered (see Figure 5b).
295
+
296
+ <table><tr><td>Model</td><td>R²</td><td>SROCC</td><td>RMSE</td><td>Recognition accuracy</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>CaffeNet</td><td>.59</td><td>.78</td><td>5.44</td><td>56%</td></tr><tr><td>GoogLeNet</td><td>.59</td><td>.79</td><td>5.45 5.40</td><td>66%</td></tr><tr><td>VGG-19</td><td>.60</td><td>.79</td><td>5.82</td><td>70%</td></tr><tr><td>ResNet-152</td><td>.53</td><td>.74</td><td></td><td>75%</td></tr></table>
297
+
298
+ Table 3: Accuracy of perceptual sensitivity prediction for baseline models (see Section 8.2; used scale: $100 \%$ ).
299
+
300
+ <table><tr><td>Model</td><td>R²</td><td>SROCC</td><td>RMSE</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>VGG-19, scrambled weights</td><td>.18</td><td>.39</td><td>7.76</td></tr><tr><td>Gabor filter bank</td><td>.32</td><td>.12</td><td>8.03</td></tr><tr><td>Steerable-pyramid filter bank</td><td>.37</td><td>.15</td><td>7.91</td></tr></table>
301
+
302
+ Table 4: Accuracy of perceptual sensitivity prediction during CaffeNet model standard training (used scale: $100 \%$ ). Last row reproduced from Table 2.
303
+
304
+ <table><tr><td>Model</td><td>R²</td><td>SROCC</td><td>RMSE</td><td>Recognition accuracy</td></tr><tr><td>CaffeNetiter1</td><td></td><td></td><td>6.30</td><td></td></tr><tr><td>CaffeNetiter50K</td><td>.46 .59</td><td>.67 .79</td><td>5.43</td><td>0% 37%</td></tr><tr><td>CaffeNetiter100K</td><td>.60</td><td>.79</td><td>5.41</td><td>39%</td></tr><tr><td>CaffeNetiter150K</td><td>.60</td><td>.78</td><td>5.43</td><td>53%</td></tr><tr><td>CaffeNetiter200K</td><td>.59</td><td>.78</td><td>5.45</td><td>54%</td></tr><tr><td>CaffeNetiter250K</td><td>.59</td><td>.78</td><td>5.43</td><td>56%</td></tr><tr><td>CaffeNetiter300K</td><td>.59</td><td>.78</td><td>5.44</td><td>56%</td></tr><tr><td>CaffeNetiter310K</td><td>.59</td><td>.78</td><td>5.44</td><td>56%</td></tr></table>
305
+
306
+ Table 5: Robustness of perceptual sensitivity prediction for varying prediction parameters for model VGG-19. First three rows reproduced from Table 1. Measurements for the lower noise range of -60:-40 dB were omitted by mistake.
307
+
308
+ <table><tr><td>Scale</td><td>Metric</td><td>Augmentation</td><td>Noise range</td><td>R²</td><td>SROCC</td><td>RMSE</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>100%</td><td>L1</td><td>noise phase</td><td>-40:25 dB</td><td>.60</td><td>.79</td><td>5.40</td></tr><tr><td>66%</td><td>L1</td><td>noise phase</td><td>-40:25 dB</td><td>.60</td><td>.79</td><td>5.42</td></tr><tr><td>50%</td><td>L1</td><td>noise phase</td><td>-40:25 dB</td><td>.57</td><td>.77</td><td>5.57</td></tr><tr><td>100%</td><td>L2</td><td>noise phase</td><td>-40:25 dB</td><td>.62</td><td>.80</td><td>5.29</td></tr><tr><td>100%</td><td>L1</td><td>None</td><td>-40:25 dB</td><td>.58</td><td>.77</td><td>5.55</td></tr><tr><td>100%</td><td>L1</td><td>noise phase</td><td>-20:25 dB</td><td>.59</td><td>.78</td><td>5.46</td></tr><tr><td>100%</td><td>L1</td><td>noise phase</td><td>-40:5 dB</td><td>.59</td><td>.79</td><td>5.43</td></tr></table>
309
+
310
+ Table 6: Background context for Shape. Shown is the Spearmann correlation coefficient (SROCC) of perceptual data vs. model-based MI prediction across shapes (i.e. considering all shapes rather than only Easy vs. Hard; note that the original robust finding the superiority of the Easy shape). Perceptual data from Weisstein & Harris (1974), where ”Day 1” and ”Days $2 { - } 4 ^ { \dag }$ (averaged) are for the reduced-masking condition depicted in their Figure 3.)
311
+
312
+ <table><tr><td>Model</td><td></td><td>Day 1 Days 2-4</td><td>Masked</td></tr><tr><td>VGG-19</td><td>.36</td><td></td><td>.15</td></tr><tr><td>GoogLeNet</td><td>.31</td><td>.37 .22</td><td>.16</td></tr><tr><td>MRSA-152</td><td>.26</td><td>.26</td><td>.11</td></tr><tr><td>CaffeNet iter 1</td><td>.32</td><td></td><td>.39</td></tr><tr><td>CaffeNet iter 50K</td><td>.15</td><td>.29</td><td></td></tr><tr><td>CaffeNetiter310K</td><td>.16</td><td>.19</td><td>.16 .18</td></tr><tr><td></td><td>.26</td><td>.12</td><td>.48</td></tr><tr><td>Gabor Decomposition Steerable Pyramid</td><td>.24</td><td>.27 .32</td><td>.25</td></tr></table>
313
+
314
+ ![](images/8b57e7f7fd5822e264b389c7eed47b9194ccbdae2e14e5d0ad2c550462747c76.jpg)
315
+ Figure 6: Images where predicted threshold is too high (”Overshoot”, where perturbation saliency is better than predicted) or too low (”Undershoot”), considered from several perceptual threshold ranges $\pm 2$ dB of shown number). Some images are reproduced from Figure 1.
316
+
317
+ ![](images/6f9b1ef405c1200ecea4e9d17fea6192cb6189de656d2eabe5418e4163295a79.jpg)
318
+ Figure 7: Background context for different DNN models (following figure 2).
319
+
320
+ ![](images/7138a34a90ab813f56ea5bb8f05be4794e2f461e3666d4db9eca006d09a47ca1.jpg)
321
+ Figure 8: Background context for baseline DNN models (following figure 2). ”CaffeNet iter 310K” is reproduced from Figure 7.
322
+
323
+ ![](images/27d167da9bfbd680de4450c36836d45b46cd94cb5fc4e9f608fdee72b4544a91.jpg)
324
+ Figure 9: Background context for Shape. Shown for each model is the measured MI for the six ”Hard” shapes as a function of the MI for the ”Easy” shape. The last panel shows an analagous comparison measured in human subjects by Weisstein & Harris (1974). A data point which lies below the dashed diagonal indicates a configuration for which discriminating line location is easier for the Easy shape compared with the relevant Hard shape.
325
+
326
+ ![](images/861dd0c87dd67be34fa74c6f7d5a517cb2e6e8d0d20c9adf7334aceb7112e790.jpg)
327
+ Figure 10: Contrast sensitivity (following Figure 3) for DNN architectures CaffeNet, GoogLeNet, and ResNet-152.
328
+
329
+ ![](images/74f90c0c817b0bea67bc6afa2e46b878b82a65de2628d7e46d194d25a2c10385.jpg)
330
+ Figure 11: Comparison of contrast sensitivity. Shown are iso-output curves, for which perceived contrast is the same (Human), or for which the $L _ { 1 }$ change relative to a gray image is the same (DNN model VGG-19). To obtain a correspondence between human frequency values (given in cycles per degree of visual field) to DNN frequency values (given in cycles per image), a scaling was chosen such that the minima of the blue curve is given at the same frequency value. Human data is for subject M.A.G. as measured by Georgeson & Sullivan (1975).
331
+
332
+ # 8 APPENDIX: EXPERIMENTAL SETUP
333
+
334
+ # 8.1 DNN MODELS
335
+
336
+ To collect DNN computation snapshots, we used MATLAB with MatConvNet version 1.0-beta20 (Vedaldi & Lenc, 2015). All MATLAB code will be made available upon acceptance of this manuscript. The pre-trained DNN models we have used are: CaffeNet (which is a variant of AlexNet provided in Caffe, Jia et al., 2014), GoogLeNet (Szegedy et al., 2014), VGG-19 (Simonyan & Zisserman, 2014), and ResNet-152 (He et al., 2015). The models were trained on the same ImageNet LSVRC. The CaffeNet model was trained using Caffe with the default ImageNet training parameters (stopping at iteration 310, 000) and imported into MatConvNet. For the GoogLeNet model, we used the imported pre-trained reference-Caffe implementation. For VGG-19 and ResNet-152, we used the imported pre-trained original versions. In all experiments input image size was $2 2 4 \times 2 2 4$ or $2 2 7 \times 2 2 7$ .
337
+
338
+ # 8.2 BASELINE MODELS
339
+
340
+ As baselines to compare with pre-trained DNN models, we consider: (a) a multiscale linear filter bank of Gabor functions, (b) a steerable-pyramid linear filter bank (Simoncelli & Freeman, 1995), (c) the VGG-19 model for which the learned parameters (weights) were randomly scrambled within layer, and (d) the CaffeNet model at multiple time points during training. For the Gabor decomposition, the following Gabor filters were used: all compositions of $\sigma = \bar { \{ 1 , 2 , 4 , 8 , 1 6 , 3 2 , 6 4 \} } \mathrm { p x }$ , $\lambda = \{ 1 , 2 \} \cdot \sigma$ , orientation $\underline { { \underline { { \mathbf { \Pi } } } } } = \{ 0 , \pi / 3 , 2 \pi / 3 , \pi , 4 \pi / 3 , 5 \pi / 3 \}$ , and phase $= \{ 0 , \pi / 2 \}$ .
341
+
342
+ # 8.3 IMAGE PERTURBATION EXPERIMENT
343
+
344
+ The noiseless images were obtained from Alam et al. (2014). In main text, ”image scale” refers to percent coverage of DNN input. Since size of original images $( 1 4 9 \times 1 4 9 )$ is smaller than DNN input of $( 2 2 4 \times 2 2 4 )$ or $( 2 2 7 \times 2 2 7 )$ ), the images were resized by a factor of 1.5 so that $100 \%$ image scale covers approximately the entire DNN input area.
345
+
346
+ Human psychophysics and DNN experiments were done for nearly identical images. A slight discrepancy relates to how the image is blended with the background in the special case where the region where noise is added has no image surround at one or two side. In these sides (which depend on the technical procedure with which images were obtained, see Alam et al., 2014), the surround blending here was hard, while the original was smooth.
347
+
348
+ # 8.4 BACKGROUND CONTEXT EXPERIMENT
349
+
350
+ # 8.4.1 SEGMENTATION
351
+
352
+ The images used are based on the Texture Discrimination Task (Karni & Sagi, 1991). In the variant considered here (Pinchuk-Yacobi et al., 2015), subjects were presented with a grid of lines, all of which were horizontal, except two or three that were diagonal. Subjects discriminated whether the arrangement of diagonal lines is horizontal or vertical, and this discrimination was found to be more difficult when the central line is horizontal rather than diagonal (”Hard” vs. ”Easy” in Figure 2a). To limit human performance in this task, two manipulations were applied: (a) the location of each line in the pattern was jittered, and (b) a noise mask was presented briefly after the pattern. Here we only retained (a).
353
+
354
+ A total of 90 configurations were tested, obtained by combinations of the following alternatives:
355
+
356
+ • Three scales: line length of 9, 12.3, or $1 9 . 4 \ \mathrm { p x }$ (number of lines co-varied with line length, see Figure 12).
357
+ • Three levels of location jittering, defined as a multiple of line length: $\{ 1 , 2 , 3 \} \cdot 0 . 0 6 2 5 \cdot l$ px, where $l$ is the length of a line in the pattern. Jittering was applied separately to each line in the pattern.
358
+ • Ten locations of diagonal lines: center, random, four locations of half-distance from center to corners, four locations of half-distance from center to image borders.
359
+
360
+ For each configuration, the discriminated arrangement of diagonal lines was either horizontal or vertical, and the central line was either horizontal or diagonal (i.e. hard or easy).
361
+
362
+ ![](images/e61f99d55dac1fec445d942c16502244e20273274c1c7ec161dba0ab42e4345e.jpg)
363
+ Figure 12: Pattern scales used in the different configurations of the Segmentation condition. Actual images used were white-on-black rather than black-on-white.
364
+
365
+ # 8.4.2 CROWDING
366
+
367
+ The images used are motivated by the crowding effect (Livne & Sagi, 2007; Pelli et al., 2004).
368
+
369
+ A total of 90 configurations were tested, obtained by combinations of the following alternatives:
370
+
371
+ • Three scales: font size of 15.1, 20.6, or $3 2 . 4 { \mathrm { p x } }$ (see Figure 13).
372
+ • Three levels of discriminated-letter location jittering, defined as a multiple of font size: $\{ 1 , 2 , 3 \} \cdot 0 . 0 6 2 5 \cdot l$ px, where $l$ is font size. The jitter of surround letters (M, N, S, and T) was fixed (i.e. the background was static).
373
+ • Ten locations: center, random, four locations of half-distance from center to corners, four locations of half-distance from center to image borders.
374
+
375
+ For each configuration, the discriminated letter was either A, B, C, D, E, or F, and the background was either blank (easy) or composed of the letters M, N, S, and T (hard).
376
+
377
+ ![](images/3b00649747048479281c6d49a31d32f1e301675100b165b5e0554a56148e123c.jpg)
378
+ Figure 13: Pattern scales used in the different configurations of the Crowding condition. Actual images used were white-on-black rather than black-on-white.
379
+
380
+ # 8.4.3 SHAPE
381
+
382
+ The images used are based on the object superiority effect by Weisstein & Harris (1974), where discriminating a line location is easier when combined with surrounding lines a shape is formed.
383
+
384
+ A total of 90 configurations were tested, obtained by combinations of the following alternatives:
385
+
386
+ • Three scales: discriminated-line length of 9, 15.1, or 22.7 px (see Figure 14). • Five levels of whole-pattern location jittering, defined as a multiple of discriminated-line length: $\{ 1 , 2 , 5 , 1 0 , 1 \bar { 5 } \} \cdot 0 . 0 6 2 5 \cdot l$ px, where $l$ is the length of the discriminated line.
387
+
388
+ • Six ”hard” background line layouts (patterns $b { - } f$ of their Figure 2 and the additional pattern $f$ of their Figure 3 in Weisstein & Harris, 1974). The ”easy” layout was always the same (pattern $a$ ).
389
+
390
+ For each configuration, the line whose location is discriminated had four possible locations (two locations are shown in Figure 2c), and the surrounding background line layout could compose a shape (easy) or not (hard).
391
+
392
+ ![](images/3a4cd4d746343780ed7fd9d056ac0f854d4db1895ecffe90c3de68ac7286044d.jpg)
393
+
394
+ Figure 14: Pattern scales used in the different configurations of the Shape condition. Actual images used were white-on-black rather than black-on-white.
395
+
396
+ # 8.5 CONTRAST SENSITIVITY EXPERIMENT
397
+
398
+ Used images depicted sine gratings at different contrast, spatial frequency, sine phase, and sine orientation combinations.
md/train/BJgcwh4FwS/BJgcwh4FwS.md ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NEURAL MAXIMUM COMMON SUBGRAPH DETECTION WITH GUIDED SUBGRAPH EXTRACTION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Maximum Common Subgraph (MCS) is defined as the largest subgraph that is commonly present in both graphs of a graph pair. Exact MCS detection is NPhard, and its state-of-the-art exact solver based on heuristic search is slow in practice without any time complexity guarantee. Given the huge importance of this task yet the lack of fast solver, we propose an efficient MCS detection algorithm, NEURALMCS, consisting of a novel neural network model that learns the nodenode correspondence from the ground-truth MCS result, and a subgraph extraction procedure that uses the neural network output as guidance for final MCS prediction. The whole model guarantees polynomial time complexity with respect to the number of the nodes of the larger of the two input graphs. Experiments on four real graph datasets show that the proposed model is $3 1 . 7 8 \times$ faster than the exact solver while achieving near-perfect accuracy in MCS detection.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Graph data are ubiquitous. Due to its flexible and expressive nature, graphs have been used to store data of various domains. In computational biology, atomic networks can represent molecular compounds. In software analysis, program dependence graphs can describe the data and control dependencies. In social science, social networks can represent community structures. Because of graphs’ unique ability to capture these data, algorithms tackling novel tasks on graphs across different domains have been gaining increased interest in the representation learning community.
12
+
13
+ Graph matching, in particular, is a recently popular task with new approaches such as Zanfir & Sminchisescu (2018), Bai et al. (2019a), and Li et al. (2019). These methods either produce a score indicating how much and/or how well two graphs match or a graph alignment indicating how and where two graphs match. The latter case is a far more difficult task than the former one. Current methods perform a special case of graph alignment, namely image matching, where the two input graphs are of spatial structures (ex. pixel grids, object orientation, etc.) To account for more general graphs, we extract the Maximum Common Subgraph (MCS) (Bunke & Shearer, 1998), a widely used metric for graph alignment, and perform matching on the extracted subgraphs.
14
+
15
+ MCS is a very useful metric to match two graphs in real-world applications. For example, in drug discovery, identifying compounds sharing similar substructures which tend to share similarity properties can dramatically reduce the amount of molecules that need to be manually tested (Ehrlich & Rarey, 2011). In addition to molecular science, MCS also has application values in malware detection (Park et al., 2013), pattern recognition (Solnon et al., 2015), computer-aided circuit design (Djoko et al., 1997; Li et al., 2012), etc. Unfortunately, MCS is NP-hard and, to the best of our knowledge, no existing algorithms tackle this problem from a purely machine learning approach.
16
+
17
+ We are among the first to tackle graph matching defined by MCS. This is more challenging than image matching or graph similarity computation, because MCS requires the extraction of the largest connected subgraph that is commonly present in both input graphs. This implies that the two extracted subgraphs must not only be contained in both graphs but also be isomorphic to each other. To capture the MCS definition, our proposed model, NEURALMCS, fundamentally changes the way that the representations are learned. Instead of computing similarity all in one step, we introduce an iterative procedure to match nodes one at a time. By selecting nodes successively, we ensure the extracted subgraphs are connected. We utilize subgraph embeddings to perform a stopping condition check, dealing with subgraph isomorphism and ending the procedure when the connected subgraphs are the largest. By performing this iterative procedure, we both better ensure the isomorphism of the extracted subgraph as well as capture the recurrent relationship between matching pairs of nodes.
18
+
19
+ ![](images/3b709cc607db6fa1ce65918001d29e7e9068fc14b7d5f9e275dd8306ebf5d953.jpg)
20
+ Figure 1: For a graph pair $( \mathcal { G } _ { 1 } , \mathcal { G } _ { 2 } )$ , previous works (Bai et al., $2 0 1 9 \mathrm { a }$ ; 2018; Li et al., 2019) focus on predicting their graph-graph similarity score. In this work, we aim to find the Maximum Common Subgraph (MCS) (circled in red), which requires fine-grained node-node correspondence prediction. It is more useful both due to the application value as described in Section 1 and because of the interpretable similarity result indicated by the node-node mapping. Node text indicates node labels.
21
+
22
+ We experimentally verify NEURALMCS on four real graph datasets. and show that NEURALMCS can achieve $4 8 . 1 \times$ runtime gain over state-of-the-art exact MCS computation algorithm MCSPLIT (McCreesh et al., 2017), and is much more accurate than all the baseline approximate approaches to graph matching.
23
+
24
+ # 2 PROBLEM DEFINITION AND PRELIMINARIES
25
+
26
+ # 2.1 PROBLEM DEFINITION
27
+
28
+ We denote a graph as $\mathcal { G } = ( V , E )$ with node set $V$ and edge set $E$ . We define as an induced subgraph as $\boldsymbol { \mathcal { G } } ^ { \prime } = ( \boldsymbol { V } ^ { \prime } , \boldsymbol { E } ^ { \prime } )$ where $V ^ { ' } \subseteq V$ and $E ^ { ' } \subseteq E$ and $E ^ { ' }$ preserves all edges between nodes in $V ^ { ' }$ in the original graph $\mathcal { G }$ . In other words, for two nodes in $V ^ { ' }$ , if there is an edge between them in $\mathcal { G }$ , the induced subgraph must also contain the edge. In the rest of the paper, we use the term “subgraph” to refer to “induced subgraph”.
29
+
30
+ In this work, our goal is to detect the Maximum Common Subgraph (MCS) for an input graph pair $( \mathcal { G } _ { 1 } , \mathcal { G } _ { 2 } )$ . In general, MCS refers to the largest (induced) subgraph that is common to both graphs. In this paper, we make the following qualifications:
31
+
32
+ • Labeled graph. The nodes of $\mathcal { G } _ { 1 }$ and $\mathcal { G } _ { 2 }$ are labeled, and nodes of different labels cannot be matched.
33
+ • Connected subgraph. We require the detected subgraph to be connected, which is a common qualification consistent with McCreesh et al. (2017).
34
+
35
+ Our goal is to detect the MCS for an input graph pair $\mathcal { G } _ { 1 } , \mathcal { G } _ { 2 }$ . We adopt the state-of-the-art exact solver, MCSPLIT (McCreesh et al., 2017), to provide ground-truth MCS results for a set of training graph pairs. Specifically, MCSPLIT provides not only the nodes that are included in the MCS in both graphs, but also the node-node correspondence in the MCS, as illustrated in Figure 1.
36
+
37
+ # 2.2 NODE REPRESENTATION LEARNING
38
+
39
+ Among various node embedding methods, GRAPH MATCHING NETWORKS (GMN) (Li et al., 2019) are recent models designed for graph similarity computation. GMN is based on GRAPH CONVOLUTIONAL NETWORKS (GCN) (Kipf & Welling, 2016), but in addition to message passing within a graph (intra-graph), GMN explicitly handles inter-graph information passing between the two input graphs.
40
+
41
+ First, GMN performs explicit cross-graph communication on node embeddings denoted as $\mathbf { \Omega } _ { h } ( l )$ where initial node features have $l = 0$ . More specifically, cross-graph communication is achieved through the following attention based mechanism: $\begin{array} { r } { a _ { j \to i } = \frac { \exp ( \cos ( \pmb { h } _ { i } ^ { ( l ) } , \pmb { h } _ { j } ^ { ( l ) } ) } { \sum _ { j ^ { \prime } } \exp ( \cos ( \pmb { h } _ { i } ^ { ( l ) } , \pmb { h } _ { j ^ { \prime } } ^ { ( l ) } ) } } \end{array}$ Next, a softmax function is applied to the cosine similarity between two node embeddings which makes sure similar node pairs across graphs receive greater attention. This weight is then multiplied with the difference between cross-graph node embeddings to allow all node pairs in the two graphs to communicate with each other. Finally each node embedding resulted from inter-graph message passing is concatenated with embedding from intra-graph neighborhood aggregation and placed through a MLP or a GRU core to complete a single layer update of a $h _ { i }$ .
42
+
43
+ # 3 THE PROPOSED APPROACH: NEURALMCS
44
+
45
+ Our proposed approach, NEURALMCS, relies on the learning capacity of the embedding model to generate a good matching matrix for each input graph pair, encoding the likelihood of each nodenode pair being included in the MCS and matched to each other. Therefore, the training process aims to learn a matching matrix for each graph pair that is as close to the ground-truth node-node correspondence (as illustrated in Figure 1) as possible.
46
+
47
+ However, we suppose that a good matching matrix by itself is not enough for an accurate prediction of the MCS, mainly due to the fact that MCS by definition requires the two extracted subgraphs must be isomorphic to each other and both subgraphs must also be connected (see Section 2.1). To satisfy these two requirements, we propose a novel GUIDED SUBGRAPH EXTRACTION (GSE) process that iteratively performs a guided search procedure to enlarge both extracted subgraphs using the matching matrix as guidance. The rest of the section details our proposed approach.
48
+
49
+ # 3.1 MATCHING MATRIX GENERATION
50
+
51
+ Our task fundamentally requires the matching between two graphs. Therefore, the ideal node embeddings should receive information from the nodes of both graphs. Thus, we adopt the state-of-theart node embedding model, GRAPH MATCHING NETWORKS (GMN), as described in Section 2.2. Specifically, we stack $L$ GMN layers on the input node representations to allow inter-graph message passing at multiple scales for sufficient interaction of the two graphs. We denote the final node representations as U1 ∈ R|V1|×D(L) and U2 ∈ R|V2|×D(L) .
52
+
53
+ To match nodes from the input graphs, we compute the likelihood of matching each node in $\mathcal { G } _ { 1 }$ to each node in $\mathcal { G } _ { 2 }$ . This likelihood indicates which node pair is most likely to be in the MCS, and should account for cases where some nodes in $\mathcal { G } _ { 1 }$ do not match any nodes in $\mathcal { G } _ { 2 }$ (and vice-versa). We naturally encode these likelihoods into a matching matrix, $Y \in [ 0 , 1 ] ^ { | \mathcal { G } _ { 1 } | \times | \mathcal { G } _ { 2 } | }$ .
54
+
55
+ To compute $\mathbf { Y }$ , one can simply calculate the dot product between the node embeddings, $U _ { 1 } \pmb { U } _ { 2 } ^ { \top }$ . However, this resulting matrix is simply the similarity score between each pair of nodes in the two graphs, which is in the range of $( - \operatorname { i n f } , + \operatorname { i n f } )$ and requires further processing to reflect the probability of the node pair matched and being included in the MCS.
56
+
57
+ As this matrix encode the general similarity between nodes, we denote it as the similarity matrix, $\boldsymbol { X }$ , and further normalize it to obtain $\mathbf { Y }$ . Specifically, we perform the following transformations.
58
+
59
+ To find the likelihood of each node in one graph matching each node in the other graph, we apply column-wise and row-wise normalization on $\boldsymbol { X }$ .
60
+
61
+ $$
62
+ \tilde { p } _ { c o l n } ( i , j ) = \frac { e ^ { X _ { i j } } } { \sum _ { k } e ^ { X _ { i k } } } , ~ \tilde { p } _ { r o w } ( i , j ) = \frac { e ^ { X _ { i j } } } { \sum _ { k } e ^ { X _ { k j } } }
63
+ $$
64
+
65
+ To allow for some nodes to go unmatched, we multiply these likelihoods by a value encoding the overall matching score of a node in one graph to nodes in the other graph.
66
+
67
+ $$
68
+ p _ { c o l n } ( i , j ) = \sigma ( \frac { \sum _ { j } X _ { i j } } { | V _ { 2 } | } ) \cdot \tilde { p } _ { c o l n } ( i , j ) , ~ p _ { r o w } ( i , j ) = \sigma ( \frac { \sum _ { i } X _ { i j } } { | V _ { 1 } | } ) \cdot \tilde { p } _ { r o w } ( i , j )
69
+ $$
70
+
71
+ We consider both row-wise and column-wise normalization by taking the average of both scores, $\begin{array} { r } { \tilde { p } ( i , j ) = \frac { p _ { c o l n } ( i , j ) + p _ { r o w } ( i , j ) } { 2 } } \end{array}$ , and, to ensure we only select nodes with the same labels, we mask out node pairs with different labels to form $\mathbf { Y }$ .
72
+
73
+ # 3.2 LEARNING OF NEURALMCS
74
+
75
+ Although there exist multiple points where we can apply our loss function (before, during, or after GSE), we found that applying binary cross entropy loss as early as possible allows for GMN to receive a better learning signal. For this reason, our loss function acts directly on the matching matrix.
76
+
77
+ ![](images/4a4ace361aa52456241d185c40ca4da878d5d2e7f06d58ba7be373377ab7e23a.jpg)
78
+ Figure 2: A detailed illustration of NEURALMCS using the example graph pair in Figure 1. For the input graph pair $( \mathcal { G } _ { 1 } , \mathcal { G } _ { 2 } )$ , the NEURALMCS first generates a matching matrix encoding the likelihood of each pair of node being matched ((a) and (b)). The GUIDED SUBGRAPH EXTRACTION (GSE) process uses the matching matrix as follows: NEURALMCS selects the initial pair to be included in the predicted MCS, node 2 in $\mathcal { G } _ { 1 }$ and node 6 in $\mathcal { G } _ { 2 }$ ((b) and (c)). Next, NEURALMCS sets its search frontier as the neighbors of the selected nodes, circled in dashed blue lines. By selecting the pair with the largest matching score which still preserves subgraph isomorphism, node 3 in $\mathcal { G } _ { 1 }$ and node 5 in $\mathcal { G } _ { 2 }$ , the extracted subgraphs in both graphs grow to size 2 ((d) and (e)). The procedure continues until a stopping condition is reached, which is detailed in Section 3.3.
79
+
80
+ Specifically, we design the following loss function to train the model $\begin{array} { r } { L ( \pmb { Y } ) = - \sum _ { i } \sum _ { j } \frac { I _ { i j } l o g ( Y _ { i j } ) } { | V _ { 1 } | \cdot | V _ { 2 } | } } \end{array}$ where $Y _ { i j }$ denotes our predicted matching matrix and $I _ { i j }$ denote an indicator value of whether the node $i$ matches node $j$ in the ground truth.
81
+
82
+ Since for a given graph pair, there can be multiple correct MCSs of equal size, we also employ multiple choice learning (Guzman-Rivera et al., 2012; Li et al., 2018). This is done by ensembling various copies of the model and propagating the loss function only through the copy which achieves the lowest loss, as shown by the following: $L = m i n _ { \mathbf { Y } \in \mathcal { Y } } ( L ( \mathbf { Y } ) )$ .
83
+
84
+ # 3.3 GUIDED SUBGRAPH EXTRACTION (GSE)
85
+
86
+ Given a matching matrix $\mathbf { Y }$ encoding the matching likelihood for all node pairs between $\mathcal { G } _ { 1 }$ and $\mathcal { G } _ { 2 }$ , we propose the following GUIDED SUBGRAPH EXTRACTION (GSE) process. It starts by finding the most likely pair, and iteratively expands the extracted subgraphs by selecting one more node pair at a time. The procedure stops once the addition of any additional pair would lead to non-isomorphic subgraphs. In summary, the proposed algorithm is shown in Algorithm 1. A detailed illustration using an example pair from Figure 1 is shown in Figure 2.
87
+
88
+ The GSE algorithm internally maintains a binary assignment matrix $_ { \mathbf { T } }$ which will be the final output indicating the predicted MCS, and a masking matrix $M$ , which is used to mask and select entries of the matching matrix $\mathbf { Y }$ . Both matrices are of the same dimension as $\mathbf { Y }$ . $\mathbf { T }$ is initialized to all zeros, indicating no selected nodes, i.e. extracted subgraphs are zero-size. $M$ is initialized to all ones, since NEURALMCS may select any node pair for its initial subgraph.
89
+
90
+ To select the most likely node matching, the algorithm decides which pair of nodes should be selected (see Section 3.3.1 for details) by order of their matching scores. This involves checking whether the selection of the pair would result in two isomorphic subgraphs or not. Only if so, the algorithm would select the pair (circled in red in Figure 1) and include it in the predicted MCS by updating $T _ { i ^ { \dag } , j ^ { \dag } }$ to be 1. Once a new node pair is included, GSE updates the mask $M$ to reflect the
91
+
92
+ # Algorithm 1 GUIDED SUBGRAPH EXTRACTION (GSE)
93
+
94
+ 1: Input: $\left\{ A _ { 1 } , A _ { 2 } \right\}$ , $\mathbf { Y }$ , node embeddings $\{ U _ { 1 } , U _ { 2 } \}$ , .
95
+ 2: Output: Assignment matrix $_ { \mathbf { T } }$ .
96
+ 3: Initialize $T \gets 0 * Y$ . \\ initialize to all zeros
97
+ 4: Initialize $M \gets 1 * Y$ . \\ initialize to all ones
98
+ 5: Initialize update True
99
+ 6: while update $=$ True
100
+ 7: $\mathbf { I } $ sorted indices by highest to lowest value of elements in $\mathbf { M } \odot \mathbf { Y }$
101
+ 8: for node pair $( { \bf i } ^ { \dag } , j ^ { \dag } ) { \bf \bar { \Lambda } } = { \bf I }$
102
+ 9: update $\because \mathtt { F a l s e }$
103
+ 10: Compute subgraph embeddings $w _ { 1 } , w _ { 2 }$ via Equation 4.
104
+ 11: if $| | \boldsymbol { \bar { w } } _ { 1 } - \boldsymbol { w } _ { 2 } | | _ { 2 } \stackrel { - } { \le } \epsilon \stackrel { \cdot } { \backslash } \backslash$ subgraph isormorphism check
105
+ 12: Select the found pair $( i ^ { \dagger } , j ^ { \dagger } )$ by updating $T _ { i ^ { \dagger } , j ^ { \dagger } } \gets 1$ .
106
+ 13: Expand the search frontier by updating the mask $M$ via Equation 6.
107
+ 14: update $\gets$ True
108
+ 15: break
109
+
110
+ search frontier for the next iteration (see Section 3.3.2 for details) and proceeds to the next iteration. Since the MCS by definiton requires the extracted subgraphs to be connected graphs, we define the search frontier as the first-order neighboring nodes of the current selected nodes. This guarantees the final predicted MCS satisfies the connectivity constraint described in Section 1.
111
+
112
+ # 3.3.1 SUBGRAPH ISOMORPHISM CHECK
113
+
114
+ To decide whether node pair $( i ^ { \dagger } , j ^ { \dagger } )$ from the search frontier can be selected or not, we check if the inclusion of node $i ^ { \dagger }$ in $\mathcal { G } _ { 1 }$ and $j ^ { \dagger }$ in $\mathcal { G } _ { 2 }$ would result in two isomorphic subgraphs. To do this, we compute the two subgraph-level embeddings, ${ \pmb w } _ { 1 }$ and ${ \pmb w } _ { 2 }$ and check if their Euclidean distance is greater than a hyperparameter threshold $\epsilon$ . A more detailed discussion can be found in Appendix H and I.
115
+
116
+ Computing the subgraph-level embeddings, however, involves more than a simple aggregation of node embeddings from $U _ { 1 }$ or $U _ { 2 }$ . This is because for subgraph isomorphism check, we are only concerned with nodes included in the subgraph. The nodes outside the selected subgraph should not affect the nodes inside. However, during node embedding generation, both intra- and inter-graph message passing are performed, resulting in $U _ { 1 }$ and $U _ { 2 }$ containing unwanted information.
117
+
118
+ Inspired by the Weisfeiler-Lehman (WL) algorithm for approximate graph isomorphism test (Shervashidze et al., 2011), as well as the connection between the WL algorithm and the GCNs, we recompute the node embeddings by only aggregating neighboring nodes that are included in the current predicted MCS indicated by $\mathbf { T }$ :
119
+
120
+ $$
121
+ \begin{array} { r } { U _ { 1 } ^ { ( k + 1 ) } = A _ { 1 } ( \pmb { v _ { 1 } } \odot \pmb { U } _ { 1 } ^ { ( k ) } ) , } \\ { U _ { 2 } ^ { ( k + 1 ) } = A _ { 2 } ( \pmb { v _ { 2 } } \odot \pmb { U } _ { 2 } ^ { ( k ) } ) , } \end{array}
122
+ $$
123
+
124
+ where $\pmb { A }$ denotes the adjacency matrix, ${ \pmb v } _ { 1 } \in \{ 0 , 1 \} ^ { | V _ { 1 } | }$ and $v _ { 2 } \in \{ 0 , 1 \} ^ { | V _ { 2 } | }$ are defined as the row and column summation1 of $\mathbf { T }$ , i.e. $\begin{array} { r } { v _ { 1 i } = \sum _ { j = 1 } ^ { | V _ { 2 } | } T _ { i , j } , v _ { 2 j } = \sum _ { i = 1 } ^ { | V _ { 1 } | } T _ { i , j } } \end{array}$ , followed by setting $v _ { 1 i ^ { \dagger } }$ and $v _ { 2 j ^ { \dagger } }$ to 1, and $_ { v \odot U }$ denotes element-wise multiplication, i.e. $( v \odot U ) _ { i , j } = v _ { i } U _ { i , j }$ . For each graph, this performs message passing between nodes in the extracted subgraph plus the node $i ^ { \dagger }$ (for $\mathcal { G } _ { 1 }$ ) or $j ^ { \dagger }$ (for $\mathcal { G } _ { 2 }$ ). All the edges between these nodes are involved via the adjacency matrices $\pmb { A } _ { 1 }$ and $A _ { 2 }$ , ensuring the subgraph is an induced subgraph required by the MCS definition as mentioned in Section 2.1.
125
+
126
+ The above updates are performed for $K$ times to yield the final subgraph node embeddings denoted as U (K) ∈ R|V1|×D(K) and $U _ { 2 } ^ { ( K ) } \ \in \ \mathbb { R } ^ { | V _ { 2 } | \times D ^ { \hat { ( } K ) } }$ . We finally compute the two subgraph-level embeddings whose Euclidean distance is computed for apporximate subgraph isomorphism test:
127
+
128
+ $$
129
+ \begin{array} { r } { \pmb { w } _ { 1 } = \sum _ { i = 1 } ^ { | V _ { 1 } | } ( \pmb { v } _ { 1 } \odot \pmb { U } _ { 1 i , : } ^ { ( K ) } ) , } \\ { \pmb { w } _ { 2 } = \sum _ { j = 1 } ^ { | V _ { 2 } | } ( \pmb { v } _ { 2 } \odot \pmb { U } _ { 2 j , : } ^ { ( K ) } ) , } \end{array}
130
+ $$
131
+
132
+ # 3.3.2 SEARCH FRONTIER EXPANSION
133
+
134
+ As the search process finds more node pairs, the mask $M$ reflects the search frontier, i.e. the candidate node pairs for the next iteration to select from. Specifically, $M _ { i , j }$ denotes whether the node pair $( i , j )$ should be a candidate pair, and the sorting for node pairs is performed on $M \odot Y$ .
135
+
136
+ Once node pair $( i ^ { \dagger } , j ^ { \dagger } )$ is selected by passing the check described in Section 3.3.1, GSE updates the search frontier by first obtaining two binary vectors indicating the neighbors of the selected nodes. Since each row of the adjacency matrix indicates the neighbors of the nodes of a particular graph, and we need to include neighbors of all the selected nodes, we first perform the following aggregation of rows of the adjacency matrix:
137
+
138
+ $$
139
+ \begin{array} { r } { \pmb { p } _ { 1 } = ( \sum _ { i = 1 } ^ { | V _ { 1 } | } \pmb { v } _ { 1 } \odot \pmb { A } _ { 1 i , : } ) \odot ( 1 - \pmb { v } _ { 1 } ) , } \\ { \pmb { p } _ { 2 } = ( \sum _ { j = 1 } ^ { | V _ { 2 } | } \pmb { v } _ { 2 } \odot \pmb { A } _ { 2 j , : } ) \odot ( 1 - \pmb { v } _ { 2 } ) . } \end{array}
140
+ $$
141
+
142
+ The $( 1 - v )$ term is for excluding the nodes that are already selected, which is key for ensuring that the next step does not select nodes that are already selected. This further guarantees that the final $_ { \mathbf { T } }$ matrix is an assignment matrix as required by Equation 3.
143
+
144
+ To obtain a binary indicator vector for the neighbors of selected nodes, we apply an element-wise indicator function, checking whether each entry of $\pmb { p } _ { 1 }$ and $\mathbf { \mathit { p } } _ { 2 }$ is greater than zero, yielding $\pmb q _ { 1 } ~ \in$ $\{ 0 , 1 \} ^ { | V _ { 1 } | }$ and $\pmb { q } _ { 2 } \in \{ 0 , 1 \} ^ { | V _ { 2 } | }$ . Then we can obtain the updated mask $M$ via
145
+
146
+ $$
147
+ { \cal M } = q _ { 1 } \otimes q _ { 2 } ,
148
+ $$
149
+
150
+ where $\otimes$ denotes the dyadic product of two vectors. This allows the selection to choose from the pairs formed by the nodes indicated by $\pmb q _ { 1 }$ and $\pmb { q } _ { 2 }$ .
151
+
152
+ # 3.4 OVERALL TIME COMPLEXITY
153
+
154
+ Each GMN layer involves the message passing for all node-node pairs, whose time complexity is quadratic with respect to the number of nodes. The matching matrix computation computes the dot product for all node-node pairs. The GSE process selects one node pair each time, and expands the search frontier by reaching to neighbors of selected nodes. Thus, GSE in the worst case reaches out to all nodes of the smaller of the two input graphs, and each GSE step involves a quadratic mask computation. Therefore, NEURALMCS runs in ${ \cal \bar { O } } ( s * | V _ { 1 } | * | V _ { 2 } | * l o g ( | V _ { 1 } | * | V _ { 2 } | ) )$ time, where $s$ is the size of the predicted MCS, which in the worst case is $\operatorname* { m i n } ( | V _ { 1 } | , | V _ { 2 } | )$ .
155
+
156
+ # 4 EXPERIMENTS
157
+
158
+ We evaluate NEURALMCS on its accuracy and efficiency against the state-of-the-art exact MCS solver, MCSPLIT (McCreesh et al., 2017), and current machine learning approaches (Zanfir & Sminchisescu, 2018; Wang et al., $2 0 1 9 \mathrm { a }$ ; Velickovic et al., 2018; Li et al., 2019), on four realworld datasets, AIDS, LINUX, IMDB, and REDDIT from a diverse range of domains. Our baselines incldude the state-of-art MCS computation algorithm, MCSPLIT (McCreesh et al., 2017), IMAGEGMN (Zanfir & Sminchisescu, 2018), IMAGE-PCA (Wang et al., 2019a), BASIC-GAT (Velickovic et al., 2018), and BASIC-GMN (Li et al., 2019). Appendix A and B give more details.
159
+
160
+ # 4.1 EVALUATION METRICS
161
+
162
+ For accuracy, we evaluate an exact and a soft metric:
163
+
164
+ $$
165
+ { \mathrm { E x a c t ~ } } \% = { \frac { \sum _ { i } ^ { N } C ( S _ { i 1 } , S _ { i 2 } ) \cdot \mathbf { 1 } _ { ( \left| S _ { i 1 } \right| = \left| { \mathrm { M C S } } _ { i } \right| ) } } { N } }
166
+ $$
167
+
168
+ $$
169
+ \mathrm { S o f t } ~ \% = \frac { \sum _ { i } ^ { N } C ( S _ { i 1 } , S _ { i 2 } ) \cdot \frac { | S _ { i 1 } | + | S _ { i 2 } | } { 2 | \mathrm { M C S } _ { i } | } } { N }
170
+ $$
171
+
172
+ where $N$ is the number of graph pairs in the testing set; $S _ { i 1 }$ and $S _ { i 2 }$ are the subgraphs extracted from the first and second graph, respectively; $C ( \cdot , \cdot )$ is a function that returns 1 if the two input graphs are isomorphic to each other and 0 otherwise; 1 is the indicator function that returns 1 when the condition is true and 0 otherwise; $| \mathrm { M C S } _ { i } |$ is the true MCS size. For efficiency, we evaluate the average running time across graph pairs.
173
+
174
+ # 4.2 RESULTS
175
+
176
+ We see that in terms of accuracy, NEURALMCS improves current methods of subgraph extraction substantially, especially on the AIDS and LINUX datasets, where NEURALMCS performs close to the ground truth solver. For IMDB and REDDIT, the performance is also drastically higher than the baselines. Most interestingly, we find that, when the model does not find the exact ground-truth solution, it still extracts high-quality subgraphs with sizes on average above $90 \%$ of the true MCS size, where all graphs are isomorphic (see Appendix E). The poor performance of computer vision baselines IMAGE-GMN and IMAGE-PCA suggests that the assumptions for image matching do not work for MCS based graph matching very well. Appendix F provides a thorough analysis of the performance boost from each component of the proposed model compared with various alternative designs. Compared against the 2 basic models, we see that both the representation learning scheme and the extraction strategy greatly enhance the performance of the model. The exact accuracy results can be seen in Table 1.
177
+
178
+ Table 1: Exact $\%$ and Soft $\%$ accuracy metrics across four real graph datasets. All methods have been adapted for the MCS detection task. MCSPLIT is the ground-truth MCS solver labeled with \*.
179
+
180
+ <table><tr><td rowspan="2">Method</td><td colspan="2">AIDS</td><td colspan="2">LINUX</td><td colspan="2">IMDB</td><td colspan="2">REDDIT</td></tr><tr><td>Exact %</td><td>Soft %</td><td>Exact %</td><td>Soft %</td><td>Exact %</td><td>Soft %</td><td>Exact %</td><td>Soft %</td></tr><tr><td>MCSPLIT *</td><td>100.000</td><td>100.000</td><td>100.000</td><td>100.000</td><td>100.000</td><td>100.000</td><td>100.000</td><td>100.000</td></tr><tr><td>IMAGE-GMN</td><td>0.033</td><td>0.033</td><td>19.790</td><td>19.790</td><td>N/A</td><td>N/A</td><td>20.261</td><td>20.261</td></tr><tr><td>IMAGE-PCA</td><td>0.229</td><td>0.229</td><td>22.693</td><td>22.693</td><td>38.582</td><td>38.582</td><td>33.987</td><td>33.987</td></tr><tr><td>BASIC-GAT</td><td>11.013</td><td>22.199</td><td>41.135</td><td>53.070</td><td>47.462</td><td>51.680</td><td>37.908</td><td>50.196</td></tr><tr><td>BASIC-GMN</td><td>12.488</td><td>19.256</td><td>48.082</td><td>52.590</td><td>55.273</td><td>62.738</td><td>43.137</td><td>51.782</td></tr><tr><td>NEURALMCS</td><td>98.525</td><td>99.626</td><td>99.674</td><td>99.955</td><td>97.235</td><td>99.613</td><td>96.078</td><td>99.562</td></tr></table>
181
+
182
+ In terms of efficiency, NEURALMCS is $3 1 . 7 8 \times$ faster than the ground-truth solver averaged across the four datasets, while being slightly slower than the baselines.
183
+
184
+ However, as shown in Table 1, the baseline methods fail to consider the connectivity and subgraph isomorphism constraints during maximum common subgraph extraction resulting in worse accuracy. The exact performance results can be seen in Figure 3.
185
+
186
+ ![](images/790a8630f4ddb566085e971c2976250766d11579abf5d1eee572f4c4d40e99e4.jpg)
187
+ Figure 3: Running time comparison.
188
+
189
+ # 4.3 CASE STUDY
190
+
191
+ The iterative expansion ensures that extracted subgraphs satisfy the connectivity constraint. The representation learning component ensures that we select the correct node at each step. As seen in Figure 4, for the AIDS dataset, the learnable matching matrix helps NEURALMCS select good nodes, and, for the IMDB dataset, the iterative procedure indeed helps our model stop once adding additional nodes would break the isomorphism constraint. More importantly, our model is also able to solve both the subgraph isomorphism and graph matching problems. Additional case studies and analysis can be found in Appendix J.
192
+
193
+ ![](images/aaa70f601959c9cd050159d4b031fda53ec660dd6d3d03cc386bb6b81849390b.jpg)
194
+ Figure 4: Case study: Three MCS examples from each dataset. AIDS has node labels as node text. For clarity, we draw only two node-node correspondences for each example, represented as dashed lines between nodes in the two graphs.
195
+
196
+ # 5 RELATED WORK
197
+
198
+ Graph isomorphism is a classic problem that goes back to at least the early work by Sussenguth (1965) and Corneil & Gotlieb (1970). Recently Babai (2016) shows that graph isomorphism can be solved in quasipolynomial time. However, graph isomorphism is only concerned with whether two graphs are exactly the same or not, which may be too rigid in real-world applications. For example, what if two graphs are not isomorphic? In such scenario, a more useful output can be the similarity (or distance) between them, defined by metrics such as Graph Edit Distance (GED) (Bunke, 1983), Maximum Common Subgraph (MCS) (Bunke & Shearer, 1998; Bunke, 1997).
199
+
200
+ In this work, we focus on the more challenging task of graph matching, specifically the matching of two graphs defined by the MCS metric. The MCS detection problem is NP-hard, and remain computationally challenging. Existing works use constraint programming (Vismara & Valery, 2008; McCreesh et al., 2016), branch-and-bound (McCreesh et al., 2017; Liu et al., 2019), mathematical programming (Bahiense et al., 2012), reduction to maximum clique detection (Levi, 1973; McCreesh et al., 2016), etc. MCS has many definitions tailored to different graph types and application specifics (McCreesh et al., 2017), and is a domain-agnostic metric to compare graphs in a detailed way, so it has occurred widely in applications such as graph database systems (Yan et al., 2005), cloud computing platforms (Cao et al., 2011), etc.
201
+
202
+ The term “graph matching” is very general and has been adopted by many recent works: (1) Graph similarity computation (Bai et al., 2019a; Li et al., 2019) aims to output a similarity score for an input graph pair, which can be defined by the MCS metric but less challenging due to the score output. (2) Image matching is a classic task in computer vision with traditional approaches based on quadratic assignment problem solving (Zhou & De la Torre, 2012; Yu et al., 2018) and more recent methods using neural networks (IMAGE-GMN (Zanfir & Sminchisescu, 2018) and IMAGEPCA (Wang et al., 2019a)). (3) The two-graph alignment (Heimann et al., 2018; Xu et al., 2019) problem deals with the alignment of two general structured graph objects. However, the alignment is typically not defined by domain-agnostic metrics such as GED or MCS. There is currently no such methods learning from ground-truth graph pairs to the best of our knowledge.
203
+
204
+ # 6 CONCLUSION
205
+
206
+ In this paper, we propose a neural network approach to solve the NP-hard problem, Maximum Common Subgraph (MCS) detection, in an approximate and accurate way. For an input graph pair, our model NEURALMCS computes the likelihood of each pair of nodes being included in the MCS and matched, which is used by the proposed GUIDED SUBGRAPH EXTRACTION (GSE) algorithm to iteratively include more and more nodes in the predicted MCS. The whole model runs in polynomial time complexity, and experimental results on four real graph datasets demonstrate that NEURALMCS is $3 1 . 7 8 \times$ faster than the exact solver whole achieving very good accuracy compared to a series of strong approximate graph matching baseline approaches.
207
+
208
+ # REFERENCES
209
+
210
+ Laszl ´ o Babai. Graph isomorphism in quasipolynomial time. In ´ STOC, pp. 684–697. ACM, 2016.
211
+
212
+ Laura Bahiense, Gordana Manic, Breno Piva, and Cid C De Souza. The maximum common edge ´ subgraph problem: A polyhedral investigation. Discrete Applied Mathematics, 160(18):2523– 2541, 2012.
213
+
214
+ Yunsheng Bai, Hao Ding, Yizhou Sun, and Wei Wang. Convolutional set matching for graph similarity. NeurIPS Workshop on Relational Representation Learning Workshop, 2018.
215
+
216
+ Yunsheng Bai, Hao Ding, Song Bian, Ting Chen, Yizhou Sun, and Wei Wang. Simgnn: A neural network approach to fast graph similarity computation. WSDM, 2019a.
217
+
218
+ Yunsheng Bai, Hao Ding, Yang Qiao, Agustin Marinovic, Ken Gu, Ting Chen, Yizhou Sun, and Wei Wang. Unsupervised inductive whole-graph embedding by preserving graph proximity. IJCAI, 2019b.
219
+
220
+ Albert-Laszl ´ o Barab ´ asi and R ´ eka Albert. Emergence of scaling in random networks. ´ science, 286 (5439):509–512, 1999.
221
+
222
+ Horst Bunke. What is the distance between graphs. Bulletin of the EATCS, 20:35–39, 1983.
223
+
224
+ Horst Bunke. On a relation between graph edit distance and maximum common subgraph. Pattern Recognition Letters, 18(8):689–694, 1997.
225
+
226
+ Horst Bunke and Kim Shearer. A graph distance metric based on the maximal common subgraph. Pattern recognition letters, 19(3-4):255–259, 1998.
227
+
228
+ Ning Cao, Zhenyu Yang, Cong Wang, Kui Ren, and Wenjing Lou. Privacy-preserving query over encrypted graph-structured data in cloud computing. In 2011 31st International Conference on Distributed Computing Systems, pp. 393–402. IEEE, 2011.
229
+
230
+ Derek Gordon Corneil and Calvin C Gotlieb. An efficient algorithm for graph isomorphism. Journal of the ACM (JACM), 17(1):51–64, 1970.
231
+
232
+ Surnjani Djoko, Diane J. Cook, and Lawrence B. Holder. An empirical study of domain knowledge and its benefits to substructure discovery. TKDE, 9(4):575–586, 1997.
233
+
234
+ Hans-Christian Ehrlich and Matthias Rarey. Maximum common subgraph isomorphism algorithms and their applications in molecular science: a review. Wiley Interdisciplinary Reviews: Computational Molecular Science, 1(1):68–79, 2011.
235
+
236
+ Matthias Fey and Jan E. Lenssen. Fast graph representation learning with PyTorch Geometric. In ICLR Workshop on Representation Learning on Graphs and Manifolds, 2019.
237
+
238
+ Abner Guzman-Rivera, Dhruv Batra, and Pushmeet Kohli. Multiple choice learning: Learning to produce multiple structured outputs. In NeurIPS, pp. 1799–1807, 2012.
239
+
240
+ Mark Heimann, Haoming Shen, Tara Safavi, and Danai Koutra. Regal: Representation learningbased graph alignment. In CIKM, pp. 117–126. ACM, 2018.
241
+
242
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. ICLR, 2015.
243
+
244
+ Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. ICLR, 2016.
245
+
246
+ Philip A Knight. The sinkhorn–knopp algorithm: convergence and applications. SIAM Journal on Matrix Analysis and Applications, 30(1):261–275, 2008.
247
+
248
+ Harold W Kuhn. The hungarian method for the assignment problem. Naval research logistics quarterly, 2(1-2):83–97, 1955.
249
+
250
+ Der-Tsai Lee and Bruce J Schachter. Two algorithms for constructing a delaunay triangulation. International Journal of Computer & Information Sciences, 9(3):219–242, 1980.
251
+
252
+ Giorgio Levi. A note on the derivation of maximal common subgraphs of two directed or undirected graphs. Calcolo, 9(4):341, 1973.
253
+
254
+ Wenchao Li, Zach Wasson, and Sanjit A Seshia. Reverse engineering circuits using behavioral pattern mining. In 2012 IEEE international symposium on hardware-oriented security and trust, pp. 83–88. IEEE, 2012.
255
+
256
+ Yujia Li, Chenjie Gu, Thomas Dullien, Oriol Vinyals, and Pushmeet Kohli. Graph matching networks for learning the similarity of graph structured objects. ICML, 2019.
257
+
258
+ Zhuwen Li, Qifeng Chen, and Vladlen Koltun. Combinatorial optimization with graph convolutional networks and guided tree search. In NeurIPS, pp. 539–548, 2018.
259
+
260
+ Yongjiang Liang and Peixiang Zhao. Similarity search in graph databases: A multi-layered indexing approach. In ICDE, pp. 783–794. IEEE, 2017.
261
+
262
+ Yan-li Liu, Chu-min Li, Hua Jiang, and Kun He. A learning based branch and bound for maximum common subgraph problems. IJCAI, 2019.
263
+
264
+ Ciaran McCreesh, Samba Ndojh Ndiaye, Patrick Prosser, and Christine Solnon. Clique and constraint models for maximum common (connected) subgraph problems. In International Conference on Principles and Practice of Constraint Programming, pp. 350–368. Springer, 2016.
265
+
266
+ Ciaran McCreesh, Patrick Prosser, and James Trimble. A partitioning algorithm for maximum common subgraph problems. 2017.
267
+
268
+ Younghee Park, Douglas S Reeves, and Mark Stamp. Deriving common malware behavior through graph clustering. Computers & Security, 39:419–430, 2013.
269
+
270
+ Nino Shervashidze, Pascal Schweitzer, Erik Jan van Leeuwen, Kurt Mehlhorn, and Karsten M Borgwardt. Weisfeiler-lehman graph kernels. JMLR, 12(Sep):2539–2561, 2011.
271
+
272
+ Christine Solnon, Guillaume Damiand, Colin De La Higuera, and Jean-Christophe Janodet. On the complexity of submap isomorphism and maximum common submap problems. Pattern Recognition, 48(2):302–316, 2015.
273
+
274
+ Edward H Sussenguth. A graph-theoretic algorithm for matching chemical structures. Journal of Chemical Documentation, 5(1):36–43, 1965.
275
+
276
+ Petar Velickovic, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua Bengio. Graph attention networks. ICLR, 2018.
277
+
278
+ Philippe Vismara and Benoˆıt Valery. Finding maximum common connected subgraphs using clique detection or constraint satisfaction algorithms. In International Conference on Modelling, Computation and Optimization in Information Systems and Management Sciences, pp. 358–368. Springer, 2008.
279
+
280
+ Runzhong Wang, Junchi Yan, and Xiaokang Yang. Learning combinatorial embedding networks for deep graph matching. ICCV, 2019a.
281
+
282
+ Xiaoli Wang, Xiaofeng Ding, Anthony KH Tung, Shanshan Ying, and Hai Jin. An efficient graph indexing method. In ICDE, pp. 210–221. IEEE, 2012.
283
+
284
+ Yue Wang and Justin M Solomon. Deep closest point: Learning representations for point cloud registration. ICCV, 2019.
285
+
286
+ Yue Wang, Yongbin Sun, Ziwei Liu, Sanjay E Sarma, Michael M Bronstein, and Justin M Solomon. Dynamic graph cnn for learning on point clouds. ACM Transactions on Graphics (TOG), 38(5): 146, 2019b.
287
+
288
+ Hongteng Xu, Dixin Luo, Hongyuan Zha, and Lawrence Carin. Gromov-wasserstein learning for graph matching and node embedding. ICML, 2019.
289
+
290
+ Xifeng Yan, Philip S Yu, and Jiawei Han. Substructure similarity search in graph databases. In SIGMOD, pp. 766–777. ACM, 2005.
291
+
292
+ Pinar Yanardag and SVN Vishwanathan. Deep graph kernels. In SIGKDD, pp. 1365–1374. ACM, 2015.
293
+
294
+ Tianshu Yu, Junchi Yan, Yilin Wang, Wei Liu, et al. Generalizing graph matching beyond quadratic assignment model. In NeurIPS, pp. 853–863, 2018.
295
+
296
+ Andrei Zanfir and Cristian Sminchisescu. Deep learning of graph matching. In CVPR, pp. 2684– 2693, 2018.
297
+
298
+ Zhiping Zeng, Anthony KH Tung, Jianyong Wang, Jianhua Feng, and Lizhu Zhou. Comparing stars: On approximating graph edit distance. PVLDB, 2(1):25–36, 2009.
299
+
300
+ Xinyi Zhang and Lihui Chen. Capsule graph neural network. ICLR, 2019.
301
+
302
+ Xiang Zhao, Chuan Xiao, Xuemin Lin, Qing Liu, and Wenjie Zhang. A partition-based approach to structure similarity search. PVLDB, 7(3):169–180, 2013.
303
+
304
+ Weiguo Zheng, Lei Zou, Xiang Lian, Dong Wang, and Dongyan Zhao. Graph similarity search with edit distance constraint in large graph databases. In CIKM, pp. 1595–1600. ACM, 2013.
305
+
306
+ Feng Zhou and Fernando De la Torre. Factorized graph matching. In CVPR, pp. 127–134. IEEE, 2012.
307
+
308
+ # A DATASET DESCRIPTION
309
+
310
+ We run experiments on 4 diverse different real world datasets coming from the chemical, programming language, and social network domains. For each dataset, we split the pairs into training, validation, and testing sets in the ratio of 6:2:2 such that none of the training, validation, or testing sets share any common graphs. For each dataset, we either one-hot encode node labels, if the dataset has node labels, or provide the same initial encoding, if the dataset does not have node labels. The code and the datasets have been published to this anonymous link: https://github.com/openpublicforpapers/NeuralMCS.
311
+
312
+ # A.1 AIDS
313
+
314
+ AIDS is a dataset of antivirus screen chemical compounds, coming from the Developmental Therapeutics Program at $\mathrm { N C I } / \mathrm { N I H } ^ { 2 }$ . The AIDS dataset has been used by various works in graph matching (Zeng et al., 2009; Wang et al., 2012; Zheng et al., 2013; Zhao et al., 2013; Liang & Zhao, 2017; Bai et al., 2019a). These graphs consist of labeled nodes and unlabeled edges, where nodes represent chemical elements (ex. Carbon, Nitrogen, Chlorine, and etc.) and edges represent bonds between atoms. There are a total of 700 graphs, from which we sample 29610 graph pairs. The average graph size is 8.664 with the largest graph having 10 nodes.
315
+
316
+ # A.2 LINUX
317
+
318
+ LINUX is a dataset of program dependence graphs (PDG) describing individual functions generated from the Linux kernel (Wang et al., 2012). These graphs consist of unlabeled nodes and unlabeled edges, where nodes represent statements and edges represent control flow between statements. There are a total of 1000 graphs, from which we sample 60114 graph pairs. The average graph size is 7.591 and the largest graphs have 10 nodes.
319
+
320
+ # A.3 IMDB
321
+
322
+ IMDB is a dataset of ego-networks of movie actors/actresses from the IMDB website (Yanardag & Vishwanathan, 2015). This dataset has been used by various works in graph classification (Zhang & Chen, 2019; Bai et al., 2019b). These graphs consist of unlabeled nodes and unlabeled edges, where nodes represent actors/actresses and edges represent whether they have had collaborations. There are a total of 1500 graphs, from which we sample 135702 graph pairs. The average graph size is 12.981 and the largest graphs have 89 nodes.
323
+
324
+ # A.4 REDDIT
325
+
326
+ REDDIT is a dataset of online dicussion networks from the Reddit online discussion website (Yanardag & Vishwanathan, 2015). These graphs consist of unlabeled nodes and unlabeled edges, where nodes represent users and edges represent whether users have responded to eachother’s comments. There are a total of 7112 graphs, from which we sample 3556 pairs. The average graph size is 11.8 nodes and the largest graph has 16 nodes.
327
+
328
+ # B BASELINES
329
+
330
+ We evaluate NEURALMCS against the state-of-the-art solver, MCSPLIT, which uses heuristics and the branch and bound algorithm to achieve efficient computation for MCS. While the fastest among exact solvers, this method still has, in the worst case, exponential time complexity (McCreesh et al., 2017). For this reason, in practice, its running time is much slower than the other approximate baselines. However, we still use MCSPLIT to generate ground-truth MCS results and it only takes a few days on a standard CPU server with multi-threading to handle all the ground-truth result generation.
331
+
332
+ The representation learning baselines are adapted from recent graph matching techniques, specifically IMAGE-GMN (Zanfir & Sminchisescu, 2018) and IMAGE-PCA (Permutation Loss and Crossgraph Affinity) (Wang et al., 2019a). Both these methods utilize similarity scores and normalization to perform graph matching. As IMAGE-GMN uses CNN layers to form their node embeddings from images (with techniques such as Delaunay triangulation (Lee & Schachter, 1980)), we adapt the model to our task by replacing these layers with 3 GAT layers, consistent with NEURALMCS. IMAGE-PCA uses a node embedding mechanism similar to GMN, not requiring further adaptation. As the loss functions for both these methods were designed for image graphs, we alter their loss functions to binary cross entropy loss (the same as NEURALMCS).
333
+
334
+ We conduct the extraction process by first removing all nodes where its corresponding summation of similarity scores across rows or columns falls below a tuneable threshold (the values of which can be found in Appendix C) in the matching matrix, then selecting an equal number of nodes in both graphs. The latter is done by maximizing the similarity scores of uniquely selected node pairs through applying the Hungarian Algorithm (Kuhn, 1955) on the remaining nodes of the matching matrix. This is because the extracted subgraphs, after just thresholding, may be of different sizes due to thresholding. The extra procedure ensures that we extract subgraphs of equal sizes and in addition, the Hungarian Algorithm yields one-to-one node-node correspondences for the extracted subgraphs. However, these methods do not necessarily result in isomorphic subgraphs.
335
+
336
+ We also compare against two basic models, BASIC-GAT (Velickovic et al., 2018) and BASICGMN (Li et al., 2019), which use 3 GAT and GMN layers respectively to encode the initial node features, followed by similarity score computation. These baselines uses a simpler normalization scheme by appling element-wise sigmoid function $( y = 1 / ( 1 + e ^ { - x } ) )$ to the matching matrix, and directly feed the similarity matrix to the same loss function as defined by NEURALMCS. BASICGAT and BASIC-GMN use the same extraction method as the graph matching baselines.
337
+
338
+ With exception to MCSPLIT, all these baselines run in polynomial time complexity with respect to the number of nodes in the two input graphs.
339
+
340
+ # C PARAMETER SETTINGS
341
+
342
+ For our model, we utilize 3 layers of GMN with 64 dimensions each for the initial embedding. We use ${ \mathrm { R e L U } } ( x ) = { \mathrm { m a x } } ( 0 , x )$ as our activation function. We fix the number of outputs for multiple choice learning to 10 on the AIDS, LINUX, and REDDIT datasets, and to 3 on the IMDB dataset. To evaluate the efficacy of multiple choice learning, we also use the same technique and settings for BASIC-GAT and BASIC-GMN. We set $\epsilon$ to $1 0 ^ { - 4 }$ , to account for numerical errors during floating point arithmetic. For the extraction procedure in our baselines, we set the threshold to 0.5 on the AIDS, LINUX, and REDDIT datasets, and to 0.7 on the IMDB dataset. We ran all experiments with Intel i7-6800K CPU and one Nvidia Titan GPU. For training, we set the batch size to 64, the learning rate to 0.001, the number of iterations to 5000, and use the Adam optimizer (Kingma & Ba,
343
+
344
+ 2015). All experiments were implemented with the PyTorch and PyTorch Geometric libraries (Fey & Lenssen, 2019).
345
+
346
+ For more on dataset setup and training/validation/testing splits, please refer to Appendix A. For more on baseline setups, including their extraction procedure, please refer to Appendix B. For more on the extraction procedure of NEURALMCS, please refer to the main text.
347
+
348
+ # D DETAILS ON EVALUATION PROCEDURE
349
+
350
+ As mentioned in Section 4.1, for a graph pair $i$ in the test set, we first check whether the predicted MCS satisfies the MCS constraints or not. In this section we give more details.
351
+
352
+ Denote the extracted subgraphs from the $i$ -th graph pair as $S _ { i 1 }$ and $S _ { i 2 }$ , respectively. The MCS constraint satisfaction check includes the following steps: First, we check if $S _ { i 1 }$ and $S _ { i 2 }$ are both connected (i.e. no isolated components); Second, we check if $S _ { i 1 }$ and $S _ { i 2 }$ are isomorphic to each other. Since exact isomorphism checking may take a long time in practice, we set a timeout for exact isomorphism checking, and when timeout happens, we switch to an approximate checker3. The timeout as well as the whole procedure is applied across all the methods to ensure fair comparison.
353
+
354
+ When we generate $S _ { i 1 }$ and $S _ { i 2 }$ for NEURALMCS in the first place, we would take the induced subgraph, satisfying the inductivity constraint mentioned in Section 2.1. Specifically, we use the output assignment matrix $\mathbf { T }$ and check if a node has a 1 in its corresponding row (for $\mathcal { G } _ { 1 }$ ) or column (for $\mathcal { G } _ { 2 }$ ) in $_ { \mathbf { T } }$ to decide whether it is selected in the predicted MCS.
355
+
356
+ Notice that by checking the size of the extracted subgraphs against the ground-truth MCS size (Equation 7 and 8), we allow equal-sized MCS results to be evaluated correctly, since for many graph pairs there are more than one correct MCS result.
357
+
358
+ Here we give more insights behind the two metrics. The intuition behind the hard metric is that we only check whether the the extracted subgraphs are strictly equal to the size of the true MCS or not. However, this is too strict and does not reveal too much information about the model performance when the extracted subgraphs are not the same size as the true MCS. An easy measure would be to directly report on the predicted MCS size, but this does not take into account non-isomorphic subgraphs. The soft metric accounts for both these issues by checking the fraction of the predicted MCS size over the true MCS size only for isomorphic subgraphs. Notice that if the predicted MCS is even larger than the true MCS, the $C ( \cdot , \cdot )$ function will return 0 because it is not possible for the subgrpahs to be both larger than the true MCS (generated by the exact solver MCSPLIT) and isomorphic.
359
+
360
+ # E RESULT ANALYSIS
361
+
362
+ In addition to Exact $\%$ and Soft $\%$ metrics, we may also evaluate our model on the percentage of extracted subgraphs which are isomorphic $( \mathrm { I s o } \%$ ).
363
+
364
+ Following the same notation used to define Exact $\%$ and Soft $\%$ , we define Iso $\%$ as follows:
365
+
366
+ $$
367
+ \mathrm { I s o ~ \% } = { \frac { \sum _ { i } ^ { N } C ( S _ { i 1 } , S _ { i 2 } ) } { N } }
368
+ $$
369
+
370
+ As seen in Table 2, NEURALMCS explicitly encodes the isomorphism constraint into the stopping condition. This is one reason why NEURALMCS is able to achieve high accuracy, especially in Soft $\%$ in Table 1. Notice, our method does not guarantee exclusion of false-positives (predicting isomorphic when not isomorphic), as it is possible for 2 differently structured graphs, with different node embeddings, to have the same subgraph embedding once all the node embeddings are aggregated. Because these situations are relatively rare (both graphs would need to have the same subgraph embedding to floating point precision), NEURALMCS is extract isomorphic subgraphs $100 \%$ of the time on the provided datasets. Our model does guarantee exclusion of false-negatives, as, if two graphs are isomorphic, our embedding propagation methodology must produce the same subgraph embeddings.
371
+
372
+ Table 2: Iso $\%$ accuracy metric across four real graph datasets. All methods have been adapted for the MCS detection task. Dataset descriptions and details can be found in Appendix A.
373
+
374
+ <table><tr><td>Method</td><td>AIDS</td><td>LINUX</td><td>IMDB</td><td>REDDIT</td></tr><tr><td>McSPLIT *</td><td>100.000</td><td>100.000</td><td>100.000</td><td>100.000</td></tr><tr><td>IMAGE-GMN</td><td>0.033</td><td>19.790</td><td>N/A</td><td>20.261</td></tr><tr><td>IMAGE-PCA</td><td>0.229</td><td>22.693</td><td>38.582</td><td>33.987</td></tr><tr><td>BASIC-GAT</td><td>80.039</td><td>82.269</td><td>99.365</td><td>73.856</td></tr><tr><td>BASIC-GMN</td><td>91.183</td><td>97.230</td><td>96.924</td><td>95.425</td></tr><tr><td>NEURALMCS</td><td>100.000</td><td>100.000</td><td>100.000</td><td>100.000</td></tr></table>
375
+
376
+ # F ABLATION STUDY
377
+
378
+ We first form a matching matrix then extract a subgraph guided by this matrix. To form the matching matrix, we utilize representation learning to make node embeddings; compute $\boldsymbol { X }$ using similarity scores from node embeddings (Section 3.1); compute $\mathbf { Y }$ through normalization of $\boldsymbol { X }$ (Section 3.1). To perform extraction, we utilize the GUIDED SUBGRAPH EXTRACTION method proposed (Section 3.3).
379
+
380
+ We perform more in-depth ablation studies to show the importance of each component whose results are shown in Table 3.
381
+
382
+ Table 3: Abaltion study results on AIDS. The numbers are the “Exact $\%$ ” defined in Section 4.1.
383
+
384
+ <table><tr><td rowspan="2">Matching Matrix Computation</td><td colspan="3">Subgraph Extraction Strategy</td></tr><tr><td>GSE</td><td>Threshold</td><td>Threshold +LSAP</td></tr><tr><td>GMN+ Our Normalization</td><td>98.525 (NEURALMCS)</td><td>25.795</td><td>17.076</td></tr><tr><td>GAT+ Our Normalization</td><td>98.525</td><td>26.057</td><td>17.339</td></tr><tr><td>DGCNN+ Our Normalization</td><td>96.657</td><td>22.091</td><td>13.045</td></tr><tr><td>GMN + Sigmoid</td><td>97.083</td><td>10.521</td><td>12.488 (BASIC-GMN)</td></tr><tr><td>GMN + Sinkhorn Softmax</td><td>60.439</td><td>12.488</td><td>0.197</td></tr></table>
385
+
386
+ # F.1 ON THE IMPORTANCE OF GMN
387
+
388
+ GAT $^ +$ Our Normalization and DGCNN $^ +$ Our Normalization use GAT (Velickovic et al., 2018) and DGCNN (Wang et al., 2019b) used in Wang & Solomon (2019) respectively to perform node embeddings. Interestingly, when fed into our proposed GSE step, their exactly solved percentages are quite close to GMN, which is close to perfectly detecting the MCSs for all the testing pairs. Even with simpler thresholding based subgraph extraction strategies (see Section F.3 below for details), their performances are still similar to (or even better than) GMN. This seems to suggest that the choice of node embedding methods does not appear to influence the performance much when our proposed GSE strategy is used.
389
+
390
+ It should be noted that earlier we used a simpler GSE strategy which always selected the node pair with the largest matching score in $\mathbf { Y }$ in during search frontier expansion. This model did not check all the possible node pairs by sorting the node matching scores and iterate through these pairs for consideration of being selected in the MCS prediction. When tested on this simpler GSE strategy, GMN indeed performed approximately $4 . 0 \%$ better than GAT and DGCNN.
391
+
392
+ In summary, the choice of node embedding representation methods does not influence the performance too much, and very good accuracy can be obtained when the proposed normalization and GSE methods are both used.
393
+
394
+ # F.2 ON THE IMPORTANCE OF NORMALIZATION
395
+
396
+ $\mathrm { G M N } +$ Sigmoid (BASIC-GMN) uses sigmoid normalization on each individual element of the $\boldsymbol { X }$ matrix, instead of our normalization scheme (Section 3.1; Equations 1 and 2) to obtain $\mathbf { Y }$ . As sigmoid treats each node-node pair in $\mathbf { Y }$ as independent (an incorrect assumption), we see that its performance worse than our proposed normalization scheme, especially when the threshold or threshold $+ \ \mathrm { L S A P }$ strategies are used. However, similar to our findings in Section F.1, when our proposed GSE strategy is used, $\mathrm { G M N } + \mathrm { S }$ igmoid performs only slightly worse than NEURALMCS, which further confirming the usefulness of the proposed normalization scheme and the GSE method.
397
+
398
+ $\mathrm { G M N } +$ Sinkhorn Softmax uses successive row- and column-wise softmax normalization (softmax to ensure that the matching matrix $\mathbf { Y }$ is in the range (0,1)) on the $\boldsymbol { X }$ matrix (similar to the Sinkhorn algorithm (Knight, 2008) used in IMAGE-PCA for image matching4) instead of our normalization scheme. As softmax does not explicitly allow nodes to go unmatched (Section 3.1), as dictated by the MCS definition, we see that our normalization procedure performs much better.
399
+
400
+ As mention in Section 4.2, the assumptions made for image matching do not naturally transfer to and work well for the MCS detection task. In fact, with the simple element-wise sigmoid normalization on $\boldsymbol { X }$ , the performance is much better than the Sinkhorn normalization technique. The iterative rowand column-wise normalization on $\boldsymbol { X }$ is not a good choice for the task of MCS where nodes can remain unmatched with low scores in the final $\mathbf { Y }$ .
401
+
402
+ # F.3 ON THE IMPORTANCE OF GSE
403
+
404
+ For each Matching Matrix Computation method, we run 3 different subgraph extraction strategies: GSE, thresholding, and thresholding $+ \mathrm { L S A P }$ (Linear Sum Assignment Problem which we use the Hungarian algorithm (Kuhn, 1955) to solve, described in Appendix B).
405
+
406
+ For thresholding, for each of the two graphs, we select the nodes whose probabilities of being included in the MCS are greater than a tunable threshold, yielding two subgraphs. We calculate such probabilities by taking the summation of rows and columns of the matching matrix $\mathbf { Y }$ . More details can be found in Appendix B.
407
+
408
+ For thresholding $+ \mathrm { L S A P } ,$ , we ensure that the detected subgraphs are of equal size and have a one-toone node-node mapping (to validate their isomorphism) by running the Hungarian algorithm on the remaining rows and columns of $\mathbf { Y }$ after thresholding. We cannot run LSAP on the original $\mathbf { Y }$ since LSAP would select all nodes in the smaller of the two graphs.
409
+
410
+ Neither of these simpler subgraph extraction methods enforces the subgraph isomorphism constraint, which explains their worse performance compared with GSE.
411
+
412
+ We find that our major novelties (GSE and normalization technique) are the most important components in producing good performance.
413
+
414
+ # G SCALABILITY STUDY
415
+
416
+ is trained on graph pairs with ground-truth MCS results, which can be either obtained by MCSPLIT or the following way which provides cheap supervision without using any exact MCS solver. The high level idea of generating ground-truth MCS training pairs without exact MCS solver is to create such pairs with a smart design instead of computing MCS for any given pair of graphs. One possible way to create such pair is to extract an induced subgraph from a given graph, and the ground-truth MCS of the two graphs is naturally the extracted subgraph. More concretely, our experimental setup is as follows: We generate training graph pairs by first using the BarabsiAlbert model (Barabasi & ´ Albert, 1999) to generate 1000 graphs of size 32. For each generated graph, We randomly extract one connected 16-node subgraph from it. Each generated graph and extracted subgraph form one pair, giving a total of 1000 training graph pairs (our training set). Notice, this generation procedure allows us to know the MCSs during generation.
417
+
418
+ We follow a similar procedure for testing set, where we use the Barabsi-Albert model to generate 100 graphs of size 16, 32, 64, and 128 (denoted as “Test Dataset Size” in the table below). For each generated graph, we extract one connected 8-, 16-, 32-, and 64- node subgraph respectively. This gives us 5 test sets, each with 100 graph pairs.
419
+
420
+ We use the following 5 metrics for thorough evaluation:
421
+
422
+ 1. Solved $\%$ : It measures the percentage of pairs that the model can successfully finish within 100 seconds.
423
+ 2. Soft $\%$ : It measures the fraction of the predicted MCS size over the true MCS size for the isomorphic extracted subgraphs (Appendix D).
424
+ 3. Iso $\%$ : Among the pairs that can be solved within the time budget, it measures the percentage of pairs whose extracted subgraphs are isomorphic. This is an important metric because subgraph isomorphism is a key constraint required by the definition of MCS.
425
+ 4. Dev in $\#$ nodes: among the pairs that can be solved within the time budget, it measures the average deviation of the number of nodes in the predicted MCS versus the number of nodes in the true MCS. The range of this metric is $[ 0 , N ]$ where $\mathbf { N }$ is the number of nodes of the largest graph in a dataset. This metric gives a more intuitive understanding of the performance of a model compared to “Soft $\%$ ” since it reports the number of nodes directly.
426
+ 5. (Average) Runtime (msec): It measures the average running time per testing pairs that the model solves within the time budget. In other words, if a model fails at solving a pair within the time budget, the runtime will NOT be taken into account by this metric for fair comparison
427
+
428
+ We set the time budget to 100 seconds and 500 seconds for MCSPLIT respectively, and the results are shown in Table 4.
429
+
430
+ Table 4: Scalability study results on AIDS.
431
+
432
+ <table><tr><td>Test Dataset size</td><td>Metrics</td><td>MCSPLIT (100s)</td><td>MCSPLIT (500s)</td><td>McSPLIT</td></tr><tr><td rowspan="5">16</td><td>Solved %</td><td>100.000</td><td>100.000</td><td>100.000</td></tr><tr><td>Soft %</td><td>100.000</td><td>100.000</td><td>99.625</td></tr><tr><td>Iso %</td><td>100.000</td><td>100.000</td><td>100.000</td></tr><tr><td>Dev in # nodes</td><td>0</td><td>0</td><td>0.030</td></tr><tr><td>Runtime (msec)</td><td>295.576</td><td>236.502</td><td>550.688</td></tr><tr><td rowspan="5">32</td><td>Solved %</td><td>100.000</td><td>100.000</td><td>100.000</td></tr><tr><td>Soft %</td><td>100.000</td><td>100.000</td><td>99.563</td></tr><tr><td>Iso %</td><td>100.000</td><td>100.000</td><td>100.000</td></tr><tr><td>Dev in # nodes</td><td>0</td><td>0</td><td>0.070</td></tr><tr><td>Runtime (msec)</td><td>333.793</td><td>340.310</td><td>787.901</td></tr><tr><td rowspan="5">64</td><td>Solved %</td><td>61.000</td><td>62.000</td><td>100.000</td></tr><tr><td>Soft %</td><td>61.000</td><td>62.000</td><td>98.843</td></tr><tr><td>Iso %</td><td>100.000</td><td>100.000</td><td>100.000</td></tr><tr><td>Dev in # nodes</td><td>0</td><td>0</td><td>0.370</td></tr><tr><td>Runtime (msec)</td><td>4509.056</td><td>10351.813</td><td>940.581</td></tr><tr><td rowspan="5">128</td><td>Solved %</td><td>26.000</td><td>28.000</td><td>100.000</td></tr><tr><td>Soft %</td><td>26.000</td><td>28.000</td><td>75.484</td></tr><tr><td>Iso %</td><td>100.000</td><td>100.000</td><td>100.000</td></tr><tr><td>Dev in # nodes</td><td>0</td><td>0</td><td>15.690</td></tr><tr><td>Runtime (msec)</td><td>1220.117</td><td>18809.848</td><td>1194.089</td></tr></table>
433
+
434
+ NEURALMCS achieves performance close to the exact ground truth solver in terms of accuracy, and can scale to much larger graphs which the exact solver fails, most of the time, at solving within the time budget.
435
+
436
+ For accuracy, we see that the size of MCS extracted for the model is often over $98 \%$ the true MCS size. Interestingly, for graphs of size 64, we find that the extracted subgraphs differ between our model and the true MCS only in less than one node (0.37 nodes) on average. This indicates that our proposed method (NEURALMCS) can detect MCS that the current state of the art (MCSPLIT) cannot, due to our careful design and the incorporation of learning algorithms.
437
+
438
+ For running time, our model is comparable to or slower than the ground truth detector for simpler cases (¡ 1 second) but much faster for larger graphs. This could be due to our model incurring overhead from Python implementation, while MCSPLIT is implemented in $\mathrm { C } { + } { + }$ . However, when the dataset size equals 128, MCSPLIT fails for most pairs, as the MCS problem is NP-hard, while NEURALMCS can solve all the pairs due to guaranteed time complexity (Section 3.4). Notice, there is no theoretical time complexity guarantee for MCSPLIT (exponential time complexity in the worst case (McCreesh et al., 2017)), resulting in significant average running time increase from 1220.1 msec to 18809.8 msec when only 2 additional pairs are solved by increasing the time budget from 100 seconds to 500 seconds. In fact, we observed that the actual running time of the branch-andbound algorithm MCSPLIT strongly depends on the actual graph structures varying from graph to graph.
439
+
440
+ In summary, when graphs are larger and larger, MCSPLIT quickly becomes almost unusable in practice due to an inability to yield results most of the time, while NEURALMCS still extracts highaccuracy MCSs consistently and runs much faster than MCSPLIT with guaranteed theoretical time complexity. In practice, we observe that our model can run successfully on a 12-GB GPU until 4000-node graphs when the GPU runs out of memory, in which case MCSPLIT almost surely cannot be used either.
441
+
442
+ # H DISCUSSION ON SUBGRAPH ISOMORPHISM CHECKING OF GUIDED SUBGRAPH EXTRACTION
443
+
444
+ In the proposed GUIDED SUBGRAPH EXTRACTION (GSE) strategy (Section 3.3.1), we check if the inclusion of a new node pair would result in two isomorphic subgraphs by checking if $| | \mathbf { w } _ { 1 } - \pmb { w } _ { 2 } | |$ is smaller than or equal to a threshold, which is a criteria that allows us to punish mismatched nodes more softly. While an iterative check would achieve efficiency benefits by avoiding computing the subgraph embeddings, it assumes at every step we have performed a non-ambiguous matching. For example, suppose we have 2 graphs, where in the current iteration of GSE, we have 2 fully connected 3-node subgraphs currently extracted with node-node mappings. We label the node ids of these 2 graphs as 1-2-3 and a-b-c respectively and the mappings as 1-a, 2-b, 3-c. If we select a new node 4 from $\mathcal { G } _ { 1 }$ and a new node d from $\mathcal { G } _ { 2 }$ and 4 is connected to 2 and d is connected to a, an iterative procedure would not be able to tell that the addition of node 4 and d to the MCS is valid (since 2-b is matched but NOT 2-a). Fundamentally, the structure for 1,2,3 and a,b,c are similar, so it is uncertain (and expected) that the computed node matchings would be 2-a, 1-b or 2-b, 1-a.
445
+
446
+ In contrast, our proposed checking strategy can account for the above-mentioned uncertainty by doing aggregation of node embeddings to obtain subgraph-level embeddings $w _ { 1 }$ and $w _ { 2 }$ , since this does not involve explicitly finding the node-node mappings. Instead, it checks the isomorphism in a more principled way borrowing insights from Weisfeiler-Lehman (WL) graph isomorphism test (Shervashidze et al., 2011). In WL, each node in the two graphs is represented as an aggregation of local node features, and each graph is represented as an aggregation of node labels. The algorithm stops and decides two graphs are not isomorphic when the two graph-level node label sets are different. In our model, the graph-level node label set is equivalent to ${ \pmb w } _ { 1 }$ and ${ \pmb w } _ { 2 }$ , and our GSE decides that the subgraphs are not isomorphic when the two graph-level representations are different enough.
447
+
448
+ In conclusion, our proposed checking strategy addresses the ambiguous node mapping issue which the iterative isomorphism check could not solve, and is theoretically connected to the WL algorithm for graph isomorphism test.
449
+
450
+ # I DISCUSSION ON LEARNINING CAPACITY OF GUIDED SUBGRAPH EXTRACTION
451
+
452
+ In our current model, we form a matching matrix for both training and inference, and perform our loss function on the matching matrix during training (Section 3.2), and utilize GSE (Section 3.3) guided by the matching matrix during inference to extract subgraphs. We use GMN for node embeddings (Section 2.2 and Section 3.1) and feed the matching matrix into GSE, which is fixed during the iterative GSE process. However, one potential issue is that once a node pair is selected, the extracted subgraph grows by one node causing the candidate pairs to change in the next iteration.
453
+
454
+ Ideally, node embeddings should be updated to reflect such change after each iteration. By introducing learnable components to iteratively update the node embeddings to reflect such change, we can train the GSE component using guidance from the ground-truth node mappings in the MCS, making the training stage and inference stage consistent and match each other.
455
+
456
+ To accomplish this, we propagate the node embeddings at each iteration of GSE with learnable weights to recompute the matching matrix $\mathbf { Y }$ such that the next iteration’s node embeddings will be conditionally updated based on the current extracted subgraph. To achieve it, we extend GMN to update the node embeddings for the extracted subgraph at each GSE iteration. GMN updates the node embeddings of two graphs jointly by performing intra- and inter-graph message passing. Thus, one can directly apply GMN to the extracted subgraph at each GSE iteration, and calculate the loss function at the end of GSE process (replacing the current BCE loss on the matching matrix $\mathbf { Y }$ ), achieving conditional node embeddings in the GSE step of the model.
457
+
458
+ In implementation, we make a further modification to GMN by not propagating to matched nodes in the two extracted subgraphs. This is because we want the node embeddings for the currently extracted isomorphic subgraphs to stay as consistent as possible and not be influenced by any unpicked nodes in the larger graph or any nodes from the opposing graph.
459
+
460
+ We run both modified versions (with and without further modification) of NEURALMCS on AIDS, and the performance increase is only marginal $( < 1 \%$ increase). Therefore, by forgoing this step during training and only using GSE only during testing, we can gain a free speed up in training time.
461
+
462
+ # J MORE CASE STUDY
463
+
464
+ All case study plots can be seen in Figure 5. We see that our model is able to differentiate difficult input pairs, where adding any extra nodes would break the MCS constraints. In the LINUX, IMDB, and REDDIT dataset, we see examples where the graph structures are vastly different, yet NEURALMCS is still able to correctly differentiate MCS nodes. In the AIDS dataset, we see the model is able to successfully extract subgraphs which maintain node labels. In the IMDB dataset, we see the model can handle denser and larger size graphs.
465
+
466
+ ![](images/dcc1a7d11a3d319ccde8b6d7a60b58d09f71722a5141adadf63135d03c640877.jpg)
467
+ Figure 5: Case study.
md/train/BJl_VnR9Km/BJl_VnR9Km.md ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A MODEL CORTICAL NETWORK FOR SPATIOTEMPORAL SEQUENCE LEARNING AND PREDICTION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ In this paper we developed a hierarchical network model, called Hierarchical Prediction Network (HPNet) to understand how spatiotemporal memories might be learned and encoded in a representational hierarchy for predicting future video frames. The model is inspired by the feedforward, feedback and lateral recurrent circuits in the mammalian hierarchical visual system. It assumes that spatiotemporal memories are encoded in the recurrent connections within each level and between different levels of the hierarchy. The model contains a feed-forward path that computes and encodes spatiotemporal features of successive complexity and a feedback path that projects interpretation from a higher level to the level below. Within each level, the feed-forward path and the feedback path intersect in a recurrent gated circuit that integrates their signals as well as the circuit’s internal memory states to generate a prediction of the incoming signals. The network learns by comparing the incoming signals with its prediction, updating its internal model of the world by minimizing the prediction errors at each level of the hierarchy in the style of predictive self-supervised learning. The network processes data in blocks of video frames rather than a frame-to-frame basis. This allows it to learn relationships among movement patterns, yielding state-of-the-art performance in long range video sequence predictions in benchmark datasets. We observed that hierarchical interaction in the network introduces sensitivity to memories of global movement patterns even in the population representation of the units in the earliest level. Finally, we provided neurophysiological evidence, showing that neurons in the early visual cortex of awake monkeys exhibit very similar sensitivity and behaviors. These findings suggest that predictive self-supervised learning might be an important principle for representational learning in the visual cortex.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ While the hippocampus is known to play a critical role in encoding episodic memories, the storage of these memories might ultimately rest in the sensory areas of the neocortex (McClelland & McNaughton, 1999). Indeed, a number of neurophysiological studies suggest that neurons throughout the hierarchical visual cortex, including those in the early visual areas such as V1 and V2, might be encoding memories of object images (Huang et al., 2018) and of visual sequences in cell assemblies (Yao et al., 2007; Han et al., 2008; Xu et al., 2012; Cooke & Bear, 2014; 2015). As specific priors, these memories, together with the generic statistical priors encoded in receptive fields and connectivity of neurons, serve as internal models of the world for predicting incoming visual experiences. In fact, learning to predict incoming visual signals has also been proposed as an objective that drives representation learning in a recurrent neural network in a self-supervised learning paradigm, where the discrepancy between the model’s prediction and the incoming signals can be used to train the network using backpropagation, without the need of labeled data (Elman, 1990; Mathieu et al., 2015; Villegas et al., 2017; Srivastava et al., 2015; O’Reilly et al., 2014; Lee, 2015).
12
+
13
+ In computer vision, a number of hierarchical recurrent neural network models, notably PredNet (Lotter et al., 2016) and PredRNN $^ { + + }$ (Wang et al., 2018), have been developed for video prediction with state-of-the-art performance. PredNet, in particular, was inspired by the neuroscience principle of predictive coding (Mumford, 1991; Rao & Ballard, 1999; Lee, 2015; Dijkstra et al., 2017; Friston, 2018). It learns a LSTM (long short-term memory) model at each level to predict the prediction errors made in an earlier level of the hierarchical visual system. Because the error representations are sparse, the computation of PredNet is very efficient. However, the model builds a hierarchical representation to model and predict its own errors, rather than learning a hierarchy of features of successive complexities and scales to model the world. The lack of a compositional feature hierarchy hampers its ability in long range video predictions.
14
+
15
+ Here, we proposed an alternative hierarchical network architecture. The proposed model, HPNet (Hierarchical Prediction Network), contains a fast feedforward path, instantiated currently by a fast deep convolutional neural network (DCNN) that learns a representational hierarchy of features of successive complexity, and a feedback path that brings a higher order interpretation to influence the computation a level below. The two paths intersect at each level through a gated recurrent circuit to generate a hypothetical interpretation of the current state of the world and make a prediction to explain the bottom-up input. The gated recurrent circuit, currently implemented in the form of LSTM, performs this prediction by integrating top-down, bottom-up, and horizontal information. The discrepancy between this prediction and the bottom-up input at each level is called prediction error, which is fed back to influence the interpretation of the gated recurrent circuits at the same level as well as the level above.
16
+
17
+ To facilitate the learning of relationships between movement patterns, HPNet processes data in the unit of a spatiotemporal block that is composed of a sequence of video frames, rather than frame by frame, as in PredNet and $\mathrm { P r e d R N N + + }$ . We used a 3D convolutional LSTM at each level of the hierarchy to process these spatiotemporal blocks of signals (Choy et al., 2016), which is a key factor underlying HPNet’s better performance in long range video prediction.
18
+
19
+ In the paper, we will first demonstrate HPNet’s effectiveness in predictive learning and its competency in long range video prediction. Then we will provide neurophysiological evidence showing that neurons in the early visual cortex of the primate visual system exhibit the same sensitivity to memories of global movement patterns as units in the lowest modules of HPNet. Our results suggest that predictive self-supervised learning might indeed be an important strategy for representation learning in the visual cortex, and that HPNet is a viable computational model for understanding the computation in the visual cortical circuits.
20
+
21
+ # 2 RELATED WORKS
22
+
23
+ Our objective is to develop a hierarchical cortical model for predictive learning of spatiotemporal memories that is competitive both for video prediction, and for understanding the learning principles and the computational mechanisms of the hierarchical visual system. In this regard, our model is similar conceptually to Ullman’s counter-stream model (Ullman, 1995), Mumford’s analysis by synthesis framework (Mumford, 1992), and Hawkin’s hierarchical spatiotemporal memory model (HTM) (Hawkins & George, 2006) for hierarchical cortical processing. At a conceptual level, it can also be considered as a deep learning implementation of hierarchical Bayesian inference model of the visual cortex (Lee & Mumford, 2003; Dayan et al., 1995; Kersten & Yuille, 2003).
24
+
25
+ HPNet integrates ideas of predictive coding (Mumford, 1992; Rao & Ballard, 1999; Lotter et al., 2016) and associative coding (McClelland & Rumelhart, 1985; Grossberg, 1987). It differs from the predictive coding models (Rao & Ballard, 1999; Lotter et al., 2016) in that it learns a hierarchy of feature representations in the feedforward path to model features in the world as in normal deep convolutional neural networks (DCNN). PredNet, on the other hand, builds a hierarchy to model successive prediction errors of its own prediction of the world. PredNet is efficient because its convolution is operated on sparse prediction error codes, but we believe lacking a hierarchical feature representation limits its ability to model relationships among more global and abstract movement concepts for longer range video prediction. We believe having a fast bottom-up hierarchy of spatiotemporal features of successive scale and abstraction will allow the system to see further into the future and make better prediction.
26
+
27
+ A key difference between the genre of predictive learning models (HPNet, PredNet) and the earlier predictive coding models implemented by Kalman filters (Rao & Ballard, 1999) or associative coding models implemented by interactive activation (McClelland & Rumelhart, 1985; Grossberg, 1987) is that the synthesis of expectation is not done simply by the feedback path, via weight matrix multiplication, but by local gated recurrent circuits at each level. This key feature makes this genre of predictive learning models more powerful and competent in solving real computer vision problems.
28
+
29
+ The idea of predictive learning, using incoming video frames as self-supervising teaching labels to train recurrent networks, can be traced back to Elman (1990). Recently, there has been active exploration of self-supervised learning in computer vision (Palm, 2012; O’Reilly et al., 2014; Goroshin et al., 2015; Srivastava et al., 2015; Patraucean et al., 2015; Vondrick et al., 2016), particularly in the area of video prediction research (Mathieu et al., 2015; Kalchbrenner et al., 2017; Tulyakov et al., 2017; Xu et al., 2018; Oh et al., 2015; Villegas et al., 2017; Lee et al., 2018; Wichers et al., 2018). The large variety of models can be roughly grouped into three categories: autoencoders, DCNN, and hierarchy of LSTMs. Some models also involve feedforward and feedback paths, where the feedback paths have been implemented by deconvolution, autoencoder networks, LSTM or adversary networks (Finn et al., 2016; Lotter et al., 2016; Wang et al., 2017; 2018). Some other models, such as variational autoencoders, allowed multiple hypotheses to be sampled (Babaeizadeh et al., 2017; Denton & Fergus, 2018).
30
+
31
+ PredRNN $^ { + + }$ (Wang et al., 2018) is the state-of-the-art hierarchical model for video prediction. It consists of a stack of LSTM, with the LSTM at one level providing feedforward input directly to the LSTM at the next level, and ultimately predicting the next video frame at its top level. Thus, its hierarchical representation is more similar to an autoencoder, with the intermediate layers modeling the most abstract and global spatiotemporal memories of movement patterns and the subsequent layers representing the unfolding of the feedback path into a feedforward network with its top-layer’s output providing the prediction of the next frame. PredR $\mathrm { N N } { + } { + }$ does not claim neural plausibility, but it offers state-of-the-art performance for benchmark performance evaluation, with documented comparisons to other approaches.
32
+
33
+ Recent single-unit recording experiments in the inferotemporal cortex (IT) of monkeys have shown that neurons responded significantly less to predictable sequences than to novel sequences (Meyer & Olson, 2011; Meyer et al., 2014; Ramachandran et al., 2017), suggesting that neural activities might signal prediction errors. The novel neurophysiolgical experiment we presented here demonstrated similar prediction suppression effects in the early visual cortex of monkeys for well-learned videos, suggesting neuronal sensitivity to memories of global movement patterns and scene context in the earliest visual areas. This is consistent with other recent studies that showed neurons in mouse V1 might be able to encode some forms of spatiotemporal memories in their recurrent circuits (Han et al., 2008; Xu et al., 2012; Cooke & Bear, 2015).
34
+
35
+ # 3 HIERARCHICAL PREDICTION NETWORK
36
+
37
+ # 3.1 CORTICAL MODULE
38
+
39
+ HPNet is composed of a stack of Cortical Modules (CM). Each CM can be considered as a visual area along the ventral stream of the primate visual system, such as V1, V2, V4 and IT. We used four Cortical Modules in our experiment. The network contains a feedforward path that is realized in a deep convolutional neural network (DCNN), a stack of Long Short Term Memory (LSTM) modules that link the feedforward path and the feedback path together.
40
+
41
+ Figure 1 (a) shows two CMs stacked on top of each other. The feedforward path performs convolution (indicated by $\star$ ) on the input spatiotemporal block $I _ { l }$ with a kernel to produce $R _ { l }$ , where $l$ indicates CM level. $R _ { l }$ is then down-sampled to provide the input $I _ { l + 1 }$ for $\mathrm { C M } _ { l + 1 }$ for another round of convolution in the feedforward path. $I _ { l + 1 }$ also goes into $\mathrm { L S T M } _ { l + 1 }$ (Lhe STM in $\mathrm { C M t } _ { l + 1 }$ ). In each $\mathrm { C M } _ { l }$ level, the bottom-up input $I _ { l }$ is compared with the prediction $P _ { l }$ generated from the interpretation output $H _ { l }$ of $\mathrm { L S T M } _ { l }$ . The prediction error signal is transformed by a convolution into $E _ { l }$ , which is fed back to both $\mathrm { L S T M } _ { l }$ and $\mathrm { L S T M } _ { l + 1 }$ to influence their generation of new hypotheses $H _ { l }$ and $H _ { l + 1 }$ . To make the timing relationship between the different interacting variables more explicit, we now use $k$ to indicate time step or, equivalently, the video input frame. $\mathrm { L S T M } _ { l }$ at step $k$ integrates the bottom-up feature input $\mathrm { \bar { \cal R } } _ { l - 1 } ^ { k }$ , the top-down feedback of the higher CM’s LSTM’s output $H _ { l + 1 } ^ { k }$ , and the prediction errors $E _ { l - 1 } ^ { k }$ and $E _ { l } ^ { k - d }$ to generate new hypothesis output $H _ { l } ^ { k }$ , which is then transformed into a new prediction $P _ { l } ^ { k }$ , where $d$ is is the number of frames in each spatiotemporal block (details in Algorithm 1).
42
+
43
+ ![](images/78e52f715bdc1ed4b827d548f5e47231932ee1d6559ad5caa4aa98e07d11ffe8.jpg)
44
+ Figure 1: (a) Two Cortical Modules stacked on top of each other. The input $I _ { 1 }$ would be the spatiotemporal block of video frames. The $\star$ notation means a convolution along that path. $2 \uparrow$ indicates up-sampling or expansion operation. $2 \downarrow$ means down-sample or reduction in resolution. $\odot$ indicates comparator or subtraction operation; (b) The DCNN analysis path is actually implemented in a sparsified convolution scheme to speed up bottom-up processing; (c) Detailed structure of the LSTM used. $C _ { t }$ is the internal state, and $H _ { t }$ is the output. X is external input, which includes multiple sources in our model. (d) Frame-by-frame method; (e) Block-by-frame method; and (f) Block-by-block method, where left and right part indicates output and input with the middle indicating 2D or 3D convolution LSTM.
45
+
46
+ # 3.2 SPARSE CONVOLUTION
47
+
48
+ The feedforward DCNN path in Figure 1 (a) runs much faster if the input to each convolution layer is made sparse, as shown in Pan et al. (2018). In video processing, a scheme has been proposed by Liu et al. (2017); Dave et al. (2017); Pan et al. (2018) to sparsify the input of a convolution layer by performing convolution on the difference $\Delta I _ { l } ^ { k } = I _ { l } ^ { k } - I _ { l } ^ { k - 1 }$ between two consecutive frames, where $k$ indicates the $\mathbf { k }$ -th frame. The resulting $\Delta R _ { l } ^ { k }$ is added back to the representation of the last time frame $R _ { l } ^ { k - 1 }$ to recover the representation at the current frame $R _ { l } ^ { k }$ . This allows the network to maintain a full higher order representation $R$ at all times in the next layer while enjoying the benefit of fast computation on sparse input. In their scheme (Pan et al., 2018), the first frame $I ^ { k = 0 }$ was convolved with a set of dense convolution kernels and then the subsequent frames were convolved with a set of sparse convolution kernels. For parsimony and neural plausibility, we used the same set of sparse kernels for processing both the first full frame and the subsequent temporal-difference frames, at the expense of incurring some inaccuracy in our prediction of the first few frames.
49
+
50
+ # 3.3 SPATIOTEMPORAL BLOCKS AND 3D CONVOLUTION
51
+
52
+ The input data of our network model is a sequence of video frames or a spatiotemporal block. For our implementation, each block contains 5 video frames. If we consider that each frame corresponds roughly to $2 5 ~ \mathrm { m s }$ , this would translate into $1 2 5 ~ \mathrm { m s }$ , in the range of the length of temporal kernel of a cortical neuron. Our convolution kernel is in three dimension, processing the video by spatiotemporal blocks. The block could slide in time with a temporal stride of one frame or a stride as large as the length of the block $d$ . The LSTM is a 3D convolutional LSTM (Choy et al., 2016) because of 3D convolution and spatiotemporal blocks. Convolution LSTM (Shi et al., 2015), in which Hadamard product in LSTM is replaced by a convolution, has greatly improved the performance of LSTM in many applications. Earlier video prediction models (e.g. PredNet, PredRNN) processed video sequences frame by frame, as shown in Figure 1 (d). We experimented with different data units and approaches. In the Frame-to-Frame (F-F) approach, an input frame is used to generate one predicted future frame (Figure 1 (d)). In the Block-to-Frame (B-F) approach (Figure 1 (e)), a block of input frames is used to generate one predicted future frame. This approach is time consuming, but provides more accurate near-range predictions. For longer-range predictions, we found using a spatiotemporal block to predict a spatiotemporal block, i.e. the Block-to-Block (B-B) approach ( Figure 1(f)), to be the most effective, because the LSTM learns the relationship between movement segments in the sequences. The details of our algorithm of the 3D convolutional LSTM is specified in Appendix A.
53
+
54
+ # 3.4 TRAINING AND LOSS FUNCTION
55
+
56
+ The entire network is trained by minimizing a loss function which is the weighted sum of all the prediction errors, with the following algorithm,
57
+
58
+ $$
59
+ \begin{array} { r l } { I _ { l } ^ { k } = \left\{ \begin{array} { l l } { M a x P o o l ( R e L U ( R _ { l - 1 } ^ { k } ) ) } & { l > 1 } \\ { x _ { t } } & { l = 1 } \end{array} \right. P _ { l } ^ { k } = \left\{ \begin{array} { l l } { R e L U ( c o n v ( H _ { l } ^ { k } ) ) } & { l > 1 } \\ { S A T L ( R e L U ( c o n v ( H _ { l } ^ { k } ) ) ) } & { l = 1 } \end{array} \right. } \\ { \Delta I _ { l } ^ { k } = I _ { l } ^ { k } - I _ { l } ^ { k - d } , } & { \Delta E _ { l } ^ { k } = I _ { l } ^ { k } - P _ { l } ^ { k } } \end{array}
60
+ $$
61
+
62
+ where $x _ { t }$ is the input sequence, $H _ { l } ^ { k }$ is the output of LSTM, $P _ { l } ^ { k }$ is the prediction, SATLU is a saturating non-linearity set at the maximum pixel value: $\mathrm { S A T L U } ( x ; p _ { m a x } ) { : = \operatorname* { m i n } ( p _ { m a x } , x ) }$ , spconv is sparse convolution, $\lambda _ { k }$ and $\lambda _ { l }$ are weighting factors by time and CM level, respectively, and $n _ { l }$ is the number of units in the lth CM level, and $d$ is the number of frames in each spatiotemporal block. The full algorithm is shown in Algorithm 1.
63
+
64
+ # 4 EXPERIMENTAL RESULTS
65
+
66
+ In this section, we first evaluate the performance of our model in video prediction using two benchmark datasets: (1) synthetic sequences of the Moving-MNIST database and (2) the $\mathrm { K T \check { H } ^ { 1 } }$ real world human movement database. We then investigate the representations in the model to understand how recurrent network structures have impacted on the feedforward representation. We finally compare the temporal activities of neurons in the network model with that of neurons in the visual cortex of monkeys, in video sequence learning, to evaluate the plausibility of HPNet.
67
+
68
+ Since for video prediction, PredNet is the most neurally plausible model and $\mathrm { P r e d R N N + + }$ provides state-of-the-art computer vision performance, we will compare HPNet’s performance with these two network models. Because these two models work on frame-to-frame basis, we implemented three versions of our network for comparison: (1) Frame-to-Frame (F-F), where we set our data spatiotemporal block size to one frame and used 2D convLSTM instead of 3D convLSTM to predict the next frame based on the current frame; (2) Block-to-Frame (B-F), where we used a sliding block window to predict the next frame based on the current block of frames; (3) Block-to-Block (B-B), where the next spatiotemporal block was predicted from the current spatiotemporal block (Figure 1 (d)).
69
+
70
+ We trained all five networks using 40-frame sequences extracted from the two databases in the same way as described in (Lotter et al., 2016; Wang et al., 2018). We then compared their performance in predicting the next 20 frames when only the first 20 frames were given. The test sequences were drawn from the same dataset but not in the training set. The common practice in PreNet and $\mathrm { P r e d R N N + + }$ for predicting future frames when input is no longer available is to make the prediction of the last time step the next input and use that to generate prediction of the next time step. All models tested have four modules (layers). All three versions of our model and PredNet used the same number of feature channels in each layer, optimized by grid search, i.e. (16,32,64,128) for the Moving-MNIST dataset, and (24,48,96,192) for the KTH dataset. For PredRNN $^ { + + }$ , we used
71
+
72
+ # Algorithm 1 The algorithm of our model
73
+
74
+ Input: $I _ { 1 } ^ { k } \gets x _ { t }$
75
+ 1: for $t = 1$ to $T$ do
76
+ 2: for $l = L$ to 1 do . Top-down procedure
77
+ 3: if $l = L$ then
78
+ 4: $H _ { l } ^ { k } = 3 D c o n v L S T M ( H _ { l } ^ { k - d } , E _ { l } ^ { k - d } , M a x P o o l ( R e L U ( R _ { l - 1 } ^ { k } , E _ { l - 1 } ^ { k } ) ) )$
79
+ 5: else
80
+ 6: $H _ { l } ^ { k } = 3 D c o n v L S T M ( H _ { l } ^ { k - d } , E _ { l } ^ { k - d } , M a x P o o l ( R e L U ( R _ { l - 1 } ^ { k } , E _ { l - 1 } ^ { k } ) ) , u p s a m p l e ( H _ { l + 1 } ^ { k } ) )$
81
+ 7: end if
82
+ 8: end for
83
+ 9: for $l = 1$ to $L$ do . Bottom-up procedure
84
+ 10: if $l = 1$ then
85
+ 11: $I _ { l } ^ { k } = x _ { t } , \ P _ { l } ^ { k } = S A T L U ( R e L U ( c o n v ( H _ { l } ^ { k } ) ) )$
86
+ 12: else
87
+ 13: $I _ { l } ^ { k } = M a x P o o l ( R e L U ( R _ { l - 1 } ^ { k } ) ) , P _ { l } ^ { k } = R e L U ( c o n v ( H _ { l } ^ { k } )$
88
+ 14: end if
89
+ 15: $\overline { { \Delta I _ { l } ^ { k } } } = I _ { l } ^ { k } - I _ { l } ^ { k - d } , \Delta R _ { l } ^ { k } = s p c o n v ( \Delta I _ { l } ^ { k } ) , R _ { l } ^ { k } = R _ { l } ^ { k - d } + \Delta R _ { l } ^ { k }$
90
+ 16: ∆ E kl = I kl − P kl , $E _ { l } ^ { k } = s p c o n v ( \Delta E _ { l } ^ { k } )$
91
+ 17: end for
92
+ 18: end for
93
+
94
+ the same architecture and feature channel numbers provided by Wang et al. (2018). All kernel sizes are either $3 \times 3$ (for F-F) or $3 \times 3 \times 3$ (for B-F and B-B) for all five models. The input image frame’s spatial resolution is $6 4 \times 6 4$ .
95
+
96
+ The models were trained and tested on GeForce GTX TITAN X GPUs. We evaluated the prediction performance based on two quantitative metrics: Mean-Squared Error (MSE) and the standard Structural Similarity Index Measure (SSIM) (Wang et al., 2004) of the last 20 frames between the predicted frames and the actual frames. The values of SSIM range from -1 to 1, with a larger value indicating greater similarity between the predicted frames and the actual future frames.
97
+
98
+ # 4.1 SYNTHETIC SEQUENCE PREDICTION ON THE MOVING-MNIST DATASET
99
+
100
+ We randomly chose subsets of digits in the Moving MNIST2 dataset in which the video sequences contain two handwritten digits bouncing inside a frame of $6 4 \times 6 4$ pixels. We extracted 40-frame sequences at random starting frame position in the video in the same way as in Srivastava et al. (2015) (followed by PredNet and PredRNN $^ { + + }$ ). This extraction process is repeated 15000 times, resulting in a training set of 10000 sequences, a validation set of 2000 sequences, and a testing set of 3000 sequences.
101
+
102
+ Figure 2 and Table 1 compare the results of different models on the Moving-MNIST dataset. There are 40 frames in total and we show the results every two frames. The yellow vertical line in the middle represents the border between the first 20 and the last 20 predicted frames by various models. We can see B-F achieves better performance than B-B in short term prediction task when actual input frames are provided, but B-B outperforms B-F in the longer range prediction, reflecting learning of the relationships at the movement levels by the 3D convLSTM. B-F doing better than F-F confirmed that the spatiotemporal block data structure provides additional information for modeling movement tendency. Finally, we found that even F-F achieved better prediction results than PredNet, suggesting that a feature hierarchy might be more useful than a hierarchy of predicted errors. Finally, our B-B network outperformed the state-of-the-art PredRNN $^ { + + }$ .
103
+
104
+ # 4.2 REAL-WORLD SEQUENCE PREDICTION ON THE KTH DATASET
105
+
106
+ Schuldt et al. (2004) introduced the KTH video database which contains 2391 sequences of six ¨ human actions: walking, jogging, running, boxing, hand waving, and hand clapping, performed by 25 subjects in four different scenarios. We divided video clips across all 6 action categories into a training set of 108717 sequences (persons $\# 1 - 1 6 )$ ) and a test set of 4086 sequences (persons $\# 1 7$ -
107
+
108
+ ![](images/a72c9c51fbb7c5180ada71286fb5a2c6b87e525e6512b595f67a3f37b124be03.jpg)
109
+ Figure 2: Video prediction results on Moving-MNIST dataset, where the first row to last row are ground truth (GT), results from three different version of HPNet (block-to-block (B-B), block-toframe (B-F), frame-to-frame (F-F)), PredNet, and $\mathrm { P r e d R N N + + }$ , respectively. ${ \bf k } { = } 1$ to $\mathbf { k } { = } 1 9$ are predicted frames of the models when the input frames were available. $\mathrm { k } { = } 2 1$ to $\mathrm { k } = 3 9$ are the ”deadreckoning” predicted frames of the model when there are no input.
110
+
111
+ Table 1: Comparison Results of different methods on Moving-MNIST datatset for long time prediction experiment.
112
+
113
+ <table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>SSIM</td><td rowspan=1 colspan=1>MSE</td></tr><tr><td rowspan=1 colspan=1>Ours(B-B)</td><td rowspan=1 colspan=1>0.915</td><td rowspan=1 colspan=1>65.2</td></tr><tr><td rowspan=1 colspan=1>Ours(B-F)</td><td rowspan=1 colspan=1>0.793</td><td rowspan=1 colspan=1>73.2</td></tr><tr><td rowspan=1 colspan=1>CM+ConvLSTM (F-F)</td><td rowspan=1 colspan=1>0.692</td><td rowspan=1 colspan=1>89.5</td></tr><tr><td rowspan=1 colspan=1>PredNet (Lotter et al., 2016)</td><td rowspan=1 colspan=1>0.658</td><td rowspan=1 colspan=1>101.2</td></tr><tr><td rowspan=1 colspan=1>PredRNN++ (Wang et al., 2018)</td><td rowspan=1 colspan=1>0.872</td><td rowspan=1 colspan=1>69.4</td></tr></table>
114
+
115
+ Table 2: Comparison Results of different methods on the KTH datatset for long time prediction experiment.
116
+
117
+ <table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>SSIM</td><td rowspan=1 colspan=1>MSE</td></tr><tr><td rowspan=1 colspan=1>Ours(B-B)</td><td rowspan=1 colspan=1>0.882</td><td rowspan=1 colspan=1>80.3</td></tr><tr><td rowspan=1 colspan=1>Ours(B-F)</td><td rowspan=1 colspan=1>0.784</td><td rowspan=1 colspan=1>93.1</td></tr><tr><td rowspan=1 colspan=1>CM+ConvLSTM (F-F)</td><td rowspan=1 colspan=1>0.701</td><td rowspan=1 colspan=1>103.4</td></tr><tr><td rowspan=1 colspan=1>PredNet (Lotter et al., 2016)</td><td rowspan=1 colspan=1>0.656</td><td rowspan=1 colspan=1>108.9</td></tr><tr><td rowspan=1 colspan=1>PredRNN++ (Wang et al., 2018)</td><td rowspan=1 colspan=1>0.865</td><td rowspan=1 colspan=1>86.7</td></tr></table>
118
+
119
+ 25) as was done in Wang et al. (2018), except we extracted 40-frame sequences. We center-cropped each frame to a $1 2 0 \times 1 2 0$ square and then re-sized it to input frame size of $6 4 \times 6 4$ .
120
+
121
+ ![](images/18c628c442287f0ce09ccb8e63c6191b299b6c46c8e6eed3d1d035906c769d3e.jpg)
122
+ Figure 3: Video prediction results on the KTH dataset, where the first row to last row are ground truth (GT), results from block-to-block (B-B), block-to-frame (B-F), frame-to-frame (F-F), PredNet, and PredRNN $^ { + + }$ , respectively, same format as Figure 2.
123
+
124
+ Figure 3 and Table 2 compared the results of the different models on the KTH dataset, essentially reproducing all the observations we made based on the Moving-MINST dataset (Figure 2). BB outperformed all tested models in the long range video prediction task. Figure 4 (a) and (b) compared the video prediction performance of the different models in terms of the “dead-reckoning frames” to be predicted when only the first twenty frames were provided for the two datasets. The results show that, in both cases, B-B is far more effective than B-F in long range video prediction. Figure 4 (c) showed that the ratio of SSIM and training time peaks at a 4-module network. The SSIM of a 5-module network was about the same as that of a 4-module network but took longer time to converge. The B-F, with a sliding window of a single frame stride, took much longer to train yet still under-performed. Figure 4 (d) showed SSIM performance and training time of the different models. It shows that the B-B (sparse) version of HPNet took only $10 \%$ longer to train than PredRNN $^ { + + }$ even though it has more loops into the networks and has to process spatiotemporal blocks. Both PredR $\mathrm { N N } { + } { + }$ and HPNet require twice amount of the training time relative to PredNet, illustrating the computational efficiency of using sparse codes. Sparsifying our DCNN feedforward path reduced our B-B network’s training time by $13 \%$ (comparing B-B (sparse) versus B-B (non-sparse) in Figure 4 (d)).
125
+
126
+ ![](images/c54b32dff62dc386cd978ee7162bd2cd751997b7e83c9dd684f43c4719c5c414.jpg)
127
+ Figure 4: (a) Comparison of the prediction results of the five models for the Moving-MINST dataset on the last 20 frames in structural similarity measures (SSIM). (b) Comparison of the prediction results on the KTH datset. (c) Comparison of the performance (and training time) of the B-B and the B-F networks as a function of the number of modules in the network. (d) Training time versus SSIM performance of the different models. Note, the training time $\mathbf { \tau } ( \mathbf { x } )$ axis not in a linear scale.
128
+
129
+ To understand the importance of the hierarchical representation and recurrent feedback in the model, we trained the B-B network with different numbers of modules and then used t-SNE (van der Maaten & Hinton, 2008) to visualize the representation $R$ in the different modules of the various networks in response to the last of the 20 future dead-reckoning frames of 600 testing sequences belonging to the six movements in the KTH dataset. The results are shown in Figure 5. We observed that having more higher modules introduced cluster of global movement patterns in the representation units even in the earliest module (Figure 5 (a) versus Figure 5 (e)), which resulted in significant decoding accuracy improvement in the classification of the six classes of movement patterns, from chance $( 1 6 \% )$ to $26 \%$ , based on the unit activities in the first module alone. The representations of the top module of the 4-module network provide a decoding accuracy of $63 \%$ , suggesting that the HPNet has learned semantically meaningful hierarchical spatiotemporal feature representations (see Appendix B for details) and can learn movement-to-movement relationships for making better long range video predictions (see also Kheradpisheh et al. (2018)). Decoding results indicate that higher order semantic representations of the global movement patterns are significantly weaker or absent in the hierarchical representations of PredRNN or PredNet respectively (see Appendix B for details).
130
+
131
+ # 4.3 VISUAL SEQUENCE LEARNING EFFECTS IN THE VISUAL CORTEX
132
+
133
+ Hierarchical feedback in HPNet endows the representations in the earliest Cortical Modules with sensitivity to global movement and image patterns, despite these units’ very localized receptive fields, particularly R in the feedforward path (Figure 5). Could the neurons in the early visual areas of the mammalian hierarchical visual systems behave in a similar way, becoming sensitive to the memory of global movement patterns of familiar movies?
134
+
135
+ We found this to be the case in a series of neurophysiological experiments that we have performed to study the effect of unsupervised learning of video sequences on the early visual cortical representations. Two monkeys, implanted with Gray-Matter semi-chronic multielectrode arrays (SC32 and SC96) over the V1 operculum with access to neurons in V1 and V2, participated in the experiment. Each experiment lasted for at least seven daily recording sessions. In each recording session, the monkey was required to fixate on a red dot on the screen for a water reward while a set of 40 video clips of natural scenes with global movement patterns was presented. One clip was presented per trial. Each clip lasted for $8 0 0 ~ \mathrm { { m s } }$ . A total of 40 clips were presented once each in a random interleaved fashion in a block of trials, and each block was repeated 20-25 times each day3. Among the
136
+
137
+ 40 movie clips tested every day, twenty of these were the same each day, designated as “Predicted set”. Twenty of them were different each day, designated as “Unpredicted set”. Each set consisted of 20 movies.
138
+
139
+ ![](images/9519100cf2967e267437c1c3a9cb4b017da0545800c0379da636e5fcacda3850.jpg)
140
+ Figure 5: (a)-(d) are the top CM’s R representation of networks with different number of modules, from one to four; (e)-(h) are the representation of each modules in a four-modules network, from the first module to the fourth, left to right. Better clustering leads to better decoding results of the different movement classes. Full details are in Appendix B.
141
+
142
+ The rationale for the experimental design is as follows. Given that we were recording from $3 0 +$ neurons in each session, even though the neurons have different stimulus preferences in their local receptive fields, each neuron would experience about 400 movie frames for the Predicted movie set, as well as for each of the Unpredicted movie sets. When we averaged the temporal responses of all the neurons to each of the 20-movie sets, they should be roughly the same. In the first two days of the experiment, the clips in the Predicted set were still unpredicted, hence there should have been no difference between the population averaged responses to the Predicted set and the Unpredicted set. This was indeed the case as shown in Figure 6b (top row) which compared the averaged temporal responses of the neurons to the Predicted set and to the Unpredicted set for the first two days of training in one experiment.
143
+
144
+ Interestingly, we found that after only three days of unsupervised training, with 20-25 exposures of each familiar movie per day, the neurons started to respond significantly less to predicted movies than to novel movies in the later part of their responses, starting around $1 0 0 \mathrm { m s }$ post-stimulus onset, as shown in Figure 6(b) (bottom row). The evolution of daily mean of all neurons’ familiarity suppression index over days is shown as the magenta curve. As the neurons became more and more familiar with the Predicted set, the prediction suppression effect gradually increased and saturated at around the sixth and seventh days. We repeated the experiments six times in two monkeys and obtained fairly consistent results. Note that the movie clips were shown in a $8 ^ { o }$ aperture during the experiment. Given that the V1 and V2 neurons being studied have very local and small receptive fields $0 . 5 ^ { o }$ to $2 ^ { o }$ ), it is rather improbable that the neurons would have remembered or adapted to the local movement patterns of the Predicted set within their receptive fields, as they would be experiencing millions of such local spatiotemporal patterns in their daily experience. Indeed, when the video clips were shown to the neurons through a smaller $3 ^ { o }$ diameter aperture, the prediction suppression effects were much attenuated, suggesting that the neurons had indeed became sensitive to the global context of movement patterns!
145
+
146
+ To check whether neurons in our network behave in the same way, we performed a similar experiment on our network, pretrained with the KTH dataset. We randomly extracted 20 sequences from the BAIR dataset (Ebert et al., 2017), resized the sequence length to 40 frames and each frame size to $6 4 \times 6 4$ . We separated the 20 video sequences into two sets – the Predicted set and the Unpredicted set. We averaged the responses to the two movie sets respectively of each type of neurons in the network $E$ (prediction error units), $P$ (prediction units), and $R$ (representation units)) in each CM within the center $8 \times 8$ hypercolumns. Before training, the responses of each type of neurons are indeed the same for both movie sets (not shown, but similar to Figure 6(b) data). Then, we trained the network with the Predicted set for 2000 epochs. After training, all three types of units in each
147
+
148
+ CM exhibited the prediction suppression effect as shown in Figure 6 (c)-(h) (full details in Appendix C).
149
+
150
+ ![](images/e5f66d7a3e15ecbee2b1ef73fd797ecbddf19d736dba1d6e32d12e9a48d2243b.jpg)
151
+ Figure 6: (a) The development of the prediction suppression effect across days in one experiment. Each dot is the prediction suppression index of a neuron. Color indicates whether the effect was significant or not (red - significant, blue - insignificant, green - significant in the opposite way) based on t-test with $p < 0 . 0 5$ as statistical significance threshold. (b) Averaged temporal responses of the V1 and V2 neurons (combined) of one monkey to Predicted set and the Unpredicted sets in the first two days (top row), showing no difference. The averaged responses (combining data from day 5 to day 12) to the Predicted set was significantly weaker than the responses to the Unpredicted sets, indicating prediction suppression. (c)-(e) Module 1’s normalized averaged population responses of the three types of units to the Predicted set and the Unpredicted set. (f)-(h) Module 4’s normalized averaged population responses of the three types of units.
152
+
153
+ We observed the prediction suppression effect in all three types of neurons in all the modules in the hierarchy, with the higher modules showing a stronger effect. It is not surprising that the prediction error neurons $E$ would decrease their responses as the network learns to predict the familiar movies better. It is rather interesting to find the representation neurons $R$ and the prediction neurons $P$ also exhibit prediction suppression, even though these neurons represent features rather than prediction errors. The precise reasons remain to be determined, but the fact that all neuron types in the model exhibited the prediction suppression effect might explain why the prediction suppression effects were commonly observed in most of the randomly sampled neurons in the visual cortex (see Figure 6a). These findings suggest that (1) predictive self-supervised learning might indeed be an important principle and mechanism by which the visual cortex learns its representations, and (2) the neurophysiological observations on prediction suppression in IT (see Appendix D) and now in the early visual cortex might be explained by this class of hierarchical cortical models.
154
+
155
+ # 5 CONCLUSION
156
+
157
+ In this paper, we developed a hierarchical prediction network model (HPNet), with a fast DCNN feedforward path, a feedback path and local recurrent LSTM circuits for modeling the counterstream / analysis-by-synthesis architecture of the mammalian hierarchical visual systems. HPNet utilizes predictive self-supervised learning as in PredNet and PredRNN $^ { + + }$ , but integrates additional neural constraints or theoretical neuroscience ideas on spatiotemporal processing, counter-stream architecture, feature hierarchy, prediction evaluation and sparse convolution into a new model that delivers the state-of-the-art performance in long range video prediction. Most importantly, we found that the hierarchical interaction in HPNet introduces sensitivity to global movement patterns in the representational units of the earliest module in the network and that real cortical neurons in the early visual cortex of awake monkeys exhibit very similar sensitivity to memories of global movement patterns, despite their very local receptive fields. These findings support predictive self-supervised learning as an important principle for representation learning in the visual cortex and suggest that HPNet might be a viable computational model for understanding the cortical circuits in the hierarchical visual system at the functional level. Further evaluations are needed to determine definitively whether PredNet or HPNet is a better fit to the biological reality.
158
+
159
+ # REFERENCES
160
+
161
+ Mohammad Babaeizadeh, Chelsea Finn, Dumitru Erhan, Roy H. Campbell, and Sergey Levine. Stochastic variational video prediction. CoRR, abs/1710.11252, 2017.
162
+
163
+ Christopher Bongsoo Choy, Danfei Xu, JunYoung Gwak, Kevin Chen, and Silvio Savarese. 3d-r2n2: A unified approach for single and multi-view 3d object reconstruction. In ECCV, 2016.
164
+
165
+ Sam F. Cooke and Mark F. Bear. How the mechanisms of long-term synaptic potentiation and depression serve experience-dependent plasticity in primary visual cortex. Philosophical transactions of the Royal Society of London. Series B, Biological sciences, 369 1633:20130284, 2014.
166
+
167
+ Sam F. Cooke and Mark F. Bear. Visual recognition memory: a view from v1. Current opinion in neurobiology, 35:57–65, 2015.
168
+
169
+ Achal Dave, Olga Russakovsky, and Deva Ramanan. Predictive-corrective networks for action detection. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2067– 2076, 2017.
170
+
171
+ Peter Dayan, Geoffrey E. Hinton, Radford M. Neal, and Richard S. Zemel. The helmholtz machine. Neural Computation, 7:889–904, 1995.
172
+
173
+ Emily L. Denton and Rob Fergus. Stochastic video generation with a learned prior. In ICML, 2018.
174
+
175
+ Nadine Dijkstra, Peter Zeidman, Sasha Ondobaka, Marcel A J van Gerven, and Karl J. Friston. Distinct top-down and bottom-up brain connectivity during visual perception and imagery. In Scientific Reports, 2017.
176
+
177
+ Frederik Ebert, Chelsea Finn, Alex Lee, and Sergey Levine. Self-supervised visual planning with temporal skip connections. In Conference on Robot Learning (CoRL), 2017.
178
+
179
+ Jeffrey L. Elman. Finding structure in time. Cognitive Science, 14:179–211, 1990.
180
+
181
+ Chelsea Finn, Ian J. Goodfellow, and Sergey Levine. Unsupervised learning for physical interaction through video prediction. In NIPS, 2016.
182
+
183
+ Karl J. Friston. Does predictive coding have a future? Nature Neuroscience, 21:1019–1021, 2018.
184
+
185
+ Ross Goroshin, Michael Mathieu, and Yann LeCun. Learning to linearize under uncertainty. In ¨ NIPS, 2015.
186
+
187
+ Stephen Grossberg. Competitive learning: From interactive activation to adaptive resonance. Cognitive Science, 11:23–63, 1987.
188
+
189
+ Feng Han, Natalia Caporale, and Yang Dan. Reverberation of recent visual experience in spontaneous cortical waves. Neuron, 60:321–327, 2008.
190
+
191
+ Jeff Hawkins and Dileep George. Hierarchical temporal memory concepts , theory , and terminology. 2006.
192
+
193
+ Ge Huang, Suchitra Ramachandran, Tai Sing Lee, and Carl R. Olson. Neural correlate of visual familiarity in macaque area v2. The Journal of neuroscience : the official journal of the Society for Neuroscience, 2018.
194
+
195
+ Nal Kalchbrenner, Aaron van den Oord, Karen Simonyan, Ivo Danihelka, Oriol Vinyals, Alex ¨ Graves, and Koray Kavukcuoglu. Video pixel networks. In ICML, 2017.
196
+
197
+ Daniel J. Kersten and Alan L. Yuille. Bayesian models of object perception. Current opinion in neurobiology, 13 2:150–8, 2003.
198
+
199
+ Saeed Reza Kheradpisheh, Mohammad Ganjtabesh, Simon J. Thorpe, and Timothee Masquelier. ´ Stdp-based spiking deep convolutional neural networks for object recognition. Neural networks : the official journal of the International Neural Network Society, 99:56–67, 2018.
200
+
201
+ Alex X. Lee, Richard Zhang, Frederik Ebert, Pieter Abbeel, Chelsea Finn, and Sergey Levine. Stochastic adversarial video prediction. CoRR, abs/1804.01523, 2018.
202
+
203
+ Tai Sing Lee. The visual system’s internal models of the world. Proceedings of the IEEE, 103: 1359–1378, 2015.
204
+
205
+ Tai Sing Lee and David Mumford. Hierarchical bayesian inference in the visual cortex. Journal of the Optical Society of America. A, Optics, image science, and vision, 20 7:1434–48, 2003.
206
+
207
+ Xingyu Liu, Jeff Pool, Song Han, and William J. Dally. Efficient sparse-winograd convolutional neural networks. CoRR, abs/1802.06367, 2017.
208
+
209
+ William Lotter, Gabriel Kreiman, and David D. Cox. Deep predictive coding networks for video prediction and unsupervised learning. CoRR, abs/1605.08104, 2016.
210
+
211
+ William Lotter, Gabriel Kreiman, and David Cox. A neural network trained to predict future video frames mimics critical properties of biological neuronal responses and perception. CoRR, abs/1805.10734, 2018.
212
+
213
+ Michael Mathieu, Camille Couprie, and Yann LeCun. Deep multi-scale video prediction beyond ¨ mean square error. CoRR, abs/1511.05440, 2015.
214
+
215
+ James L. McClelland and Bruce L. McNaughton. Complementary learning systems 1 why there are complementary learning systems in the hippocampus and neocortex $:$ Insights from the successes and failures of connectionist models of learning and memory. 1999.
216
+
217
+ James L. McClelland and David E. Rumelhart. Distributed memory and the representation of general and specific information. Journal of experimental psychology. General, 114 2:159–97, 1985.
218
+
219
+ Travis Meyer and Carl R. Olson. Statistical learning of visual transitions in monkey inferotemporal cortex. Proceedings of the National Academy of Sciences of the United States of America, 108 48:19401–6, 2011.
220
+
221
+ Travis Meyer, Christopher Walker, Raymond Y. Cho, and Carl R. Olson. Image familiarization sharpens response dynamics of neurons in inferotemporal cortex. Nature Neuroscience, 17:1388– 1394, 2014.
222
+
223
+ David Mumford. On the computational architecture of the neocortex. Biological Cybernetics, 65: 135–145, 1991.
224
+
225
+ David Mumford. On the computational architecture of the neocortex. ii. the role of cortico-cortical loops. Biological cybernetics, 66 3:241–51, 1992.
226
+
227
+ Junhyuk Oh, Xiaoxiao Guo, Honglak Lee, Richard L. Lewis, and Satinder P. Singh. Actionconditional video prediction using deep networks in atari games. In NIPS, 2015.
228
+
229
+ Randall C. O’Reilly, Dean Wyatte, and John Rohrlich. Learning through time in the thalamocortical loops. 2014.
230
+
231
+ Rasmus Berg Palm. Prediction as a candidate for learning deep hierarchical models of data. 2012.
232
+
233
+ Bowen Pan, Wuwei Lin, Xiaolin Fang, Chaoqin Huang, Bolei Zhou, and Cewu Lu. Recurrent residual module for fast inference in videos. CoRR, abs/1802.09723, 2018.
234
+
235
+ Viorica Patraucean, Ankur Handa, and Roberto Cipolla. Spatio-temporal video autoencoder with differentiable memory. CoRR, abs/1511.06309, 2015.
236
+
237
+ Suchitra Ramachandran, Travis Meyer, and Carl R. Olson. Prediction suppression and surprise enhancement in monkey inferotemporal cortex. Journal of neurophysiology, 118 1:374–382, 2017.
238
+
239
+ Rajesh P. N. Rao and Dana H. Ballard. Predictive coding in the visual cortex: a functional interpretation of some extra-classical receptive-field effects. Nature neuroscience, 2 1:79–87, 1999.
240
+
241
+ Christian Schuldt, Ivan Laptev, and Barbara Caputo. Recognizing human actions: a local svm ¨ approach. Proceedings of the 17th International Conference on Pattern Recognition, 2004. ICPR 2004., 3:32–36 Vol.3, 2004.
242
+
243
+ Xingjian Shi, Zhourong Chen, Hao Wang, Dit-Yan Yeung, Wai-Kin Wong, and Wang chun Woo. Convolutional lstm network: A machine learning approach for precipitation nowcasting. In NIPS, 2015.
244
+
245
+ Nitish Srivastava, Elman Mansimov, and Ruslan Salakhutdinov. Unsupervised learning of video representations using lstms. In ICML, 2015.
246
+
247
+ Sergey Tulyakov, Ming-Yu Liu, Xiaodong Yang, and Jan Kautz. Mocogan: Decomposing motion and content for video generation. CoRR, abs/1707.04993, 2017.
248
+
249
+ S Ullman. Sequential seeking and counter streams: a computational model for bidirectional flow in the visual cortex. Cerebral Cortex, 5:1:1–1, 1995.
250
+
251
+ Laurens van der Maaten and Geoffrey E. Hinton. Visualizing data using t-sne. 2008.
252
+
253
+ Ruben Villegas, Jimei Yang, Yuliang Zou, Sungryull Sohn, Xunyu Lin, and Honglak Lee. Learning to generate long-term future via hierarchical prediction. In ICML, 2017.
254
+
255
+ Carl Vondrick, Hamed Pirsiavash, and Antonio Torralba. Generating videos with scene dynamics. In NIPS, 2016.
256
+
257
+ Yunbo Wang, Mingsheng Long, Jianmin Wang, Zhifeng Gao, and Philip S. Yu. Predrnn: Recurrent neural networks for predictive learning using spatiotemporal lstms. In NIPS, 2017.
258
+
259
+ Yunbo Wang, Zhifeng Gao, Mingsheng Long, Jianmin Wang, and Philip S. Yu. Predrnn $^ { + + }$ : Towards a resolution of the deep-in-time dilemma in spatiotemporal predictive learning. In ICML, 2018.
260
+
261
+ Zhou Wang, Alan C. Bovik, Hamid R. Sheikh, and Eero P. Simoncelli. Image quality assessment: from error visibility to structural similarity. IEEE Transactions on Image Processing, 13:600–612, 2004.
262
+
263
+ Nevan Wichers, Ruben Villegas, Dumitru Erhan, and Honglak Lee. Hierarchical long-term video prediction without supervision. In ICML, 2018.
264
+
265
+ Shengjin Xu, Wanchen Jiang, Mu-Ming Poo, and Yang Dan. Activity recall in visual cortical ensemble. In Nature Neuroscience, 2012.
266
+
267
+ Ziru Xu, Yunbo Wang, Mingsheng Long, and Jianmin Wang. Predcnn: Predictive learning with cascade convolutions. In IJCAI, 2018.
268
+
269
+ Haishan Yao, Lei Shi, Feng Han, Hongfeng Gao, and Yang Dan. Rapid learning in cortical coding of visual scenes. Nature Neuroscience, 10:772–778, 2007.
270
+
271
+ # APPENDIX
272
+
273
+ # A 3D CONVOLUTIONAL LSTM
274
+
275
+ Because our data are in the unit of spatitemporal block, we have to use a 3D form of the 2D convolutional LSTM. 3D convolutional LSTM has been used by Choy et al. (2016) in the stereo setting. The dimensions of the input video or the various representations $[ , E $ and $H$ ) in any module are $c \times d \times h \times w$ , where $c$ is the number of channels, $d$ is the number of adjacent frames, $h$ and $w$ specify the spatial dimensions of the frame. The 3D spatiotemporal convolution kernel is $m \times k \times k$ in size, where $m$ is kernel temporal depth and $k$ is kernel spatial size. The spatial stride of the convolution is 1. The size of the output with $n$ kernels is $n \times d \times h \times w$ . We define the inputs as $X _ { 1 } , . . . , X _ { t }$ , the cell states as $C _ { 1 } , . . . , C _ { t }$ , the outputs as $H _ { 1 } , . . . , H _ { t }$ , and the gates as $i _ { t } , f _ { t } , o _ { t }$ . Our 3D convolutional LSTM is specified by the equations below, where the function of 3D convolution is indicated by $\star$ and the Hadamard product is indicated by $\circ$ .
276
+
277
+ $$
278
+ \begin{array} { r l } & { i _ { t } = \sigma ( W _ { x i } \star X _ { t } + W _ { h i } \star H _ { t - 1 } + W _ { c i } \circ C _ { t - 1 } + b _ { i } ) } \\ & { f _ { t } = \sigma ( W _ { x f } \star X _ { t } + W _ { h f } \star H _ { t - 1 } + W _ { c f } \circ C _ { t - 1 } + b _ { f } ) } \\ & { C _ { t } = f _ { t } \circ C _ { t - 1 } + i _ { t } \circ t a n h ( W _ { x c } \star X _ { t } + W _ { h c } \star H _ { t - 1 } + b _ { c } ) } \\ & { o _ { t } = \sigma ( W _ { x o } \star X _ { t } + W _ { h o } \star H _ { t - 1 } + W _ { c o } \circ C _ { t } + b _ { o } ) } \\ & { H _ { t } = o _ { t } \circ t a n h ( C _ { t } ) } \end{array}
279
+ $$
280
+
281
+ # B SEMANTIC CLUSTERING IN THE HIERARCHICAL REPRESENTATIONS
282
+
283
+ ![](images/c0e556c9d7f79ffdcd2a3195b469c4be33fc009cc3505934f6a6f9a4ba0df9bc.jpg)
284
+ Figure 7: Visualization of R representational units of the different modules in (a) a one-module network; (b)-(c) a two-module network; (d)-(f) a three-module network; and (g)-(j) a four-module network.
285
+
286
+ Figure 7 compares the t-SNE (van der Maaten & Hinton, 2008) projection of the responses of the R representation units in the center $8 \times 8$ “hypercolumns” of the different modules for networks of different number of modules to the 6 movement classes in the KTH dataset. Partial results are shown in Figure 5 of the main text of the paper. The figures demonstrate that as more higher order modules are stacked up in the hierarchy, the semantic clustering into the six movement classes become more pronounced even in the early modules, suggesting that the hierarchical interaction has steered the feature representation into semantic clusters even in the early modules. Module 4-1 means representation of module 1 in a 4-module network.
287
+
288
+ We use linear decoding (multi-class SVM) to assess the distinctiveness of the semantiuc clusters in the representation of the different modules in the different networks. The decoding results in Table 3 shows that the decoding accuracy based on the reprsentation of module 1 has improved from chance $( 1 6 \% )$ to $26 \%$ , an improvement of $60 \%$ between a 1-module HPNet and a 4-module HPNet, and that the representation of module 4 of a 4-module HPNet can achieve a $63 \%$ accuracy in classifying the six movement classes, suggesting that the network only needs to learn to predict unlabelled video sequences, and it automatically learns reasonable semantic representations for recognition.
289
+
290
+ Table 3: Our model’s decoding results of six movement classes in the KTH dataset based on R representations in different modules of networks of different number of modules. Module 4-2 means Module 2 of a 4-module HPNet.
291
+
292
+ <table><tr><td rowspan=1 colspan=1>Representation in</td><td rowspan=1 colspan=1>Module 1-1</td><td rowspan=1 colspan=1>Module 2-1</td><td rowspan=1 colspan=1>Module 3-1</td><td rowspan=1 colspan=1>Module 4-1</td></tr><tr><td rowspan=1 colspan=1>Mean decoding accuracy</td><td rowspan=1 colspan=1>0.16</td><td rowspan=1 colspan=1>0.19</td><td rowspan=1 colspan=1>0.21</td><td rowspan=1 colspan=1>0.26</td></tr><tr><td rowspan=1 colspan=1>Representation in</td><td rowspan=1 colspan=1>Module 4-1</td><td rowspan=1 colspan=1>Module 4-2</td><td rowspan=1 colspan=1>Module 4-3</td><td rowspan=1 colspan=1>Module 4-4</td></tr><tr><td rowspan=1 colspan=1>Mean decoding accuracy</td><td rowspan=1 colspan=1>0.26</td><td rowspan=1 colspan=1>0.45</td><td rowspan=1 colspan=1>0.57</td><td rowspan=1 colspan=1>0.63</td></tr></table>
293
+
294
+ For comparison, we also performed decoding on the output representations of each LSTM layer in the PredR $\mathrm { N N } { + } +$ and PredNet to study their representations of the six movement patterns. The results shown below indicate that the semantic clustering of the six movements is not very strong in the $\mathrm { P r e d R N N + + }$ hierarchy. We realized that this might be because the PredR $\mathrm { N N } { + } { + }$ behaves essentially like an autoencoder. The four-layer network effectively only has two layers of feature abstraction, with layer 2 being the most semantic in the hierarchy and layers 3 and 4 representing the unfolding of the feedback path. Decoding results indicate that the hierarchical representation based on the output of the LSTM at every layer in PredNet, which serve to predict errors of prediction errors of the previous layer, does not contain semantic information about the global movement patterns.
295
+
296
+ Table 4: PredR $\mathrm { N N } { + } { + }$ ’s decoding results of six movement classes in the KTH dataset based on representations in the different layers of the network.
297
+
298
+ <table><tr><td rowspan=1 colspan=1>Representation in</td><td rowspan=1 colspan=1>Layer 1</td><td rowspan=1 colspan=1>Layer 2</td><td rowspan=1 colspan=1>Layer 3</td><td rowspan=1 colspan=1>Layer 4</td></tr><tr><td rowspan=1 colspan=1>Mean decoding accuracy</td><td rowspan=1 colspan=1>0.18</td><td rowspan=1 colspan=1>0.23</td><td rowspan=1 colspan=1>0.18</td><td rowspan=1 colspan=1>0.16</td></tr></table>
299
+
300
+ Table 5: PredNet’s decoding results of six movement classes in the KTH dataset based on LSTM representations in the different layers of the network.
301
+
302
+ <table><tr><td rowspan=1 colspan=1>Representation in</td><td rowspan=1 colspan=1>Layer 1</td><td rowspan=1 colspan=1>Layer 2</td><td rowspan=1 colspan=1>Layer 3</td><td rowspan=1 colspan=1>Layer 4</td></tr><tr><td rowspan=1 colspan=1>Mean decoding accuracy</td><td rowspan=1 colspan=1>0.16</td><td rowspan=1 colspan=1>0.11</td><td rowspan=1 colspan=1>0.10</td><td rowspan=1 colspan=1>0.10</td></tr></table>
303
+
304
+ # C PREDICTION SUPPRESSION EFFECTS IN VIDEO SEQUENCE LEARNING IN HPNET
305
+
306
+ ![](images/a52d9a7b53db63f51aaa466a911037f6c15e102401c1ecbadaad8c28d6b81c90.jpg)
307
+ Figure 8: Results of video sequence learning experiments showing prediction suppression can be observed in $E$ , $P$ , and $R$ units in every module along the hierarchical network. The abscissa is time after stimulus onset - where we set each video frame to be $2 5 ~ \mathrm { m s }$ for comparison with neural data. The ordinate is the normalized averaged temporal response of all the units within the center $8 \times 8$ hypercolumns, averaged across all neurons and across the 20 movies in the Predicted set (blue) and the Unpredicted set (red) respectively. Prediction suppression can be observed in all types of units, though more pronounced in the E and $\mathrm { \bf P }$ units.
308
+
309
+ # D PREDICTION SUPPRESSION EFFECT IN IT NEURONS AND HPNET
310
+
311
+ HPNet readily reproduces the prediction suppression effects observed in IT neurons. Meyer & Olson (2011) trained monkeys to image pairs in a fixed order for over 800 trials for each 8 pair images, and then compared the responses of the neurons to these images in the trained order against the responses of the neurons to the same images but in novel pairings. Figure 9 shows the mean responses of 81 IT neurons during testing stage for predicted pairs and unpredicted pairs. All the stimuli are presented in both pairs. They found that neural responses to the expected second images in a familiar sequence order is much weaker than the neural responses to the image in an unfamiliar or unexpected sequence order. To evaluate whether HPNet can produce the same effect, we performed exactly the same experiments with 2000 epochs of training on the image pairs, with a gap of 2 frames, and our model produced the same results, with lower responses for the predicted second stimulus relative to the unpredicted second stimulus. Each stimulus sequence was presented first with 5 gray frames, followed by 10 frames of the first image in the pair, then 2 gray frames as gap, then 10 frames of the second image in the pair. The responses of the units to the trained set and the untrained set are the same prior to training. After training, the images when arranged in the trained order responded much less after the initial responses than the same images but arranged in unpredicted pairs. The result shown in Figure 10 duplicated the observations in Meyer & Olson (2011), the average neural response of $E$ unit is lower than the unpredicted pairs. All three types of units of NPNet exhibit prediction suppression though the effect is much weaker for the R units (see Figure 11. Lotter et al. (2018) also tested the prediction suppression effect, but their model couldn’t allow any gap between the stimuli as in the experiment. Our model can handle gap because of our model is processing information in spatiotemporal blocks.
312
+
313
+ ![](images/dadf1c00e4142c5d9085ecb55c8cae4ef9d1f1d31d877d4431b6da52878f9a57.jpg)
314
+ Figure 9: Prediction suppression in IT neurons ((Meyer & Olson, 2011)).
315
+
316
+ ![](images/4bfafb24e1bf7b578d7b8a0d93fc8608570cb8c01cfbd2d31c90b01803090968.jpg)
317
+ Figure 10: Prediction suppression results on $E 4$ units in HPNet.
318
+
319
+ ![](images/a59f40cc192119d38876a7577eb784609d40eeeab86412eeddb413ef21c94456.jpg)
320
+ Figure 11: Prediction suppression behaviors in the E, P, and R units of module 4 of HPNet, respectively.
md/train/ByG8A7cee/ByG8A7cee.md ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # REFERENCE-AWARE LANGUAGE MODELS
2
+
3
+ Zichao $\mathbf { Y a n g ^ { 1 * } }$ ∗, Phil Blunsom2,3, Chris Dyer1,2, and Wang Ling2 1Carnegie Mellon University, 2DeepMind, and 3University of Oxford zichaoy@cs.cmu.edu, {pblunsom,cdyer,lingwang}@google.com
4
+
5
+ # ABSTRACT
6
+
7
+ We propose a general class of language models that treat reference as an explicit stochastic latent variable. This architecture allows models to create mentions of entities and their attributes by accessing external databases (required by, e.g., dialogue generation and recipe generation) and internal state (required by, e.g. language models which are aware of coreference). This facilitates the incorporation of information that can be accessed in predictable locations in databases or discourse context, even when the targets of the reference may be rare words. Experiments on three tasks show our model variants outperform models based on deterministic attention.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Referring expressions (REs) in natural language are noun phrases (proper nouns, common nouns, and pronouns) that identify objects, entities, and events in an environment. REs occur frequently and they play a key role in communicating information efficiently. While REs are common, previous works neglect to model REs explicitly, either treating REs as ordinary words in the model or replacing them with special tokens. Here we propose a language modeling framework that explicitly incorporates reference decisions.
12
+
13
+ In Figure 1 we list examples of REs in the context of the three tasks that we consider in this work. Firstly, reference to a database is crucial in many applications. One example is in task oriented dialogue where access to a database is necessary to answer a user’s query (Young et al., 2013; Li et al., 2016; Vinyals & Le, 2015; Wen et al., 2015; Sordoni et al., 2015; Serban et al., 2016; Bordes & Weston, 2016; Williams & Zweig, 2016; Shang et al., 2015; Wen et al., 2016). Here we consider the domain of restaurant recommendation where a system refers to restaurants (name) and their attributes (address, phone number etc) in its responses. When the system says “the nirala is a nice restaurant”, it refers to the restaurant name the nirala from the database. Secondly, many models need to refer to a list of items (Kiddon et al., 2016; Wen et al., 2015). In the task of recipe generation from a list of ingredients (Kiddon et al., 2016), the generation of the recipe will frequently reference these items. As shown in Figure 1, in the recipe “Blend soy milk and . . . ”, soy milk refers to the ingredient summaries. Finally, we address references within a document (Mikolov et al., 2010; Ji et al., 2015; Wang & Cho, 2015), as the generation of words will ofter refer to previously generated words. For instance the same entity will often be referred to throughout a document. In Figure 1, the entity you refers to I in a previous utterance.
14
+
15
+ In this work we develop a language model that has a specific module for generating REs. A series of latent decisions (should I generate a RE? If yes, which entity in the context should I refer to? How should the RE be rendered?) augment a traditional recurrent neural network language model and the two components are combined as a mixture model. Selecting an entity in context is similar to familiar models of attention (Bahdanau et al., 2014), but rather than being a deterministic function that reweights representations of elements in the context, it is treated as a distribution over contextual elements which are stochastically selected and then copied or, if the task warrants it, transformed (e.g., a pronoun rather than a proper name is produced as output). Two variants are possible for updating the RNN state: one that only looks at the generated output form; and a second that looks at values of the latent variables. The former admits trivial unsupervised learning, latent decisions are conditionally independent of each other given observed context, whereas the latter enables more expressive models that can extract information from the entity that is being referred to. In each of the three tasks, we demonstrate our reference aware model’s efficacy in evaluations against models that do not explicitly include a reference operation.
16
+
17
+ ![](images/b3c493786dc3a9b650fc7c012d8f1e8c16fa322597d6a17781862a6e4457f828.jpg)
18
+ Figure 1: Reference-aware language models.
19
+
20
+ Our contributions are as follows:
21
+
22
+ • We propose a general framework to model reference in language and instantiate it in the context of dialogue modeling, recipe generation and coreference based language models. • We build three data sets to test our models. There lack existing data sets that satisfy our need, so we build these data sets ourselves. These data sets are either built on top existing data set (we constructed the table for DSTC2 data set for dialogue evaluation), crawled from websites (we crawled all recipes in www.allrecipes.com) or annotated with NLP tools (we annotate the coreference with Gigaword corpus for our evaluation). • We perform comprehensive evaluation of our models on the three data sets and verify our models perform better than strong baselines.
23
+
24
+ # 2 REFERENCE-AWARE LANGUAGE MODELS
25
+
26
+ Here we propose a general framework for reference-aware language models.
27
+
28
+ We denote each document as a series of tokens $x _ { 1 } , \ldots , x _ { L }$ , where $L$ is the number of tokens in the document. Our goal is to maximize the probabilities $p ( x _ { i } \mid c _ { i } )$ , for each word in the document based on its previous context $c _ { i } = x _ { 1 } , \ldots , x _ { i - 1 }$ . In contrast to traditional neural language models, we introduce a variable at each position $z _ { i }$ , which controls the decision on which source $x _ { i }$ is generated from. The token conditional probably is then obtained by:
29
+
30
+ $$
31
+ p ( x _ { i } \mid c _ { i } ) = p ( x _ { i } \mid z _ { i } , c _ { i } ) p ( z _ { i } \mid c _ { i } ) .
32
+ $$
33
+
34
+ In dialogue modeling and recipe generation, $z _ { i }$ will simply taken on values in $\{ 0 , 1 \}$ . Where $z _ { i } = 1$ denotes that $x _ { i }$ is generated as a reference, either to a database entry or an item in a list. However, $z _ { i }$ can also be defined as a distribution over previous entities, allowing the model to predict $x _ { i }$ conditioned on its a previous mention word. This will be the focus of the coreference language model. When $z _ { i }$ is not observed (which it generally will not be), we will train our model to maximize the marginal probability in Eq. 1 directly.
35
+
36
+ # 2.1 DIALOGUE MODEL WITH DATABASE SUPPORT
37
+
38
+ We first apply our model on task-oriented dialogue systems in the domain of restaurant recommendations, and work on the data set from the second Dialogue State Tracking Challenge (DSTC2) (Henderson et al., 2014). Table. 1 is one example dialogue from this dataset.
39
+
40
+ We can observe from this example, users get recommendations of restaurants based on queries that specify the area, price and food type of the restaurant. We can support the system’s decisions by incorporating a mechanism that allows the model to query the database allowing the model to find restaurants that satisfy the users queries. Thus, we crawled TripAdvisor for restaurants in the
41
+
42
+ M: Hello , welcome to the Cambridge restaurant system? You can ask for restaurants by area, price range or food type . How may I help you? U: i want a moderately priced restaurant in the north town M: the nirala is a nice restaurant in the north of town in the moderate price range U: what is the address M: Sure , the nirala is on 7 Milton Road Chesterton
43
+
44
+ Table 1: Example dialogue, M stands for Machine and U stands for User
45
+ Table 2: Fragment of database for dialogue system.
46
+
47
+ <table><tr><td rowspan=1 colspan=1>NAME</td><td rowspan=1 colspan=1>PRICE RANGE</td><td rowspan=1 colspan=1>FOOD</td><td rowspan=1 colspan=1>AREA</td><td rowspan=1 colspan=1>ADDRESS</td><td rowspan=1 colspan=1>POST CODE</td><td rowspan=1 colspan=1>PHONE</td></tr><tr><td rowspan=1 colspan=1>ali baba</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>lebanese</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>59 Hills Road City Cen-tre</td><td rowspan=1 colspan=1>CB 2,1NT</td><td rowspan=1 colspan=1>01462 432565</td></tr><tr><td rowspan=1 colspan=1>thenirala</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>north</td><td rowspan=1 colspan=1>7 Milton Road Chester-ton</td><td rowspan=1 colspan=1>CB 4,1 UY</td><td rowspan=1 colspan=1>01223 360966</td></tr></table>
48
+
49
+ Cambridge area, where the dialog dataset was collected. Then, we remove restaurants that do not appear in the data set and create a database with 109 entries with restaurants and their attributes (e.g. food type). A sample of our database is shown in Table. 2. We can observe that each restaurant contains 6 attributes that are generally referred in the dialogue dataset. As such, if the user requests a restaurant that serves “indian” food, we wish to train a model that can search for entries whose “food” column contains “indian”. Now, we describe how we deploy a model that fulfills these requirements.
50
+
51
+ # 2.1.1 DIALOGUE MODEL
52
+
53
+ ![](images/87ef1fc8d188ea02069cf542faffb56d265b9b1740204980353fa21d6da852bf.jpg)
54
+ Figure 2: Hierarchical RNN Seq2Seq model
55
+
56
+ We build a model based on the hierarchical RNN model described in (Serban et al., 2016), as in dialogues, the generation of the response is not only dependent on the previous sentence, but on all sentences leading to the response. We assume that a dialogue is alternated between a machine and a user. An illustration of the model is shown in Figure 2.
57
+
58
+ Consider a dialogue with $T$ turns, and the utterance from a user is denoted as $X = \{ x _ { i } \} _ { i = 1 } ^ { T }$ , where $i$ is the $i$ -th utterance, whereas the utterance from a machine is denoted as ${ \cal Y } = \{ y _ { i } \} _ { i = 1 } ^ { T }$ , where $i$ is the $i$ -th utterance. We define $x _ { i } = \{ x _ { i j } \} _ { j = 1 } ^ { | x _ { i } | }$ , $y _ { i } = \{ y _ { i v } \} _ { v = 1 } ^ { | y _ { i } | }$ , where $x _ { i j }$ denotes the $j$ -th token in the $i$ -th utterance from the user, whereas $y _ { i v }$ denotes the $v$ -th token in the $i$ -th utterance from the machine. Finally, $\left| x _ { i } \right|$ and $| y _ { i } |$ denote the number of tokens in the user and machine utterances, respectively. The dialogue sequence starts with machine utterance $\left\{ y _ { 1 } , x _ { 1 } , y _ { 2 } , x _ { 2 } , \dots , y _ { T } , x _ { T } \right\}$ . We would like to model the utterances from the machine
59
+
60
+ $$
61
+ p ( y _ { 1 } , y _ { 2 } , \ldots , y _ { T } | x _ { 1 } , x _ { 2 } , \ldots , x _ { T } ) = \prod _ { i } p ( y _ { i } | y _ { < i } , x _ { < i } ) = \prod _ { i , v } p ( y _ { i , v } | y _ { i , < v } , y _ { < i } , x _ { < i } ) ,
62
+ $$
63
+
64
+ where $y _ { < i }$ denotes all the utterances before $i$ and $y _ { i , < v }$ denotes the first $v - 1$ tokens in the $i$ -th utterance of the machine. A neural model is employed to predict $p ( y _ { i , v } | y _ { i , < v } , y _ { < i } , x _ { < i } )$ , which operates as follows:
65
+
66
+ Sentence Encoder: We first encode previous utterances $y _ { < i }$ and $x _ { < i }$ into continuous space by generatistate mploying a LSTM encodand apply the recursion $x _ { i }$ , and sta, where he initial LSTMdenotes a word $h _ { i , 0 } ^ { x }$ $h _ { i , j } ^ { x } = \mathrm { L S T M } _ { \mathrm { E } } ^ { - } ( W _ { E } x _ { i , j } , h _ { i , j - 1 } ^ { x } )$ $W _ { E } x _ { i , j }$
67
+
68
+ embedding lookup for the token $x _ { i , j }$ , and $\mathbf { L S T M _ { E } }$ denotes the LSTM transition function described in Hochreiter & Schmidhuber (1997). The representation of the user utterance is represented by the final LSTM state $h _ { i } ^ { x } \ = \ h _ { i , | x _ { i } | } ^ { x }$ The same process is applied to obtain the machine utterance representation $h _ { i } ^ { y } = h _ { i , | y _ { i } | } ^ { y }$ hyi,|yi|
69
+
70
+ Turn Encoder: Then, combine all the representations of all the utterances with a second LSTM, which encodes the sequence $\{ h _ { 1 } ^ { y } , h _ { 1 } ^ { x } , . . . , h _ { i } ^ { \bar { y } } , h _ { i } ^ { x } \}$ into a continuous vector. Once again, we start with an initial state $u _ { 0 }$ and feed each of the utterance representation to obtain the following LSTM state, until the final state is obtained. For simplicity, we shall refer to this as $u _ { i }$ , which can be seen as the hierarchical encoding of the previous $i$ utterances.
71
+
72
+ Seq2Seq Decoder: As for decoding, in order to generate each utterance $y _ { i }$ , we can feed $u _ { i - 1 }$ into the decoder LSTM as the initial state $s _ { i , 0 } = u _ { i - 1 }$ and decode each token in $y _ { i }$ . Thus, we can express the decoder as:
73
+
74
+ $$
75
+ \begin{array} { r l } & { s _ { i , v } ^ { y } = \mathrm { L S T M } _ { \mathrm { D } } ( W _ { E } y _ { i , v - 1 } , s _ { i , v - 1 } ) , } \\ & { p _ { i , v } ^ { y } = \mathrm { s o f t m a x } ( W s _ { i , v } ^ { y } ) , } \end{array}
76
+ $$
77
+
78
+ where the desired probability $p ( y _ { i , v } | y _ { i , < v } , y _ { < i } , x _ { < i } )$ is expressed by $p _ { i , v } ^ { y }$
79
+
80
+ Attention based decoder: We can also incorporate the attention mechanism in our hierarchical model. An attention model builds a representation $d$ by averaging over a set of vectors $p$ . We define the attention function as $a = \mathrm { A T T N } ( p , q )$ , where $a$ is a probability distribution over the set of vectors $p$ , conditioned on any input representation $q$ . A full description of this operation is described in (Bahon the current decoder state danau et al., 2014). Thus, for each generated token $s _ { i , v } ^ { y }$ , obtaining the attentions over input tokens from previous turn $y _ { i , v }$ , we compute the attentions $a _ { i , v }$ , conditioned $( i - 1 )$ . We denote the vector of all tokens in previous turn as $h _ { i - 1 } ^ { x , y } = [ \{ h _ { i - 1 , j } ^ { x } \} _ { j = 1 } ^ { | x _ { i - 1 } | } , \{ h _ { i - 1 , v } ^ { y } \} _ { v = 1 } ^ { | y _ { i - 1 } | } ]$ }|yi−1|] Let . $K = | h _ { i - 1 } ^ { x , y } |$ be the number of tokens in previous turn. Thus, we obtain the attention probabilities − over all previous tokens $a _ { i , v }$ as $\mathrm { A T T N } ( s _ { i , v } ^ { y } , h _ { i - 1 } ^ { x , y } )$ . Then, the weighted sum is computed over these probabilities $\begin{array} { r } { d _ { i , v } = \sum _ { k \in K } a _ { i , v , k } h _ { i - 1 , k } ^ { x , y } } \end{array}$ , where $_ { a _ { i , v , k } }$ is the probability of aligning to the $k$ -th token from previous turn. The resulting vector $d _ { i , v }$ is used to obtain the probability of the following word $p _ { i , v } ^ { y }$ . Thus, we express the decoder as:
81
+
82
+ $$
83
+ \begin{array} { r l } & { s _ { i , v } ^ { y } = \mathrm { L S T M } _ { \mathrm { D } } ( [ { W } _ { \mathrm { E } } y _ { i , v - 1 } , d _ { i , v - 1 } ] , s _ { i , v - 1 } ) , } \\ & { a _ { i , v } = \mathrm { A T T N } ( h _ { i - 1 } ^ { x , y } , s _ { i , v } ^ { y } ) , } \\ & { d _ { i , v } = \displaystyle \sum _ { k \in K } a _ { i , v , k } h _ { i - 1 , k } ^ { x , y } , } \\ & { p _ { i , v } ^ { y } = \mathrm { s o f t m a x } ( W [ s _ { i , v } ^ { y } , d _ { i , v } ] ) . } \end{array}
84
+ $$
85
+
86
+ # 2.1.2 INCORPORATING TABLE ATTENTION
87
+
88
+ ![](images/b0ecbcb0faa2ea176f8574992b4d9fd0e2656f8d2a9d4622b8cbcf038acd89ca.jpg)
89
+ Figure 3: Table based decoder.
90
+
91
+ We now extend the attention model in order to allow the attention to be computed over a table, allowing the model to condition the generation on a database.
92
+
93
+ We denote a table with $R$ rows and $C$ columns as $\{ f _ { r , c } \} , r \in [ 1 , R ] , c \in [ 1 , C ]$ , where $f _ { r , c }$ is the cell in row $r$ and column $c$ . The attribute of each column is denoted as $s _ { c }$ , where $c$ is the $c$ -th attribute. $f _ { r , c }$ and $s _ { c }$ are one-hot vector.
94
+
95
+ Table Encoding: To encode the table, we build an attribute vector $g _ { c }$ for each column. For each cell $f _ { r , c }$ of the table, we concatenate it with the corresponding attribute $g _ { c }$ and then feed it through a one-layer MLP as follows: $g _ { c } = W _ { E } s _ { c }$ and then $e _ { r , c } = \operatorname { t a n h } ( W [ W _ { E } f _ { r , c } , g _ { c } ] )$ .
96
+
97
+ Table Attention: The diagram for table attention is shown in Figure 3a. The attention over cells in the table is conditioned on a given vector $q$ , similarly to the attention model for sequences $\mathbf { A T T N } ( p , q )$ . However, rather than a sequence $p$ , we now operate over a table $f$ . Our attention model computes a attribute attention followed by row attention of the table. We first use the attention mechanism on the attributes to find out which attribute the user asks about. Suppose a user says cheap, then we should focus on the price attribute. After we get the attention probability $p ^ { a } = \mathrm { A T T N } ( \{ g _ { c } \} , q )$ , over the attribute, we calculate the weighted representation for each row $\begin{array} { r } { e _ { r } = \sum _ { c } p _ { c } ^ { a } e _ { r c } } \end{array}$ conditioned on $p ^ { a }$ . Then $e _ { r }$ has the price information of each row. We further use attention mechanism on $e _ { r }$ and get the probability $p ^ { r } \bar { \mathbf { \Psi } } = \mathrm { A T T N } ( \{ e _ { r } \} , q )$ over the rows. Then restaurants with cheap price will be picked. Then, using the probabilities $p ^ { r }$ , we compute the weighted average over the all rows $\begin{array} { r } { e _ { c } = \sum _ { r } p _ { r } ^ { r } e _ { r , c } } \end{array}$ , which is used in the decoder. The detailed process is:
98
+
99
+ $$
100
+ \begin{array} { r l r } { { p _ { a } = \mathrm { A T T N } ( \{ g _ { c } \} , q ) , } } \\ & { } & { \quad e _ { r } = \displaystyle \sum _ { c } p _ { c } ^ { a } e _ { r c } \quad \forall r , } \\ & { } & { \quad p _ { r } = \mathrm { A T T N } ( \{ e _ { r } \} , q ) , } \\ & { } & { \quad e _ { c } = \displaystyle \sum _ { r } p _ { r } ^ { r } e _ { r , c } \quad \forall c . } \end{array}
101
+ $$
102
+
103
+ This is embedded in the decoder by replacing the conditioned state as the current decoder state $s _ { i , 0 } ^ { y }$ and then at each step, conditioning the prediction of ach step. The detailed diagram of table attention is s $y _ { i , v }$ on n in $\{ e _ { c } \}$ by using attention mechanismre 3a.
104
+
105
+ # 2.1.3 INCORPORATING TABLE POINTER NETWORKS
106
+
107
+ We now describe the mechanism used to refer to specific database entries during decoding. At each timestep, the model needs to decide whether to generate the next token from an entry of the database or from the word softmax. This is performed as follows.
108
+
109
+ Pointer Switch: We use $z _ { i , v } \in [ 0 , 1 ]$ to denote the decision of whether to copy one cell from the table. We compute this probability as follows:
110
+
111
+ $$
112
+ p ( z _ { i , v } | s _ { i , v } ) = \mathrm { s i g m o i d } ( W [ s _ { i , v } , d _ { i , v } ] ) .
113
+ $$
114
+
115
+ Thus, if $z _ { i , v } = 1$ , the next token $y _ { i , v }$ will be generated from the database, whereas if $z _ { i , v } = 0$ , then the following token is generated from a softmax. We shall now describe how we generate tokens from the database.
116
+
117
+ Table Pointer: If $z _ { i , v } = 1$ , the token is generated from the table. The detailed process of calculating the probability distribution over the table is shown in Figure 3b. This is similar to the attention mechanism, except that we perform a column attention to compute the probabilities of copying from each column after Equation. 5. More formally:
118
+
119
+ $$
120
+ \begin{array} { c } { { p ^ { c } = \mathrm { A T T N } ( \{ e _ { c } \} , q ) , } } \\ { { p ^ { \mathrm { c o p y } } = p ^ { r } \otimes p ^ { c } , } } \end{array}
121
+ $$
122
+
123
+ where $p ^ { c }$ is a probability distribution over columns, whereas $p ^ { r }$ is a probability distribution over rows. In order to compute a matrix with the probability of copying each cell, we simply compute the outer product $p ^ { \mathrm { c o p y } } = p ^ { r } \otimes p ^ { c }$ .
124
+
125
+ Objective: As we treat $z _ { i }$ as a latent variable, we wish to maximize the marginal probability of the sequence $y _ { i }$ over all possible values of $z _ { i }$ . Thus, our objective function is defined as:
126
+
127
+ $$
128
+ p ( y _ { i , v } | s _ { i , v } ) = p ^ { \mathrm { v o c a b } } p ( 0 | s _ { i , v } ) + p ^ { \mathrm { c o p y } } p ( 1 | s _ { i , v } ) = p ^ { \mathrm { v o c a b } } ( 1 - p ( 1 | s _ { i , v } ) ) + p ^ { \mathrm { c o p y } } p ( 1 | s _ { i , v } ) .
129
+ $$
130
+
131
+ The model can also be trained in a fully supervised fashion, if $z _ { i , v }$ is observed. In such cases, we simply maximize the likelihood of $p ( z _ { i , v } | s _ { i , v } )$ , based on the observations, rather than using the marginal probability over $z _ { i , v }$ .
132
+
133
+ # 2.2 RECIPE GENERATION
134
+
135
+ Table 3: Ingredients and recipe for Spinach and Banana Power Smoothie.
136
+
137
+ <table><tr><td>ingredients</td><td>recipe</td></tr><tr><td>1 cup plain soy milk 3/4 cup packed fresh spinach leaves 1 large banana, sliced</td><td>Blend soy milk and spinach leaves together in a blender until smooth. Add banana and pulse until thoroughly blended.</td></tr></table>
138
+
139
+ Next, we consider the task of recipe generation conditioning on the ingredient lists. In this task, we must generate the recipe from a list of ingredients. Table. 3 illustrates the ingredient list and recipe for Spinach and Banana Power Smoothie. We can see that the ingredients soy milk, spinach leaves, and banana occur in the recipe.
140
+
141
+ ![](images/97d1e470685ca1f07412db7cba45713c6027dcdcb3319467583430504adf11d3.jpg)
142
+ Figure 4: Recipe pointer
143
+
144
+ Let the ingredients of a recipe be $X ~ = ~ \{ x _ { i } \} _ { i = 1 } ^ { T }$ and each ingredient contains $L$ tokens $\begin{array} { r l } { x _ { i } } & { { } = } \end{array}$ $\{ x _ { i j } \} _ { j = 1 } ^ { L }$ . The corresponding recipe is $y = \{ y _ { v } \} _ { v = 1 } ^ { K }$ . We first use a LSTM to encode each ingredient:
145
+
146
+ $$
147
+ h _ { i , j } = \mathrm { L S T M } _ { \mathrm { E } } ( W _ { E } x _ { i j } , h _ { i , j - 1 } ) \quad \forall i .
148
+ $$
149
+
150
+ Then, we sum the resulting state of each ingredient to obtain the starting LSTM state of the decoder. Once again we use an attention based decoder:
151
+
152
+ $$
153
+ \begin{array} { c } { { s _ { v } = \mathrm { L S T M } _ { \mathrm { D } } \displaystyle ( s _ { v - 1 } , d _ { v - 1 } , W _ { \mathrm { E } } y _ { v - 1 } ) , } } \\ { { p _ { v } ^ { \mathrm { c o p y } } = \mathrm { A T T N } \displaystyle ( \{ \left\{ h _ { i , j } \right\} _ { i = 1 } ^ { T } \} _ { j = 1 } ^ { L } , s _ { v } ) , } } \\ { { d _ { v } = \displaystyle \sum _ { i j } p _ { v , i , j } h _ { i , j } , } } \\ { { p ( z _ { v } | s _ { v } ) = \mathrm { s i g m o i d } ( W [ s _ { v } , d _ { v } ] ) , } } \\ { { p _ { v } ^ { \mathrm { v o c a b } } = \mathrm { s o f t m a x } ( W [ s _ { v } , d _ { v } ] ) . } } \end{array}
154
+ $$
155
+
156
+ Similar to the previous task, the decision to copy from the ingredient list or generate a new
157
+ word from the softmax is performed using a switch, denoted as $p ( z _ { v } | s _ { v } )$ . We can obtain a copying each of the words in the ingredients by computing in the attention mechanism. For training, we optimize the $p _ { v } ^ { \mathrm { c o p y } } =$
158
+ $\mathsf { \bar { A } T T N } ( \{ \{ \bar { h } _ { i , j } \} _ { i = 1 } ^ { T } \} _ { j = 1 } ^ { L } , s _ { v } )$
159
+ likelihood function employed in the previous task.
160
+
161
+ # 2.3 COREFERENCE BASED LANGUAGE MODEL
162
+
163
+ Finally, we build a language model that uses coreference links to point to previous words. Before generating a word, we first make the decision on whether it is an entity mention. If so, we decide which entity this mention belongs to, then we generate the word based on that entity. Denote the document as $X = \{ x _ { i } \} _ { i = 1 } ^ { L }$ , and the entities are $E = \{ e _ { i } \} _ { i = 1 } ^ { N }$ , each entity has $M _ { i }$ mentions, $e _ { i } =$ $\{ m _ { i j } \} _ { j = 1 } ^ { M _ { i } }$ , such that $\{ x _ { m _ { i j } } \} _ { j = 1 } ^ { M _ { i } }$ refer to the same entity. We use a LSTM to model the document, the hidden state of each token is $h _ { i } = \mathrm { L S T M } ( W _ { E } x _ { i } , h _ { i - 1 } )$ . We use a set $h ^ { e } = \{ h _ { 0 } ^ { e } , h _ { 1 } ^ { e } , . . . , h _ { M } ^ { e } \}$ to keep track of the entity states, where $h _ { j } ^ { e }$ is the state of entity $j$ .
164
+
165
+ um and $[ \mathrm { I l } _ { 1 }$ think that is whats - Go ahead [Linda]2. Well and thanks goes to $[ \mathrm { y o u l } _ { 1 }$ and to [the media]3 to help $[ \mathrm { u s } ] _ { 4 } . . . \mathrm { S o } [ \mathrm { o u r } ] _ { 4 }$ hat is off to all of [you]5...
166
+
167
+ ![](images/787f483a8556a3d8a8f59733ad85ae9b906c646cdc53288cac6b92ec15023293.jpg)
168
+ Figure 5: Coreference based language model, example taken from Wiseman et al. (2016).
169
+
170
+ Word generation: At each time step before generating the next word, we predict whether the word is an entity mention:
171
+
172
+ $$
173
+ \begin{array} { r l r } { { p ^ { \mathrm { c o r e f } } ( v _ { i } | h _ { i - 1 } , h ^ { e } ) = \mathrm { A T T N } ( h ^ { e } , h _ { i - 1 } ) , } } \\ & { } & { d _ { i } = \sum _ { v _ { i } } p ( v _ { i } ) h _ { v _ { i } } ^ { e } } \\ & { } & { p ( z _ { i } | h _ { i - 1 } ) = \mathrm { s i g m o i d } ( W [ d _ { i } , h _ { i - 1 } ] ) , } \end{array}
174
+ $$
175
+
176
+ where $z _ { i }$ denotes whether the next word is an entity and if yes $v _ { i }$ denotes which entity the next word corefers to. If the next word is an entity mention, then $p ( x _ { i } | v _ { i } , h _ { i - 1 } , h ^ { e } ) =$ softmax $( W _ { 1 } \operatorname { t a n h } ( W _ { 2 } [ h _ { v _ { i } } ^ { e } , h _ { i - 1 } ] ) )$ else $p ( x _ { i } | h _ { i - 1 } ) = \mathrm { s o f t m a x } ( W _ { 1 } h _ { i - 1 } )$ ,
177
+
178
+ $$
179
+ p ( x _ { i } | x _ { < i } ) = \left\{ \begin{array} { l l } { p ( x _ { i } | h _ { i - 1 } ) p ( z _ { i } | h _ { i - 1 } , h ^ { e } ) } & { \quad \mathrm { i f } \quad z _ { i } = 0 . } \\ { p ( x _ { i } | v _ { i } , h _ { i - 1 } , h ^ { e } ) p ^ { \mathrm { c o r e f } } ( v _ { i } | h _ { i - 1 } , h ^ { e } ) p ( z _ { i } | h _ { i - 1 } , h ^ { e } ) } & { \quad \mathrm { i f } \quad z _ { i } = 1 . } \end{array} \right.
180
+ $$
181
+
182
+ Entity state update: We update the entity state $h ^ { e }$ at each time step. In the beginning, $h ^ { e } = \{ h _ { 0 } ^ { e } \}$ , $h _ { 0 } ^ { e }$ denotes the state of an virtual empty entity and is a learnable variable. If $z _ { i } = 1$ and $v _ { i } = 0$ , then it indicates the next word is a new entity mention, then in the next step, we append $h _ { i }$ to $h ^ { e }$ , i.e., $h ^ { e } = \{ h ^ { e } , h _ { i } \}$ , if $e _ { i } > 0$ , then we update the corresponding entity state with the new hidden state, $h ^ { e } [ v _ { i } ] = h _ { i }$ . Another way to update the entity state is to use one LSTM to encode the mention states and get the new entity state. Here we use the latest entity mention state as the new entity state for simplicity. The detailed update process is shown in Figure 5.
183
+
184
+ # 3 EXPERIMENTS
185
+
186
+ # 4 DATA SETS AND PREPROCESSING
187
+
188
+ Dialogue: We use the DSTC2 data set. We only extracted the dialogue transcript from data set. There are about 3,200 dialogues in total. Since this is a small data set, we use 5-fold cross validation and report the average result over the 5 partitions. There may be multiple tokens in each table cell, for example in Table.2, the name, address, post code and phone number have multiple tokens, we replace them with one special token. For the name, address, post code and phone number of the $j$ -th row, we replace the tokens in each cell with NAME $j$ , ADDR $j$ , POSTCODE $j$ , PHONE $j$ . If a table cell is empty, we replace it with an empty token EMPTY. We do a string match in the transcript and replace the corresponding tokens in transcripts from the table with the special tokens.
189
+
190
+ Each dialogue on average has 8 turns (16 sentences). We use a vocabulary size of 900, including about 400 table tokens and 500 words.
191
+
192
+ Recipes: We crawl all recipes from www.allrecipes.com. There are about 31, 000 recipes in total, and every recipe has a ingredient list and a corresponding recipe. We exclude the recipes that have less than 10 tokens or more than 500 tokens, those recipes take about $0 . 1 \%$ of all data set. On average each recipe has 118 tokens and 9 ingredients. We random shuffle the whole data set and take $80 \%$ as training and $10 \%$ for validation and test. We use a vocabulary size of 10,000 in the model.
193
+
194
+ Coref LM: We use the Xinhua News data set from Gigaword Fifth Edition and sample 100,000 documents from it that has length in range from 100 to 500. Each document has on average 234 tokens, so there are 23 million tokens in total. We use a tool to annotate all the entity mentions and use the annotation in the training. We take $80 \%$ as training and $10 \%$ as validation and test respectively. We ignore the entities that have only one mention and for the mentions that have multiple tokens, we take the token that is most frequent in the all the mentions for this entity. After the preprocessing, tokens that are entity mentions take about $10 \%$ of all tokens. We use a vocabulary size of 50,000 in the model.
195
+
196
+ # 4.1 MODEL TRAINING AND EVALUATION
197
+
198
+ We train all models with simple stochastic gradient descent with clipping. We use a one-layer LSTM for all RNN components. Hyper-parameters are selected using grid search based on the validation set. We use dropout after the input embedding and LSTM output. The learning rate is selected from [0.1, 0.2, 0.5, 1], maximum gradient norm is selected from [1, 2, 5, 10] and drop ratio is selected from [0.2, 0.3, 0.5]. The batch size and LSTM dimension size is slightly different for different tasks so as to make the model fit into memory. The number of epochs to train are different for each task and we drop the learning rate after reaching a given number of epochs. We report the per-word perplexity for all tasks, specifically, we report the perplexity of all words, words that can be generated from reference and non-reference words. For recipe generation, we also generate the recipe using beam size of 10 and evaluate the generated recipe with BLEU.
199
+
200
+ <table><tr><td>model</td><td>all</td><td>table</td><td>table oov</td><td>word</td></tr><tr><td>seq2seq</td><td>1.35±0.01</td><td>4.98±0.38</td><td>1.99E7±7.75E6</td><td>1.23±0.01</td></tr><tr><td>table attn</td><td>1.37±0.01</td><td>5.09±0.64</td><td>7.91E7±1.39E8</td><td>1.24±0.01</td></tr><tr><td>table pointer</td><td>1.33±0.01</td><td>3.99±0.36</td><td>1360 ± 2600</td><td>1.23±0.01</td></tr><tr><td>table latent</td><td>1.36±0.01</td><td>4.99±0.20</td><td>3.78E7±6.08E7</td><td>1.24±0.01</td></tr><tr><td colspan="5">+ sentence attn</td></tr><tr><td>seq2seq</td><td>1.28±0.01</td><td>3.31±0.21</td><td>2.83E9±4.69E9</td><td>1.19±0.01</td></tr><tr><td>table attn</td><td>1.28±0.01</td><td>3.17±0.21</td><td>1.67E7±9.5E6</td><td>1.20±0.01</td></tr><tr><td>table pointer</td><td>1.27±0.01</td><td>2.99±0.19</td><td>82.86±110</td><td>1.20±0.01</td></tr><tr><td>table latent</td><td>1.28±0.01</td><td>3.26±0.25</td><td>1.27E7±1.41E7</td><td>1.20±0.01</td></tr></table>
201
+
202
+ Table 4: Dialogue perplexity results. (All means all tokens, table means tokens from table, table oov denotes table tokens that does not appear in the training set, word means non-table tokens). sentence attn denotes we use attention mechanism over tokens from past turn. Table pointer and table latent differs in that table pointer, we provide supervised signal on when to generate a table token, while in table latent it is a latent decision.
203
+
204
+ <table><tr><td rowspan="3">model</td><td colspan="4">val</td><td colspan="4">test</td></tr><tr><td colspan="3">ppl</td><td rowspan="2">BLEU</td><td colspan="3">ppl</td><td rowspan="2">BLEU</td></tr><tr><td>all</td><td>ing</td><td>word</td><td>all</td><td>ing</td><td>word</td></tr><tr><td>seq2seq</td><td>5.60</td><td>11.26</td><td>5.00</td><td>14.07</td><td>5.52</td><td>11.26</td><td>4.91</td><td>14.39</td></tr><tr><td>attn</td><td>5.25</td><td>6.86</td><td>5.03</td><td>14.84</td><td>5.19</td><td>6.92</td><td>4.95</td><td>15.15</td></tr><tr><td>pointer</td><td>5.15</td><td>5.86</td><td>5.04</td><td>15.06</td><td>5.11</td><td>6.04</td><td>4.98</td><td>15.29</td></tr><tr><td>latent</td><td>5.02</td><td>5.10</td><td>5.01</td><td>14.87</td><td>4.97</td><td>5.19</td><td>4.94</td><td>15.41</td></tr></table>
205
+
206
+ Table 5: Recipe result, evaluated in perplexity and BLEU score. ing denotes tokens from recipe that appear in ingredients.
207
+
208
+ <table><tr><td rowspan="2">model</td><td colspan="3">val</td><td colspan="3">test</td></tr><tr><td>all</td><td>entity</td><td>word</td><td>all</td><td>entity</td><td>word</td></tr><tr><td>lm</td><td>33.08</td><td>44.52</td><td>32.04</td><td>33.08</td><td>43.86</td><td>32.10</td></tr><tr><td>pointer</td><td>32.57</td><td>32.07</td><td>32.62</td><td>32.62</td><td>32.07</td><td>32.69</td></tr><tr><td>pointer +init</td><td>30.43</td><td>28.56</td><td>30.63</td><td>30.42</td><td>28.56</td><td>30.66</td></tr></table>
209
+
210
+ Table 6: Coreference based LM. pointer $^ +$ init means we initialize the model with the LM weights.
211
+
212
+ # 4.2 RESULTS AND ANALYSIS
213
+
214
+ The results for dialogue, recipe generation and coref language model are shown in Table 4, 5 and 6 respectively. We can see from Table 4 that models that condition on table performs better in predicting table tokens in general. Table pointer has the lowest perplexity for token in the table. Since the table token appears rarely in the dialogue, the overall perplexity does not differ much and the non-table tokens perplexity are similar. With attention mechanism over the table, the perplexity of table token improves over basic seq2seq model, but not as good as directly pointing to cells in the table. As expected, using sentence attention improves significantly over models without sentence attention. Surprisingly, table latent performs much worse than table pointer. We also measure the perplexity of table tokens that appear only in test set. For models other than table pointer, because the tokens never appear in training set, the perplexity is quite high, while table pointer can predict these tokens much more accurately. The recipe results in Table 5 in general follows that findings from the dialogue. But the latent model performs better than pointer model since that tokens in ingredients that match with recipe does not necessarily come from the ingredients. Imposing a supervised signal will give wrong information to the model and hence make the result worse. Hence with latent decision, the model learns to when to copy and when to generate it from the vocabulary. The coref LM results are shown in Table 6. We find that coref based LM performs much better on the entities perplexities, but however is a little bit worse than for non-entity words. We found it is an optimization problem and perhaps the model is stuck in local optimum. So we initialize the pointer model with the weights learned from LM, the pointer model performs better than LM both for entity perplexity and non-entity words perplexity.
215
+
216
+ # 5 RELATED WORK
217
+
218
+ Recently, there has been great progresses in modeling languages based on neural network, including language modeling (Mikolov et al., 2010; Jozefowicz et al., 2016), machine translation (Sutskever et al., 2014; Bahdanau et al., 2014), question answering (Hermann et al., 2015) etc. Based on the success of seq2seq models, neural networks are applied in modeling chit-chat dialogue (Li et al., 2016; Vinyals & Le, 2015; Sordoni et al., 2015; Serban et al., 2016; Shang et al., 2015) and task oriented dialogue (Wen et al., 2015; Bordes & Weston, 2016; Williams & Zweig, 2016; Wen et al., 2016). Most of the chit-chat neural dialogue models are simply applying the seq2seq models. For the task oriented dialogues, most of them embed the seq2seq model in traditional dialogue systems, in which the table query part is not differentiable. while our model queries the database directly. Recipe generation was proposed in (Kiddon et al., 2016). Their model extents previous work on attention models (Allamanis et al., 2016) to checklists, whereas our work models explicit references to those checklists. Context dependent language models (Mikolov et al., 2010; Ji et al., 2015; Wang & Cho, 2015) are proposed to capture long term dependency of text. There are also lots of works on coreference resolution (Haghighi & Klein, 2010; Wiseman et al., 2016). We are the first to combine coreference with language modeling, to the best of our knowledge. Much effort has been invested in embedding a copying mechanism for neural models (Gulc¸ehre et al. ¨ , 2016; Gu et al., 2016; Ling et al., 2016). In general, a gating mechanism is employed to combine the softmax over observed words and a pointer network (Vinyals et al., 2015). These gates can be trained either by marginalizing over both outcomes, or using heuristics (e.g. copy low frequency words). Our models are similar to models proposed in (Ahn et al., 2016; Merity et al., 2016), where the generation of each word can be conditioned on a particular entry in knowledge lists and previous words. In our work, we describe a model with broader applications, allowing us to condition, on databases, lists and dynamic lists.
219
+
220
+ # 6 CONCLUSION
221
+
222
+ We introduce reference-aware language models which explicitly model the decision of from where to generate the token at each step. Our model can also learns the decision by treating it as a latent variable. We demonstrate on three tasks, table based dialogue modeling, recipe generation and coref based LM, that our model performs better than attention based model, which does not incorporate this decision explicitly. There are several directions to explore further based on our framework. The current evaluation method is based on perplexity and BLEU. In task oriented dialogues, we can also try human evaluation to see if the model can reply users’ query accurately. It is also interesting to use reinforcement learning to learn the actions in each step.
223
+
224
+ # REFERENCES
225
+
226
+ Sungjin Ahn, Heeyoul Choi, Tanel Parnamaa, and Yoshua Bengio. A neural knowledge language ¨ model. CoRR, abs/1608.00318, 2016.
227
+
228
+ Miltiadis Allamanis, Hao Peng, and Charles A. Sutton. A convolutional attention network for extreme summarization of source code. CoRR, abs/1602.03001, 2016. URL http://arxiv. org/abs/1602.03001.
229
+
230
+ Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. CoRR, abs/1409.0473, 2014. URL http://arxiv.org/ abs/1409.0473.
231
+
232
+ Antoine Bordes and Jason Weston. Learning end-to-end goal-oriented dialog. arXiv preprint arXiv:1605.07683, 2016.
233
+
234
+ Jiatao Gu, Zhengdong Lu, Hang Li, and Victor O. K. Li. Incorporating copying mechanism in sequence-to-sequence learning. CoRR, abs/1603.06393, 2016. URL http://arxiv.org/ abs/1603.06393.
235
+
236
+ C¸ aglar Gulc¸ehre, Sungjin Ahn, Ramesh Nallapati, Bowen Zhou, and Yoshua Bengio. Pointing ¨ the unknown words. CoRR, abs/1603.08148, 2016. URL http://arxiv.org/abs/1603. 08148.
237
+
238
+ Aria Haghighi and Dan Klein. Coreference resolution in a modular, entity-centered model. In Human Language Technologies: The 2010 Annual Conference of the North American Chapter of the Association for Computational Linguistics, pp. 385–393. Association for Computational Linguistics, 2010.
239
+
240
+ Matthew Henderson, Blaise Thomson, and Jason Williams. Dialog state tracking challenge 2 & 3, 2014.
241
+
242
+ Karl Moritz Hermann, Tomas Kocisky, Edward Grefenstette, Lasse Espeholt, Will Kay, Mustafa Suleyman, and Phil Blunsom. Teaching machines to read and comprehend. In Advances in Neural Information Processing Systems, pp. 1693–1701, 2015.
243
+
244
+ Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural Comput., 9(8):1735– 1780, November 1997. ISSN 0899-7667. doi: 10.1162/neco.1997.9.8.1735. URL http://dx. doi.org/10.1162/neco.1997.9.8.1735.
245
+
246
+ Yangfeng Ji, Trevor Cohn, Lingpeng Kong, Chris Dyer, and Jacob Eisenstein. Document context language models. arXiv preprint arXiv:1511.03962, 2015.
247
+
248
+ Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring the limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.
249
+
250
+ Chloe Kiddon, Luke Zettlemoyer, and Yejin Choi. Globally coherent text generation with neural ´ checklist models. In Proc. EMNLP, 2016.
251
+
252
+ Jiwei Li, Will Monroe, Alan Ritter, Michel Galley, Jianfeng Gao, and Dan Jurafsky. Deep reinforcement learning for dialogue generation. In Proc. EMNLP, 2016.
253
+
254
+ Wang Ling, Edward Grefenstette, Karl Moritz Hermann, Toma´s Ko ˇ cisk ˇ y, Andrew Senior, Fumin ´ Wang, and Phil Blunsom. Latent predictor networks for code generation. In Proc. ACL, 2016.
255
+
256
+ Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. arXiv preprint arXiv:1609.07843, 2016.
257
+
258
+ Tomas Mikolov, Martin Karafiat, Lukas Burget, Jan Cernock ´ y, and Sanjeev Khudanpur. Recurrent \` neural network based language model. In Interspeech, volume 2, pp. 3, 2010.
259
+
260
+ Iulian V Serban, Alessandro Sordoni, Yoshua Bengio, Aaron Courville, and Joelle Pineau. Building end-to-end dialogue systems using generative hierarchical neural network models. In Proceedings of the 30th AAAI Conference on Artificial Intelligence (AAAI-16), 2016.
261
+
262
+ Lifeng Shang, Zhengdong Lu, and Hang Li. Neural responding machine for short-text conversation. arXiv preprint arXiv:1503.02364, 2015.
263
+
264
+ Alessandro Sordoni, Michel Galley, Michael Auli, Chris Brockett, Yangfeng Ji, Meg Mitchell, JianYun Nie, Jianfeng Gao, and Bill Dolan. A neural network approach to context-sensitive generation of conversational responses. In Proc. NAACL, 2015.
265
+
266
+ Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. In Advances in neural information processing systems, pp. 3104–3112, 2014.
267
+
268
+ Oriol Vinyals and Quoc V. Le. A neural conversational model. In Proc. ICML Deep Learning Workshop, 2015.
269
+
270
+ Oriol Vinyals, Meire Fortunato, and Navdeep Jaitly. Pointer networks. In Proc. NIPS, 2015.
271
+
272
+ Tian Wang and Kyunghyun Cho. Larger-context language modelling. arXiv preprint arXiv:1511.03729, 2015.
273
+
274
+ Tsung-Hsien Wen, Milica Gasic, Nikola Mrksic, Pei-hao Su, David Vandyke, and Steve J. Young. Semantically conditioned LSTM-based natural language generation for spoken dialogue systems. In Proc. EMNLP, 2015.
275
+
276
+ Tsung-Hsien Wen, Milica Gasic, Nikola Mrksic, Lina M Rojas-Barahona, Pei-Hao Su, Stefan Ultes, David Vandyke, and Steve Young. A network-based end-to-end trainable task-oriented dialogue system. arXiv preprint arXiv:1604.04562, 2016.
277
+
278
+ Jason D Williams and Geoffrey Zweig. End-to-end lstm-based dialog control optimized with supervised and reinforcement learning. arXiv preprint arXiv:1606.01269, 2016.
279
+
280
+ Sam Wiseman, Alexander M Rush, and Stuart M Shieber. Learning global features for coreference resolution. arXiv preprint arXiv:1604.03035, 2016.
281
+
282
+ Steve Young, Milica Gasiˇ c, Blaise Thomson, and Jason D Williams. Pomdp-based statistical spoken ´ dialog systems: A review. Proceedings of the IEEE, 101(5):1160–1179, 2013.
283
+
284
+ # A VISUALIZATION
285
+
286
+ M: Hello , welcome to the Cambridge restaurant system ? You can ask for restaurants by area , price range or food type . How may I help you ?
287
+ U: and expensive restaurant that serves tuscan food
288
+ M: Sorry there is no tuscan restaurant in the expensive price range
289
+ U: french food
290
+ M: cote is a great restaurant serving french food and it is in the expensive price range
291
+ U: may i have the phone number
292
+ M: The phone number of cote is 01223 311053 .
293
+ U: thank you good bye
294
+ M: Hello , welcome to the Cambridge restaurant system ? You can ask for restaurants by area , price range or food type . How may I help you ?
295
+ U: cheap restaurant
296
+ M: What kind of food would you like ?
297
+ U: in the west part of town
298
+ M: la margherita is a nice restaurant in the west of town in the cheap price range
299
+ U: address
300
+ M: Sure , la margherita is on 15 Magdalene Street City Centre
301
+ U: thank you
302
+ M: la margherita is a nice restaurant in the west of town in the cheap price range
303
+ U: good bye
304
+
305
+ (a) Dialogue script
306
+
307
+ <table><tr><td rowspan=1 colspan=1>NAME</td><td rowspan=1 colspan=1>PRICE RANGE</td><td rowspan=1 colspan=1>FOOD</td><td rowspan=1 colspan=1>AREA</td><td rowspan=1 colspan=1>ADDRESS</td><td rowspan=1 colspan=1>POST CODE</td><td rowspan=1 colspan=1>PHONE</td></tr><tr><td rowspan=1 colspan=1>charlie chan</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>chinese</td><td rowspan=1 colspan=1>east</td><td rowspan=1 colspan=1>Regent Street City Cen-tre</td><td rowspan=1 colspan=1>C.B 2, 1 D.B</td><td rowspan=1 colspan=1>01223 361763</td></tr><tr><td rowspan=1 colspan=1>chiquito restau-rant bar</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>mexican</td><td rowspan=1 colspan=1>south</td><td rowspan=1 colspan=1>2G Cambridge LeisurePark Cherry HintonRoad Cherry Hinton</td><td rowspan=1 colspan=1>C.B 1,7D.Y</td><td rowspan=1 colspan=1>01223 400170</td></tr><tr><td rowspan=1 colspan=1>city stop</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>food</td><td rowspan=1 colspan=1>north</td><td rowspan=1 colspan=1>Cambridge City Foot-ball Club Milton RoadChesterton</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 363270</td></tr><tr><td rowspan=1 colspan=1>clowns cafe</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>italian</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>C.B 1,1 L.N</td><td rowspan=1 colspan=1>01223 355711</td></tr><tr><td rowspan=1 colspan=1>cocum</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>west</td><td rowspan=1 colspan=1>71 CastleStreet CityCentre</td><td rowspan=1 colspan=1>C.B 3,0 A.H</td><td rowspan=1 colspan=1>01223 366668</td></tr><tr><td rowspan=1 colspan=1>cote</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>french</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>Bridge Street City Cen-tre</td><td rowspan=1 colspan=1>C.B 2, 1U.F</td><td rowspan=1 colspan=1>01223 311053</td></tr><tr><td rowspan=1 colspan=1> curry garden</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>106 Regent Street CityCentre</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 302330</td></tr><tr><td rowspan=1 colspan=1>curry king</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>5Jordans Yard BridgeStreet City Centre</td><td rowspan=1 colspan=1>C.B 1,2 B.D</td><td rowspan=1 colspan=1>01223 324351</td></tr><tr><td rowspan=1 colspan=1>curry prince</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>east</td><td rowspan=1 colspan=1>451 Newmarket RoadFen Ditton</td><td rowspan=1 colspan=1>C.B 5, 8 J.J</td><td rowspan=1 colspan=1>01223 566388</td></tr></table>
308
+
309
+ (b) Attention heat map: cote is a great restaurant serving french food and it is in the expensive price range.
310
+ Table 7: Dialogue visualization 1
311
+
312
+ <table><tr><td rowspan=1 colspan=1>NAME</td><td rowspan=1 colspan=1>PRICERANGE</td><td rowspan=1 colspan=1>FOOD</td><td rowspan=1 colspan=1>AREA</td><td rowspan=1 colspan=1>ADDRESS</td><td rowspan=1 colspan=1>POST CODE</td><td rowspan=1 colspan=1>PHONE</td></tr><tr><td rowspan=1 colspan=1>charlie chan</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>chinese</td><td rowspan=1 colspan=1>east</td><td rowspan=1 colspan=1>Regent Street City Cen-tre</td><td rowspan=1 colspan=1>C.B 2,1 D.B</td><td rowspan=1 colspan=1>01223 361763</td></tr><tr><td rowspan=1 colspan=1>chiquito restau-rant bar</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>mexican</td><td rowspan=1 colspan=1>south</td><td rowspan=1 colspan=1>2G Cambridge LeisurePark Cherry HintonRoad CherryHinton</td><td rowspan=1 colspan=1>C.B 1,7D.Y</td><td rowspan=1 colspan=1>01223 400170</td></tr><tr><td rowspan=1 colspan=1>city stop</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>food</td><td rowspan=1 colspan=1>north</td><td rowspan=1 colspan=1>Cambridge City Foot-ball Club Milton RoadChesterton</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 363270</td></tr><tr><td rowspan=1 colspan=1>clowns cafe</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>italian</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>C.B1, 1 L.N</td><td rowspan=1 colspan=1>01223 355711</td></tr><tr><td rowspan=1 colspan=1>cocum</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>west</td><td rowspan=1 colspan=1>71 CastleStreet CityCentre</td><td rowspan=1 colspan=1>C.B 3,0 A.H</td><td rowspan=1 colspan=1>01223 366668</td></tr><tr><td rowspan=1 colspan=1>cote</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>french</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>Bridge Street City Cen-tre</td><td rowspan=1 colspan=1>C.B 2,1 U.F</td><td rowspan=1 colspan=1>01223 311053</td></tr><tr><td rowspan=1 colspan=1>curry garden</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>106 Regent Street CityCentre</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223302330</td></tr><tr><td rowspan=1 colspan=1> curry king</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>5Jordans Yard BridgeStreet City Centre</td><td rowspan=1 colspan=1>C.B1,2 B.D</td><td rowspan=1 colspan=1>01223 324351</td></tr><tr><td rowspan=1 colspan=1>curry prince</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>east</td><td rowspan=1 colspan=1>451 Newmarket RoadFen Ditton</td><td rowspan=1 colspan=1>C.B 5, 8 J.J</td><td rowspan=1 colspan=1>01223 566388</td></tr></table>
313
+
314
+ (c) Attention heap map: The phone number of cote is 01223 311053 .
315
+
316
+ (a) Dialogue script
317
+
318
+ <table><tr><td rowspan=1 colspan=1>NAME</td><td rowspan=1 colspan=1>PRICE RANGE</td><td rowspan=1 colspan=1>FOOD</td><td rowspan=1 colspan=1>AREA</td><td rowspan=1 colspan=1>ADDRESS</td><td rowspan=1 colspan=1>POST CODE</td><td rowspan=1 colspan=1>PHONE</td></tr><tr><td rowspan=1 colspan=1>india house</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>west</td><td rowspan=1 colspan=1>31Newnham RoadNewnham</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 461661</td></tr><tr><td rowspan=1 colspan=1>j restaurant</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>oriental</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>86Regent Street CityCentre</td><td rowspan=1 colspan=1>C.B 2,1 D.P</td><td rowspan=1 colspan=1>01223 307581</td></tr><tr><td rowspan=1 colspan=1>jinlingnoodlebar</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>chinese</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>11 Peas Hill City Cen-tre</td><td rowspan=1 colspan=1>C.B 2, 3 P.P</td><td rowspan=1 colspan=1>01223 566188</td></tr><tr><td rowspan=1 colspan=1>kohinoor</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>74 Mill Road City Cen-tre</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 323639</td></tr><tr><td rowspan=1 colspan=1>kymmoy</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>oriental</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1> 52 Mill Road City Cen-tre</td><td rowspan=1 colspan=1>C.B 1,2 A.S</td><td rowspan=1 colspan=1>01223 311911</td></tr><tr><td rowspan=1 colspan=1>la margherita</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>italian</td><td rowspan=1 colspan=1>west</td><td rowspan=1 colspan=1>15MagdaleneStreetCity Centre</td><td rowspan=1 colspan=1>C.B 3,0 A.F</td><td rowspan=1 colspan=1>01223 315232</td></tr><tr><td rowspan=1 colspan=1>la mimosa</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>mediterranean</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>ThompsonsLane FenDitton</td><td rowspan=1 colspan=1>C.B 5,8 A.Q</td><td rowspan=1 colspan=1>01223 362525</td></tr><tr><td rowspan=1 colspan=1>la raza</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>spanish</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>4-6Rose Crescent</td><td rowspan=1 colspan=1>C.B 2, 3L.L</td><td rowspan=1 colspan=1>01223 464550</td></tr><tr><td rowspan=1 colspan=1>la tasca</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>spanish</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>14 -16 Bridge Street</td><td rowspan=1 colspan=1>C.B 2,1U.F</td><td rowspan=1 colspan=1>01223464630</td></tr><tr><td rowspan=1 colspan=1>lan hong house</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>chinese</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>12 Norfolk Street CityCentre</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 350420</td></tr></table>
319
+
320
+ (b) Attention heat map: la margherita is a nice restaurant in the west of town in the cheap price range
321
+ Table 8: Dialogue visualization 2
322
+
323
+ <table><tr><td rowspan=1 colspan=1>NAME</td><td rowspan=1 colspan=1>PRICE RANGE</td><td rowspan=1 colspan=1>FOOD</td><td rowspan=1 colspan=1>AREA</td><td rowspan=1 colspan=1>ADDRESS</td><td rowspan=1 colspan=1>POST CODE</td><td rowspan=1 colspan=1>PHONE</td></tr><tr><td rowspan=1 colspan=1>india house</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>west</td><td rowspan=1 colspan=1>311Newnham RoadNewnham</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 461661</td></tr><tr><td rowspan=1 colspan=1>jrestaurant</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>oriental</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>86RegentStreet CityCentre</td><td rowspan=1 colspan=1>C.B 2, 1 D.P</td><td rowspan=1 colspan=1>01223 307581</td></tr><tr><td rowspan=1 colspan=1> jinlingnoodlebar</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>chinese</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>11 Peas Hill City Cen-tre</td><td rowspan=1 colspan=1>C.B 2, 3 P.P</td><td rowspan=1 colspan=1>01223 566188</td></tr><tr><td rowspan=1 colspan=1>kohinoor</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>indian</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>74 Mill Road City Cen-tre</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 323639</td></tr><tr><td rowspan=1 colspan=1>kymmoy</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>oriental</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1> 52 Mill Road City Cen-tre</td><td rowspan=1 colspan=1>C.B 1,2 A.S</td><td rowspan=1 colspan=1>01223 311911</td></tr><tr><td rowspan=1 colspan=1>la margherita</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>italian</td><td rowspan=1 colspan=1>west</td><td rowspan=1 colspan=1> 15 MagdaleneStreetCity Centre</td><td rowspan=1 colspan=1>C.B 3,0 A.F</td><td rowspan=1 colspan=1>01223 315232</td></tr><tr><td rowspan=1 colspan=1>la mimosa</td><td rowspan=1 colspan=1>expensive</td><td rowspan=1 colspan=1>mediterranean</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>ThompsonsLane FenDitton</td><td rowspan=1 colspan=1>C.B 5, 8 A.Q</td><td rowspan=1 colspan=1>01223 362525</td></tr><tr><td rowspan=1 colspan=1>la raza</td><td rowspan=1 colspan=1>cheap</td><td rowspan=1 colspan=1>spanish</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>4 -6 Rose Crescent</td><td rowspan=1 colspan=1>C.B 2, 3 L.L</td><td rowspan=1 colspan=1>01223 464550</td></tr><tr><td rowspan=1 colspan=1>la tasca</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>spanish</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>14-16 Bridge Street</td><td rowspan=1 colspan=1>C.B 2, 1 U.F</td><td rowspan=1 colspan=1>01223 464630</td></tr><tr><td rowspan=1 colspan=1>lan hong house</td><td rowspan=1 colspan=1>moderate</td><td rowspan=1 colspan=1>chinese</td><td rowspan=1 colspan=1>centre</td><td rowspan=1 colspan=1>12 Norfolk Street CityCentre</td><td rowspan=1 colspan=1>EMPTY</td><td rowspan=1 colspan=1>01223 350420</td></tr></table>
324
+
325
+ (c) Attention heap map: Sure , la margherita is on 15 Magdalene Street City Centre.
326
+
327
+ ![](images/5c040a0339d10ef5db2a8c0736a89dc5f36207d727dc95cefe05eff4a67e065b.jpg)
328
+ Figure 6: Recipe heat map example 1. The ingredient tokens appear on the left while the recipe tokens appear on the top. The first row is the $p \big ( \bar { z } _ { v } | s _ { v } \big )$ .
329
+
330
+ ![](images/540e5f6a28797252925d3445abfb72ca056f1c0a464097561f7c4b5ff011b8df.jpg)
331
+ Figure 7: Recipe heat map example 2.
md/train/CoJibBRjPXQ/CoJibBRjPXQ.md ADDED
@@ -0,0 +1,509 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Distributional Generalization: Characterizing Classifiers Beyond Test Error
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 We present a new set of empirical properties of interpolating classifiers, includ
11
+ 2 ing neural networks, kernel machines and decision trees. Informally, the output
12
+ 3 distribution of an interpolating classifier matches the distribution of true labels,
13
+ 4 when conditioned on certain subgroups of the input space. For example, if we
14
+ 5 mislabel $30 \%$ of dogs as cats in the train set of CIFAR-10, then a ResNet trained
15
+ 6 to interpolation will in fact mislabel roughly $30 \%$ of dogs as cats on the test set
16
+ 7 as well, while leaving other classes unaffected. These behaviors are not captured
17
+ 8 by classical generalization, which would only consider the average error over
18
+ 9 the inputs, and not where these errors occur. We introduce and experimentally
19
+ 10 validate a formal conjecture that specifies the subgroups for which we expect this
20
+ 11 distributional closeness. Further, we show that these properties can be seen as a
21
+ 12 new form of generalization, which advances our understanding of the implicit bias
22
+ 13 of interpolating methods.
23
+
24
+ # 14 1 Introduction
25
+
26
+ 15 In learning theory, when we study how well a classifier “generalizes”, we usually consider a single
27
+ 16 metric – its test error $\mathbb { \left. \boldsymbol { \mathsf { E 9 } } \right. }$ . However, there could be many different classifiers with the same test error
28
+ 17 that differ substantially in, say, the subgroups of inputs on which they make errors or in the features
29
+ 18 they use to attain this performance. Reducing classifiers to a single number misses these rich aspects
30
+ 19 of their behavior. In this work, we propose formally studying the entire joint distribution of classifier
31
+ 20 inputs and outputs. That is, the distribution $( x , f ( { \overset { \cdot } { x } } ) )$ for samples from the distribution $x \sim D$ for a
32
+ 21 classifier $f ( x )$ . This distribution reveals many structural properties of the classifier beyond test error
33
+ 22 (such as where the errors occur). In fact, we discover new behaviors of modern classifiers that can
34
+ 23 only be understood in this framework. As an example, consider the following experiment (Figure 1).
35
+ 24 Experiment 1. Consider a binary classification version of CIFAR-10, where CIFAR-10 images $x$
36
+ 25 have binary labels Animal/Object. Take 50K samples from this distribution as a train set, but
37
+ 26 apply the following label noise: flip the label of cats to Object with probability $30 \%$ . Now train
38
+ 27 a WideResNet $f$ to 0 train error on this train set. How does the trained classifier behave on test
39
+ 28 samples? Options below:
40
+
41
+ 29 (1) The test error is low across all classes, since there is only $3 \%$ overall label noise in the train set.
42
+
43
+ 30 (2) Test error is “spread” across the animal class. After all, the classifier is not explicitly told what a
44
+ 31 cat or a dog is, just that they are all animals.
45
+ 32 (3) The classifier misclassifies roughly $30 \%$ of test cats as “objects”, but all other animals are largely
46
+ 33 unaffected.
47
+ 34 The reality is closest to option (3) as shown in Figure $\mathbb { \underline { { \Pi } } }$ The left panel shows the joint density of
48
+ 35 train inputs $x$ with train labels Object/Animal. Since the classifier is interpolating, the classifier
49
+ 36 outputs on the train set are identical to the left panel. The right panel shows the classifier predictions
50
+ 37 $f ( \bar { x } )$ on test inputs $x$ .
51
+ 38 There are several notable things about this experiment. First, the error is localized to cats in the test
52
+ 39 set as it was in the train set, even though no explicit cat labels were provided. The interpolating
53
+ 40 model is thus sensitive to subgroup-structures in the distribution. Second, the amount of error on
54
+ 41 the cat class is close to the noise applied on the train set. Thus, the behavior of the classifier on the
55
+ 42 train set generalizes to the test set in a stronger sense than just average error. Specifically, when
56
+ 43 conditioned on a subgroup (cat), the distribution of the true labels is close to that of the classifier
57
+ 44 outputs. Third, this is not the behavior of the Bayes-optimal classifier, which would always output
58
+ 45 the maximum-likelihood label instead of reproducing the noise in the distribution. The network
59
+ 46 is thus behaving poorly from the perspective of Bayes-optimality, but behaving well in a certain
60
+ 47 distributional sense (which we will formalize soon).
61
+ 48 Now, consider a seemingly unrelated experimental observation. Take an AlexNet trained on ImageNet,
62
+ 49 a 1000-way classification problem with 116 varieties of dogs. AlexNet only achieves $56 . 5 \%$ test
63
+ 50 accuracy on ImageNet. However, it at least classifies most dogs as some variety of dog (with $9 8 . 4 \%$
64
+ 51 accuracy), though it may mistake the exact breed. In this work, we show that both of these experiments
65
+ 52 are examples of the same underlying phenomenon. We empirically show that for an interpolating
66
+ 53 classifier, its classification outputs are close in distribution to the true labels — even when conditioned
67
+ 54 on many subsets of the domain. For example, in Figure 1, the distribution of $p ( f ( x ) | x = \mathrm { c a t } )$ is close
68
+ 55 to the true label distribution of $p ( y | x = \mathrm { c a t } )$ . We propose a formal conjecture (Feature Calibration),
69
+ 56 that predicts which subgroups of the domain can be conditioned on for the above distributional
70
+ 57 closeness to hold.
71
+ 58 These experimental behaviors could not have been captured solely by looking at average test error,
72
+ 59 as is done in the classical theory of generalization. In fact, they are special cases of a new kind of
73
+ 60 generalization, which we call “Distributional Generalization”.
74
+
75
+ ![](images/beb9208b2ea626ae58269efe27de7f9a751af1070e33cc6b87154a22c4bb5b6a.jpg)
76
+ Figure 1: The setup and result of Experiment 1. The CIFAR-10 train set is labeled as either Animals or Objects, with label noise affecting only cats. A WideResNet-28-10 is then trained to 0 train error on this train set, and evaluated on the test set. Full experimental details in Appendix C.2
77
+
78
+ # 61 1.1 Distributional Generalization
79
+
80
+ 62 Informally, Distributional Generalization states that the outputs of classifiers $f$ on their train sets 63 and test sets are close as distributions (as opposed to close in just error). That is, the following joint distributions1 64 are close:
81
+
82
+ $$
83
+ ( x , f ( x ) ) _ { x \sim \mathrm { T e s t S e t } } \approx ( x , f ( x ) ) _ { x \sim \mathrm { T r a i n S e t } }
84
+ $$
85
+
86
+ 65 The remainder of this paper is devoted to making the above statement precise, and empirically
87
+ 66 checking its validity on real-world tasks. Specifically, we want to formally define the notion of
88
+ 67 approximation $( \approx )$ , and understand how it depends on the problem parameters (the type of classifier,
89
+ 68 number of train samples, etc). We focus primarily on interpolating methods, where we formalize
90
+ 69 Equation $( 1 )$ through our Feature Calibration Conjecture.
91
+
92
+ # 70 1.2 Our Contributions and Organization
93
+
94
+ 71 In this work, we discover new empirical properties of interpolating classifiers, which are not captured
95
+ 72 in the classical framework of generalization. We then propose formal conjectures to characterize
96
+ 73 these behaviors.
97
+
98
+ • In Section $\textcircled { 3 }$ we introduce a formal “Feature Calibration” conjecture, which unifies our experimental observations. Roughly, Feature Calibration says that the outputs of classifiers match the statistics of their training distribution when conditioned on certain subgroups.
99
+ • In Section $\textcircled { 4 }$ we experimentally stress test our Feature Calibration conjecture across various settings in machine learning, including neural networks, kernel machines, and decision trees. This highlights the universality of our results across machine learning.
100
+ • In Section $5 ,$ we relate our results to classical generalization, by defining a new notion of Distributional Generalization which subsumes both classical generalization and our new conjectures.
101
+ • Finally, in Section $5 . 2$ we informally discuss how Distributional Generalization can be applied even for non-interpolating methods.
102
+
103
+ Our results, thus, extend our understanding of the implicit bias of interpolating methods, and introduce a new type of generalization exhibited across many methods in machine learning.
104
+
105
+ # 1.3 Related Work and Significance
106
+
107
+ Our work has connections to, and implications for many existing research programs in deep learning.
108
+
109
+ Implicit Bias and Overparameterization. There has been a long line of recent work towards understanding overparameterized and interpolating methods, since these pose challenges for classical theories of generalization (e.g. Belkin et al. [8, 9, 10], Breiman [11], Gunasekar et al. $\mathbb { \left[ \left. 2 5 \right] \right. }$ , Liang and Rakhlin $\boxed { \ B 6 }$ , Nakkiran et al. $\mathbb { \lVert \boldsymbol { 4 3 } \rVert }$ , Schapire et al. [58], Soudry et al. [62], Zhang et al. $\pmb { \mathbb { Z } 1 } \mathbf { l }$ ). The “implicit bias” program here aims to answer: Among all models with 0 train error, which model is actually produced by SGD? Most existing work seeks to characterize the exact implicit bias of models under certain (sometimes strong) assumptions on the model, training method or the data distribution. In contrast, our conjecture applies across many different interpolating models (from neural nets to decision trees) as they would be used in practice, and thus form a sort of “universal implicit bias” of these methods. Moreover, our results place constraints on potential future theories of implicit bias, and guide us towards theories that better capture practice.
110
+
111
+ 100 Benign Overfitting. Most prior works on interpolating classifiers attempt to explain why training
112
+ 101 to interpolation “does not harm” the the model. This has been dubbed “benign overfitting” [7] and
113
+ 102 “harmless interpolation” [40], reflecting the widely-held belief that interpolation does not harm the
114
+ 103 decision boundary of classifiers. In contrast, we find that interpolation actually does “harm” classifiers,
115
+ 104 in predictable ways: fitting the label noise on the train set causes similar noise to be reproduced at
116
+ 105 test time. Our results thus indicate that interpolation can significantly affect the decision boundary of
117
+ 106 classifiers, and should not be considered a purely “benign” effect.
118
+ 107 Classical Generalization and Scaling Limits. Our framework of Distributional Generalization is
119
+ 108 insightful even to study classical generalization, since it reveals much more about models than just
120
+ 109 their test error. For example, statistical learning theory attempts to understand if and when models
121
+ 110 will asymptotically converge to Bayes optimal classifiers, in the limit of large data (“asymptotic
122
+ 111 consistency” [59, $\dot { 6 5 } \|$ ). In deep learning, there are at least two distinct ways to scale model and data
123
+ 112 to infinity together: the underparameterized scaling limit, where data-size $\gg$ model-size always, and
124
+ 113 the overparameterized scaling limit, where data-size $\ll$ model-size always. The underparameterized
125
+ 114 scaling limit is well-understood: when data is essentially infinite, neural networks will converge to
126
+ 115 the Bayes-optimal classifier (provided the model-size is large enough, and the optimization is run
127
+ 116 for long enough, with enough noise to escape local minima). On the other hand, our work suggests
128
+ 117 that in the overparameterized scaling limit, models will not converge to the Bayes-optimal classifier.
129
+ 118 Specifically, our Feature Calibration Conjecture implies that in the limit of large data, interpolating
130
+ 119 models will approach a sampler from the distribution. That is, the limiting model $f$ will be such that
131
+ 120 the output $f ( x )$ is a sample from $p ( y | x )$ , as opposed to the Bayes-optimal $f ^ { * } ( x ) = \mathop { \mathrm { a r g m a x } } _ { y } p ( y | x )$ .
132
+ 121 This claim— that overparameterized models do not converge to Bayes-optimal classifiers— is unique
133
+ 122 to our work as far as we know, and highlights the broad implications of our results.
134
+ 123 Locality and Manifold Learning. Our intuition for the behaviors in this work is that they arise due to
135
+ 124 some form of “locality” of the trained classifiers, in an appropriate embedding space. For example, the
136
+ 125 behavior observed in Experiment $\perp$ would be consistent with that of a 1-Nearest-Neighbor classifier
137
+ 126 in a embedding that separates the CIFAR-10 classes well. This intuition that classifiers learn good
138
+ 127 embeddings is present in various forms in the literature, for example: the so-called called “manifold
139
+ 128 hypothesis,” that natural data lie on a low-dimensional manifold [44, 61], as well as works on local
140
+ 129 stiffness of the loss landscape $\mathbb { \lVert 1 9 \rVert }$ , and works showing that overparameterized neural networks can
141
+ 130 learn hidden low-dimensional structure in high-dimensional settings [6, 15, 21]. It is open to more
142
+ 131 formally understand connections between our work and the above.
143
+ 132 Other Related Works. Our conjectures also describe neural networks under label noise, which has
144
+ 133 been empirically and theoretically studied in the past [9, 14, 45, 54, 63, 71, 72], though not formally
145
+ 134 characterized. A full discussion of related works is in Appendix A.
146
+
147
+ # 135 2 Preliminaries
148
+
149
+ 136 Notation. We consider joint distributions $\mathcal { D }$ on $x \in \mathcal { X }$ and discrete $y \in \mathcal { y } = [ k ]$ . Let $S =$
150
+ 137 $\{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { n } \sim { \mathcal { D } } ^ { n }$ denote a train set of $n$ iid samples from $\mathcal { D }$ . Let $\mathcal { A }$ denote the training procedure
151
+ 138 (including architecture and training algorithm for neural networks), and let $f \gets \mathrm { T r a i n } _ { \mathcal { A } } ( S )$ denote
152
+ 139 training a classifier $f$ on train-set $S$ using procedure $\mathcal { A }$ . We consider classifiers which output hard
153
+ 140 decisions $f : \mathcal { X } \mathcal { Y }$ . Let $\mathrm { N N } _ { S } ( x ) = x _ { i }$ denote the nearest-neighbor to $x$ in train-set $S$ , with
154
+ 141 respect to a distance metric $d$ . Our theorems will apply to any distance metric, and so we leave
155
+ 142 this unspecified. Let $\mathrm { N N } _ { S } ^ { ( y ) } ( x )$ denote the nearest-neighbor estimator itself, that is, $\mathrm { N N } _ { S } ^ { ( y ) } ( x ) : = y _ { i }$
156
+ 143 where $x _ { i } = \mathrm { N N } _ { S } ( x )$ .
157
+ 144 Experimental Setup. Briefly, we train all classifiers to interpolation (to 0 train error). Neural
158
+ 145 networks (MLPs and ResNets $\mathbb { \oplus } \mathbb { I } ,$ ) are trained with SGD. Interpolating decision trees are trained
159
+ 146 using the growth rule from Random Forests $\mathbb { \lVert 1 2 \rVert }$ . For kernel classification, we consider kernel
160
+ 147 regression on one-hot labels and kernel SVM, with small or 0 of regularization (which is often
161
+ 148 optimal $\pmb { \mathbb { H } }$ ). Full experimental details are provided in Appendix B.
162
+ 149 Distributional Closeness. We consider the following notion of closeness for two probability dis
163
+ 150 tributions: For two distributions $P , Q$ over $\mathcal { X } \times \mathcal { V }$ , let a “test” (or “distinguisher”) be a function
164
+ 151 $T : \mathcal { X } \times \mathcal { Y } [ 0 , 1 ]$ which accepts a sample from either distribution, and is intended to classify the
165
+ 152 sample as either from distribution $P$ or $Q$ . For any set ${ \mathcal { C } } \subseteq \{ T : \mathcal { X } \times \mathcal { Y } \to [ 0 , 1 ] \}$ of tests, we say
166
+ 153 distributions $P$ and $Q$ are “ $\varepsilon$ -indistinguishable up to $\mathcal { C }$ -tests” if they are close with respect to all tests
167
+ 154 in class $\mathcal { C }$ . That is,
168
+
169
+ $$
170
+ P \approx _ { \varepsilon } ^ { \mathcal { C } } Q \longleftrightarrow \operatorname* { s u p } _ { T \in { \mathcal { C } } } \Big | \underset { ( x , y ) \sim P } { \mathbb { E } } [ T ( x , y ) ] - \underset { ( x , y ) \sim Q } { \mathbb { E } } [ T ( x , y ) ] \Big | \leq \varepsilon
171
+ $$
172
+
173
+ 155 Total-Variation distance is equivalent to closeness in all tests, i.e. $\mathcal { C } = \{ T : \mathcal { X } \times \mathcal { Y } [ 0 , 1 ] \}$ , but we
174
+ 156 consider closeness for restricted families of tests $\mathcal { C }$ . $P \approx _ { \varepsilon } Q$ denotes $\varepsilon$ -closeness in TV-distance.
175
+
176
+ # 3 Feature Calibration Conjecture
177
+
178
+ # 3.1 Distributions of Interest
179
+
180
+ 59 We first define three key distributions that we will use in stating our formal conjecture. For a given
181
+ 60 data distribution $\mathcal { D }$ over $\mathcal { X } \times \mathcal { V }$ and training procedure $\operatorname { T r a i n } _ { A }$ , we consider the following three
182
+ 61 distributions over $\mathcal { X } \times \mathcal { V }$ :
183
+ 1. Source D: $( x , y )$ where $x , y \sim \mathcal { D }$ .
184
+ 2. Train ${ \mathcal { D } } _ { \mathrm { t r } }$ : $( x _ { \mathrm { t r } } , f ( x _ { \mathrm { t r } } ) )$ where $S \sim \mathcal { D } ^ { n }$ $, f \mathrm { T r a i n } _ { \cal A } ( S ) , ( x _ { \mathrm { t r } } , y _ { \mathrm { t r } } ) \sim S$
185
+ 3. Test $\underline { { \mathcal { D } _ { \mathrm { t e } } \mathbf { : } } } \left( x , f ( x ) \right)$ where $S \sim \mathcal { D } ^ { n } , f \operatorname { T r a i n } _ { A } ( S ) , x , y \sim \mathcal { D }$
186
+ 165 The source distribution $\mathcal { D }$ is simply the original distribution. To sample once from the Train Dis
187
+ 166 tribution ${ \mathcal { D } } _ { \mathrm { t r } }$ , we first sample a train set $S \sim \mathcal { D } ^ { n }$ , train a classifier $f$ on it, then output $( x _ { \mathrm { t r } } , f ( x _ { \mathrm { t r } } ) )$
188
+ 167 for a random train point $x _ { \mathrm { t r } } \in S$ . That is, ${ \mathcal { D } } _ { \mathrm { t r } }$ is the distribution of input and outputs of a trained
189
+ 168 classifier $f$ on its train set. To sample once from the Test Distribution $\mathcal { D } _ { \mathrm { t e } }$ , we do this same proce
190
+ 169 dure, but output $( x , f ( x ) )$ for a random test point $x$ . That is, the $\mathcal { D } _ { \mathrm { t e } }$ is the distribution of input and
191
+ 170 outputs of a trained classifier $f$ at test time. The only difference between the Train Distribution and
192
+ 171 Test Distribution is that the point $x$ is sampled from the train set or the test set, respectively.2 For
193
+ 172 interpolating classifiers, $f ( x _ { \mathrm { t r } } ) = y _ { \mathrm { t r } }$ on the train set, and so the Source and Train distributions are
194
+ 173 equivalent: $\mathcal { D } \equiv \mathcal { D } _ { \mathrm { t r } }$ . (Note that these definitions, crucially, involve randomness from sampling the
195
+ 174 train set, training the classifier, and sampling a test point).
196
+
197
+ # 175 3.2 Feature Calibration
198
+
199
+ We now formally describe the Feature Calibration Conjecture. At a high level, we argue that the distributions $\mathcal { D } _ { \mathrm { t e } }$ and $\mathcal { D }$ are statistically close for interpolating classifiers if we first “coarsen” the domain of $x$ by some partition $L : \mathcal { X } [ M ]$ in to $M$ parts. That is, for certain partitions $L$ , the following distributions are statistically close:
200
+
201
+ $$
202
+ ( L ( x ) , f ( x ) ) _ { x \sim \mathcal { D } } \approx _ { \varepsilon } ( L ( x ) , y ) _ { x \sim \mathcal { D } }
203
+ $$
204
+
205
+ 176 We think of $L$ as defining subgroups over the domain— for example, $L ( x ) \in \{ \deg , \mathrm { c a t } , \mathrm { h o r s e . } . . \}$ .
206
+ 177 Then, the above statistical closeness is essentially equivalent to requiring that for all subgroups
207
+ 178 $\ell \in [ M ]$ , the conditional distribution of classifier output on the subgroup— $p ( f ( x ) | L ( x ) = \bar { \ell } )$ — is
208
+ 179 close to the true conditional distribution: $p ( y | L ( x ) = \bar { \ell } )$ ).
209
+ 180 The crux of our conjecture lies in defining exactly which subgroups $L$ satisfy this distributional
210
+ 181 closeness, and quantifying the $\varepsilon$ approximation. This is subtle, since it must depend on almost all
211
+ 182 parameters of the problem. For example, consider a modification to Experiment 1, where we use
212
+ 183 a fully-connected network (MLP) instead of a ResNet. An MLP cannot properly distinguish cats
213
+ 184 even when it is actually provided the real CIFAR-10 labels, and so (informally) it has no hope of
214
+ 185 behaving differently on cats in the setting of Experiment 1, where the cats are not labeled explicitly
215
+ 186 (See Figure ${ \bf C } . 2$ for results with MLPs). Similarly, if we train the ResNet with very few samples from
216
+ 187 the distribution, the network will be unable to recognize cats. Thus, the allowable partitions must
217
+ 188 depend on the classifier family and the training method, including the number of samples.
218
+ 189 We conjecture that allowable partitions are those which can themselves be learnt to good test
219
+ 190 performance with an identical training procedure, but trained with the labels of the partition $L$ instead
220
+ 191 of $y$ . To formalize this, we define a distinguishable feature: a partition of the domain $\mathcal { X }$ that is
221
+ 192 learnable for a given training procedure. Thus, in Experiment $^ { 1 , }$ the partition into CIFAR-10 classes
222
+ 193 would be a distinguishable feature for ResNets (trained with SGD with 50K or more samples), but
223
+ 194 not for MLPs. The definition below depends on the training procedure $\mathcal { A }$ , the data distribution $\mathcal { D }$
224
+ 195 number of train samples $n$ , and an approximation parameter $\varepsilon$ (which we think of as $\varepsilon \approx 0$ ).
225
+
226
+ Definition 1 $( ( \varepsilon , \mathcal { A } , \mathcal { D } , n )$ -Distinguishable Feature). For a distribution $\mathcal { D }$ over $\mathcal { X } \times \mathcal { V }$ , number of samples $n$ , training procedure $\mathcal { A }$ , and small $\varepsilon \geq 0$ , an $( \varepsilon , \mathcal { A } , \mathcal { D } , n )$ -distinguishable feature is $a$ partition $L : \mathcal { X } [ M ]$ of the domain $\mathcal { X }$ into $M$ parts, such that training a model using $\mathcal { A }$ on $n$ samples labeled by $L$ works to classify $L$ with high test accuracy. Precisely, $L$ is a $( \varepsilon , \mathcal { A } , \mathcal { D } , n )$ - distinguishable feature $i f$ :
227
+
228
+ $$
229
+ \begin{array} { c c } { { } } & { { \mathrm { ~ P r ~ } } } & { { [ f ( x ) = L ( x ) ] \geq 1 - \varepsilon } } \\ { { } } & { { } } & { { \nonumber } } \\ { { } } & { { \nonumber } } & { { f \mathrm { T r a i n } _ { \cal A } ( S ) ; x { \sim } \mathcal { D } } } \end{array}
230
+ $$
231
+
232
+ 196 This definition depends only on the marginal distribution of $\mathcal { D }$ on $x$ , and not on the label distribution
233
+ 197 $p _ { \mathcal { D } } ( y | x )$ . To recap, this definition is meant to capture a labeling of the domain $\mathcal { X }$ that is learnable for
234
+ 198 a given training procedure $\mathcal { A }$ . It must depend on the architecture used by $\mathcal { A }$ and number of samples
235
+ 199 $n$ , since more powerful classifiers can distinguish more features. Note that there could be many
236
+ 200 distinguishable features for a given setting $( \varepsilon , \mathcal { A } , \mathcal { D } , n )$ — including features not implied by the class
237
+ 201 label such as the presence of grass in a CIFAR-10 image. Our main conjecture follows.
238
+ 202 Conjecture 1 (Feature Calibration). For all natural distributions $\mathcal { D }$ , number of samples $n$ , interpo
239
+ 203 lating training procedures $A$ , and $\varepsilon \geq 0$ , the following distributions are statistically close for all
240
+ 204 $( \varepsilon , \mathcal { A } , \mathcal { D } , n )$ -distinguishable features $L$ :
241
+
242
+ $$
243
+ \begin{array} { r l r l } { ( L ( x ) , f ( x ) ) } & { { } \approx _ { \varepsilon } } & { } & { { } ( L ( x ) , y ) } \\ { f \gets \mathrm { T r a i n } _ { \cal A } ( \mathscr { D } ^ { n } ) ; x , y { \sim } \mathscr { D } } & { } & { { } x , y { \sim } \mathscr { D } } \end{array}
244
+ $$
245
+
246
+ $$
247
+ \begin{array} { r l r } { ( L ( x ) , \widehat { y } ) } & { { } \approx _ { \varepsilon } } & { ( L ( x ) , y ) } \\ { _ { - } x , \widehat { y } { \sim } \mathcal { D } _ { \mathrm { t e } } } & { { } } & { x , y { \sim } \mathcal { D } } \end{array}
248
+ $$
249
+
250
+ 206 This claims that the TV distance between the LHS and RHS of Equation $\textcircled{4}$ is at most $\varepsilon$ , where $\varepsilon$ is the
251
+ 207 error of the distinguishable feature (in Definition $\mathbb { D }$ . We claim that this holds for all distinguishable
252
+ 208 features $L$ “automatically” – we simply train a classifier, without specifying any particular partition.
253
+ 209 The formal statements of Definition $\dot { 1 }$ and Conjecture $^ 1$ may seem somewhat arbitrary, involving
254
+ 210 many quantifiers over $( \varepsilon , \mathcal { A } , \mathcal { D } , n )$ . However, we believe these statements are natural: In addition
255
+ 211 to extensive experimental evidence in Section $^ { 4 , }$ we also prove that Conjecture $^ 1$ is formally true as
256
+ 212 stated for 1-Nearest-Neighbor classifiers in Theorem 1.
257
+
258
+ # 213 3.3 Feature Calibration for 1-Nearest-Neighbors
259
+
260
+ 214 Here we prove that the 1-Nearest-Neighbor classifier formally satisfies Conjecture $^ { 1 , }$ under mild
261
+ 215 assumptions. We view this theorem as support for our (somewhat involved) formalism of Conjecture 1.
262
+ 216 Indeed, without Theorem 1 below, it is unclear if our statement of Conjecture 1 can ever be satisfied by
263
+ 217 any classifier, or if it is simply too strong to be true. This theorem applies generically to a wide class
264
+ 218 of distributions; the only assumption is a weak regularity condition: sampling the nearest-neighbor
265
+ 219 train point to a random test point should yield (close to) a uniformly random test point.
266
+ 220 Theorem 1. Let $\mathcal { D }$ be a distribution over $\mathcal { X } \times \mathcal { V } _ { : }$ , and let $n \in \mathbb N$ be the number of train samples.
267
+ 221 Assume the following regularity condition holds: Sampling the nearest-neighbor train point to a
268
+ 222 random test point yields (close to) a uniformly random test point. That is, suppose that for some
269
+ 223 small $\delta \geq 0$ , the distributions: $\begin{array} { r l r } { \{ \mathrm { N N } _ { S } ( x ) \} _ { S \sim \mathcal { D } ^ { n } } } & { { } \approx _ { \delta } } & { \{ x \} _ { x \sim \mathcal { D } } } \end{array}$ . Then, Conjecture 1 holds. That is,
270
+ 224 for all $( \varepsilon , \mathrm { N N } , \mathcal { D } , n )$ -distinguishable partitions $L$ , the following distributions are statistically close:
271
+
272
+ $$
273
+ \begin{array} { r l } { \{ ( y , L ( x ) ) \} _ { x , y \sim \mathcal { D } } } & { { } \approx _ { \varepsilon + \delta } \quad \{ ( \mathrm { N N } _ { S } ^ { ( y ) } ( x ) , L ( x ) \} _ { S \sim \mathcal { D } ^ { n } } } \end{array}
274
+ $$
275
+
276
+ The proof of Theorem $\bigstar$ is straightforward, and provided in Appendix $\overline { { \mathbb { D } } } -$ but this strong property of nearest-neighbors was not know before, to our knowledge.
277
+
278
+ # 3.4 Limitations: Natural Distributions
279
+
280
+ Technically, Conjecture $\bigtriangledown$ is not fully specified, since it does not specify exactly which classifiers or distributions obey the conjecture. We do not claim that all classifiers and distributions satisfy our conjectures. Nevertheless, we claim our conjectures hold in all “natural” settings, which informally means settings with real data and classifiers that are actually used in practice. The problem of understanding what separates “natural distributions” from artificial ones is not unique to our work, and lies at the heart of deep learning theory. Many theoretical works handle this by considering simplified distributional assumptions (e.g. smoothness, well-separatedness, gaussianity), which are mathematically tractable, but untested in practice [2, 4, 35]. In contrast, we do not make untestable mathematical assumptions. This benefit of realism comes at the cost of mathematical formalism. We hope that as the theory of deep learning evolves, we will better understand how to formalize the notion of “natural” in our conjectures.
281
+
282
+ # 239 4 Experiments: Feature Calibration
283
+
284
+ 240 We now give empirical evidence for our conjecture in a variety of settings in machine learning,
285
+ 241 including neural networks, kernel machines, and decision trees. In each experiment, we consider
286
+ 242 a feature that is (verifiably) distinguishable, and then test our Feature Calibration conjecture for
287
+ 243 this feature. Each of the experimental settings below highlights a different aspect of interpolating
288
+ 244 classifiers, which may be of independent interest. Selected experiments are summarized here, with
289
+ 245 full details and further experiments in Appendix C.
290
+
291
+ Constant Partition: Consider the trivially-distinguishable constant feature: $L ( x ) = 0$ everywhere. For this feature, Conjecture $^ 1$ reduces to the statement that the marginal distribution of class labels for any interpolating classifier is close to the true marginals $p ( y )$ . To test this, we construct a variant of CIFAR-10 with class-imbalance and train classifiers with varying levels of test errors to interpolation on it. As shown in Figure $2 \mathrm { B }$ , the marginals of the classifier outputs are close to the true marginals, even for a classifier that only achieves $37 \%$ test error.
292
+
293
+ 252 Coarse Partition: Consider AlexNet trained on ILSVRC-2012 ImageNet $\begin{array} { r l } { { \bigl [ \bigl | \boldsymbol { 5 } 6 \bigr | \bigr ] } } \end{array}$ , a 1000-class image
294
+ 253 classification problem with 116 varieties of dogs. The network achieves only $56 . 5 \%$ accuracy
295
+ 254 on the test set. But it will at least classify most dogs as dogs (with $9 8 . 4 \%$ accuracy), making
296
+ 255 $L ( x ) \in \{ \log , \mathrm { n o t } \mathrm { - d o g } \}$ a distinguishable feature. Moreover, as predicted by Conjecture 1, the
297
+ 256 network is calibrated with respect to dogs: $2 2 . 4 \%$ of all dogs in ImageNet are Terriers, and indeed
298
+ 257 the network classifies $2 0 . 9 \%$ of all dogs as Terriers (though it has $9 \%$ error on which specific dogs
299
+ 258 it classifies as Terriers). See Appendix Table $2$ for details, and related experiments on ResNets and
300
+ 259 kernels in Appendix C.
301
+ 260 Class Partition: We now consider settings where the class labels are themselves distinguishable
302
+ 261 features (eg: CIFAR-10 classes are distinguishable by ResNets). Here our conjecture predicts the
303
+ 262 behavior of interpolating classifiers under structured label noise. As an example, we generate a
304
+ 263 random spare confusion matrix and apply this to the labels of CIFAR-10 as shown in Figure $2 \mathrm { A }$ .
305
+ 264 We find that a WideResNet trained to interpolation outputs the same confusion matrix on the test
306
+ 265 set as well (Figure $\bigstar \bigstar \bigstar$ ). Now, to test that this phenomenon is indeed robust to the level of noise, we
307
+ 266 mislabel class $0 \overline { { 1 } }$ with probability $p$ in the CIFAR-10 train set for varying levels of $p$ . We then
308
+ 267 observe $\widehat { p } .$ , the fraction of samples mislabeled by this network from $0 1$ in the test set (Figure $3 \mathsf { A }$
309
+ 268 shows $p$ versus $\widehat { p } \big )$ ). The Bayes optimal classifier for this distribution behaves as a step function (in
310
+ 269 bred), and a classifier that obeys Conjecture 1 exactly would follow the diagonal (in green). The actual
311
+ 270 experiment (in blue) is close to the behavior predicted by Conjecture 1. This experiment shows a
312
+ 271 contrast with classical learning theory. While most existing theory focuses on whether classifiers
313
+ 272 converge to the Bayes optimal solution, we show that interpolating classifiers behave “optimally” in a
314
+ 273 different sense: they match the distribution of their train set. We discuss this further in Section 5. See
315
+ 274 Appendix C.4 for more experiments, including other classifiers such as Decisions Trees.
316
+ 275 Multiple features: Conjecture 1 states that the network should be automatically calibrated for
317
+ 276 all distinguishable features, without any explicit labels for them. To do this, we use the CelebA
318
+ 277 dataset $\ [ \overbrace { 3 7 } ]$ , containing images with many binary attributes per image. (“male”, “blond hair”, etc).
319
+ 78 We train a ResNet-50 to classify one of the hard attributes (accuracy $80 \%$ ) and confirm that the
320
+ 279 Feature Calibration holds for all the other attributes (Figure $3 )$ that are themselves distinguishable.
321
+ 280 Quantitative predictions: We now test the quantitative predictions made by Conjecture $\boxed { 1 }$ This
322
+ 281 conjecture states that the TV-distance between the joint distributions $( L ( x ) , f ( x ) )$ and $( \overline { { \cal L } } ( x ) , y )$
323
+ 282 is at most $\varepsilon$ , where $\varepsilon$ is the error of the training procedure in learning $L$ (see Definition $\blacktriangleleft$ . To
324
+ 283 test this, we consider binary task similar to Experiment $^ 1$ where (Ship, Plane) are labeled as
325
+ 284 class 0 and (Cat, Dog) are labeled as class 1, with $p = \overline { { 0 . 3 } }$ fraction of cats mislabeled to class 0.
326
+ 285 Then, we train a convolutional network to interpolation on this task. To vary the error $\varepsilon$ on these
327
+ 286 distinguishable features systematically, we train networks with varying number of train samples.
328
+ 287 Networks with fewer samples have larger $\varepsilon$ since they are worse at classifying the distinguishable
329
+ 288 features of (Ship,Plane,Cat,Dog). Then, we use the same setup to train networks on the binary
330
+ 289 task and measure the TV-distance between $( L ( x ) , f ( x ) )$ and $( L ( x ) , y )$ in this task. The results are
331
+ 290 shown in Figure $\textcircled { 3 } \textcircled { C }$ . As predicted, the TV distance on the binary task is upper bounded by $\varepsilon$ error on
332
+ 291 the 4-way classification task.
333
+
334
+ ![](images/6ff6f349cc56237c12e10b9449254ccf8182d950c2d49c7bf5f90d180bc78987.jpg)
335
+ Figure 2: Feature Calibration. (A) Random confusion matrix on CIFAR-10, with a WideResNet28- 10 trained to interpolation. Left: Joint density of labels $y$ and original class $L$ on the train set. Right: Joint density of classifier predictions $f ( x )$ and original class $L$ on the test set. These two joint densities are close, as predicted by Conjecture 1. $\mathbf { ( B ) }$ Constant partition: The CIFAR-10 train set is class-rebalanced according to the left panel distribution. The center and right panels show that both ResNets and MLPs have the correct marginal distribution of outputs, even though the MLP has high test error.
336
+
337
+ ![](images/351b3d01446a41281fb1f6bfd070bfaac6e6ab5323b60b36975e762dea5c4603.jpg)
338
+ Figure 3: Feature Calibration. (A) CIFAR-10 with $p$ fraction of class $0 1$ mislabeled on the train set. Plotting observed noise on classifier outputs vs. applied noise on the train set. $\mathbf { ( B ) }$ Multiple feature calibration on CelebA. (C) TV-distance between $( \bar { L } \bar { ( } x ) , f ( x ) )$ and $( L ( x ) , y )$ for a variant of Experiment $\bigtriangledown$ with error on the distinguishable partitions $( \varepsilon )$ . The error was changed by changing the number of samples $n$ .
339
+
340
+ # 92 5 Distributional Generalization
341
+
342
+ In order to relate our results to the classical theory of generalization, we now propose a formal notion of “Distributional Generalization”, which subsumes both Feature Calibration and classical generalization. In fact, we will also give preliminary evidence that this new notion can apply even for non-interpolating methods, unlike Feature Calibration.
343
+
344
+ 7 A trained model $f$ obeys classical generalization (with respect to test error) if its error on the train set
345
+ 98 is close to its error on the test distribution. We first rewrite this using our definitions below.
346
+
347
+ Classical Generalization (informal): Let $f$ be a trained classifier. Then $f$ generalizes if:
348
+
349
+ $$
350
+ \begin{array} { r } { \underset { x \sim T r a i n S e t } { \mathbb { E } } [ \mathbb { 1 } \{ \widehat { y } \neq y ( x ) \} ] \approx \underset { \stackrel { x \sim T e s t S e t } { \widehat { y } f ( x ) } } { \mathbb { E } } [ \mathbb { 1 } \{ \widehat { y } \neq y ( x ) \} ] } \\ { \quad \widehat { y } f ( x ) } \end{array}
351
+ $$
352
+
353
+ 300 Above, $y ( x )$ is the true class of $x$ and $\widehat { y }$ is the predicted class. The LHS of Equation $\textcircled{6}$ is the train
354
+ 301 error of $f$ , and the RHS is the test error. Using our definitions of $\mathcal { D } _ { \mathrm { t r } } , \mathcal { D } _ { \mathrm { t e } }$ from Section $\boxed { 3 . 1 }$ and
355
+ 302 defining $T _ { \mathrm { e r r } } ( x , \widehat { y } ) : = \mathbb { 1 } \{ \widehat { y } \neq y ( x ) \}$ , we can write Equation $6$ equivalently:
356
+
357
+ $$
358
+ \underset { x , \widehat { y } \sim \mathcal { D } _ { \mathrm { t r } } } { \mathbb { E } } [ T _ { \mathrm { e r r } } ( x , \widehat { y } ) ] \approx \underset { x , \widehat { y } \sim \mathcal { D } _ { \mathrm { t e } } } { \mathbb { E } } [ T _ { \mathrm { e r r } } ( x , \widehat { y } ) ]
359
+ $$
360
+
361
+ 303 That is, classical generalization states that a certain function $T _ { \mathrm { e r r } } )$ has similar expectations on both the
362
+ 304 Train Distribution ${ \mathcal { D } } _ { \mathrm { t r } }$ and Test Distribution $\mathcal { D } _ { \mathrm { t e } }$ . We can now introduce Distributional Generalization,
363
+ 305 which is a property of trained classifiers. It is parameterized by a set of bounded functions (“tests”):
364
+ 306 ${ \mathcal { T } } \subseteq \{ T : { \dot { \mathcal { X } } } \times { \dot { \mathcal { y } } } \} \to [ 0 , 1 ] \}$ .
365
+ 307 Distributional Generalization: Let $f$ be a trained classifier. Then $f$ satisfies Distributional Gener
366
+ 308 alization with respect to tests $\tau$ if:
367
+
368
+ $$
369
+ \forall T \in { \mathcal { T } } : \quad \underset { x , \widehat { y } \sim \mathcal { D } _ { \mathrm { t r } } } { \mathbb { E } } [ T ( x , \widehat { y } ) ] \approx \underset { x , \widehat { y } \sim \mathcal { D } _ { \mathrm { t e } } } { \mathbb { E } } [ T ( x , \widehat { y } ) ]
370
+ $$
371
+
372
+ 309
373
+
374
+ 310 This states that the train and test distribution have similar expectations for all functions in the family
375
+ 311 $\tau$ , which we can write as: $\mathcal { D } _ { \mathrm { t r } } \approx ^ { \mathcal { T } } \ \mathcal { D } _ { \mathrm { t e } }$ . For the singleton set $\mathcal { T } = \{ T _ { \mathrm { e r r } } \}$ , this is equivalent to
376
+ 312 classical generalization, but it may hold for much larger sets $\tau$ . This definition of Distributional
377
+ 313 Generalization, like the definition of classical generalization, is just defining an object— not stating
378
+ 314 when or how it is satisfied. Feature Calibration turns this into a concrete conjecture.
379
+
380
+ # 15 5.1 Feature Calibration as Distributional Generalization
381
+
382
+ We can write our Feature Calibration Conjecture as a special case of Distributional Generalization, for a certain family of tests $\tau$ . Informally, for a given setting, the family $\tau$ is all tests which take input $( x , y )$ , but only depend on $x$ via a distinguishable feature (Definition $^ { 1 ) }$ . For example, a test of the form $T ( x , y ) \dot { = } g \bar { ( } L ( x ) , y )$ where $L$ is a distinguishable feature, and $g$ is arbitrary. Formally, for a given problem setting, suppose $\mathcal { L }$ is the set of $( \varepsilon , \mathcal { A } , \mathcal { D } , n )$ -distinguishable features. Then Conjecture $\bar { 1 }$ states that $\forall L \in \mathcal { L } : ( L ( x ) , f ( x ) ) \approx _ { \varepsilon } ( L ( x ) , y )$ . This is equivalent to the statement
383
+
384
+ $$
385
+ \mathcal { D } _ { \mathrm { t e } } \approx _ { \varepsilon } ^ { T } \mathcal { D }
386
+ $$
387
+
388
+ ![](images/d5260b32140f48e31ae50f7a04c4cbecb56357865c0ece09591403361bb9abd2.jpg)
389
+ Figure 4: Distributional Generalization for WideResNet on CIFAR-10. The confusion matrices on the train set (top row) and test set (bottom row) remain close throughout training.
390
+
391
+ 322 where $\tau$ is the set of functions $\mathcal T : = \{ T : T ( x , y ) = g ( L ( x ) , y )$ , $L \in \mathcal { L } , g : \mathcal { X } \times \mathcal { Y } [ 0 , 1 ] \}$ .
392
+ 323 For interpolating classifiers, we have $\mathcal { D } \equiv \mathcal { D } _ { \mathrm { t r } }$ , and so Equation $\textcircled { 9 }$ is equivalent to $\mathcal { D } _ { \mathrm { t e } } \approx _ { \varepsilon } ^ { \mathcal { T } } \mathcal { D } _ { \mathrm { t r } }$
393
+ 324 which is a statement of Distributional Generalization. Since any classifier family will contain a large
394
+ 325 number of distinguishable features, the set $\mathcal { L }$ may be very large. Hence, the distributions ${ \mathcal { D } } _ { \mathrm { t r } }$ and $\mathcal { D } _ { \mathrm { t e } }$
395
+ 326 can be thought of as being close as distributions.
396
+
397
+ # 5.2 Beyond Interpolating Methods
398
+
399
+ The previous sections have focused on interpolating classifiers, which fit their train sets exactly. Here we informally discuss how to extend our results beyond interpolating methods. The discussion in this section is not as precise as in previous sections, and is only meant to suggest that our abstraction of Distributional Generalization can be useful in other settings.
400
+
401
+ For non-interpolating classifiers, we may still expect that they behave similarly on their test and train sets – that is, $\mathcal { D } _ { \mathrm { t e } } \approx ^ { \tau } \mathcal { D } _ { \mathrm { t r } }$ for some family of tests $\tau$ . For example, the following is a possible generalization of Feature Calibration to non-interpolating methods.
402
+
403
+ 335 Conjecture 2 (Generalized Feature Calibration, informal). For trained classifiers $f _ { i }$ , the following
404
+ 336 distributions are statistically close for many partitions $L$ of the domain:
405
+
406
+ $$
407
+ \begin{array} { r l r } { ( L ( x ) , \widehat { y } ) } & { { } \approx } & { ( L ( x ) , \widehat { y } ) } \\ { x , \widehat { y } \sim \mathcal { D } _ { \mathrm { t e } } } & { { } } & { x , \widehat { y } \sim \mathcal { D } _ { \mathrm { t r } } } \end{array}
408
+ $$
409
+
410
+ 337 We leave unspecified the exact set of partitions $L$ for which this holds, since we do not yet understand
411
+ 338 the appropriate notion of “distinguishable feature” in this setting. However, we give experimental
412
+ 339 evidence suggesting some refinement of Conjecture $2$ is true. In Figure $^ { 4 , }$ we apply label noise from
413
+ 340 a random sparse confusion to the CIFAR-10 train set. We then train a single WideResNet28-10, and
414
+ 341 measure its predictions on the train and test sets over increasing train time (SGD steps). The top row
415
+ 342 shows the confusion matrix of predictions $f ( x )$ vs true labels $L ( x )$ on the train set, and the bottom
416
+ 343 row shows the corresponding confusion matrix on the test set. As the network is trained for longer, it
417
+ 344 fits more of the noise on the train set, and this noise is mirrored almost identically on the test set. Full
418
+ 345 experimental details, and an analogous experiment for kernels, are given in Appendix B.
419
+
420
+ # 346 6 Conclusion
421
+
422
+ 347 This work initiates the study of a new kind of generalization— Distributional Generalization— which
423
+ 348 considers the entire input-output behavior of classifiers, instead of just their test error. We presented
424
+ 349 both new empirical behaviors, and new formal conjectures which characterize these behaviors.
425
+ 350 Roughly, our conjecture states that the outputs of classifiers on the test set are “close in distribution”
426
+ 351 to their outputs on the train set. These results build a deeper understanding of models used in practice,
427
+ 352 and we hope our results inspire further work on distributional generalization in machine learning.
428
+
429
+ References [1] Madhu S Advani and Andrew M Saxe. High-dimensional dynamics of generalization error in neural networks. arXiv preprint arXiv:1710.03667, 2017. [2] Zeyuan Allen-Zhu, Yuanzhi Li, and Yingyu Liang. Learning and generalization in overparameterized neural networks, going beyond two layers. arXiv preprint arXiv:1811.04918, 2018. [3] Zeyuan Allen-Zhu, Yuanzhi Li, and Yingyu Liang. Learning and generalization in overparameterized neural networks, going beyond two layers. In Advances in neural information processing systems, pages 6158–6169, 2019. [4] Sanjeev Arora, Simon Du, Wei Hu, Zhiyuan Li, and Ruosong Wang. Fine-grained analysis of optimization and generalization for overparameterized two-layer neural networks. In International Conference on Machine Learning, pages 322–332, 2019. [5] Susan Athey, Julie Tibshirani, Stefan Wager, et al. Generalized random forests. The Annals of Statistics, 47(2):1148–1178, 2019. [6] Francis Bach. Breaking the curse of dimensionality with convex neural networks. The Journal of Machine Learning Research, 18(1):629–681, 2017. [7] Peter L Bartlett, Philip M Long, Gábor Lugosi, and Alexander Tsigler. Benign overfitting in linear regression. Proceedings of the National Academy of Sciences, 2020. [8] Mikhail Belkin, Daniel J Hsu, and Partha Mitra. Overfitting or perfect fitting? risk bounds for classification and regression rules that interpolate. In Advances in neural information processing systems, pages 2300–2311, 2018. [9] Mikhail Belkin, Siyuan Ma, and Soumik Mandal. To understand deep learning we need to understand kernel learning. arXiv preprint arXiv:1802.01396, 2018.
430
+ [10] Mikhail Belkin, Daniel Hsu, Siyuan Ma, and Soumik Mandal. Reconciling modern machinelearning practice and the classical bias–variance trade-off. Proceedings of the National Academy of Sciences, 116(32):15849–15854, 2019.
431
+ [11] Leo Breiman. Reflections after refereeing papers for nips. The Mathematics of Generalization, pages 11–15, 1995.
432
+ [12] Leo Breiman. Random forests. Machine learning, 45(1):5–32, 2001.
433
+ [13] Leo Breiman, Jerome Friedman, Charles J Stone, and Richard A Olshen. Classification and regression trees. CRC press, 1984.
434
+ [14] Niladri S Chatterji and Philip M Long. Finite-sample analysis of interpolating linear classifiers in the overparameterized regime. arXiv preprint arXiv:2004.12019, 2020.
435
+ [15] Lenaic Chizat and Francis Bach. Implicit bias of gradient descent for wide two-layer neural networks trained with the logistic loss. arXiv preprint arXiv:2002.04486, 2020.
436
+ [16] Dheeru Dua and Casey Graff. UCI machine learning repository, 2017. URL http://archive. ics.uci.edu/ml.
437
+ [17] Gintare Karolina Dziugaite and Daniel M Roy. Computing nonvacuous generalization bounds for deep (stochastic) neural networks with many more parameters than training data. arXiv preprint arXiv:1703.11008, 2017.
438
+ [18] Manuel Fernández-Delgado, Eva Cernadas, Senén Barro, and Dinani Amorim. Do we need hundreds of classifiers to solve real world classification problems? The journal of machine learning research, 15(1):3133–3181, 2014.
439
+ [19] Stanislav Fort, Paweł Krzysztof Nowak, Stanislaw Jastrzebski, and Srini Narayanan. Stiffness: A new perspective on generalization in neural networks. arXiv preprint arXiv:1901.09491, 2019.
440
+ [20] Mario Geiger, Stefano Spigler, Stéphane d’Ascoli, Levent Sagun, Marco Baity-Jesi, Giulio Biroli, and Matthieu Wyart. Jamming transition as a paradigm to understand the loss landscape of deep neural networks. Physical Review E, 100(1):012115, 2019.
441
+ [21] Federica Gerace, Bruno Loureiro, Florent Krzakala, Marc Mézard, and Lenka Zdeborová. Generalisation error in learning with random features and the hidden manifold model. arXiv preprint arXiv:2002.09339, 2020.
442
+ [22] Behrooz Ghorbani, Song Mei, Theodor Misiakiewicz, and Andrea Montanari. Linearized two-layers neural networks in high dimension. arXiv preprint arXiv:1904.12191, 2019.
443
+ [23] Tilmann Gneiting and Adrian E Raftery. Strictly proper scoring rules, prediction, and estimation. Journal of the American statistical Association, 102(477):359–378, 2007.
444
+ [24] Sebastian Goldt, Madhu S Advani, Andrew M Saxe, Florent Krzakala, and Lenka Zdeborova. Generalisation dynamics of online learning in over-parameterised neural networks. arXiv preprint arXiv:1901.09085, 2019.
445
+ [25] Suriya Gunasekar, Jason Lee, Daniel Soudry, and Nathan Srebro. Characterizing implicit bias in terms of optimization geometry. In International Conference on Machine Learning, pages 1832–1841. PMLR, 2018.
446
+ [26] Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q Weinberger. On calibration of modern neural networks. arXiv preprint arXiv:1706.04599, 2017.
447
+ [27] Trevor Hastie, Robert Tibshirani, and Jerome Friedman. The elements of statistical learning: data mining, inference, and prediction. Springer Science & Business Media, 2009.
448
+ [28] Trevor Hastie, Andrea Montanari, Saharon Rosset, and Ryan J Tibshirani. Surprises in highdimensional ridgeless least squares interpolation. arXiv preprint arXiv:1903.08560, 2019.
449
+ [29] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
450
+ [30] Úrsula Hébert-Johnson, Michael Kim, Omer Reingold, and Guy Rothblum. Multicalibration: Calibration for the (computationally-identifiable) masses. In International Conference on Machine Learning, pages 1939–1948, 2018.
451
+ [31] Tin Kam Ho. Random decision forests. In Proceedings of 3rd international conference on document analysis and recognition, volume 1, pages 278–282. IEEE, 1995.
452
+ [32] Rashidedin Jahandideh, Alireza Tavakoli Targhi, and Maryam Tahmasbi. Physical attribute prediction using deep residual neural networks. arXiv preprint arXiv:1812.07857, 2018.
453
+ [33] Alex Krizhevsky et al. Learning multiple layers of features from tiny images. 2009.
454
+ [34] Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
455
+ [35] Yuanzhi Li, Colin Wei, and Tengyu Ma. Towards explaining the regularization effect of initial large learning rate in training neural networks. arXiv preprint arXiv:1907.04595, 2019.
456
+ [36] Tengyuan Liang and Alexander Rakhlin. Just interpolate: Kernel" ridgeless" regression can generalize. arXiv preprint arXiv:1808.00387, 2018.
457
+ [37] Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015.
458
+ [38] Song Mei and Andrea Montanari. The generalization error of random features regression: Precise asymptotics and double descent curve. arXiv preprint arXiv:1908.05355, 2019.
459
+ [39] Nicolai Meinshausen. Quantile regression forests. Journal of Machine Learning Research, 7 (Jun):983–999, 2006. [40] Vidya Muthukumar, Kailas Vodrahalli, Vignesh Subramanian, and Anant Sahai. Harmless interpolation of noisy data in regression. IEEE Journal on Selected Areas in Information Theory, 2020.
460
+ 47 [41] Elizbar A Nadaraya. On estimating regression. Theory of Probability & Its Applications, 9(1): 141–142, 1964.
461
+ 49 [42] Vaishnavh Nagarajan and J. Zico Kolter. Uniform convergence may be unable to explain generalization in deep learning, 2019. [43] Preetum Nakkiran, Gal Kaplun, Yamini Bansal, Tristan Yang, Boaz Barak, and Ilya Sutskever. Deep double descent: Where bigger models and more data hurt. In International Conference on Learning Representations, 2020.
462
+ 454 [44] Hariharan Narayanan and Sanjoy Mitter. Sample complexity of testing the manifold hypothesis. In Advances in neural information processing systems, pages 1786–1794, 2010. [45] Nagarajan Natarajan, Inderjit S Dhillon, Pradeep K Ravikumar, and Ambuj Tewari. Learning with noisy labels. In Advances in neural information processing systems, pages 1196–1204, 2013. [46] Brady Neal, Sarthak Mittal, Aristide Baratin, Vinayak Tantia, Matthew Scicluna, Simon LacosteJulien, and Ioannis Mitliagkas. A modern take on the bias-variance tradeoff in neural networks. arXiv preprint arXiv:1810.08591, 2018. [47] Behnam Neyshabur, Zhiyuan Li, Srinadh Bhojanapalli, Yann LeCun, and Nathan Srebro. Towards understanding the role of over-parametrization in generalization of neural networks. arXiv preprint arXiv:1805.12076, 2018. [48] Alexandru Niculescu-Mizil and Rich Caruana. Predicting good probabilities with supervised learning. In Proceedings of the 22nd international conference on Machine learning, pages 625–632, 2005. [49] Matthew A Olson and Abraham J Wyner. Making sense of random forest probabilities: a kernel perspective. arXiv preprint arXiv:1812.05792, 2018. [50] 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. 2017. [51] F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12:2825–2830, 2011. [52] Taylor Pospisil and Ann B Lee. Rfcde: Random forests for conditional density estimation. arXiv preprint arXiv:1804.05753, 2018. [53] Ali Rahimi and Benjamin Recht. Random features for large-scale kernel machines. In Advances in neural information processing systems, pages 1177–1184, 2008. [54] David Rolnick, Andreas Veit, Serge Belongie, and Nir Shavit. Deep learning is robust to massive label noise. arXiv preprint arXiv:1705.10694, 2017. [55] Jonas Rothfuss, Fabio Ferreira, Simon Walther, and Maxim Ulrich. Conditional density estimation with neural networks: Best practices and benchmarks. arXiv preprint arXiv:1903.00954, 2019. [56] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211–252, 2015. doi: 10.1007/s11263-015-0816-y. [57] Robert E Schapire. Theoretical views of boosting. In European conference on computational learning theory, pages 1–10. Springer, 1999.
463
+ [58] Robert E Schapire, Yoav Freund, Peter Bartlett, Wee Sun Lee, et al. Boosting the margin: A new explanation for the effectiveness of voting methods. The annals of statistics, 26(5):1651–1686, 1998.
464
+ [59] Shai Shalev-Shwartz and Shai Ben-David. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014.
465
+ [60] Vaishaal Shankar, Alex Fang, Wenshuo Guo, Sara Fridovich-Keil, Ludwig Schmidt, Jonathan Ragan-Kelley, and Benjamin Recht. Neural kernels without tangents. arXiv preprint arXiv:2003.02237, 2020.
466
+ [61] Utkarsh Sharma and Jared Kaplan. A neural scaling law from the dimension of the data manifold. arXiv preprint arXiv:2004.10802, 2020.
467
+ [62] Daniel Soudry, Elad Hoffer, Mor Shpigel Nacson, Suriya Gunasekar, and Nathan Srebro. The implicit bias of gradient descent on separable data. The Journal of Machine Learning Research, 19(1):2822–2878, 2018.
468
+ [63] Sunil Thulasidasan, Tanmoy Bhattacharya, Jeff Bilmes, Gopinath Chennupati, and Jamal Mohd-Yusof. Combating label noise in deep learning using abstention. arXiv preprint arXiv:1905.10964, 2019.
469
+ [64] Pauli Virtanen, Ralf Gommers, Travis E. Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, Stéfan J. van der Walt, Matthew Brett, Joshua Wilson, K. Jarrod Millman, Nikolay Mayorov, Andrew R. J. Nelson, Eric Jones, Robert Kern, Eric Larson, CJ Carey, ˙ Ilhan Polat, Yu Feng, Eric W. Moore, Jake Vand erPlas, Denis Laxalde, Josef Perktold, Robert Cimrman, Ian Henriksen, E. A. Quintero, Charles R Harris, Anne M. Archibald, Antônio H. Ribeiro, Fabian Pedregosa, Paul van Mulbregt, and SciPy 1. 0 Contributors. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods, 17:261–272, 2020. doi: https://doi.org/10. 1038/s41592-019-0686-2.
470
+ [65] Larry Wasserman. All of statistics: a concise course in statistical inference. Springer Science & Business Media, 2013.
471
+ [66] Geoffrey S Watson. Smooth regression analysis. Sankhya: The Indian Journal of Statistics, ¯ Series A, pages 359–372, 1964.
472
+ [67] Abraham J Wyner, Matthew Olson, Justin Bleich, and David Mease. Explaining the success of adaboost and random forests as interpolating classifiers. The Journal of Machine Learning Research, 18(1):1558–1590, 2017.
473
+ [68] Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017.
474
+ [69] Mohammad Yaghini, Bogdan Kulynych, and Carmela Troncoso. Disparate vulnerability: On the unfairness of privacy attacks against machine learning. arXiv preprint arXiv:1906.00389, 2019.
475
+ [70] Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016.
476
+ [71] Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv preprint arXiv:1611.03530, 2016.
477
+ [72] Liu Ziyin, Blair Chen, Ru Wang, Paul Pu Liang, Ruslan Salakhutdinov, Louis-Philippe Morency, and Masahito Ueda. Learning not to learn in the presence of noisy labels. arXiv preprint arXiv:2002.06541, 2020.
478
+
479
+ 1. For all authors...
480
+
481
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
482
+ (b) Did you describe the limitations of your work? [Yes]
483
+ (c) Did you discuss any potential negative societal impacts of your work? [No] This paper does not introduce any new methods or applications, and we thus cannot predict any near-term societal impact (positive or negative).
484
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
485
+
486
+ 2. If you are including theoretical results...
487
+
488
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes]
489
+
490
+ 3. If you ran experiments...
491
+
492
+ (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] No new methods were introduced, so the code is standard. We fully specify all experimental hyperparameters for the sake of reproduction.
493
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
494
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] The experiments we consider all exhibit concentration around their expected values, and this is well-known in the community. Notably, we only consider supervised learning.
495
+ (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)? [No]
496
+
497
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
498
+
499
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
500
+ (b) Did you mention the license of the assets? [No]
501
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
502
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
503
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
504
+
505
+ 5. If you used crowdsourcing or conducted research with human subjects...
506
+
507
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
508
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
509
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/train/FsLTUzZlsgT/FsLTUzZlsgT.md ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LEARNING CURVES FOR ANALYSIS OF DEEP NETWORKS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ A learning curve models a classifier’s test error as a function of the number of training samples. Prior works show that learning curves can be used to select model parameters and extrapolate performance. We investigate how to use learning curves to analyze the impact of design choices, such as pretraining, architecture, and data augmentation. We propose a method to robustly estimate learning curves, abstract their parameters into error and data-reliance, and evaluate the effectiveness of different parameterizations. We also provide several interesting observations based on learning curves for a variety of image classification models.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ What gets measured gets optimized. We need better measures of learning ability to design better classifiers and predict the payoff of collecting more data. Currently, classifiers are evaluated and compared by measuring performance on one or more datasets according to a fixed train/test split. Ablation studies help evaluate the impact of design decisions. However, one of the most important characteristics of a classifier, how it performs with varying numbers of training samples, is rarely measured or modeled.
12
+
13
+ In this paper, we refine the idea of learning curves that model error as a function of training set size. Learning curves were introduced nearly thirty years (e.g. by Cortes et al. (1993)) to accelerate model selection of deep networks. Recent works have demonstrated the predictability of performance improvements with more data (Hestness et al., 2017; Johnson & Nguyen, 2017; Kaplan et al., 2020; Rosenfeld et al., 2020) or more network parameters (Kaplan et al., 2020; Rosenfeld et al., 2020). But such studies have typically required large-scale experiments that are outside the computational budgets of many research groups, and their purpose is extrapolation rather than validating design choices. We find that a generalized power law function provides the best learning curve fit, while a model linear in $n ^ { - 0 . 5 }$ , where $n$ is the number of training samples (or “training size”), provides a good local approximation. We abstract the curve into two key parameters: $e _ { N }$ and $\beta _ { N } , e _ { N }$ is error at $n = N$ , and $\beta _ { N }$ is a measure of data-reliance, revealing how much a classifier’s error will change if the training set size changes. Learning curves provide valuable insights that cannot be obtained by single-point comparisons of performance. Our aim is to promote the use of learning curves as part of a standard learning system evaluation.
14
+
15
+ # Our key contributions:
16
+
17
+ • Investigate how to best model, estimate, characterize, and display learning curves for use in classifier analysis • Use learning curves to analyze impact on error and data-reliance due to network architecture, depth, width, fine-tuning, data augmentation, and pretraining
18
+
19
+ Table 1 shows validated and rejected popular beliefs that single-point comparisons often overlook. In the following sections, we investigate how to model learning curves (Sec. 2), how to estimate them (Sec. 3), and what they can tell us about the impact of design decisions (Sec. 4), with discussion of limitations and future work in Sec. 5.
20
+
21
+ <table><tr><td>Popular beliefs</td><td>Your guess</td><td>Our guess</td><td>Our result</td><td>Result figures</td></tr><tr><td>Pre-training on similar domains nearly always helps compared to training from scratch.</td><td></td><td></td><td></td><td>9a,9b,3</td></tr><tr><td>Pre-training,even on similar domains,introduces bias that would harm performance with alarge enough training set.</td><td></td><td></td><td></td><td>3</td></tr><tr><td>Self-/un-supervised training performs better than supervised pre-training for small datasets.</td><td></td><td></td><td></td><td>3</td></tr><tr><td>Fine-tuning the entire network (vs. just the classification layer)is only helpful if the training set is large.</td><td></td><td></td><td></td><td>9a,9b</td></tr><tr><td>Increasing network depth,when fine-tuning,harms performance forsmalltraining sets,duetoanoverly complex model.</td><td></td><td></td><td></td><td>4a,4b</td></tr><tr><td>Increasing network depth, when fine-tuning,is more helpful for larger training sets than smaller ones.</td><td></td><td></td><td></td><td>4a, 4b</td></tr><tr><td>Increasing network depth,if thebackbone is frozen,is more helpful for smaller trainingsets than larger ones.</td><td></td><td></td><td></td><td>4a, 4b</td></tr><tr><td>Increasing depth or width improves more than ensembles of smaller networks with the same numberof parameters.</td><td></td><td></td><td></td><td>4e,4a</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Data augmentation is roughly equivalent to using a m-times larger training set for some m.</td><td></td><td></td><td></td><td>5</td></tr></table>
22
+
23
+ Table 1: Deep learning quiz! We encourage our readers to judge each claim as T (true) or F (false), and then compare to our guesses and results. In the results column, “T” means the experiments are consistent with the belief, “F” for inconsistent, and “?” for hard to say.
24
+
25
+ # 2 MODELING LEARNING CURVES
26
+
27
+ The learning curve measures test error $e _ { t e s t }$ as a function of the number of training samples $n$ for a given classification model and learning method. Previous empirical observations suggest a functional form $e _ { t e s t } ( n ) = \alpha + \eta n ^ { \gamma }$ , with bias-variance trade-off and generalization theories typically indicating $\gamma = - 0 . 5$ . We summarize what bias-variance trade-off and generalization theories (Sec. 2.1) and empirical studies (Sec. 2.2) can tell us about learning curves, and describe our proposed abstraction in Sec. 2.3.
28
+
29
+ # 2.1 BIAS-VARIANCE TRADE-OFF AND GENERALIZATION THEORY
30
+
31
+ The bias-variance trade-off is an intuitive and theoretical way to think about generalization. The “bias” is error due to inability of the classifier to encode the optimal decision function, and the “variance” is error due to variations in predictions due to limited availability of training samples for parameter estimation. This is called a trade-off because a classifier with more parameters tends to have less bias but higher variance. Geman et al. (1992) decompose mean squared regression error into bias and variance and explore the implications for neural networks, leading to the conclusion that “identifying the right preconditions is the substantial problem in neural modeling”. This conclusion foreshadows the importance of pretraining, though Geman et al. thought the preconditions must be built in rather than learned. Domingos (2000) extends the analysis to classification. Theoretically, the mean squared error (MSE) can be modeled as $e _ { t e s t } ^ { 2 } ( n ) = \dot { b } i a s ^ { 2 } + n o i s e ^ { 2 } + v a r ( n )$ , where “noise” is irreducible error due to non-unique mapping from inputs to labels, and variance can be modeled as $v a r ( n ) = \sigma ^ { 2 } / n$ for $n$ training samples.
32
+
33
+ The $\eta n ^ { - 0 . 5 }$ term appears throughout machine learning generalization theory. For example, the bounds based on hypothesis VC-dimension (Vapnik & Chervonenkis, 1971) and Rademacher Complexity (Gnecco & Sanguineti, 2008) are both $\bar { O } ( c n ^ { - 0 . 5 } )$ where $c$ depends on the complexity of the classification model. More recent work also follows this form. We give some examples of bounds in Table 2 without describing all of the parameters because the point is that the test error bounds vary with training size $n$ as a function of $\bar { n ^ { - 0 . 5 } }$ , for all approaches.
34
+
35
+ Table 2: Generalization bound examples: The bounds each predict generalization error increasing as a function of $n ^ { - 0 . 5 }$ . Note: variable notation is consistent only within each line, except $n$ .
36
+
37
+ <table><tr><td>Work</td><td>Key Variables</td><td>Bound</td></tr><tr><td>Neyshabur et al. (2018)</td><td>network depth d</td><td>0(n-0.5Bd) </td></tr><tr><td>Bartlett et al.(2017)</td><td>spectral complexity Rw</td><td>(Rlg(max hi)+n−0.5) 0 γn</td></tr><tr><td>Arora et al. (2018)</td><td>compressibility toqparameters withr discrete values</td><td>O(n-0.5√qlogr)</td></tr><tr><td></td><td>Bousquet &amp; Elisseeff (2Oo2)based on analysis of stability with margin </td><td>O(n-0.5/2)</td></tr></table>
38
+
39
+ # 2.2 EMPIRICAL STUDIES
40
+
41
+ Some recent empirical studies (e.g. Sun et al. (2017)) claim a log-linear relationship between error and training size, but this holds only when asymptotic error is zero. Hestness et al. (2017) model error as $e _ { t e s t } ( n ) = \alpha + \eta n ^ { \gamma }$ but often find $\gamma$ much smaller in magnitude than $- 0 . 5$ and suggest that poor fits indicate need for better hyperparameter tuning. This raises an interesting point that sample efficiency depends both on the classification model and on the efficacy of the optimization algorithm and parameters. Johnson & Nguyen (2017) also find a better fit with this extended power law model than by restricting $\gamma = - 0 . 5$ or $\alpha = 0$ . We find that, by selecting the learning rate through validation on one training size and using the Ranger optimizer (Wright, 2019), we can achieve a good approximate fit with $\gamma = - 0 . 5$ and best fit with $- 0 . 3 < \gamma < - 0 . 7$ .
42
+
43
+ In the language domain, learning curves are used in a fascinating study by Kaplan et al. (2020). For natural language transformers, they show that a power law relationship between logistic loss, model size, compute time, and dataset size is maintained if (and only if) each is increased in tandem. We draw some similar conclusions to their study, such as that increasing model size tends to improve performance especially for small training sets (which surprised us). However, the studies are largely complementary, as we study convolutional nets in computer vision, classification error (instead of logistic loss), and a broader range of design choices such as effects across depth, width, data augmentation, pretraining source, architecture, and dataset. Also related, Rosenfeld et al. (2020) model error as a function of both training size and number of model parameters with a five-parameter function that accounts for training size, model parameter size, and chance performance.
44
+
45
+ A key difference in our work is that we focus on how to best draw insights about design choices from learning curves, rather than on extrapolation. As such, we propose methods to estimate learning curves and their variance from a relatively small number of trained models.
46
+
47
+ # 2.3 PROPOSED CHARACTERIZATION OF LEARNING CURVES FOR EVALUATION
48
+
49
+ A classifier’s performance can be characterized in terms of its error and data-reliance, or how quickly the error changes with training size $n$ . With $e ( n ) = \alpha + \eta n ^ { \gamma }$ , we find that $\gamma = - 0 . 5$ provides a good local approximation but that fitting $\gamma$ significantly improves leave-one-size-out RMS error and extrapolation accuracy, as we detail in Sec. 4. However, $\alpha , \eta _ { \mathrm { { ; } } }$ , and $\gamma$ cannot be meaningfully compared across curves because the parameters have high covariance with small data perturbations, and comparing $\eta$ values is not meaningful unless $\gamma$ is fixed and vice-versa.
50
+
51
+ We propose to report error and sensitivity to training size in a way that can be derived from various learning curve models and is insensitive to data perturbations. The curve is characterized by error $e _ { N } = \alpha + \eta N ^ { \gamma }$ and data-reliance $\beta _ { N }$ at $N$ , and we typically choose $N$ as the full dataset size. Noting that most learning curves are locally well approximated by a model linear in $n ^ { - 0 . 5 }$ , we compute data-reliance as βN = N −0.5 $\begin{array} { r } { \dot { \beta } _ { N } = N ^ { - 0 . 5 } \ \frac { \partial e ^ { - } } { \partial n ^ { - 0 . 5 } } | _ { n = N } = - 2 \eta \gamma N ^ { \gamma } } \end{array}$ . When the error is plotted against $n ^ { - 0 . 5 }$ , $\beta _ { N }$ is the slope at $N$ scaled by $N ^ { - 0 . 5 }$ , where the scaling was chosen to make the practical implications of $\beta _ { N }$ more intuitive. This yields a simple predictor for error when changing training size by a factor of $d$ :
52
+
53
+ $$
54
+ e ( d \cdot N ) = e _ { N } + \left( \frac { 1 } { \sqrt { d } } - 1 \right) \beta _ { N } .
55
+ $$
56
+
57
+ Thus, by this linearized estimate, asymptotic error is $e _ { N } - \beta _ { N }$ , a 4-fold increase in data (e.g. $4 0 0 $ 1600) reduces error by $0 . 5 \beta _ { N }$ , and using only one quarter of the dataset (e.g. $4 0 0 1 0 0$ ) increases the error by $\beta _ { N }$ . For two models with similar $e _ { N }$ , the one with a larger $\beta _ { N }$ would outperform with more data but underperform with less. Note that $( e _ { N } , \beta _ { N } , \gamma )$ is a complete re-parameterization of the extended power law, with $\gamma + 0 . 5$ indicating the curvature in $n ^ { - 0 . 5 }$ scale.
58
+
59
+ # 3 ESTIMATING LEARNING CURVES
60
+
61
+ We now describe the method for estimating the learning curve from error measurements with confi
62
+ the model is trained old $e _ { i j }$ samples (either per class or in total). We ssume $j ^ { \mathrm { t h } }$ $n _ { i }$ $\{ e _ { i j } \} _ { j = 1 } ^ { F _ { i } }$ $\mathcal { N } ( \mu _ { i } , \sigma _ { i } ^ { 2 } )$ $\alpha$
63
+ ror), $\eta$ , and $\gamma$ , such that $e _ { i j } \ : = \ : \alpha + \eta n _ { i } ^ { \gamma } + \epsilon _ { i j }$ where $\epsilon _ { i j } \sim \mathcal { N } ( 0 , \bar { \sigma } _ { i } ^ { 2 } )$ and $\mu _ { i j } = { \bar { \mathbb { E } } } [ e _ { i j } ] = \mu _ { i }$ .
64
+
65
+ Sections 3.1 and 3.2 describe how to estimate mean and variance of $\alpha$ and $\eta$ for a given $\gamma$ , and Sec. 3.3 describes our approach for estimating $\gamma$ .
66
+
67
+ # 3.1 WEIGHTED LEAST SQUARES FORMULATION
68
+
69
+ We estimate learning curve parameters $\{ \alpha , \eta \}$ by optimizing a weighted least squares objective:
70
+
71
+ $$
72
+ \mathcal { G } ( \gamma ) = \operatorname* { m i n } _ { \alpha , \eta } \sum _ { i = 1 } ^ { S } \sum _ { j = 1 } ^ { F _ { i } } w _ { i j } \left( e _ { i j } - \alpha - \eta n ^ { \gamma } \right) ^ { 2 }
73
+ $$
74
+
75
+ where $w _ { i j } = 1 / ( F _ { i } \sigma _ { i } ^ { 2 } )$ . $F _ { i }$ is the number of models trained with data size $n _ { i }$ and is used to normalize the weight so that the total weight for observations from each training size does not depend on $F _ { i }$ . The factor of $\sigma _ { i } ^ { 2 }$ accounts for the variance of $\epsilon _ { i j }$ . Assuming constant $\bar { \sigma } _ { i } ^ { 2 }$ and removing the $F _ { i }$ factor would yield unweighted least squares.
76
+
77
+ The variance of the estimate of $\sigma _ { i } ^ { 2 }$ from $F _ { i }$ samples is $2 \sigma _ { i } ^ { 4 } / F _ { i }$ , which can lead to over- or underweighting data for particular $i$ if $F _ { i }$ is small. Recall that each sample $e _ { i j }$ requires training an entire model, so $F _ { i }$ is always small in our experiments. We would expect the variance to have the form $\sigma _ { i } ^ { 2 } = \sigma _ { 0 } ^ { 2 } + \hat { \sigma } ^ { 2 } / n _ { i }$ , where $\sigma _ { 0 } ^ { 2 }$ is the variance due to random initialization and optimization and ${ \hat { \sigma } } ^ { 2 } / n _ { i }$ is the variance due to randomness in selecting $n _ { i }$ samples. Indeed, by averaging over the variance estimates for many different network models on the CIFAR-100 (Krizhevsky, 2012) dataset, we find a good fit with $\sigma _ { 0 } ^ { 2 } = 0 . 2$ . This enables us to estimate a single $\hat { \sigma } ^ { 2 }$ parameter from all samples $\mathbf { e }$ in a given learning curve as a least squares fit and also upper-bounds $w _ { i j } < = 5$ even if two models happen to have the same error. This attention to $w _ { i j }$ may seem fussy, but without such care we find that the learning curve often fails to account sufficiently for all the data in some cases.
78
+
79
+ # 3.2 SOLVING FOR LEARNING CURVE MEAN AND VARIANCE
80
+
81
+ dimension Concatenating errors across dataset sizes (indexed by $\textstyle D = \sum _ { i = 1 } ^ { S } F _ { i }$ . For each $d \in \{ 1 , \cdots , D \} , e [ d$ $i$ ) and folds results in an error vector ] is an observation of error at dataset size of $n _ { i _ { d } }$ that follows $\mathcal { N } ( \mu _ { i _ { d } } , \sigma _ { i _ { d } } ^ { 2 } )$ with $i _ { d }$ mapping $d$ to the corresponding .
82
+
83
+ The weighted least squares problem can be formulated as solving a system of linear equations denoted by $W ^ { 1 / 2 } e ~ = ~ W ^ { 1 / 2 } A \pmb { \theta }$ , where $W \in \mathbb { R } ^ { D \times D }$ is a diagonal matrix of weights $W _ { d d } = w _ { d }$ , $A \in \mathbb { R } ^ { D \times 2 }$ is a matrix with $A [ d , : ] = [ 1 n _ { d } ^ { \gamma } ]$ , and $\pmb { \theta } = \left[ \alpha \eta \right] ^ { T }$ are the parameters of the learning curve, treating $\gamma$ as fixed for now. The estimator for the learning curve is then given by $\pmb { \hat { \theta } } = ( W ^ { 1 / 2 } A ) ^ { + } W ^ { 1 / 2 } \pmb { e } = M \pmb { e }$ , where $M \in \mathbb { R } ^ { 2 \times D }$ and $^ +$ is pseudo-inverse operator.
84
+
85
+ We compute a mean curve using
86
+
87
+ $$
88
+ \overline { { \pmb { \theta } } } = \mathbb { E } [ \pmb { \hat { \theta } } ] = M \mathbb { E } [ \pmb { e } ] = M \pmb { \mu }
89
+ $$
90
+
91
+ $\pmb { \mu } \in \mathbb { R } ^ { D }$ with $\mu [ d ] = \hat { \mu } _ { i _ { d } }$ computed by empirical estimate as $\textstyle \sum _ { j = 1 } ^ { F _ { i } } e _ { i j } / F _ { i }$
92
+
93
+ The covariance of the estimator is given by
94
+
95
+ $$
96
+ \Sigma _ { \hat { \pmb { \theta } } } = M \Sigma _ { e } M ^ { T }
97
+ $$
98
+
99
+ where $\Sigma _ { \hat { \pmb { \theta } } } \in \mathbb { R } ^ { 2 \times 2 }$ and $\Sigma _ { e } \in \mathbb { R } ^ { D \times D }$ is the covariance of $e$ , where $\Sigma _ { e } [ d _ { 1 } , d _ { 2 } ] = \sigma _ { i _ { d _ { 1 } } } ^ { 2 }$ if $i _ { d _ { 1 } } = i _ { d _ { 2 } }$ and 0 otherwise. We compute our empirical estimate of $\sigma _ { i } ^ { 2 }$ as described in Sec. 3.1.
100
+
101
+ Since the curve is given by $e ( n ) = [ 1 n ^ { \gamma } ] \pmb { \theta }$ , the mean curve can be computed as
102
+
103
+ $$
104
+ \begin{array} { r } { \overline { { e } } ( n ) = [ 1 \quad n ^ { \gamma } ] \overline { { \theta } } = \overline { { \alpha } } + \overline { { \eta } } n ^ { \gamma } . } \end{array}
105
+ $$
106
+
107
+ The $9 5 \%$ bounds at any $n$ can be computed as $\overline { { e } } ( n ) \pm 1 . 9 6 \times \hat { \sigma } ( n )$ with
108
+
109
+ $$
110
+ \hat { \sigma } ^ { 2 } ( n ) = [ 1 n ^ { \gamma } ] \Sigma _ { \hat { \theta } } \left[ \begin{array} { l } { 1 } \\ { n ^ { \gamma } } \end{array} \right]
111
+ $$
112
+
113
+ where $\hat { \alpha }$ and $\hat { \eta }$ are the empirical estimates of $\alpha$ and $\eta$ . These confidence bounds reflect the variance in error measurements, assuming the parameterization is capable of fitting the true mean.
114
+
115
+ # 3.3 ESTIMATING $\gamma$
116
+
117
+ We search for $\gamma$ that minimizes the weighted least squares objective with an L1-prior that slightly encourages values close to 0.5. Specifically, we solve
118
+
119
+ $$
120
+ \operatorname* { m i n } _ { \gamma \in ( - 1 , 0 ) } \mathcal { G } ( \gamma ) + \lambda | \gamma + 0 . 5 |
121
+ $$
122
+
123
+ by searching over $\gamma \in \{ - 0 . 9 9 , . . . , - 0 . 0 1 \}$ with $\lambda = 5$ for our experiments.
124
+
125
+ # 4 EXPERIMENTS
126
+
127
+ We describe our implementation details in Sec. 4.1, apply learning curves to gain insights about error and data-reliance in Sec. 4.2, and validate our choice of learning curve parameterization and fitting weights used in the least squares objective in Sec. 4.3.
128
+
129
+ # 4.1 IMPLEMENTATION DETAILS
130
+
131
+ We use Pytorch-Lightning (Falcon, 2019) for our implementation with various architectures, weight initializations, data augmentation, and linear or fine-tuning optimization.
132
+
133
+ Training: We train models with images of size $3 2 \times 3 2$ for CIFAR (Krizhevsky, 2012) and $2 2 4 \times 2 2 4$ for Places365 (Zhou et al., 2017) with a batch size of 64 (except for Wide-ResNet101 and WideResNeXt101, where we use a batch size of 32 and performed one optimizer step every two batches). For each experiment setting, we conduct a learning rate search on a subset of the training data and choose the learning rate with the highest validation accuracy, and use it for all other subsets. We determine each fold’s training schedule on a mini-train/mini-val split of 2:1 on the train set. Each time the mini-val error stops decreasing for some epochs (“patience”), we revert to the best epoch and decrease the learning rate to $10 \%$ , and we perform this twice. Then we use this optimal mini-train learning rate schedule and ending epoch to train on the whole fold. The patience is $\propto 1 / \sqrt { n }$ , and is 5 at the $n = 4 0 0$ samples/class for CIFAR100/Places365 and 15 at the largest training size for other smaller datasets. We use a weight decay value of 0.0001. We use the Ranger optimizer (Wright, 2019), which combines Rectified Adam (Liu et al., 2019), Look Ahead (Zhang et al., 2019), and Gradient Centralization (Yong et al., 2020). In early experiments, we found Ranger to lead to lower error and to reduce sensitivity of hyperparameters, compared to vanilla SGD or Adam (Kingma & Ba, 2015).
134
+
135
+ Backbone Architecture: We use the default Pytorch implementations of all of the following architectures: AlexNet (Krizhevsky et al., 2012), ResNet-18, ResNet-50, ResNet-101 (He et al., 2015b), ResNeXt-50, ResNeXt-100 (Xie et al., 2016), VGG16 BN (Simonyan & Zisserman, 2014), Wide-ResNet-50, and Wide-ResNet-101 (Zagoruyko & Komodakis, 2016). For each architecture, we modify the last layer to match the same number of classes as the test dataset with Kaiming initialization (He et al., 2015a).
136
+
137
+ Number of Training Examples: To compute learning curves for CIFAR and Places365, we vary the number of training examples per class, partition the train set, and train one model per partition. For CIFAR100 (Krizhevsky, 2012), we use $\left\{ 2 5 , 5 0 , 1 0 0 , 2 0 0 , 4 0 0 \right\}$ training examples per class, and the number of models trained for each respectively is $\{ 1 6 , 8 , 4 , 2 , 1 \}$ . Similar to Hestness et al. (2017), we find training sizes smaller than 25 samples per class are strongly influenced by bounded error and deviate from our model. For Places365 dataset, we use $\{ 2 \bar { 5 } , 5 0 , 1 0 0 , 2 0 0 , 4 0 0 , 1 6 0 0 \}$ training examples per class and $\{ 1 6 , 8 , 4 , 3 , 3 , 1 \}$ models each. For other datasets (Fig. 6), we use $\{ 2 0 \% , \bar { 4 } 0 \% , 8 \bar { 0 } \% \}$ of the full data and train $\{ 4 , 2 , 1 \}$ models each. We hold out $20 \%$ of data from the original training set for testing (a validation set could also be used if available) to discourage metafitting on the test set. For example, we hold out 100 samples per class from the original CIFAR100 training set and perform hyperparameter selection and training on the remaining 400 samples.
138
+
139
+ Pretraining: When pretraining is used, we initialize models with pretrained weights learned through supervised training on ImageNet or Places365, or MOCO self-supervised training on ImageNet (He et al., 2020). Otherwise, weights are randomly initialized with Kaiming initialization.
140
+
141
+ Data Augmentation: For CIFAR, we pad by 4 pixels and use a random $3 2 \times 3 2$ crop (test without augmentation), and for Places365 we use random-sized crop (Szegedy et al., 2015) to $2 2 4 \times 2 2 4$ and random flipping (center crop $2 2 4 \times 2 2 4$ test time). For remaining datasets, we follow the preprocessing in Zhai et al. (2020) that produced the best results when training from scratch.
142
+
143
+ Linear vs. Fine-tuning: For “linear”, we only train the final classification layer, with the other weights frozen to initialized values. All weights are trained when “fine-tuning”.
144
+
145
+ # 4.2 LEARNING CURVE COMPARISONS
146
+
147
+ We plot the fitted learning curves and confidence bounds, with observed test errors as black points. The legend displays $\gamma$ , error $e _ { N }$ , and data reliance $\beta _ { N }$ with $N = 4 0 0$ . The $\mathbf { X }$ -axis is in scale $n ^ { - 0 . 5 }$ $\mathbf { \xi } _ { n }$ in parentheses), but bestfitting $\gamma$ is used in all cases.In all plots, $n$ denotes number of samples per class except Fig. 6 where $n$ is the total number of samples. A vertical bar indicates $n = 1 6 0 0$ , which we consider the limit of accurate extrapolation from curves fit to $n \leq 4 0 0$ samples. All points are used for fitting, except in Fig. 9b $n = 1 6 0 0$ is held out to test extrapolation.
148
+
149
+ ![](images/89dc0dbfcc7066be63c89da91847b0fd180ba62457c254ed6522bf2367fb6122.jpg)
150
+ Figure 1: Architecture (w/ finetuning)
151
+
152
+ Network architecture: Advances in CNN architectures have reduced number of parameters while also reducing error over the range of training sizes. On CIFAR100,
153
+
154
+ AlexNet has 61M parameters; VGG-16, 138M; ResNet-50, 26M; ResNeXt-50, 25M; and ResNet101, 45M. Fig. 1 shows that each major advance through ResNet reduces both data-reliance and $e _ { 4 0 0 }$ , while ResNeXt appears to slightly reduce $e _ { 4 0 0 }$ without change to data-reliance.
155
+
156
+ ![](images/b331ba9fcbeaca172316403cb0b4ebdfbe11471aa090f32df610a297d3f1fc0d.jpg)
157
+ Figure 2: Pretraining and fine-tuning with ResNet-18.
158
+
159
+ Pretraining and fine-tuning: In Fig. 2 we see that, for linear classifiers, pretraining leads to a huge improvement in $e _ { 4 0 0 }$ though with a moderate increase in data-reliance. When fine-tuning, the pretraining greatly reduces datareliance $\beta _ { 4 0 0 }$ and also reduces $e _ { 4 0 0 }$ . Pretraining clearly improves performance with smaller training sizes. However, we cannot draw conclusions about bias because extrapolated asymptotic error is not reliable, and the full story is complicated. On an object detection task, He et al. (2019) find that, with long learning schedules, randomly initialized networks approach the performance of pretrained networks (for the CNN backbone), even with finite data. Experiments by Zoph et al. (2020), also on object detection, show that pretraining can sometimes harm performance when strong data augmentation is used. Kornblith et al. (2019) show that fine-tuned pretrained models outperform randomly initialized models on many datasets, but the gap is often small and narrows as data size grows. All agree that pretraining is at least important for providing a warm start that greatly reduces the training time, but whether it introduces bias (i.e. asymptotic error) likely depends on the tasks, domains, and optimization settings.
160
+
161
+ ![](images/e24cb5c4d040a659a68786e3fd48877b4126b0eaaba0feca3d55d6c4809d5c93.jpg)
162
+ Figure 3: Pretraining sources (test on Cifar100).
163
+
164
+ Pretraining data sources: In Fig. 3, we compare pretraining strategies: random, supervised on ImageNet or Places365, and self-supervised on ImageNet (MOCO by He et al. (2020)). All initializations have similar extrapolated error at $n = 1 6 0 0$ , but different data-reliance. Self-supervised MOCO leads to lower $e _ { 4 0 0 }$ and $\beta _ { 4 0 0 }$ compared to Places365 pretraining. Supervised pretraining on ImageNet has the lowest $e _ { 4 0 0 }$ and $\beta _ { 4 0 0 }$ . We suspect that the $\gamma = - 0 . 6 7$ and higher extrapolated asymptotic error may be due to measurement noise and suboptimal hyperparameter selection.
165
+
166
+ ![](images/71bc00f37af6f6fadc6bf231cc61a63db5b20fd0f4a4fac621b2dc5afd909dff.jpg)
167
+ Figure 4: Depth, width, and ensembles on Cifar100.
168
+
169
+ Network depth, width, and ensembles: The classical view is that smaller datasets need simpler models to avoid overfitting. In Figs. 4a, 4b, we show that, not only do deeper networks have better potential at higher data sizes, their data reliance does not increase (nearly parallel and drops a little for fine-tuning), making deeper networks perfectly suitable for smaller datasets. For linear classifiers (Fig. 4b), the deeper networks provide better features, leading to consistent drop in $e _ { 4 0 0 }$ . The small jump in data reliance between Resnet-34 and Resnet-50 may be due to the increased last layer input size from 512 to 2048 nodes. When increasing width, the fine-tuned networks (Fig. 4c) have reduced $e _ { 4 0 0 }$ without much change to data-reliance. With linear classifiers (Fig. 4d), increasing the width leads to little change or even increase in $e _ { 4 0 0 }$ with slight decrease in data-reliance. Rosenfeld et al. (2020) show that error can be modeled as a function of either training size, model size, or both. Modeling both jointly can provide additional capabilities such as selecting model size based on data size, but requires many more experiments to fit the curve.
170
+
171
+ An alternative to using a deeper or wider network is forming ensembles. In Figure 4e, we find that while an ensemble of six ResNet-18’s (each 11.7M parameters) improves over a single model, it has higher $e _ { 4 0 0 }$ and data-reliance than ResNet-101 (44.5M), Wide-ResNet-50 (68.9M), and WideResNet-101 (126.9M). Three ResNet-50’s (each 25.6M) underperforms Wide-ResNet-50 on $e _ { 4 0 0 }$ but outperforms for small amounts of data due to lower data reliance.
172
+
173
+ ![](images/127d6c997d6b33031f3726ecd06e71d71a44e9e9b5345b9a7337ab78e64e30d5.jpg)
174
+ Figure 5: Data augmentation on Places365.
175
+
176
+ Data Augmentation: One may expect that data augmentation acts as a regularizer with reduced effect for large training sizes, or even possibly negative effect due to introducing bias. However, Fig. 5 shows that data augmentation on Places365 reduces error for all training sizes with little or no change to data-reliance when fine-tuning. $e ( n )$ with augmentation roughly equals $e ( 1 . 8 n )$ without it, supporting the view that augmentation acts as a multiplier on the value of an example. For the linear classifier, data augmentation has little apparent effect due to low data-reliance, but the results are still consistent with this multiplier.
177
+
178
+ Additional datasets: In Fig. 6, we verify that our learning curve model fits to multiple other datasets (chosen from natural tasks in Zhai et al. (2020)), comparing fine-tuned vs. linear with Resnet-18. For these plots only, $n$ is the total number of samples. The $\gamma$ values are estimated from data, but the prior has more effect here due to fewer error measurements.
179
+
180
+ We see fine-tuning consistently outperforms linear, though the difference is most dramatic for Sun397. Pretraining provides large benefits across datasets.
181
+
182
+ ![](images/95c163ce7a2adf0dd0e0d1c78fe5f113ee774c59e8eaa74f74df08e4aa2fd338.jpg)
183
+ Figure 6: Additional datasets
184
+
185
+ # 4.3 EVALUATION OF LEARNING CURVES MODEL AND FITTING
186
+
187
+ We validate our learning curve model using leave-one-size-out prediction error, for example, predicting empirical mean performance with 400 samples per class based on observing error from models trained on 25, 50, 100, and 200 samples. We consider various choices of weighting schemes ( $w$ ’s in Eq. 2) and estimating different parameters in a general form of the learning curve given by $e ( n ) = \alpha { \dot { + } } \eta n ^ { \gamma } + \delta n ^ { 2 \gamma }$ . Note that setting $\delta = 0$ yields the learning curve model described in Sec. 3.
188
+
189
+ Weighting Schemes. In the Fig. 7 table, we compare three weighting schemes across 16 classifiers: $w _ { i j } = 1$ is unweighted; $w _ { i j } \stackrel { \mathbf { \textstyle = } } { = } 1 / \sigma _ { i } ^ { 2 }$ is weighted by estimated size-dependent standard deviation; $\dot { w _ { i j } } = 1 / ( F _ { i } \sigma _ { i } ^ { 2 } )$ makes the total weight for a given dataset size invariant to the number of folds. On average our proposed weighting performs best with high significance compared to unweighted. The p-value is paired t-test of difference of means calculated across all dataset sizes.
190
+
191
+ Model Choice. We consider other parameterizations that are special cases of $e ( n ) = \alpha + \eta n ^ { \gamma } + \delta n ^ { 2 \gamma }$ The table in Fig. 7 shows that the parameterization used for our experiments outperforms the others, in most cases with high significance, and achieves a very good fit with $R ^ { 2 }$ of 0.998.
192
+
193
+ Model Stability. We test stability and sample requirements by repeatedly fitting curves to four resampled data points for a model (Resnet-18, no pretraining, fine-tuned, tested on Places365). Based on estimates of mean and standard deviation, one point each at $n = \{ 5 0 , 1 0 0 , 2 0 0 , 4 0 0 \}$ is sampled and used to fit a curve, repeated 100 times. Parentheses in legend show standard deviation of estimates of $e _ { N }$ , $\beta _ { N }$ , and $\gamma$ . Our preferred model extrapolates best to $n = 1 6 0 0$ and $n = 2 5$ while retaining stable estimates of of $e _ { N }$ and $\beta _ { N }$ , but predicted asymptotic error $\alpha$ varies widely.
194
+
195
+ Appendix C shows similar estimates of $e _ { N }$ and $\beta _ { N }$ by fixing $\gamma = - 0 . 5$ and fitting only $\alpha$ and $\eta$ on the three largest sizes (typically $n = \{ 1 0 0 , 2 0 0 , 4 0 0 \} \rangle$ , indicating that a lightweight approach of training a few models can yield similar conclusions.
196
+
197
+ ![](images/a31c32ca5b343ccd589f5d5f55ff5693deef4785c72b7ddde171ee03ebf39045.jpg)
198
+
199
+ Figure 7: Learning curve model and weights validation. See text for explanation.
200
+
201
+ <table><tr><td></td><td></td><td></td><td colspan="7">RMSE</td></tr><tr><td>Params</td><td>Weights</td><td>R²</td><td>25</td><td>50</td><td>100</td><td>200</td><td>400</td><td>avg</td><td>p-value</td></tr><tr><td rowspan="4">α,n,</td><td>1</td><td>0.998</td><td>2.40</td><td>0.86</td><td>0.54</td><td>0.57</td><td>0.85</td><td>1.04</td><td>-</td></tr><tr><td></td><td>0.999</td><td>2.38</td><td>0.83</td><td>0.69</td><td>0.54</td><td>1.08</td><td>1.10</td><td>0.06</td></tr><tr><td></td><td>0.998</td><td>2.66</td><td>0.86</td><td>0.79</td><td>0.50</td><td>1.26</td><td>1.21</td><td>0.008</td></tr><tr><td></td><td>0.988</td><td>3.41</td><td>1.09</td><td>0.69</td><td>0.72</td><td>1.21</td><td>1.42</td><td>&lt;0.001</td></tr><tr><td>α,n a,n,</td><td>谢 南</td><td>0.999</td><td>2.89</td><td>0.74</td><td>0.68</td><td>0.56</td><td>0.94</td><td>1.16</td><td>0.05</td></tr><tr><td>a,nd,</td><td>新</td><td>0.999</td><td>3.46</td><td>0.74</td><td>0.70</td><td>0.59</td><td>1.00</td><td>1.30</td><td>0.02</td></tr></table>
202
+
203
+ # 5 LIMITATIONS AND FUTURE WORK
204
+
205
+ Limitations: Our work in this paper is limited to classification loss, and our model does not account for small sample effects where chance performance is a major factor. Although our proposed $e _ { N }$ and $\beta _ { N }$ are stable under perturbations and different learning curve parameterizations, the asymptotic error $\alpha$ and exponent $\gamma$ parameters of the learning curve are unstable, and our confidence interval does not account for $\gamma$ variance. Unstable $\alpha$ means that little can be concluded about asymptotic performance, though $e _ { N } - \beta _ { N }$ can stand in as a measure of large-data performance. Unstable $\gamma$ may mean that conclusions are subject to the hyperparameter selection and optimization method.
206
+
207
+ Future work: Do the hyperparameters such as learning rate, schedule, and weight decay determine $\gamma$ , or something else? It appears that $\gamma \ : < \ : - 0 . 5$ is accompanied by high $\alpha$ and/or $\eta$ . Should $\gamma = - 0 . 5$ for a well-trained system? Answering these questions could lead to improved training and evaluation methodologies. It would also be interesting to investigate learning curve models for small training size, other losses and prediction types, more design parameters and interactions, and impact of imbalance in class distribution.
208
+
209
+ Appendix A offers extended discussion. Appendix B provides a guide to fitting, displaying, and using learning curves. Appendix C contains a table of learning curves for all of our experiments and compares $e _ { N }$ and $\beta _ { N }$ produced by two learning curve models.
210
+
211
+ # 6 CONCLUSION
212
+
213
+ We investigate learning curve models for analyzing classifier design decisions. We find an extended power law provides the best fit across many different architectures, datasets, and other design parameters. We propose to characterize error and data-reliance with $e _ { N }$ and $\beta _ { N }$ , which are stable under data perturbations and can be derived from different learning curve models. Our experiments lead to several interesting observations about impacts of pretraining, fine-tuning, data augmentation, depth, width, and ensembles. We anticipate learning curves can further inform training methodology, continual learning, and representation learning, among other problems, and hope to see learning curves become part of a standard classification evaluation.
214
+
215
+ # REFERENCES
216
+
217
+ Sanjeev Arora, Rong Ge, Behnam Neyshabur, and Yi Zhang. Stronger generalization bounds for deep nets via a compression approach. CoRR, abs/1802.05296, 2018. URL http://arxiv. org/abs/1802.05296.
218
+
219
+ Peter L. Bartlett, Dylan J. Foster, and Matus Telgarsky. Spectrally-normalized margin bounds for neural networks. CoRR, abs/1706.08498, 2017. URL http://arxiv.org/abs/1706. 08498.
220
+
221
+ O. Bousquet and A. Elisseeff. Stability and generalization. Journal of Machine Learning Research, 2:499–526, 2002.
222
+
223
+ Corinna Cortes, L. D. Jackel, Sara A. Solla, Vladimir Vapnik, and John S. Denker. Learning curves: Asymptotic values and rate of convergence. In NIPS, 1993.
224
+
225
+ Pedro Domingos. A unified bias-variance decomposition. In ICML, 2000.
226
+
227
+ WA Falcon. Pytorch lightning. GitHub. Note: https://github.com/PyTorchLightning/pytorchlightning, 3, 2019.
228
+
229
+ Stuart Geman, Elie Bienenstock, and Rene Doursat. Neural networks and the bias/variance dilemma. ´ Neural Computation, 4:1–58, 01 1992. doi: 10.1162/neco.1992.4.1.1.
230
+
231
+ Giorgio Gnecco and Marcello Sanguineti. Approximation error bounds via rademacher’s complexity. 2(4), 2008.
232
+
233
+ 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, 2015a.
234
+
235
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. CoRR, abs/1512.03385, 2015b. URL http://arxiv.org/abs/1512.03385.
236
+
237
+ Kaiming He, Ross Girshick, and Piotr Dollar. Rethinking imagenet pre-training. pp. 4917–4926, 10 2019. doi: 10.1109/ICCV.2019.00502.
238
+
239
+ Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9729–9738, 2020.
240
+
241
+ Joel Hestness, Sharan Narang, Newsha Ardalani, Gregory F. Diamos, Heewoo Jun, Hassan Kianinejad, Md. Mostofa Ali Patwary, Yang Yang, and Yanqi Zhou. Deep learning scaling is predictable, empirically. CoRR, 2017.
242
+
243
+ Mark Johnson and Dat Quoc Nguyen. How much data is enough? Predicting how accuracy varies with training data size. Technical report, 2017.
244
+
245
+ Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models, 2020.
246
+
247
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
248
+
249
+ S. Kornblith, J. Shlens, and Q. V. Le. Do better imagenet models transfer better? In CVPR, 2019.
250
+
251
+ Alex Krizhevsky. Learning multiple layers of features from tiny images. University of Toronto, 05 2012.
252
+
253
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In F. Pereira, C. J. C. Burges, L. Bottou, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 25, pp. 1097– 1105. Curran Associates, Inc., 2012. URL http://papers.nips.cc/paper/ 4824-imagenet-classification-with-deep-convolutional-neural-networks. pdf.
254
+
255
+ Liyuan Liu, Haoming Jiang, Pengcheng He, Weizhu Chen, Xiaodong Liu, Jianfeng Gao, and Jiawei Han. On the variance of the adaptive learning rate and beyond. arXiv preprint arXiv:1908.03265, 2019.
256
+
257
+ Behnam Neyshabur, Srinadh Bhojanapalli, and Nathan Srebro. A PAC-bayesian approach to spectrally-normalized margin bounds for neural networks. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ Skz_WfbCZ.
258
+
259
+ Jonathan S. Rosenfeld, Amir Rosenfeld, Yonatan Belinkov, and Nir Shavit. A constructive prediction of the generalization error across scales. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $=$ ryenvpEKDr.
260
+
261
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. CoRR, abs/1409.1556, 2014. URL http://arxiv.org/abs/1409.1556.
262
+
263
+ Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In IEEE International Conference on Computer Vision, pp. 843–852, 2017.
264
+
265
+ Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1–9, 2015.
266
+
267
+ Mingxing Tan and Quoc V Le. EfficientNet: Rethinking model scaling for convolutional neural networks. arXiv preprint arXiv:1905.11946, 2019.
268
+
269
+ Alexandre B. Tsybakov. Introduction to Nonparametric Estimation. Springer Publishing Company, Incorporated, 1st edition, 2008. ISBN 0387790519.
270
+
271
+ V. N. Vapnik and A. Ya. Chervonenkis. On the uniform convergence of relative frequencies of events to their probabilities. Theory of Probability and its Applications, 16(2):264–280, 1971. doi: 10.1137/1116025. URL http://link.aip.org/link/?TPR/16/264/1.
272
+
273
+ Less Wright. New deep learning optimizer, ranger: Synergistic combination of radam $^ +$ lookahead for the best of both. Github https://github.com/lessw2020/Ranger-Deep-Learning-Optimizer, 08 2019.
274
+
275
+ Saining Xie, Ross B. Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated resid- ´ ual transformations for deep neural networks. CoRR, abs/1611.05431, 2016. URL http: //arxiv.org/abs/1611.05431.
276
+
277
+ Hongwei Yong, Jianqiang Huang, Xiansheng Hua, and Lei Zhang. Gradient centralization: A new optimization technique for deep neural networks. ArXiv, abs/2004.01461, 2020.
278
+
279
+ Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. CoRR, abs/1605.07146, 2016. URL http://arxiv.org/abs/1605.07146.
280
+
281
+ Xiaohua Zhai, Joan Puigcerver, Alexander Kolesnikov, Pierre Ruyssen, Carlos Riquelme, Mario Lucic, Josip Djolonga, Andre Susano Pinto, Maxim Neumann, Alexey Dosovitskiy, Lucas Beyer, Olivier Bachem, Michael Tschannen, Marcin Michalski, Olivier Bousquet, Sylvain Gelly, and Neil Houlsby. A large-scale study of representation learning with the visual task adaptation benchmark. arXiv preprint arXiv:1910.04867, 2020.
282
+
283
+ Michael Ruogu Zhang, James Lucas, Geoffrey E. Hinton, and Jimmy Ba. Lookahead optimizer: k steps forward, 1 step back. In NeurIPS, 2019.
284
+
285
+ Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 million image database for scene recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017.
286
+
287
+ Barret Zoph, Golnaz Ghiasi, Tsung-Yi Lin, Yin Cui, Hanxiao Liu, Ekin D. Cubuk, and Quoc V. Le. Rethinking pre-training and self-training, 2020.
288
+
289
+ # A EXTENDED DISCUSSION
290
+
291
+ Evaluation methodology is the foundation of research, impacting how we choose problems and rank solutions. Large train and test sets now serve as the fuel and crucible to refine machine learning methods. The current evaluation standard of using fixed i.i.d. train/test sets has supported many classification model improvements, but as machine learning broadens to continual learning, representation learning, long-tail learning, and so on, we need evaluation methods that better reflect the uncontrollable, unpredictable, and ever-changing world. By characterizing performance in terms of error and data-reliance, we can provide a more complete understanding of model design and training size impact than single-point error. With that perspective, we discuss the limitations of our experiments and directions for future work.
292
+
293
+ • Cause and impact of $\gamma$ : We speculate that $\gamma$ is largely determined by hyperparameters and optimization rather than model design, so conclusions are conditioned on particular training parameters. This presents an opportunity to identify poor training regimes and improve them. Intuitively, one would expect that more negative $\gamma$ values are better (i.e. $\gamma = - 1$ preferable to $\gamma = - 0 . 5 )$ , since the curve is curve $O ( n ^ { \gamma } )$ , but we find the highmagnitude $\gamma$ tends to come with high asymptotic error, indicating that the efficiency comes at cost of over-commitment to initial conditions. We speculate (but with some disagreement among authors) that $\gamma = - 0 . 5$ is an indication of a well-trained curve and will generally outperform curves with higher or lower $\gamma$ , given the same classification model. It would be interesting to examine the impact of hyperparameter selection and optimization method on $\gamma$ .
294
+
295
+ • Small training sets: Error is bounded and, with small training sets, classifier performance may be modeled as transitioning from random guess to informed prediction, as shown by Rosenfeld et al. (2020). We do not model performance with very small training size, partly to keep our model simple, partly because small training performance can be easily measured empirically, and partly because performance with small training size is highly variable depending on the sample. However, studying performance with small training sizes could be interesting, particularly to determine whether design decisions have an impact at the small size that is not apparent at larger sizes.
296
+
297
+ • Losses and Prediction types: We analyze multiclass classification error, but the same analysis could likely be extended to other losses and prediction types. For example, Kaplan et al. (2020) analyze learning manifolds of cross-entropy loss, which is unbounded, of language model transformers. Problems like object detection or grounding sometimes have relatively complex evaluation measures, such as average precision after accounting for localization and label accuracy, but test evaluation of the same losses used for training should still apply. Sun et al. (2017) show an approximately log-linear behavior between mean intersection of union semantic segmentation error as a function of number of training samples.
298
+
299
+ More design parameters and interactions: The interaction between data scale, model scale, and performance is well-explored by Kaplan et al. (2020) and Rosenfeld et al. (2020), but it could also be interesting to explore interactions, e.g. between class of architecture (e.g. VGG, ResNet, EfficientNet (Tan & Le, 2019)) and some design parameters, to see how ideas such as skip-connections, residual layers and creating bottlenecks influence performance. More extensive evaluation of data augmentation, representation learning, optimization and regularization methods would also be interesting.
300
+
301
+ • Unbalanced class distributions: In most of our experiments, we use equal number of samples per class. Further experimentation is required to determine whether class imbalance impacts the form of the learning curve.
302
+
303
+ # B USER’S GUIDE TO LEARNING CURVES
304
+
305
+ # B.1 USES FOR LEARNING CURVES
306
+
307
+ • Comparison: When comparing two learners, measuring the error and data-reliance provides a better understanding of the differences than evaluating single-point error. We compare curves with $e _ { N }$ and $\beta _ { N }$ , rather than directly using the curve parameters, because they are more stable under data perturbations and do not depend on the parameterization, instead corresponding to error and rate of change about $n = N$ . $e _ { N } - \beta _ { N }$ can be used as a measure of large-sample performance.
308
+
309
+ • Performance extrapolation: A $1 0 \mathrm { x }$ increase in training data can require a large investment, sometimes millions of dollars. Learning curves can predict how much performance will improve with the additional data to judge whether the investment is worthwhile.
310
+
311
+ • Model selection: When much training data is available, architecture, hyperparameters, and losses can be designed and selected using a small subset of the data to minimize the extrapolated error of the full training set size. Higher-parameter models such as in Kaplan et al. (2020) and Rosenfeld et al. (2020) may be more useful as a mechanism to simultaneously select scale parameters and extrapolate performance, though fitting those models is much more computationally expensive due to the requirement of sampling error/loss at multiple scales and data sizes.
312
+
313
+ Hyperparameter validation: A poor fitting learning curve (or one with $\gamma$ far from $- 0 . 5 )$ is an indication of poor choice of hyperparameters, as pointed out by Hestness et al. (2017).
314
+
315
+ # B.2 ESTIMATING AND DISPLAYING LEARNING CURVES
316
+
317
+ Use validation set: We recommend computing learning curves on a validation set, rather than a test set, according to best practice of performing a single evaluation on the test set for the final version of the algorithm. All of our experiments are on a validation set, which is carved from the official training set if necessary.
318
+
319
+ Generate at least four data points: In most of our experiments on CIFAR100, we train a 31 models: 1 on 400 images, 2 on 200 images, 4 on 100 images, 8 on 50 images, and 16 on 25 images. Each trained model provides one data point, the average validation error. In each case, the training data is partitioned so that the image sets within the same size are non-overlapping. Training multiple models at each size enables estimating the standard deviation for performing weighted least squares and producing confidence bounds. However, our experiments indicate that learning curves are highly stable, so a minimal experiment of training four models on the full, half, quarter, and eighth-size training set may be sufficient as part of a standard evaluation. See Fig. 8 It may be necessary to train more models if attempting to distinguish fine differences.
320
+
321
+ ![](images/47d77477960d18d6032e3140630d6b3c650ba359e97e9bfaabdce4c1b624e1ec.jpg)
322
+ Figure 8: Stability under sparse measurements: Sampled learning curves for Places365 fine-tuned without pretraining are shown for four different learning curve parameterizations. In each case, means and standard deviations (shown by error bars) are estimated for $n = 5 0$ , $n = 1 0 0$ , $n = 2 0 0$ , $n = 4 0 0$ , using all the data points shown as white circles. Then, 100 times, we sample one point each from a Guassian distribution and fit a learning curve to the four points. In parantheses, the legend shows the standard deviation of $e _ { N }$ , $\beta _ { N }$ , and $\gamma$ . Note that the parameterization of $\{ \alpha , \eta , \gamma \}$ extrapolates best to lower and higher data sizes while still producing stable estimates of $e _ { N }$ and $\beta _ { N }$ . Asymptotic error, however, varies widely.
323
+
324
+ Set hyperparameters: The learning rate and learning schedule are key parameters to be set. We have not experimented with changes to weight decay, momentum, or other hyperparameters.
325
+
326
+ Fit learning curves: If more than one data point is available for the same training size, the standard deviation can be estimated. As described in Sec. 3, we recommend fitting a model of $\sigma _ { i } ^ { 2 } = \sigma _ { 0 } ^ { 2 } +$ $\hat { \sigma } ^ { 2 } / n$ , where $\sigma _ { 0 } ^ { 2 }$ . $\sigma _ { 0 } ^ { 2 }$ is the variance due to randomness in initialization and optimization. The fitting is not highly sensitive to this parameter, so we recommend setting $\sigma _ { 0 } ^ { 2 } = 0 . { \dot { 0 } } 1$ and fitting $\hat { \sigma }$ to observations, since estimating both from experiments to generate a single learning curve introduces high variance and instability.
327
+
328
+ Display learning curves or parameters: As in this paper, learning curves can be plotted linearly with the $\mathbf { X }$ -axis as $n ^ { - 0 . 5 }$ and the y-axis as error. We choose this rather than log-linear because it reveals prediction of asymptotic error and yields a linear plot when $\gamma = - 0 . 5$ . Since space is often a premium, the learning curve parameters can be displayed instead, as illustrated in Table 3.
329
+
330
+ Table 3: Results: $\mathrm { \ m o d e l _ { 1 } }$ and model2 have similar percent test error when training on the full set. Fitting a learning curve on the validation set, we see that $\mathrm { \ m o d e l _ { 2 } }$ has higher data-reliance, so may outperform for larger training sets. This is a hypothetical example to illustrate use of learning curves in a table.
331
+
332
+ <table><tr><td></td><td>eN</td><td>βN</td><td>2</td></tr><tr><td>model1</td><td>25.3 %</td><td>4.6</td><td>-0.36</td></tr><tr><td>model2</td><td>25.2 %</td><td>8.4</td><td>-0.47</td></tr></table>
333
+
334
+ # C TABLE OF LEARNING CURVES
335
+
336
+ Table 4 shows experimental settings and fit parameters for learning curves under two parameterizations. We can see that similar $e _ { 4 0 0 }$ and $\beta _ { 4 0 0 }$ values are obtained when fixing $\gamma = - 0 . 5$ and fitting to errors with only three training sizes (RMS difference in $e _ { 4 0 0 }$ and $\gamma _ { 4 0 0 }$ are 0.42 and 0.95, respectively). This means that learning curves can be fit and compared without training a large number of additional models.
337
+
338
+ Table 4: Experiment settings and parameters: We show the datasets, architectures, settings, and learning rate (set by mini-train/val) used to train and test our classifiers. Next, we show the parameters fit using the extended power law model $e ( n ) = \alpha + \eta n ^ { - \gamma }$ . Next to that, we show the model resulting from setting $\gamma = - 0 . 5$ and fitting to only the three training sizes with highest n.
339
+
340
+ <table><tr><td></td><td colspan="2">dataset arch</td><td colspan="2"># param pretrain/init</td><td colspan="2">fine-tune?</td><td colspan="2">data aug? IrnRate</td><td colspan="2">extended power law n 7</td><td colspan="2">β400 α</td><td colspan="2">𝑛−0.5 linear fit to last 3 points e400 β400</td></tr><tr><td colspan="9">PRETRAIN_IN2CIFAR</td><td>e.400</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>No Pretr; Linear</td><td>CIFAR</td><td>Resnet-18</td><td>51K</td><td>Random</td><td>No</td><td>Yes</td><td>0.01</td><td>78.51 120.13</td><td>-0.84</td><td>79.29</td><td>1.32</td><td>78.06</td><td>26.12 79.36</td><td>1.31</td></tr><tr><td>No Pretr; Finetune</td><td>CIFAR</td><td>Resnet-18</td><td>11.7M</td><td>Random</td><td>Yes</td><td>Yes</td><td>0.01</td><td>5.68 259.29</td><td>-0.41</td><td>27.91</td><td>18.23</td><td>11.21 336.13</td><td>28.02</td><td>16.81</td></tr><tr><td>Pretr; Linear</td><td>CIFAR</td><td>Resnet-18</td><td>51K</td><td>ImageNet</td><td>No</td><td>Yes</td><td>0.0003</td><td>24.4 65.28</td><td>-0.35</td><td>32.42</td><td>5.61 27.33</td><td>102.16</td><td>32.44</td><td>5.11</td></tr><tr><td>Pretr; Finetune</td><td>CIFAR</td><td>Resnet-18</td><td>11.7M</td><td>ImageNet</td><td>Yes</td><td>Yes</td><td>0.001</td><td>12.48 194.19</td><td>-0.57</td><td>18.86</td><td>7.28 11.37</td><td>150.73</td><td>18.91</td><td>7.54</td></tr><tr><td colspan="9">PRETRAIN_IN2PLACES</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>No Pretr; Linear</td><td>Places</td><td>Resnet-18</td><td>187K</td><td>Random</td><td>No</td><td>Yes</td><td>0.03</td><td>91.84 19.13</td><td>-0.5</td><td>92.79</td><td>0.96 91.09</td><td>29.31</td><td></td><td>1.47</td></tr><tr><td>No Pretr; Finetune</td><td>Places</td><td>Resnet-18</td><td>11.7M</td><td>Random</td><td>Yes</td><td>Yes</td><td>0.001</td><td>33.16 117.45</td><td>-0.26</td><td>57.89</td><td>12.86</td><td>44.39 263.63</td><td>92.55 57.57</td><td>13.18</td></tr><tr><td>Pretr; Linear</td><td>Places Places</td><td>Resnet-18 Resnet-18</td><td>187K 11.7M</td><td>ImageNet ImageNet</td><td>No Yes</td><td>Yes Yes</td><td>0.0003 0.0003</td><td>54.43 53.39 40.92 70.04</td><td>-0.38 -0.28</td><td>59.91</td><td>4.16 56.11</td><td>76.95</td><td>59.95</td><td>3.85</td></tr><tr><td colspan="9">Pretr; Finetune</td><td>54</td><td>7.33 44.82</td><td>174.69</td><td>53.55</td><td>8.73</td></tr><tr><td>PRETRAIN_IN_PLACES_MOCO2CIFAR</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>No Pretr</td><td>CIFAR</td><td>Resnet-50</td><td>25.6M</td><td>Random</td><td>Yes</td><td>Yes</td><td>0.01</td><td>-2.23 243.44</td><td>-0.35</td><td>27.66</td><td>20.93</td><td>9.18 372.11</td><td>27.79</td><td>18.61</td></tr><tr><td>Pretr on Imagenet Pretr on Places</td><td>CIFAR CIFAR</td><td>Resnet-50 Resnet-50</td><td>25.6M 25.6M</td><td>ImageNet Places</td><td>Yes Yes</td><td>Yes Yes</td><td>0.001 0.001</td><td>15.11 178.61 -5.61 109.92</td><td>-0.67 -0.24</td><td>18.33</td><td>4.32</td><td>13.3 99.88</td><td>18.29</td><td>4.99</td></tr><tr><td colspan="9">Pretr on Imagenet with MOCO</td><td>20.49</td><td>12.53 10.07</td><td>9.05 195.43</td><td>18.82</td><td>9.77</td></tr><tr><td></td><td>CIFAR</td><td>Resnet-50</td><td>25.6M</td><td>ImageNet (MOCO)</td><td>Yes</td><td>Yes</td><td>0.0003</td><td>0.07 112.69</td><td>-0.3</td><td>18.74</td><td>11.21</td><td>210.67</td><td>20.61</td><td>10.53</td></tr><tr><td>DEPTH_FT</td><td>CIFAR</td><td>Resnet-18</td><td>11.7M</td><td></td><td>Yes</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td colspan="9">Resnet-18 Resnet-34</td><td></td><td>7.28</td><td>11.37</td><td>150.73</td><td></td><td>7.54</td></tr><tr><td>Resnet-50</td><td>CIFAR CIFAR</td><td>Resnet-34</td><td>21.8M</td><td>ImageNet ImageNet</td><td>Yes</td><td>Yes Yes</td><td>0.001 0.001</td><td>12.48 194.19 15.76 237.19</td><td>-0.57 -0.73</td><td>18.86 18.75</td><td></td><td>104.15</td><td>18.91</td><td></td></tr><tr><td></td><td></td><td>Resnet-50</td><td>25.6M</td><td>ImageNet</td><td>Yes</td><td>Yes</td><td>0.001</td><td>15.11 178.61</td><td>-0.67</td><td>18.33</td><td>4.36 13.51 4.32</td><td>13.3 99.88</td><td>18.72 18.29</td><td>5.21 4.99</td></tr><tr><td>Resnet-101</td><td>CIFAR</td><td>Resnet-101</td><td>44.5M</td><td>ImageNet</td><td>Yes</td><td>Yes</td><td>0.0003</td><td>10.91 166.44</td><td>-0.62</td><td>14.97</td><td>5.03 8.95</td><td>117.22</td><td></td><td>5.86</td></tr><tr><td>DEPTH_LINEAR</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>14.81</td><td></td></tr><tr><td>Resnet-18</td><td>CIFAR</td><td>Resnet-18</td><td>51K</td><td>ImageNet</td><td>No</td><td>Yes</td><td>0.001</td><td>24.4 65.28</td><td>-0.35</td><td>32.42</td><td></td><td></td><td></td><td></td></tr><tr><td>Resnet-34</td><td>CIFAR</td><td>Resnet-34</td><td>51K</td><td>ImageNet</td><td>No</td><td>Yes</td><td>0.001</td><td>21.77 59.56</td><td>-0.33</td><td>30.02</td><td>5.61 5.44</td><td>27.33 102.16</td><td>32.44</td><td>5.11</td></tr><tr><td>Resnet-50</td><td>CIFAR CIFAR</td><td>Resnet-50 Resnet-101</td><td>205K 205K</td><td>ImageNet ImageNet</td><td>No No</td><td>Yes Yes</td><td>0.0003 0.0003</td><td>13.5 56.54</td><td>-0.22</td><td>28.63</td><td>25.11 6.66 23.05</td><td>98.33 112.08</td><td>30.03 28.65</td><td>4.92 5.6</td></tr><tr><td colspan="9">Resnet-101</td><td></td><td></td><td>20.98</td><td>99.32</td><td></td><td>4.97</td></tr><tr><td>WIDTH_FT</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>11.17 51.7</td><td>-0.21</td><td>25.86</td><td>6.17</td><td></td><td>25.95</td><td></td></tr><tr><td>Resnet-50</td><td>CIFAR</td><td>Resnet-50</td><td>25.6M</td><td>ImageNet</td><td>Yes</td><td>Yes</td><td>0.001</td><td>178.61</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>2xWide-Resnet-50</td><td>CIFAR</td><td>Wide_Resnet-50.2</td><td>68.9M</td><td>ImageNet</td><td>Yes</td><td>Yes</td><td>0.0003</td><td>15.11 8.78 160.14</td><td>-0.67 -0.57</td><td>18.33</td><td>4.32</td><td>13.3 99.88</td><td>18.29</td><td>4.99</td></tr><tr><td>Resnet-101</td><td>CIFAR</td><td>Resnet-101</td><td>44.5M</td><td>ImageNet</td><td>Yes</td><td>Yes Yes</td><td>0.0003 0.0003</td><td>10.91 166.44</td><td>-0.62</td><td>14.04 14.97</td><td>6 7.83 5.03 8.95</td><td>124.55 117.22</td><td>14.06 14.81</td><td>6.23 5.86</td></tr><tr><td>2xWide-Resnet-101 WIDTH_LINEAR</td><td>CIFAR</td><td>Wide_Resnet-101.2</td><td>126.9M</td><td>ImageNet</td><td>Yes</td></table>
341
+
342
+ # D DRAFT ADDITIONAL CHANGES TO INCLUDE IN FINAL VERSION
343
+
344
+ This section contains preliminary results and text requested by reviewers that will be carefully integrated into the main document in final revision.
345
+
346
+ # D.1 OPTIMIZATION EXPERIMENTS
347
+
348
+ ![](images/4ceef80b65a6e92513d70ef3b84cdf47bb9c2291c8ba8623844122d702f5bb1b.jpg)
349
+ Figure 9: Optimization on Cifar10 with ResNet-18.
350
+
351
+ In Fig. 9, we show results on Cifar10 when training ResNet-18 using four different optimization methods: Ranger (Wright, 2019), Adam (Kingma & Ba, 2015), stochastic gradient descent (SGD) w/ momentum, and SGD w/o momentum. Similarly to our experiments with Cifar100, we use $80 \%$ of the standard training set for training and validation (4000 examples per class) and the remaining $20 \%$ for testing. With pretraining, all methods perform similarly, but when training from scratch (no pretraining), Ranger outperforms with lower $e _ { 4 0 0 0 }$ and $\beta _ { 4 0 0 0 }$ . SGD without momentum performs the worst and is least consistent across folds.
352
+
353
+ # D.2 TEXT FOR SECTION 2.2
354
+
355
+ However, if the classifier parameters are functions of $n$ , then $\gamma$ may deviate from $- 0 . 5$ . For example, Tsybakov (2008) shows that a kernel density estimator (KDE) with fixed bandwidth $h$ has MSE boundedbecomes $\begin{array} { r } { O ( \frac { 1 } { n h } ) } \end{array}$ but whewhere he bandwidth is set as a function of is the kernel order. In our experi $n$ to minimize MSE, the boundnts, all aspects of our model $O ( n ^ { - \frac { 2 \beta } { 2 \beta + 1 } } )$ $\beta$
356
+ are fixed across training size when estimating one learning curve, except learning schedule, but it should be noted that error bounds and likely the learning curve parameters depend on both the classifier form and which parameters vary with $n$ .
357
+
358
+ # D.3 OTHER PLANNED IMPROVEMENTS
359
+
360
+ • Experiments to include WRN-28-10 (or similarly effective Wide ResNet model) on Cifar100 to show that learning curve methodology applies and experimental findings hold for high-performing models Discussion to clarify that experiments serve to exemplify use of learning curves and make interesting observations, but more extensive study of each design parameter is warranted. Also discuss any other concerns/limitations raised by reviewers.
md/train/H1e_cC4twS/H1e_cC4twS.md ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NON-AUTOREGRESSIVE DIALOG STATE TRACKING
2
+
3
+ Hung Le‡∗, Richard Socher†, Steven C.H. Hoi† † Salesforce Research {rsocher,shoi}@salesforce.com $\ddagger$ Singapore Management University hungle.2018@phdcs.smu.edu.sg
4
+
5
+ # ABSTRACT
6
+
7
+ Recent efforts in Dialogue State Tracking (DST) for task-oriented dialogues have progressed toward open-vocabulary or generation-based approaches where the models can generate slot value candidates from the dialogue history itself. These approaches have shown good performance gain, especially in complicated dialogue domains with dynamic slot values. However, they fall short in two aspects: (1) they do not allow models to explicitly learn signals across domains and slots to detect potential dependencies among (domain, slot) pairs; and (2) existing models follow auto-regressive approaches which incur high time cost when the dialogue evolves over multiple domains and multiple turns. In this paper, we propose a novel framework of Non-Autoregressive Dialog State Tracking (NADST) which can factor in potential dependencies among domains and slots to optimize the models towards better prediction of dialogue states as a complete set rather than separate slots. In particular, the non-autoregressive nature of our method not only enables decoding in parallel to significantly reduce the latency of DST for realtime dialogue response generation, but also detect dependencies among slots at token level in addition to slot and domain level. Our empirical results show that our model achieves the state-of-the-art joint accuracy across all domains on the MultiWOZ 2.1 corpus, and the latency of our model is an order of magnitude lower than the previous state of the art as the dialogue history extends over time.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ In task-oriented dialogues, a dialogue agent is required to assist humans for one or many tasks such as finding a restaurant and booking a hotel. As a sample dialogue shown in Table 1, each user utterance typically contains important information identified as slots related to a dialogue domain such as attraction-area and train-day. A crucial part of a task-oriented dialogue system is Dialogue State Tracking (DST), which aims to identify user goals expressed during a conversation in the form of dialogue states. A dialogue state consists of a set of (slot, value) pairs e.g. (attraction-area, centre) and (train-day, tuesday). Existing DST models can be categorized into two types: fixed- and open-vocabulary. Fixed vocabulary models assume known slot ontology and generate a score for each candidate of (slot,value) (Ramadan et al., 2018; Lee et al., 2019). Recent approaches propose open-vocabulary models that can generate the candidates, especially for slots such as entity names and time, from the dialogue history (Lei et al., 2018; Wu et al., 2019).
12
+
13
+ Most open-vocabulary DST models rely on autoregressive encoders and decoders, which encode dialogue history sequentially and generate token $t _ { i }$ of individual slot value one by one conditioned on all previously generated tokens $t _ { [ 1 : i - 1 ] }$ . For downstream tasks of DST that emphasize on low latency (e.g. generating real-time dialogue responses), auto-regressive approaches incur expensive time cost as the ongoing dialogues become more complex. The time cost is caused by two major components: length of dialogue history i.e. number of turns, and length of slot values. For complex dialogues extended over many turns and multiple domains, the time cost will increase significantly in both encoding and decoding phases.
14
+
15
+ Similar problems can be seen in the field of Neural Machine Translation (NMT) research where a long piece of text is translated from one language to another. Recent work has tried to improve the latency in NMT by using neural network architectures such as convolution (Krizhevsky et al., 2012) and attention (Luong et al., 2015). Several non- and semi-autoregressive approaches aim to generate tokens of the target language independently (Gu et al., 2018; Lee et al., 2018; Kaiser et al., 2018). Motivated by this line of research, we thus propose a non-autoregressive approach to minimize the time cost of DST models without a negative impact on the model performance.
16
+
17
+ Table 1: A sample task-oriented dialogue with annotated dialogue states after each user turn. The dialogue states in red and blue denote slots from the attraction domain and train domain respectively. Slot values are expressed in user and system utterances (highlighted by underlined text).
18
+
19
+ <table><tr><td>Human: Dialog State:</td><td>i want to visit a theater in the center of town (attraction-area, centre), (attraction-type, theatre)</td></tr><tr><td>System: Human: Dialog State:</td><td>there are 4 matches.ido not have any info on the fees.do you have any other preferences ? no other preferences,i just want to be sure to get the phone number of whichever theatre we pick . (attraction-area, centre), (attraction-type, theatre)</td></tr><tr><td>System: Human: Dialog State:</td><td>irecommendthecambridgecorn exchangethere phone numberis O1223357851.isthere anything elseican helpyou with? yes,i am looking for a tuesday train. (attraction-area,centre),(atraction-name,thecambridgecor exchange),(attraction-type,theatre),(train-day,tuesday)</td></tr><tr><td>System: Human:</td><td>where will you be departing fromand what s your destination ? from cambridge to london liverpool street</td></tr><tr><td>Dialog State:</td><td>(atraction-area,centre),(atraction-name,thecambridgecon exchange),(attraction-type,theatre),(train-day,tuesday), (train-departure, cambridge), (train-destination, london liverpool street)</td></tr></table>
20
+
21
+ We adopt the concept of fertility proposed by Gu et al. (2018). Fertility denotes the number of times each input token is copied to form a sequence as the input to the decoder for non-autoregressive decoding. We first reconstruct dialogue state as a sequence of concatenated slot values. The result sequence contains the inherent structured representation in which we can apply the fertility concept. The structure is defined by the boundaries of individual slot values. These boundaries can be easily obtained from dialogue state itself by simply measuring number of the tokens of individual slots. Our model includes a two-stage decoding process: (1) the first decoder learns relevant signals from the input dialogue history and generates a fertility for each input slot representation; and (2) the predicted fertility is used to form a structured sequence which consists of multiple sub-sequences, each represented as (slot token $\times$ slot fertility). The result sequence is used as input to the second decoder to generate all the tokens of the target dialogue state at once.
22
+
23
+ In addition to being non-autoregressive, our models explicitly consider dependencies at both slot level and token level. Most of existing DST models assume independence among slots in dialogue states without explicitly considering potential signals across the slots (Wu et al., 2019; Lee et al., 2019; Goel et al., 2019; Gao et al., 2019). However, we hypothesize that it is not true in many cases. For example, a good DST model should detect the relation that train departure should not have the same value as train destination (example in Table 1). Other cases include time-related pairs such as (taxi arriveBy, taxi leaveAt) and cross-domain pairs such as (hotel area, attraction area). Our proposed approach considers all possible signals across all domains and slots to generate a dialogue state as a set. Our approach directly optimizes towards the DST evaluation metric Joint Accuracy (Henderson et al., 2014b), which measures accuracy at state (set of slots) level rather than slot level.
24
+
25
+ Our contributions in this work include: (1) we propose a novel framework of Non-Autoregressive Dialog State Tracking (NADST), which explicitly learns inter-dependencies across slots for decoding dialogue states as a complete set rather than individual slots; (2) we propose a non-autoregressive decoding scheme, which not only enjoys low latency for real-time dialogues, but also allows to capture dependencies at token level in addition to slot level; (3) we achieve the state-of-the-art performance on the multi-domain task-oriented dialogue dataset “MultiWOZ 2.1” (Budzianowski et al., 2018; Eric et al., 2019) while significantly reducing the inference latency by an order of magnitude; (4) we conduct extensive ablation studies in which our analysis reveals that our models can detect potential signals across slots and dialogue domains to generate more correct “sets” of slots for DST.
26
+
27
+ # 2 RELATED WORK
28
+
29
+ Our work is related to two research areas: dialogue state tracking and non-autoregressive decoding.
30
+
31
+ # 2.1 DIALOGUE STATE TRACKING
32
+
33
+ Dialogue State Tracking (DST) is an important component in task-oriented dialogues, especially for dialogues with complex domains that require fine-grained tracking of relevant slots. Traditionally,
34
+
35
+ DST is coupled with Natural Language Understanding (NLU). NLU output as tagged user utterances is input to DST models to update the dialogue states turn by turn (Kurata et al., 2016; Shi et al., 2016; Rastogi et al., 2017). Recent approaches combine NLU and DST to reduce the credit assignment problem and remove the need for NLU (Mrksiˇ c et al., 2017; Xu & Hu, 2018; Zhong et al., 2018). ´ Within this body of research, Goel et al. (2019) differentiates two DST approaches: fixed- and openvocabulary. Fixed-vocabulary approaches are usually retrieval-based methods in which all candidate pairs of (slot, value) from a given slot ontology are considered and the models predict a probability score for each pair (Henderson et al., 2014c; Ramadan et al., 2018; Lee et al., 2019). Recent work has moved towards open-vocabulary approaches that can generate the candidates based on input text i.e. dialogue history (Lei et al., 2018; Gao et al., 2019; Wu et al., 2019). Our work is more related to these models, but different from most of the current work, we explicitly consider dependencies among slots and domains to decode dialogue state as a complete set.
36
+
37
+ # 2.2 NON-AUTOREGRESSIVE DECODING
38
+
39
+ Most of prior work in non- or semi-autoregressive decoding methods are used for NMT to address the need for fast translation. Schwenk (2012) proposes to estimate the translation model probabilities of a phase-based NMT system. Libovicky & Helcl (2018) formulates the decoding process as \` a sequence labeling task by projecting source sequence into a longer sequence and applying CTC loss (Graves et al., 2006) to decode the target sequence. Wang et al. (2019) adds regularization terms to NAT models (Gu et al., 2018) to reduce translation errors such as repeated tokens and incomplete sentences. Ghazvininejad et al. (2019) uses a non-autoregressive decoder with masked attention to decode target sequences over multiple generation rounds. A common challenge in nonautoregressive NMT is the large number of sequential latent variables, e.g., fertility sequences (Gu et al., 2018) and projected target sequences (Libovicky & Helcl, 2018). These latent variables are \` used as supporting signals for non- or semi-autoregressive decoding. We reformulate dialogue state as a structured sequence with sub-sequences defined as a concatenation of slot values. This form of dialogue state can be inferred easily from the dialogue state annotation itself whereas such supervision information is not directly available in NMT. The lower semantic complexity of slot values as compared to long sentences in NMT makes it easier to adopt non-autoregressive approaches into DST. According to our review, we are the first to apply a non-autoregressive framework for generation-based DST. Our approach allows joint state tracking across slots, which results in better performance and an order of magnitude lower latency during inference.
40
+
41
+ # 3 APPROACH
42
+
43
+ Our NADST model is composed of three parts: encoders, fertility decoder, and state decoder, as shown in Figure 1. The input includes the dialogue history $\boldsymbol { X } = ( x _ { 1 } , . . . , x _ { N } )$ and a sequence of applicable (domain, slot) pairs $X _ { \mathrm { d s } } = ( ( d _ { 1 } , s _ { 1 } ) , . . . , ( d _ { G } , s _ { H } ) )$ , where $G$ and $H$ are the total numbers of domains and slots, respectively. The output is the corresponding dialogue states up to the current dialogue history. Conventionally, the output of dialogue state is denoted as tuple (slot, value) (or (domain-slot, value) for multi-domain dialogues). We reformulate the output as a concatenation of slot values $Y ^ { d _ { i } , s _ { j } } \colon Y = ( Y ^ { d _ { 1 } , s _ { 1 } } , . . . , Y ^ { d _ { I } , s _ { J } } ) = ( y _ { 1 } ^ { d _ { 1 } , s _ { 1 } } , y _ { 2 } ^ { d _ { 1 } , s _ { 1 } } , . . . , y _ { 1 } ^ { d _ { I } , s _ { J } } , y _ { 2 } ^ { d _ { I } , s _ { J } } , . . . )$ where $I$ and $J$ are the numbers of domains and slots in the output dialogue state, respectively.
44
+
45
+ First, the encoders use token-level embedding and positional encoding to encode the input dialogue history and (domain, slot) pairs into continuous representations. The encoded domains and slots are then input to stacked self-attention and feed-forward network to obtain relevant signals across dialogue history and generate a fertility $Y _ { f } ^ { d _ { g } , s _ { h } }$ for each (domain, slot) pair $\left( d _ { g } , s _ { h } \right)$ . The output of fertility decoder is defined as a sequence: Yfert = Y d1,s1f , $Y _ { \mathrm { f e r t } } = Y _ { f } ^ { d _ { 1 } , s _ { 1 } } , . . . , Y _ { f } ^ { d _ { G } , s _ { H } }$ where $Y _ { f } ^ { d _ { g } , d _ { h } } \in$ $\{ 0 , \mathrm { { m a x } ( \mathrm { { S l o t L e n g t h } ) } } \}$ . For example, for the MultiWOZ dataset in our experiments, we have $\mathrm { { m a x } ( S l o t L e n g t h ) = 9 }$ according to the training data. We follow (Wu et al., 2019; Gao et al., 2019) to add a slot gating mechanism as an auxiliary prediction. Each gate $g$ is restricted to 3 possible values: “none”, “dontcare” and “generate”. They are used to form higher-level classification signals to support fertility decoding process. The gate output is defined as a sequence: $Y _ { \mathrm { g a t e } } = Y _ { g } ^ { d _ { 1 } , s _ { 1 } } , . . . , Y _ { g } ^ { d _ { G } , s _ { H } }$ .
46
+
47
+ The predicted fertilities are used to form an input sequence to the state decoder for nonautoregressive decoding. The sequence includes sub-sequences of $( d _ { g } , s _ { h } )$ repeated by $Y _ { f } ^ { d _ { g } , s _ { h } }$ times and concatenated sequentially: Xds×fert = ((d1, s1)Y d1,s1f , $X _ { \mathrm { d s } \times \mathrm { f e r t } } = ( ( d _ { 1 } , s _ { 1 } ) ^ { Y _ { f } ^ { d _ { 1 } , s _ { 1 } } } , . . . , ( d _ { G } , s _ { H } ) ^ { Y _ { f } ^ { d _ { G } , s _ { H } } } )$ and $\| X _ { \mathrm { d s } \times \mathrm { f e r t } } \| =$ $\| Y \|$ . The decoder projects this sequence through attention layers with dialogue history. During this decoding process, we maintain a memory of hidden states of dialogue history. The output from the state decoder is used as a query to attend on this memory and copy tokens from the dialogue history to generate a dialogue state.
48
+
49
+ Following Lei et al. (2018), we incorporate information from previous dialogue turns to predict current turn state by using a partially delexicalized dialogue history $X _ { \mathrm { d e l } } = ( x _ { 1 , \mathrm { d e l } } , . . . , x _ { N , \mathrm { d e l } } )$ as an input of the model. The dialogue history is delexicalized till the last system utterance by removing real-value tokens that match the previously decoded slot values to tokens expressed as domain-slot. Given a token $x _ { n }$ and the current dialogue turn $t$ , the token is delexicalized as follows:
50
+
51
+ $$
52
+ \begin{array} { r l } & { x _ { n , \mathrm { d e l } } = \mathrm { d e l e x } ( x _ { n } ) = \left\{ \begin{array} { l l } { \mathrm { d o m a i n } _ { \mathrm { i d x } } \mathrm { - s l o t } _ { \mathrm { i d x } } , } & { \mathrm { i f ~ } x _ { n } \subset \hat { Y } _ { t - 1 } . } \\ { x _ { n } , } & { \mathrm { o t h e r w i s e } . } \end{array} \right. } \\ & { \mathrm { l o m a i n } _ { \mathrm { i d x } } = X _ { \mathrm { d s } \times \mathrm { f e r t } } [ \mathrm { i d x } ] [ 0 ] , \quad \mathrm { s l o t } _ { \mathrm { i d x } } = X _ { \mathrm { d s } \times \mathrm { f e r t } } [ \mathrm { i d x } ] [ 1 ] , \quad \mathrm { i d x } = \mathrm { I n d e x } ( x _ { n } , \hat { Y } _ { t - 1 } ) } \end{array}
53
+ $$
54
+
55
+ For example, the user utterance “I look for a cheap hotel” is delexicalized to $^ { 6 6 } \mathrm { I }$ look for a hotel pricerange hotel.” if the slot hotel pricerange is predicted as “cheap” in the previous turn. This approach makes use of the delexicalized form of dialogue history while not relying on an NLU module as we utilize the predicted state from DST model itself. In addition to the belief state, we also use the system action in the previous turn to delexicalize the dialog history in a similar manner, following prior work (Rastogi et al., 2017; Zhong et al., 2018; Goel et al., 2019).
56
+
57
+ ![](images/f5241c351fcdba9b369b18e79d320b182929c54b686f729cc5306d5379ffd500.jpg)
58
+ Figure 1: Our NADST has 3 key components: encoders (“red”), fertility decoder (“blue”), and state decoder (“green”). (i) Encoders encode sequences of dialogue history, delexicalized dialogue history, and domain and slot tokens into continuous representations; (ii) Fertility Decoder has 3 attention mechanisms to learn potential dependencies across (domain, slot) pairs in combination with dialogue history. The output is used to generate fertilities and slot gates; and (iii) State Decoder receives the input sequence including sub-sequences of (domain, slot) $^ { 1 \times }$ fertility to decode a complete dialogue state sequence as concatenation of component slot values. For simplicity, we do not show feedforward, residual connection, and layer-normalization layers in the figure. Best viewed in color.
59
+
60
+ # 3.1 ENCODERS
61
+
62
+ An encoder is used to embed dialogue history $X$ into a sequence of continuous representations $Z = ( z _ { 1 } , . . . , z _ { N } ) \in \mathbb { R } ^ { N \times d }$ . Similarly, partially delexicalized dialogue history $X _ { d e l }$ is encoded to continuous representations $Z _ { \mathrm { d e l } } \in \dot { \mathbb { R } } ^ { N \times d }$ . We store the encoded dialogue history $Z$ in memory which will be passed to a pointer network to copy words for dialogue state generation. This helps to address the OOV challenge as shown in (See et al., 2017; Wu et al., 2019). We also encode each (domain, slot) pair into continuous representation $z _ { \mathrm { d s } } \in \mathbb { R } ^ { d }$ as input to the decoders. Each vector $z _ { \mathrm { d s } }$ is used to store contextual signals for slot and fertility prediction during the decoding process.
63
+
64
+ Context Encoder. Context encoder includes a token-level trainable embedding layer and layer normalization (Ba et al., 2016). The encoder also includes a positional encoding layer which follows sine and cosine functions (Vaswani et al., 2017). An element-wise summation is used to combine the token-level vectors with positional encoded vectors. We share the embedding weights to embed the raw and delexicalized dialogue history. The embedding weights are also shared to encode input to both fertility decoder and state decoder. The final embedding of $X$ and $X _ { d e l }$ is defined as:
65
+
66
+ $$
67
+ \begin{array} { c } { Z = Z _ { \mathrm { e m b } } + \mathrm { P E } ( X ) \in \mathbb { R } ^ { N \times d } } \\ { Z _ { \mathrm { d e l } } = Z _ { \mathrm { e m b , d e l } } + \mathrm { P E } ( X _ { \mathrm { d e l } } ) \in \mathbb { R } ^ { N \times d } } \end{array}
68
+ $$
69
+
70
+ Domain and Slot Encoder. Each (domain, slot) pair is encoded by using two separate embedding vectors of the corresponding domain and slot. Each domain $g$ and slot $h$ is embedded into a continuous representation $z _ { d _ { g } }$ and $\boldsymbol { z } _ { s _ { h } } \in \mathbb { R } ^ { d }$ . The final vector is combined by element-wise summation:
71
+
72
+ $$
73
+ z _ { d _ { g } , s _ { h } } = z _ { d _ { g } } + z _ { s _ { h } } \in \mathbb { R } ^ { d }
74
+ $$
75
+
76
+ We share the embedding weights to embed domain and slot tokens in both fertility decoder and state decoder. However, for input to state decoder, we inject sequential information into the input $X _ { \mathrm { d s \times f e r t } }$ to factor in position-wise information to decode target state sequence. In summary, $X _ { \mathrm { d s } }$ and $X _ { \mathrm { d s \times f e r t } }$ is encoded as following:
77
+
78
+ $$
79
+ \begin{array} { c } { { Z _ { \mathrm { d s } } = Z _ { \mathrm { e m b , d s } } = z _ { d _ { 1 } , s _ { 1 } } \oplus . . . \oplus z _ { d _ { G } , s _ { H } } } } \\ { { Z _ { \mathrm { d s } \times \mathrm { f e r t } } = Z _ { \mathrm { e m b , d s } \times \mathrm { f e r t } } + \mathrm { P E } ( X _ { \mathrm { d s } \times \mathrm { f e r t } } ) } } \\ { { Z _ { \mathrm { e m b , d s } \times \mathrm { f e r t } } = ( z _ { d _ { 1 } , s _ { 1 } } ) ^ { Y _ { f } ^ { d _ { 1 } , s _ { 1 } } } \oplus . . . \oplus ( z _ { d _ { G } , s _ { H } } ) ^ { Y _ { f } ^ { d _ { G } , s _ { H } } } } } \end{array}
80
+ $$
81
+
82
+ where $\oplus$ denotes concatenation operation. Note that different from a typical decoder input in Transformer, we do not shift the input sequences to both fertility decoder and state decoder by one position as we consider non-autoregressive decoding process in both modules. Therefore, all output tokens are generated in position $i$ based on all remaining positions of the sequence i.e. $1 , . . . , i - 1 , i + 1 , . . . \| \bar { X } _ { \mathrm { d s } } \|$ in fertility decoder and $1 , . . . , i - 1 , i + 1 , . . . \| X _ { \mathrm { d s } \times \mathrm { f e r t } } \|$ in state decoder.
83
+
84
+ # 3.2 FERTILITY DECODER
85
+
86
+ Given the encoded dialogue history $Z$ , delexicalized dialogue history $Z _ { \mathrm { d e l } }$ , and (domain,slot) pairs $Z _ { \mathrm { d s } }$ , the contextual signals are learned and passed into each $z _ { \mathrm { d s } }$ vector through a sequence of attention layers. We adopt the multi-head attention mechanism (Vaswani et al., 2017) to project the representations into multiple sub-spaces. The attention mechanism is defined as scaled dot-product attention between query $Q$ , key $K$ , and value $V$ :
87
+
88
+ $$
89
+ \mathrm { A t t e n t i o n } ( Q , K , V ) = \mathrm { s o f t m a x } ( \frac { Q K ^ { T } } { \sqrt { d _ { k } } } V )
90
+ $$
91
+
92
+ Each multi-head attention is followed by a position-wise feed-forward network. The feed-forward is applied to each position separately and identically. We use two linear layers with a ReLU activation in between. The fertility decoder consists of 3 attention layers, each of which learns relevant contextual signals and incorporates them into $z _ { d s }$ vectors as input to the next attention layer:
93
+
94
+ $$
95
+ \begin{array} { r l } & { Z _ { \mathrm { d s } } ^ { \mathrm { o u t } } = \mathrm { A t t e n t i o n } ( Z _ { \mathrm { d s } } , Z _ { \mathrm { d s } } , Z _ { \mathrm { d s } } ) \in \mathbb { R } ^ { N \times d } } \\ & { Z _ { \mathrm { d s } } ^ { \mathrm { o u t } } = \mathrm { A t t e n t i o n } ( Z _ { \mathrm { d s } } ^ { \mathrm { o u t } } , Z _ { \mathrm { d e l } } , Z _ { \mathrm { d e l } } ) \in \mathbb { R } ^ { N \times d } } \\ & { Z _ { \mathrm { d s } } ^ { \mathrm { o u t } } = \mathrm { A t t e n t i o n } ( Z _ { \mathrm { d s } } ^ { \mathrm { o u t } } , Z , Z ) \in \mathbb { R } ^ { N \times d } } \end{array}
96
+ $$
97
+
98
+ For simplicity, we do not express the multi-head and feed-forward equations. We advise the reader to review Transformer network (Vaswani et al., 2017) for more detailed description. The multi-head structure has shown to obtain good performance in many NLP tasks such as NMT (Vaswani et al., 2017) and QA (Dehghani et al., 2019). By adopting this attention mechanism, we allow the models to explicitly obtain signals of potential dependencies across (domain, slot) pairs in the first attention layer, and contextual dependencies in the subsequent attention layers. Adding the delexicalized dialogue history as input can provide important contextual signals as the models can learn the mapping between real-value tokens and generalized domain-slot tokens. To further improve the model capability to capture these dependencies, we repeat the attention sequence for $T _ { \mathrm { f e r t } }$ times with $Z _ { \mathrm { d s } }$ . In an attentionto compute . $t$ , the output from the previous attentio The output in the last attention layer $t - 1$ is used as input to current layerssed to two independent linear $Z _ { \mathrm { d s } } ^ { t }$ $Z _ { \mathrm { d s } } ^ { \mathrm { T _ { f e r t } } }$
99
+ transformations to predict fertilities and gates:
100
+
101
+ $$
102
+ \begin{array} { r } { P ^ { \mathrm { g a t e } } = \mathrm { s o f t m a x } ( W _ { \mathrm { g a t e } } Z _ { \mathrm { d s } } ^ { T _ { \mathrm { f e r t } } } ) } \\ { P ^ { \mathrm { f e r t } } = \mathrm { s o f t m a x } ( W _ { \mathrm { f e r t } } Z _ { \mathrm { d s } } ^ { T _ { \mathrm { f e r t } } } ) } \end{array}
103
+ $$
104
+
105
+ where $W _ { \mathrm { g a t e } } ~ \in ~ \mathbb { R } ^ { d \times 3 }$ and $W _ { \mathrm { f e r t } } ~ \in ~ \mathbb { R } ^ { d \times 1 0 }$ . We use the standard cross-entropy loss to train the prediction of gates and fertilities:
106
+
107
+ $$
108
+ \begin{array} { r l } & { \mathcal { L } _ { \mathrm { g a t e } } = \displaystyle \sum _ { d _ { g } , s _ { h } } - \log ( P ^ { \mathrm { g a t e } } ( Y _ { g } ^ { d _ { g } , s _ { h } } ) ) } \\ & { \mathcal { L } _ { \mathrm { f e r t } } = \displaystyle \sum _ { d _ { g } , s _ { h } } - \log ( P ^ { \mathrm { f e r t } } ( Y _ { f } ^ { d _ { g } , s _ { h } } ) ) } \end{array}
109
+ $$
110
+
111
+ # 3.3 STATE DECODER
112
+
113
+ Given the generated gates and fertilities, we form the input sequence $X _ { \mathrm { d s \times f e r t } }$ . We filter out any (domain, slot) pairs that have gate either as “none” or “dontcare”. Given the encoded input $Z _ { \mathrm { d s \times f e r t } }$ , we apply a similar attention sequence as used in the fertility decoder to incorporate contextual signals into each ${ \mathcal { Z } } _ { \mathrm { d s } \times \mathrm { f e r t } }$ vector. The dependencies are captured at the token level in this decoding stage rather than at domain/slot higher level as in the fertility decoder. After repeating the attention sequence for $T _ { \mathrm { s t a t e } }$ times, the final output $Z _ { \mathrm { d s } \times \mathrm { f e r t } } ^ { T _ { \mathrm { s t a t e } } }$ is used to predict the state in the following:
114
+
115
+ $$
116
+ P _ { \mathrm { v o c a b } } ^ { \mathrm { s t a t e } } = \mathrm { s o f t m a x } ( W _ { \mathrm { s t a t e } } Z _ { \mathrm { d s } \times \mathrm { f e r t } } ^ { T _ { \mathrm { s t a t e } } } )
117
+ $$
118
+
119
+ where $W _ { s t a t e } \in \mathbb { R } ^ { d \times \lVert V \rVert }$ with $V$ as the set of output vocabulary. As open-vocabulary DST models do not assume a known slot ontology, our models can generate the candidates from the dialogue history itself. To address OOV problem during inference, we incorporate a pointer network (Vinyals et al., 2015) into the Transformer decoder. We apply dot-product attention between the state decoder output and the stored memory of encoded dialogue history $Z$ :
120
+
121
+ $$
122
+ P _ { \mathrm { p t r } } ^ { \mathrm { s t a t e } } = \mathrm { s o f t m a x } ( Z _ { \mathrm { d s } \times \mathrm { f e r t } } ^ { T _ { \mathrm { s t a t e } } } Z ^ { T } )
123
+ $$
124
+
125
+ he final probability of predicted state is defined as the weighted sum of the two probabilities:
126
+
127
+ $$
128
+ \begin{array} { r l } & { P ^ { \mathrm { s t a t e } } = p _ { \mathrm { g e n } } ^ { \mathrm { s t a t e } } \times P _ { \mathrm { v o c a b } } ^ { \mathrm { s t a t e } } + ( 1 - p _ { \mathrm { g e n } } ^ { \mathrm { s t a t e } } ) \times P _ { \mathrm { p t r } } ^ { \mathrm { s t a t e } } } \\ & { p _ { \mathrm { g e n } } ^ { \mathrm { s t a t e } } = \mathrm { s i g m o i d } ( W _ { \mathrm { g e n } } V _ { \mathrm { g e n } } ) } \\ & { V _ { \mathrm { g e n } } = Z _ { \mathrm { d s } \times \mathrm { f e r t } } \oplus Z _ { \mathrm { d s } \times \mathrm { f e r t } } ^ { T _ { \mathrm { s t a t e } } } \oplus Z _ { \mathrm { e x p } } } \end{array}
129
+ $$
130
+
131
+ where $W _ { \mathrm { g e n } } \in \mathbb { R } ^ { 3 d \times 1 }$ and $Z _ { \mathrm { e x p } }$ is the expanded vector of $Z$ to match dimensions of $Z _ { \mathrm { d s \times f e r t } }$ . The final probability is used to train the state generation following the cross-entropy loss function:
132
+
133
+ $$
134
+ \mathcal { L } _ { \mathrm { s t a t e } } = \sum _ { d _ { g } , s _ { h } } \sum _ { m = 0 } ^ { Y _ { f } ^ { d _ { g } , s _ { h } } } - \log ( P ^ { \mathrm { s t a t e } } ( y _ { m } ^ { d _ { g } , s _ { h } } ) )
135
+ $$
136
+
137
+ # 3.4 OPTIMIZATION
138
+
139
+ We optimize all parameters by jointly training to minimize the weighted sum of the three losses:
140
+
141
+ $$
142
+ \mathcal { L } = \mathcal { L } _ { \mathrm { s t a t e } } + \alpha \mathcal { L } _ { \mathrm { g a t e } } + \beta \mathcal { L } _ { \mathrm { f e r t } }
143
+ $$
144
+
145
+ where $\alpha \geq 0$ and $\beta \geq 0$ are hyper-parameters.
146
+
147
+ # 4 EXPERIMENTS
148
+
149
+ # 4.1 DATASET
150
+
151
+ MultiWOZ (Budzianowski et al., 2018) is one of the largest publicly available multi-domain taskoriented dialogue dataset with dialogue domains extended over 7 domains. In this paper, we use the new version of the MultiWOZ dataset published by Eric et al. (2019). The new version includes some correction on dialogue state annotation with more than $40 \%$ change across dialogue turns. On average, each dialogue has more than one domain. We pre-processed the dialogues by tokenizing, lower-casing, and delexicalizing all system responses following the pre-processing scripts from (Wu et al., 2019). We identify a total of 35 (domain, slot) pairs. Other details of data pre-processing procedures, corpus statistics, and list of (domain, slot) pairs are described in Appendix A.1.
152
+
153
+ # 4.2 TRAINING PROCEDURE
154
+
155
+ We use label smoothing (Szegedy et al., 2016) to train the prediction of dialogue state $Y$ but not for prediction of fertilities $Y _ { \mathrm { f e r t } }$ and gates $Y _ { \mathrm { g a t e } }$ . During training, we adopt $100 \%$ teacher-forcing learning strategy by using the ground-truth of $X _ { \mathrm { d s \times f e r t } }$ as input to the state decoder. We also apply the same strategy to obtain delexicalized dialogue history i.e. dialogue history is delexicalized from the ground-truth belief state in previous dialogue turn rather than relying on the predicted belief state. During inference, we follow a similar strategy as (Lei et al., 2018) by generating dialogue state turn-by-turn and use the predicted belief state in turn $t - 1$ to delexicalize dialogue history in turn $t$ . During inference, $X _ { \mathrm { d s } \times \mathrm { f e r t } }$ is also constructed by prediction $\hat { Y } _ { \mathrm { g a t e } }$ and $\hat { Y } _ { \mathrm { f e r t } }$ . We adopt the Adam optimizer (Kingma & Ba, 2015) and the learning rate strategy similarly as (Vaswani et al., 2017). Best models are selected based on the best average joint accuracy of dialogue state prediction in the validation set. All parameters are randomly initialized with uniform distribution (Glorot & Bengio, 2010). We did not utilize any pretrained word- or character-based embedding weights. We tuned the hyper-parameters with grid-search over the validation set (Refer to Appendix A.2 for further details). We implemented our models using PyTorch (Paszke et al., 2017) and released the code on GitHub 1.
156
+
157
+ # 4.3 BASELINES
158
+
159
+ The DST baselines can be divided into 2 groups: open-vocabulary approach and fixed-vocabulary approach as mentioned in Section 2. Fixed-vocabulary has the advantage of access to the known candidate set of each slot and has a high performance of prediction within this candidate set. However, during inference, the approach suffers from unseen slot values for slots with evolving candidates such as entity names and time- and location-related slots.
160
+
161
+ # 4.3.1 FIXED-VOCABULARY
162
+
163
+ GLAD (Zhong et al., 2018). GLAD uses multiple self-attentive RNNs to learn a global tracker for shared parameters among slots and a local tracker for individual slot. The model utilizes previous system actions as input. The output is used to compute semantic similarity with ontology terms.
164
+
165
+ GCE (Nouri & Hosseini-Asl, 2018). GCE is a simplified and faster version of GLAD. The model removes slot-specific RNNs while maintaining competitive DST performance.
166
+
167
+ MDBT (Ramadan et al., 2018). MDBT model includes separate encoding modules for system utterances, user utterances, and (slot, value) pairs. Similar to GLAD, The model is trained based on the semantic similarity between utterances and ontology terms.
168
+
169
+ FJST and HJST (Eric et al., 2019). FJST refers to Flat Joint State Tracker, which consists of a dialog history encoder as a bidirectional LSTM network. The model also includes separate feedforward networks to encode hidden states of individual state slots. HJST follows a similar architecture but uses a hierarchical LSTM network (Serban et al., 2016) to encode the dialogue history.
170
+
171
+ SUMBT (Lee et al., 2019). SUMBT refers to Slot-independent Belief Tracker, consisting of a multi-head attention layer with query vector as a representation of a (domain, slot) pair and key and value vector as BERT-encoded dialogue history. The model follows a non-parametric approach as it is trained to minimize a score such as Euclidean distance between predicted and target slots. Our approach is different from SUMBT as we include attention among (domain, slot) pairs to explicitly learn dependencies among the pairs. Our models also generate slot values rather than relying on a fixed candidate set.
172
+
173
+ # 4.3.2 OPEN-VOCABULARY
174
+
175
+ TSCP (Lei et al., 2018). TSCP is an end-to-end dialogue model consisting of an RNN encoder and two RNN decoder with a pointer network. We choose this as a baseline because TSCP decodes dialogue state as a single sequence and hence, factor in potential dependencies among slots like our work. We adapt TSCP into multi-domain dialogues and report the performance of only the DST component rather than the end-to-end model. We also reported the performance of TSCP for two cases when the maximum length of dialogue state sequence $L$ in the state decoder is set to 8 or 20 tokens. Different from TSCP, our models dynamically learn the length of each state sequence as the sum of predicted fertilities and hence, do not rely on a fixed value of $L$ .
176
+
177
+ DST Reader (Gao et al., 2019). DST Reader reformulates the DST task as a reading comprehension task. The prediction of each slot is a span over tokens within the dialogue history. The model follows an attention-based neural network architecture and combines a slot carryover prediction module and slot type prediction module.
178
+
179
+ HyST (Goel et al., 2019). HyST model combines both fixed-vocabulary and open-vocabulary approach by separately choosing which approach is more suitable for each slot. For the openvocabulary approach, the slot candidates are formed as sets of all word n-grams in the dialogue history. The model makes use of encoder modules to encode user utterances and dialogue acts to represent the dialogue context.
180
+
181
+ TRADE (Wu et al., 2019). This is the current state-of-the-art model on the MultiWOZ2.0 and 2.1 datasets. TRADE is composed of a dialog history encoder, a slot gating module, and an RNN decoder with a pointer network for state generation. SpanPtr is a related baseline to TRADE as reported by Wu et al. (2019). The model makes use of a pointer network with index-based copying instead of a token-based copying mechanism.
182
+
183
+ # 4.4 RESULTS
184
+
185
+ We evaluate model performance by the joint goal accuracy as commonly used in DST (Henderson et al., 2014b). The metric compares the predicted dialogue states to the ground truth in each dialogue turn. A prediction is only correct if all the predicted values of all slots exactly match the corresponding ground truth labels. We ran our models for 5 times and reported the average results. For completion, we reported the results in both MultiWOZ 2.0 and 2.1.
186
+
187
+ As can be seen in Table 2, although our models are designed for non-autoregressive decoding, they can outperform state-of-the-art DST approaches that utilize autoregressive decoding such as (Wu et al., 2019). Our performance gain can be attributed to the model capability of learning crossdomain and cross-slot signals, directly optimizing towards the evaluation metric of joint goal accuracy rather than just the accuracy of individual slots. Following prior DST work, we reported the model performance on the restaurant domain in MultiWOZ 2.0 in Table 4. In this dialogue domain, our model surpasses other DST models in both Joint Accuracy and Slot Accuracy. Refer to Appendix A.3 for our model performance in other domains in both MultiWOZ2.0 and MultiWOZ2.1.
188
+
189
+ Latency Analysis. We reported the latency results in term of wall-clock time (in ms) per prediction state of our models and the two baselines TRADE (Wu et al., 2019) and TSCP (Lei et al., 2018) in Table 4. For TSCP, we reported the time cost only for the DST component instead of the end-toend models. We conducted experiments with 2 cases of TSCP when the maximum output length of dialogue state sequence in the state decoder is set as $L = 8$ and $L = 2 0$ . We varied our models for different values of $T = T _ { \mathrm { f e r t } } = T _ { \mathrm { s t a t e } } \in \{ 1 , 2 , 3 \}$ . All latency results are reported when running in a single identical GPU. As can be seen in Table 4, NADST obtains the best performance when $T = 3$ . The model outperforms the baselines while taking much less time during inference. Our approach is similar to TSCP which also decodes a complete dialogue state sequence rather than individual slots to factor in dependencies among slot values. However, as TSCP models involve sequential processing in both encoding and decoding, they require much higher latency. TRADE shortens the latency by separating the decoding process among (domain, slot) pairs. However, at the token level, TRADE models follow an auto-regressive process to decode individual slots and hence, result in higher average latency as compared to our approach. In NADST, the model latency is only affected by the number of attention layers in fertility decoder $T _ { \mathrm { f e r t } }$ and state decoder $T _ { \mathrm { s t a t e } }$ . For approaches with sequential encoding and/or decoding such as TSCP and TRADE, the latency is affected by the length of source sequences (dialog history) and target sequence (dialog state). Refer to Appendix A.3 for visualization of model latency in terms of dialogue history length.
190
+
191
+ <table><tr><td>Model</td><td>MultiWOZ2.1</td><td>MultiWOZ2.0</td></tr><tr><td>MDBT (Ramadan et al., 2018) †</td><td></td><td>15.57%</td></tr><tr><td>SpanPtr (Vinyals et al., 2015)</td><td></td><td>30.28%</td></tr><tr><td>GLAD (Zhong et al., 2018) +</td><td></td><td>35.57%</td></tr><tr><td>GCE (Nouri &amp; Hosseini-Asl, 2018) +</td><td></td><td>36.27%</td></tr><tr><td>HJST (Eric et al., 2019) *</td><td>35.55%</td><td>38.40%</td></tr><tr><td>DST Reader (single) (Gao et al., 2019) *</td><td>36.40%</td><td>39.41%</td></tr><tr><td>DST Reader (ensemble) (Gao et al.,2019)</td><td>1</td><td>42.12%</td></tr><tr><td>TSCP (Lei et al., 2018)</td><td>37.12%</td><td>39.24%</td></tr><tr><td>FJST (Eric et al., 2019) *</td><td>38.00%</td><td>40.20%</td></tr><tr><td>HyST (ensemble) (Goel et al., 2019) *</td><td>38.10%</td><td>44.24%</td></tr><tr><td>SUMBT (Lee et al., 2019) +</td><td>=</td><td>46.65%</td></tr><tr><td>TRADE (Wu et al., 2019) *</td><td>45.60%</td><td>48.60%</td></tr><tr><td>Ours</td><td>49.04%</td><td>50.52%</td></tr></table>
192
+
193
+ Table 2: DST Joint Accuracy metric on MultiWOZ 2.1 and 2.0. †: results reported on MultiWOZ2.0 leaderboard. ?: results reported by Eric et al. (2019). Best results are highlighted in bold.
194
+
195
+ Table 3: DST joint accuracy and slot accuracy on MultiWOZ2.0 restaurant domain. Baseline results (except TSCP) were from $\mathrm { W u }$ et al. (2019).
196
+
197
+ <table><tr><td>Model</td><td>Joint Acc</td><td>Slot Acc</td></tr><tr><td>MDBT</td><td>17.98%</td><td>54.99%</td></tr><tr><td>SPanPtr</td><td>49.12%</td><td>87.89%</td></tr><tr><td>GLAD</td><td>53.23%</td><td>96.54%</td></tr><tr><td>GCE</td><td>60.93%</td><td>95.85%</td></tr><tr><td>TSCP</td><td>62.01%</td><td>97.32%</td></tr><tr><td>TRADE</td><td>65.35%</td><td>93.28%</td></tr><tr><td>Ours</td><td>69.21%</td><td>98.84%</td></tr></table>
198
+
199
+ <table><tr><td>Model</td><td>Joint Acc Latency</td><td> Speed Up</td></tr><tr><td>TRADE 45.60%</td><td>362.15</td><td>×2.12</td></tr><tr><td>TSCP (L=8) 32.15%</td><td>493.44</td><td>×1.56</td></tr><tr><td>TSCP (L=20) 37.12%</td><td>767.57</td><td>×1.00</td></tr><tr><td>Ours (T=1) 42.98%</td><td>15.18</td><td>×50.56</td></tr><tr><td>Ours (T=2) 45.78%</td><td>21.67</td><td>×35.42</td></tr><tr><td>Ours (T=3) 49.04%</td><td>27.31</td><td>×28.11</td></tr></table>
200
+
201
+ Table 4: Latency analysis on MultiWOZ2.1. Latency is reported in terms of wall-clock time in ms per prediction state.
202
+
203
+ Ablation Analysis. We conduct an extensive ablation analysis with several variants of our models in Table 5. Besides the results of DST metrics, Joint Slot Accuracy and Slot Accuracy, we reported the performance of the fertility decoder in Joint Gate Accuracy and Joint Fertility Accuracy. These metrics are computed similarly as Joint Slot Accuracy in which the metrics are based on whether all predictions of gates or fertilities match the corresponding ground truth labels. We also reported the Oracle Joint Slot Accuracy and Slot Accuracy when the models are fed with ground truth $X _ { \mathrm { d s \times f e r t } }$ and $X _ { \mathrm { d e l } }$ labels instead of the model predictions. We noted that the model fails when positional encoding of $X _ { \mathrm { d s \times f e r t } }$ is removed before being passed to the state decoder. The performance drop can be explained because $P E$ is responsible for injecting sequential attributes to enable non-autoregressive decoding. Second, we also note a slight drop of performance when slot gating is removed as the models have to learn to predict a fertility of 1 for “none” and “dontcare” slots as well. Third, removing $X _ { \mathrm { d e l } }$ as an input reduces the model performance, mostly due to the sharp decrease in Joint Fertility Accuracy. Lastly, removing pointer generation and relying on only $P _ { \mathrm { v o c a b } } ^ { \mathrm { s t a t e } }$ affects the model performance as the models are not able to infer slot values unseen during training, especially for slots such as restaurant-name and train-arriveby. We conduct other ablation experiments and report additional results in Appendix A.3.
204
+
205
+ <table><tr><td>Xdel</td><td>Slot Gating</td><td>PE(Xdsxfert)</td><td>Pointer Gen.</td><td>Joint Gate Acc</td><td>Joint Fert. Acc</td><td>Joint Slot Acc</td><td>Slot Acc</td><td>Oracle Joint Slot Acc</td><td>Oracle Slot Acc</td></tr><tr><td>√</td><td>√</td><td>√</td><td>√</td><td>66.65%</td><td>63.18%</td><td>49.04%</td><td>97.31%</td><td>73.44%</td><td>99.01%</td></tr><tr><td>√</td><td>√</td><td></td><td>√</td><td>59.23%</td><td>57.83%</td><td>19.56%</td><td>94.36%</td><td>72.12%</td><td>98.96%</td></tr><tr><td>√</td><td></td><td>√</td><td>√</td><td>N/A</td><td>64.23%</td><td>48.74%</td><td>96.62%</td><td>73.01%</td><td>98.97%</td></tr><tr><td></td><td>√</td><td></td><td>√</td><td>48.23%</td><td>45.35%</td><td>39.45%</td><td>95.92%</td><td>66.27%</td><td>98.63%</td></tr><tr><td>√(no sys. act)</td><td>√</td><td>√</td><td>√</td><td>52.45%</td><td>56.81%</td><td>44.87%</td><td>96.95%</td><td>70.83%</td><td>98.74%</td></tr><tr><td></td><td>√</td><td>√</td><td></td><td>63.19%</td><td>58.31%</td><td>43.46%</td><td>96.72%</td><td>64.37%</td><td>98.39%</td></tr><tr><td></td><td>√</td><td>√</td><td></td><td>44.22%</td><td>42.01%</td><td>34.48%</td><td>95.89%</td><td>61.32%</td><td>98.24%</td></tr><tr><td></td><td></td><td>√</td><td></td><td>N/A</td><td>41.35%</td><td>33.52%</td><td>95.42%</td><td>60.99%</td><td>98.19%</td></tr></table>
206
+
207
+ Table 5: Ablation analysis on MultiWOZ 2.1 on 4 components: partially delexicalized dialogue history $X _ { d e l }$ , slot gating, positional encoding $P E ( X _ { d s \times f e r t } )$ , and pointer network.
208
+
209
+ Auto-regressive DST. We conduct experiments that use an auto-regressive state decoder and keep other parts of the model the same. For the fertility decoder, we do not use Equation 14 and 16 as fertility becomes redundant in this case. We still use the output to predict slot gates. Similar to TRADE, we use the summation of embedding vectors of each domain and slot pair as input to the state decoder and generate slot value token by token. First, From Table 6, we note that the performance does not change significantly as compared to the non-autoregressive version. This reveals that our proposed NADST models can predict fertilities reasonably well and performance is comparable with the auto-regressive approach. Second, we observe that the auto-regressive models are less sensitive to the use of system action in dialogue history delexicalization. We expect this as predicting slot gates is easier than predicting fertilities. Finally, we note that our auto-regressive model variants still outperform the existing approaches. This could be due to the high-level dependencies among (domain, slot) pairs learned during the first part of the model to predict slot gates.
210
+
211
+ <table><tr><td>MultiWOZ</td><td>Sys. Act</td><td>Joint Gate Acc</td><td>Joint Slot Acc</td><td>Slot Acc</td><td>Oracle Joint Slot Acc</td><td>Oracle Slot Acc</td></tr><tr><td>2.1</td><td>1</td><td>65.89%</td><td>49.76%</td><td>97.40%</td><td>71.39%</td><td>98.92%</td></tr><tr><td>2.1</td><td></td><td>62.04%</td><td>46.57%</td><td>97.23%</td><td>66.72%</td><td>98.65%</td></tr><tr><td>2.0</td><td>√</td><td>68.81%</td><td>50.08%</td><td>97.44%</td><td>79.04%</td><td>99.22%</td></tr><tr><td>2.0</td><td></td><td>65.27%</td><td>50.46%</td><td>97.43%</td><td>76.21%</td><td>99.08%</td></tr></table>
212
+
213
+ Table 6: Performance of auto-regressive model variants on MultiWOZ2.0 and 2.1. Fertility prediction is removed as fertility becomes redudant in auto-regressive models.
214
+
215
+ Visualization and Qualitative Evaluation. In Figure 4, we include two examples of dialogue state prediction and the corresponding visualization of self-attention scores of $X _ { d s \times f e r t }$ in state decoder. In each heatmap, the highlighted boxes express attention scores among non-symmetrical domain-slot pairs. In the first row, 5 attention heads capture the dependencies of two pairs (trainleaveat, train-arriveby) and (train-departure, train-destination). The model prediction for these two slots matches the gold labels: (train-leaveat, 09:50), (train-arriveby, 11:30) and (train-departure, cambridge), (train-destination, ely) respectively. In the second row, besides slot-level dependency between domain-slot pairs (taxi-departure, taxi-destination), token-level dependency is exhibited through the attention between attraction-type and attraction-name. By attending on token representations of attraction-name with corresponding output “christ college”, the models can infer “attraction-type=college” correctly. In addition, our model also detects contextual dependency between train-departure and attraction-name to predict “train-departure $\underline { { \underline { { \mathbf { \Pi } } } } }$ christ college.” Refer to Appendix A.4 for the dialogue history with gold and prediction states of these two sample dialogues.
216
+
217
+ # 5 CONCLUSION
218
+
219
+ We proposed NADST, a novel Non-Autoregressive neural architecture for DST that allows the model to explicitly learn dependencies at both slot-level and token-level to improve the joint accuracy rather than just individual slot accuracy. Our approach also enables fast decoding of dialogue states by adopting a parallel decoding strategy in decoding components. Our extensive experiments on the well-known MultiWOZ corpus for large-scale multi-domain dialogue systems benchmark show that our NADST model achieved the state-of-the-art accuracy results for DST tasks, while enjoying a substantially low inference latency which is an order of magnitude lower than the prior work.
220
+
221
+ # REFERENCES
222
+
223
+ Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
224
+
225
+ Paweł Budzianowski, Tsung-Hsien Wen, Bo-Hsiang Tseng, Inigo Casanueva, Stefan Ultes, Osman ˜ Ramadan, and Milica Gasiˇ c. MultiWOZ - a large-scale multi-domain wizard-of-Oz dataset for ´ task-oriented dialogue modelling. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 5016–5026, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1547. URL https://www. aclweb.org/anthology/D18-1547.
226
+
227
+ Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Lukasz Kaiser. Universal transformers. In International Conference on Learning Representations, 2019. URL https: //openreview.net/forum?id $=$ HyzdRiR9Y7.
228
+
229
+ Mihail Eric, Rahul Goel, Shachi Paul, Abhishek Sethi, Sanchit Agarwal, Shuyag Gao, and Dilek Hakkani-Tur. Multiwoz 2.1: Multi-domain dialogue state corrections and state tracking baselines. arXiv preprint arXiv:1907.01669, 2019.
230
+
231
+ Shuyang Gao, Abhishek Sethi, Sanchit Aggarwal, Tagyoung Chung, and Dilek Hakkani-Tur. Dialog state tracking: A neural reading comprehension approach. arXiv preprint arXiv:1908.01946, 2019.
232
+
233
+ Marjan Ghazvininejad, Omer Levy, Yinhan Liu, and Luke Zettlemoyer. Constant-time machine translation with conditional masked language models. arXiv preprint arXiv:1904.09324, 2019.
234
+
235
+ 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.
236
+
237
+ Rahul Goel, Shachi Paul, and Dilek Hakkani-Tur. Hyst: A hybrid approach for flexible and accurate ¨ dialogue state tracking. Proc. Interspeech 2019, pp. 1458–1462, 2019.
238
+
239
+ Alex Graves, Santiago Fernandez, Faustino Gomez, and J ´ urgen Schmidhuber. Connectionist tem- ¨ poral classification: labelling unsegmented sequence data with recurrent neural networks. In Proceedings of the 23rd international conference on Machine learning, pp. 369–376. ACM, 2006.
240
+
241
+ Jiatao Gu, James Bradbury, Caiming Xiong, Victor O.K. Li, and Richard Socher. Non-autoregressive neural machine translation. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ B1l8BtlCb.
242
+
243
+ Matthew Henderson, Blaise Thomson, and Jason D Williams. The second dialog state tracking challenge. In Proceedings of the 15th Annual Meeting of the Special Interest Group on Discourse and Dialogue (SIGDIAL), pp. 263–272, 2014a.
244
+
245
+ Matthew Henderson, Blaise Thomson, and Steve Young. Word-based dialog state tracking with recurrent neural networks. In Proceedings of the 15th Annual Meeting of the Special Interest Group on Discourse and Dialogue (SIGDIAL), pp. 292–299, 2014b.
246
+
247
+ Matthew Henderson, Blaise Thomson, and Steve J. Young. Robust dialog state tracking using delexicalised recurrent neural networks and unsupervised adaptation. 2014 IEEE Spoken Language Technology Workshop (SLT), pp. 360–365, 2014c.
248
+
249
+ Lukasz Kaiser, Samy Bengio, Aurko Roy, Ashish Vaswani, Niki Parmar, Jakob Uszkoreit, and Noam Shazeer. Fast decoding in sequence models using discrete latent variables. In International Conference on Machine Learning, pp. 2395–2404, 2018.
250
+
251
+ Diederick P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015.
252
+
253
+ 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.
254
+
255
+ Gakuto Kurata, Bing Xiang, Bowen Zhou, and Mo Yu. Leveraging sentence-level information with encoder LSTM for semantic slot filling. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 2077–2083, Austin, Texas, November 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1223. URL https: //www.aclweb.org/anthology/D16-1223.
256
+
257
+ Hwaran Lee, Jinsik Lee, and Tae yoon Kim. Sumbt: Slot-utterance matching for universal and scalable belief tracking. In ACL, 2019.
258
+
259
+ Jason Lee, Elman Mansimov, and Kyunghyun Cho. Deterministic non-autoregressive neural sequence modeling by iterative refinement. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 1173–1182, 2018.
260
+
261
+ Wenqiang Lei, Xisen Jin, Min-Yen Kan, Zhaochun Ren, Xiangnan He, and Dawei Yin. Sequicity: Simplifying task-oriented dialogue systems with single sequence-to-sequence architectures. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1437–1447, 2018.
262
+
263
+ Jindˇrich Libovicky and Jind \` ˇrich Helcl. End-to-end non-autoregressive neural machine translation with connectionist temporal classification. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 3016–3021, 2018.
264
+
265
+ Thang Luong, Hieu Pham, and Christopher D. Manning. Effective approaches to attention-based neural machine translation. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pp. 1412–1421, Lisbon, Portugal, September 2015. Association for Computational Linguistics. doi: 10.18653/v1/D15-1166. URL https://www.aclweb. org/anthology/D15-1166.
266
+
267
+ Nikola Mrksiˇ c, Diarmuid ´ O S ´ eaghdha, Tsung-Hsien Wen, Blaise Thomson, and Steve Young. ´ Neural belief tracker: Data-driven dialogue state tracking. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1777– 1788. Association for Computational Linguistics, 2017. doi: 10.18653/v1/P17-1163. URL http://www.aclweb.org/anthology/P17-1163.
268
+
269
+ Elnaz Nouri and Ehsan Hosseini-Asl. Toward scalable neural dialogue state tracking model. arXiv preprint arXiv:1812.00899, 2018.
270
+
271
+ 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. 2017.
272
+
273
+ Osman Ramadan, Paweł Budzianowski, and Milica Gasic. Large-scale multi-domain belief tracking with knowledge sharing. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics, volume 2, pp. 432–437, 2018.
274
+
275
+ Abhinav Rastogi, Dilek Z. Hakkani-Tur, and Larry P. Heck. Scalable multi-domain dialogue state ¨ tracking. 2017 IEEE Automatic Speech Recognition and Understanding Workshop (ASRU), pp. 561–568, 2017.
276
+
277
+ Holger Schwenk. Continuous space translation models for phrase-based statistical machine translation. In Proceedings of COLING 2012: Posters, pp. 1071–1080, Mumbai, India, December 2012. The COLING 2012 Organizing Committee. URL https://www.aclweb.org/ anthology/C12-2104.
278
+
279
+ Abigail See, Peter J Liu, and Christopher D Manning. Get to the point: Summarization with pointergenerator networks. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1073–1083, 2017.
280
+
281
+ Iulian V Serban, Alessandro Sordoni, Yoshua Bengio, Aaron Courville, and Joelle Pineau. Building end-to-end dialogue systems using generative hierarchical neural network models. In Thirtieth AAAI Conference on Artificial Intelligence, 2016.
282
+
283
+ Yangyang Shi, Kaisheng Yao, Hu Chen, Dong Yu, Yi-Cheng Pan, and Mei-Yuh Hwang. Recurrent support vector machines for slot tagging in spoken language understanding. In Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 393–399, San Diego, California, June 2016. Association for Computational Linguistics. doi: 10.18653/v1/N16-1044. URL https://www.aclweb.org/anthology/N16-1044.
284
+
285
+ Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The Journal of Machine Learning Research, 15(1):1929–1958, 2014.
286
+
287
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818–2826, 2016.
288
+
289
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin. Attention is all you need. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems 30, pp. 5998–6008. Curran Associates, Inc., 2017. URL http://papers.nips.cc/paper/7181-attention-is-all-you-need.pdf.
290
+
291
+ Oriol Vinyals, Meire Fortunato, and Navdeep Jaitly. Pointer networks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett (eds.), Advances in Neural Information Processing Systems 28, pp. 2692–2700. Curran Associates, Inc., 2015. URL http://papers.nips. cc/paper/5866-pointer-networks.pdf.
292
+
293
+ Yiren Wang, Fei Tian, Di He, Tao Qin, ChengXiang Zhai, and Tie-Yan Liu. Non-autoregressive machine translation with auxiliary regularization. In The Thirty-Third AAAI Conference on Artificial Intelligence (AAAI2019), pp. 5377–5384, 2019.
294
+
295
+ Tsung-Hsien Wen, David Vandyke, Nikola Mrksiˇ c, Milica Gasic, Lina M. Rojas Barahona, Pei-´ Hao Su, Stefan Ultes, and Steve Young. A network-based end-to-end trainable task-oriented dialogue system. In Proceedings of the 15th Conference of the European Chapter of the Association for Computational Linguistics: Volume 1, Long Papers, pp. 438–449, Valencia, Spain, April 2017. Association for Computational Linguistics. URL https://www.aclweb.org/ anthology/E17-1042.
296
+
297
+ Chien-Sheng Wu, Andrea Madotto, Ehsan Hosseini-Asl, Caiming Xiong, Richard Socher, and Pascale Fung. Transferable multi-domain state generator for task-oriented dialogue systems. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 808–819, Florence, Italy, July 2019. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/P19-1078.
298
+
299
+ Puyang Xu and Qi Hu. An end-to-end approach for handling unknown slot values in dialogue state tracking. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1448–1457. Association for Computational Linguistics, 2018. URL http://aclweb.org/anthology/P18-1134.
300
+
301
+ Victor Zhong, Caiming Xiong, and Richard Socher. Global-locally self-attentive encoder for dialogue state tracking. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1458–1467, Melbourne, Australia, July 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-1135. URL https: //www.aclweb.org/anthology/P18-1135.
302
+
303
+ # A APPENDIX
304
+
305
+ # A.1 DATASET PRE-PROCESSING
306
+
307
+ We follow similar data preprocessing procedures as Budzianowski et al. (2018) and Wu et al. (2019) on both MultiWOZ 2.0 and 2.1. The resulting corpus includes 8,438 multi-turn dialogues in training set with an average of 13.5 turns per dialogue. For the test and validation set, each includes 1,000 multi-turn dialogues with an average of 14.7 turns per dialogue. The average number of domains per dialogue is 1.8 for training, validation, and test sets. The MultiWOZ corpus includes much larger ontology than previous DST datasets such as WOZ (Wen et al., 2017) and DSTC2 (Henderson et al., 2014a). We identified a total of 35 (domain, slot) pairs across 7 domains. However, only 5 domains are included in the test data. Refer to Table 7 for the statistics of dialogues in these 5 domains.
308
+
309
+ Table 7: Summary of MultiWOZ dataset 2.1
310
+
311
+ <table><tr><td rowspan=1 colspan=1>Domain</td><td rowspan=1 colspan=1>attraction</td><td rowspan=1 colspan=1>hotel</td><td rowspan=1 colspan=1>restaurant</td><td rowspan=1 colspan=1>taxi</td><td rowspan=1 colspan=1>train</td><td rowspan=1 colspan=1>All</td></tr><tr><td rowspan=1 colspan=1>Slot</td><td rowspan=1 colspan=1>areanametype</td><td rowspan=1 colspan=1>areabookdaybookpeoplebookstayinternetnameparkingpricerangestarstype</td><td rowspan=1 colspan=1>areabookdaybookpeoplebooktimefoodnamepricerange</td><td rowspan=1 colspan=1>arrivebydeparturedestinationleaveat</td><td rowspan=1 colspan=1>arrivebybookpeopledaydeparturedestinationleaveat</td><td rowspan=1 colspan=1>=</td></tr><tr><td rowspan=1 colspan=1>train</td><td rowspan=1 colspan=1>3,381</td><td rowspan=1 colspan=1>3,103</td><td rowspan=1 colspan=1>2,717</td><td rowspan=1 colspan=1>3,813</td><td rowspan=1 colspan=1>1,654</td><td rowspan=1 colspan=1>8,438</td></tr><tr><td rowspan=1 colspan=1>val</td><td rowspan=1 colspan=1>416</td><td rowspan=1 colspan=1>484</td><td rowspan=1 colspan=1>401</td><td rowspan=1 colspan=1>438</td><td rowspan=1 colspan=1>207</td><td rowspan=1 colspan=1>1,000</td></tr><tr><td rowspan=1 colspan=1>test</td><td rowspan=1 colspan=1>394</td><td rowspan=1 colspan=1>494</td><td rowspan=1 colspan=1>395</td><td rowspan=1 colspan=1>437</td><td rowspan=1 colspan=1>195</td><td rowspan=1 colspan=1>1,000</td></tr></table>
312
+
313
+ # A.2 MODEL HYPER-PARAMETERS
314
+
315
+ We employed dropout (Srivastava et al., 2014) of 0.2 at all network layers except the linear layers of generation network components and pointer attention components. We used a batch size of 32, embedding dimension $d = 2 5 6$ in all experiments. We also fixed the number of attention heads to 16 in all attention layers. We shared the embedding weights to embed domain and slot tokens as input to fertility decoder and state decoder. We also shared the embedding weights between dialogue history encoder and state generator. We varied our models for different values of $T = T _ { f e r t } = T _ { s t a t e } \in$ $\{ 1 , 2 , 3 \}$ . In all experiments, the warmup steps are fine-tuned from a range from 13K to 20K training steps.
316
+
317
+ # A.3 ADDITIONAL RESULTS
318
+
319
+ Domain-specific Results. We conduct experiments to evaluate our model performance in all 5 test domains in MultiWOZ2.0 and 2.1. From Table 8, our models perform better in restaurant and attraction domain in general. The performance in the taxi and hotel domain is significantly lower than other domains. This could be explained as the hotel domain has a complicated slot ontology with 10 different slots, larger than the other domains. For the taxi domain, we observed that dialogues with this domain are usually of multiple domains, including the taxi domain in combination with other domains. Hence, it is more challenging to track dialogue states in the taxi domain.
320
+
321
+ Latency Results. We visualized the model latency against the length of dialogue history in Figure 2 and 3. In Figure 2, we only plot with dialogue history length up to 80 tokens as TSCP models do not use the full dialogue history as input. In Figure 3, for a fair comparison between TRADE and NADST, we plot the latency of the original TRADE which decodes dialogue state slot by slot and a new version of TRADE∗ model which decodes individual slots following a parallel decoding mechanism. Since TRADE independently generates dialogue state slot by slot, we enable parallel generation simply by feeding all slots into models at once (without impacts on performance). However, at the token level, TRADE∗ still follows an autoregressive decoding framework. Compared to TRADE∗ and TSCP, our model latency is only dependent on the model complexity i.e. the number of attention layers $T = T _ { f e r t } = T _ { s t a t e }$ . For TRADE∗ and TSCP, the model latency increases as dialogue extends over time while NADST latency is almost constant. The non-constant latency is mostly due to overhead processing such as delexicalizing dialogue history. Our approach is, hence, suitable especially for dialogues in multiple domains as they usually extend over more number of turns (e.g. 13 to 14 turns per dialogue in average in MultiWOZ corpus) In Figure 3, we noted that the latency of the original TRADE is almost unchanged as the dialogue history extends. This is most likely due to the model having to decode all possible (domain, slot) pairs rather than just relevant pairs as in NADST and TSCP. The TRADE∗ shows a clearer increasing trend of latency because the parallel process is independent of the number of (domain,slot) pairs considered. TRADE∗ still requires more time to decode than NADST as we also parallelize decoding at the token level.
322
+
323
+ Table 8: Additional domain-specific results of our model in MultiWOZ2.0 and MultiWOZ2.1. The model performs best with the restaurant domain and worst with the taxi domain.
324
+
325
+ <table><tr><td colspan="3">MultiWOZ2.1</td><td colspan="2">MultiWOZ2.0</td></tr><tr><td>Domain</td><td>Joint Acc</td><td>Slot</td><td>Joint Acc</td><td>Slot</td></tr><tr><td>Hotel</td><td>48.76%</td><td>97.70%</td><td>53.86%</td><td>97.75%</td></tr><tr><td>Train</td><td>62.36%</td><td>98.36%</td><td>58.58%</td><td>98.08%</td></tr><tr><td>Attraction</td><td>66.83%</td><td>98.89%</td><td>74.21%</td><td>99.19%</td></tr><tr><td>Restaurant</td><td>65.37%</td><td>98.78%</td><td>69.21%</td><td>98.84%</td></tr><tr><td>Taxi</td><td>33.80%</td><td>96.69%</td><td>34.94%</td><td>96.76%</td></tr></table>
326
+
327
+ ![](images/7d62c30615b53c3ffca6ed161c5e7b74a2c23e2990d169d20c0d2be0d5d381f8.jpg)
328
+ Figure 2: Comparison of model latency as wall-clock time (in ms) per prediction of complete dialogue state (not by individual slot). The latency is plotted against the length of the dialogue history. We compare our models with TSCP (Lei et al., 2018) with varied maximum output length of dialogue states $L = 8$ and $L = 2 0$ . We vary our models with different values of number of attention layers $T = T _ { f e r t } = T _ { s t a t e } = 1 , 2 , 3$ . Our models are more scalable as the latency does not change significantly when dialogue history extends over time.
329
+
330
+ Ablation Results. We conduct additional ablation experiments by varying the proportion of prediction values vs. ground-truth values for $X _ { d e l }$ and $X _ { d s \times f e r t }$ as input to the models. As can be seen in Table 9, the model performance increases gradually as the proportion of prediction input $\%$ pred reduces from $100 \%$ (true prediction) to $0 \%$ (oracle prediction). In particular, we observe more significant changes in performance against changes of $\%$ pred of $X _ { d s \times f e r t }$ . The model performance can increase up to more than $67 \%$ joint accuracy when we have an oracle input of $X _ { d s \times f e r t }$ . However, we consider improving model performance by $X _ { d e l }$ more practically achievable. For example, we can make use of a more sophisticated mechanism to delexicalize dialog history rather than exact word matching as the current strategy. Another example is having better $X _ { d e l }$ through a pretrained NLU model. In the ideal case with access to ground-truth labels of both $X _ { d e l }$ and $X _ { d s \times f e r t }$ , the model can obtain a joint accuracy of $73 \%$ .
331
+
332
+ ![](images/2c08b7341d37aa5dfb78de8a26e65d9b6448146ad773f5949f036455895dd369.jpg)
333
+ Figure 3: Comparison of model latency as wall-clock time (in ms) per prediction of complete dialogue state. The latency is plotted against the length of the dialogue history. For a fair comparison, we compare our models with TRADE (Wu et al., 2019) in 2 cases: original TRADE which decodes dialogue state slot by slot and TRADE∗ which decodes dialogue state in parallel at slot-level. Here we plot the base-10 logarithm of latency to show the difference between the 2 cases of TRADE. We vary our models with different values of number of attention layers $T = T _ { f e r t } = T _ { s t a t e } = 1 , 2 , 3$ . Our models are more scalable as the latency does not change significantly when dialogue history extends over time.
334
+
335
+ Table 9: Additional results of our model in MultiWOZ2.1 when we assume access to the groundtruth labels of $X _ { d e l }$ and $X _ { d s \times f e r t }$ (oracle prediction). We vary the the percentage of using the model prediction $\hat { X } _ { d e l }$ and $\hat { X } _ { d s \times f e r t }$ from $100 \%$ (true prediction) to $0 \%$ (oracle prediction).
336
+
337
+ <table><tr><td>%pred Xdel</td><td>%pred Xdsxfert</td><td>Joint Acc</td><td>Slot Acc</td><td>%pred Xdel</td><td>%pred Xdsxfert</td><td>Joint Acc</td><td>Slot Acc</td></tr><tr><td>0%</td><td>100%</td><td>57.40%</td><td>98.06%</td><td>100%</td><td>0%</td><td>67.32%</td><td>98.67%</td></tr><tr><td>20%</td><td>100%</td><td>56.50%</td><td>97.98%</td><td>100%</td><td>20%</td><td>64.09%</td><td>98.47%</td></tr><tr><td>40%</td><td>100%</td><td>55.24%</td><td>97.91%</td><td>100%</td><td>40%</td><td>61.29%</td><td>98.29%</td></tr><tr><td>60%</td><td>100%</td><td>53.58%</td><td>97.79%</td><td>100%</td><td>60%</td><td>57.02%</td><td>98.00%</td></tr><tr><td>80%</td><td>100%</td><td>52.02%</td><td>97.67%</td><td>100%</td><td>80%</td><td>54.11%</td><td>97.76%</td></tr><tr><td>100%</td><td>100%</td><td>49.04%</td><td>97.31%</td><td>100%</td><td>100%</td><td>49.04%</td><td>97.31%</td></tr><tr><td>0%</td><td>0%</td><td>73.44%</td><td>99.01%</td><td>0%</td><td>0%</td><td>73.44%</td><td>99.01%</td></tr></table>
338
+
339
+ ![](images/f24021160ad2cc8757b501d0e5677939806c5a126234b3aff52f64e8ac4dbdbc.jpg)
340
+ Figure 4: Heatmap visualization of self-attention scores of 5 heads between $\textstyle Z _ { d s \times f e r t }$ representations in the state decoder. The corresponding prediction output for each representation is presented on the right side. The examples are for the ${ \bf { \bar { 6 } } } ^ { t h }$ turn in dialogue ID MUL0536 (upper row) and PMUL3759 (lower row) in MultiWOZ2.1.
341
+
342
+ # A.4 SAMPLE PREDICTION OUTPUT
343
+
344
+ We extracted prediction output in all turns for 2 example dialogues: MUL0536 and PMUL3759.
345
+
346
+ Table 10: Full set of predicted dialogue states for dialogue ID MUL0536 in MultiWOZ2.1.
347
+
348
+ <table><tr><td>Human:</td><td></td><td>i am looking for abbey pool and astroturf pitch can you help me ?</td></tr><tr><td>Turn 1</td><td>Gold Dialog State:</td><td>(attraction-name,abbey pool and astroturf pitch)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-name,abbey pool and astroturf pitch)</td></tr><tr><td></td><td></td><td>yes,abbey pool and astroturf pitch is a swimmingpool east of town .their number is O1223902088,</td></tr><tr><td></td><td>System:</td><td>and address is pool way,whitehill road,off newmarket road . postcode cb58nt .</td></tr><tr><td>Turn 2</td><td>Human:</td><td>thank you very much for the information .that is alli needed help with . have a nice day.</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(attraction-area,east),(atraction-name,abbey pool and astroturf pitch),(atraction-type,swimming pool)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-area, east),(attraction-name,abbey pool and astroturf pitch)</td></tr><tr><td></td><td>System:</td><td>you are welcome .let me know if i can do anything else for you .</td></tr><tr><td></td><td>Human:</td><td>i actually do need to find a train going to ely.</td></tr><tr><td>Turn 3</td><td>Gold Dialog State:</td><td>(attraction-area,east),(atraction-name,abbey pool and astroturf pitch),(attraction-type,swimming pool),</td></tr><tr><td></td><td></td><td>(train-destination-ely)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-area, east),(atraction-name,abbey pool and astroturf pitch),(train-destination-ely)</td></tr><tr><td></td><td>System:</td><td>is that leaving from cambridge ?and if so,what time would you like to arrive in ely ?</td></tr><tr><td>Turn 4</td><td>Human:</td><td>yes,i willbe leaving cambridge and going toely,i would like it toarrive by 11:30. (atraction-area,east),(attraction-name,abbey pooland astroturf pitch),(attraction-type,swimming pool),</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(train-arriveby,11:3O),(train-departure,cambridge),(train-destination, ely)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-area, east),(atraction-name,abbey pool and astroturf pitch),(train-arriveby,11:30),</td></tr><tr><td></td><td></td><td>(train-departure,cambridge),(train-destination, ely) what day would yoube traveling ?there are 2,828 trains on that route.there isa train that departs friday at</td></tr><tr><td>Turn 5</td><td>System:</td><td>9:50 and will arrive in ely at 10:07 .</td></tr><tr><td></td><td>Human:</td><td>Oops !i guess forgot to mention it s thursday that i need to travel .</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(attraction-area,east),(atraction-name,abbey pool and astroturf pitch),(attraction-type,swimming pool), (train-arriveby,11:3O),(train-day,thursday),(train-departure,cambridge),(train-destination, ely)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-area, east), (atraction-name,abbey pool and astroturf pitch),(train-arriveby,11:30),</td></tr><tr><td></td><td>System:</td><td>(train-day, thursday),(train-departure,cambridge),(train-destination, ely) there are 3 trains that would fit,leaving at O5:50,O7:50,or 09:50.</td></tr><tr><td>Turn 6</td><td>Human:</td><td>can i get info for the O9:5O the price and the trains id please ?</td></tr><tr><td></td><td></td><td>(attraction-area,east),(attraction-name,abbey pool and astroturf pitch),(atraction-type,swimming pool),</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(train-arriveby,11:3O),(train-day,thursday),(train-departure,cambridge), (train-destination, ely), (train-leaveat, 09:50)</td></tr><tr><td></td><td></td><td>(attraction-area, east), (atraction-name,abbey pool and astroturf pitch),(train-arriveby,11:30),</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(train-day,thursday),(train-departure,cambridge),(train-destination,ely),(train-leaveat, 09:50)</td></tr><tr><td></td><td>System:</td><td>certainly .the train s id is tr1923,and the price for a ticket is 4.40 pounds .</td></tr><tr><td>Turn 7</td><td>Human:</td><td>great,thank you ! that will be allineed for now.</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(atraction-area,east), (attraction-name,abbey pool and astroturf pitch),(attraction-type,swimming pool), (train-arriveby,11:3O),(train-day,thursday),(train-departure,cambridge),(train-destination,ely),</td></tr><tr><td></td><td></td><td>(train-leaveat, 09:50) (attraction-area, east),(atraction-name,abbey pool and astroturf pitch),(train-arriveby,11:30),</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(train-day,thursday),(train-departure,cambridge),(train-destination,ely),(train-leaveat,09:50)</td></tr><tr><td></td><td>System:</td><td>are you certain you do not need further assistance ?</td></tr><tr><td>Turn 8</td><td>Human:</td><td>9:50 departure,4.40 pounds,trl923 .i got it,thank you ! (atraction-area,east), (attraction-name,abbey pooland astroturf pitch),(attraction-type,swimming pool),</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(train-arriveby,11:3O), (train-day,thursday),(train-departure,cambridge),(train-destination,ely),</td></tr><tr><td></td><td></td><td>(train-leaveat, 09:50)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-area,east),(atraction-name,abbey pool and astroturf pitch),(train-arriveby,11:30),</td></tr></table>
349
+
350
+ ![](images/1f28e20e859a4b30dd11d58f27bcd11faf036c53f9734e61292e6231b7416ec6.jpg)
351
+ Figure 5: Visualization of all attention heads in the last attention step $T _ { s t a t e }$ in the state decoder. The DST prediction is done for the $6 ^ { t h }$ turn in dialogue ID MUL0536 in MultiWOZ2.1.
352
+
353
+ Table 11: Full set of predicted dialogue states for dialogue ID PMUL3759 in MultiWOZ2.1.
354
+
355
+ <table><tr><td></td><td>Human:</td><td>what s your favorite college to visit in cambridge ?</td></tr><tr><td>Turn 1</td><td>Gold Dialog State:</td><td>(attraction-type,college)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-type,college)</td></tr><tr><td></td><td></td><td>ilike christ scollege in the center of town,but there are many others throughout the city.what part of</td></tr><tr><td></td><td>System:</td><td></td></tr><tr><td></td><td></td><td>the city did you want to visit ?</td></tr><tr><td>Turn 2 Human:</td><td></td><td>i think i would like to visit that location,it seems nice .could i get the phone number and the area ?</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(attraction-name,christ college),(attraction-type,college)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-area,centre),(attraction-name,christ college),(attraction-type,college)</td></tr><tr><td></td><td>System:</td><td>the area is centre and the phone number is O122333490o.is there anything else ican help you with ? actually,iam hungry .can you find me arestaurant that serves north american food ? something not</td></tr><tr><td></td><td>Turn 3Human:</td><td>super expensive,maybe in a moderate price range ?</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(araction-name,christ college),(attraction-type,college),(restaurant-food,modern american), (restaurant-pricerange, moderate)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-name,christ college),(attraction-type,college),(restaurant-food, north american),</td></tr><tr><td></td><td>System:</td><td>(restaurant-pricerange,moderate) iam sorry,there s no restaurant serving specifically north american or american food in my database,</td></tr><tr><td>Turn 4Human:</td><td></td><td>is there another type of food you would consider ? how about modern european food ?</td></tr><tr><td></td><td></td><td>(attraction-name,christ college),(atraction-type,collge),(restaurant-food,modern european),</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(restaurant-pricerange,moderate)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-name,christ college),(atraction-type,college),(restaurant-food, modern european), (restaurant-pricerange, moderate)</td></tr><tr><td></td><td>System:</td><td>there are 3 modern european restaurant -s 2 in the center and1 in the south .do you have a preference ?</td></tr><tr><td>Turn 5</td><td>Human:</td><td>i would prefer the 1 on the centre,could i have the phone number and postcode please ?</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(araction-name,christ college),(attraction-type,college),(restaurant-area,centre),</td></tr><tr><td></td><td></td><td>(restaurant-food, modern european),(restaurant-pricerange,moderate)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-name,christ college),(atraction-type,college),(restaurant-area,centre), (restaurant-food, modern european),(restaurant-pricerange, moderate)</td></tr><tr><td></td><td>System:</td><td>de luca cucina and bar s phone number is O1223356666. postcode is cb2law.</td></tr><tr><td>Turn 6</td><td>Human:</td><td>could you help me get a taxi to get from the college to the restaurant ?</td></tr><tr><td></td><td></td><td>(attraction-name,christ college),(attraction-type,college),(restaurant-area,centre),</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(restaurant-food,modern european),(restaurant-pricerange,moderate),(taxi-departure,christcolge), (taxi-destination,de luca cucina and bar)</td></tr><tr><td></td><td></td><td>(attraction-name,christ college),(attraction-type,college),(restaurant-area,centre),</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(restaurant-food, modern european), (restaurant-pricerange,moderate),(taxi-departure,christ colge), (taxi-destination,de luca cucina and bar)</td></tr><tr><td></td><td>System:</td><td>what time would you like to leave thecollege?icanbook youataxi to take you to the restaurant if you</td></tr><tr><td>Turn 7</td><td></td><td>would like.</td></tr><tr><td></td><td>Human:</td><td>i would like to leave by 13:00. (attraction-name,christ college),(attraction-type,college),(restaurant-area,centre),</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(restaurant-food, modern european),(restaurant-pricerange,moderate), (taxi-departure,christ collge),</td></tr><tr><td></td><td></td><td>(taxi-destination,de luca cucina and bar),(taxi-leaveat,12:45)</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(attraction-name,christ college),(attraction-type,college), (restaurant-area,centre), (restaurant-food, modern european), (restaurant-pricerange,moderate),(taxi-departure,christcolge),</td></tr><tr><td></td><td></td><td>(taxi-destination,de luca cucina and bar),(taxi-leaveat,13:00)</td></tr><tr><td></td><td>System:</td><td>ihave booked youataxi leaving at12:45.the car will beared toyotaand contact number is O7350032543 .anything else today ?</td></tr><tr><td>Turn 8Human:</td><td></td><td>that s it .thank you very much .</td></tr><tr><td></td><td></td><td>(attraction-name,christ college),(attraction-type,college), (restaurant-area,centre),</td></tr><tr><td></td><td>Gold Dialog State:</td><td>(restaurant-food, modern european),(restaurant-pricerange,moderate), (taxi-departure,christ collge),</td></tr><tr><td></td><td></td><td>(taxi-destination,de luca cucina and bar),(taxi-leaveat,12:45)</td></tr><tr><td></td><td></td><td>(araction-name,christ college),(attraction-type,college),(restaurant-area,centre),</td></tr><tr><td></td><td>Predicted Dialog State:</td><td>(restaurant-food, modern european), (restaurant-pricerange,moderate),(taxi-departure,christ college),</td></tr><tr><td></td><td></td><td>(taxi-destination,de luca cucina and bar),(taxi-leaveat,12:45)</td></tr><tr><td></td><td>System:</td><td>will you need anymore information concerning your stay ?</td></tr><tr><td></td><td></td><td>that is all,thanks for the help.</td></tr><tr><td>Turn 9</td><td>Human:</td><td></td></tr><tr><td></td><td></td><td>(attraction-name,christ college),(attraction-type,college),(restaurant-area,centre),</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td>Gold Dialog State:</td><td>(restaurant-food,modern european),(restaurant-pricerange,moderate), (taxi-departure,christ college),</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td>(taxi-destination,de luca cucina and bar),(taxi-leaveat,12:45)</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td>(attraction-name,christ college),(attraction-type,college),(restaurant-area,centre),</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td>Predicted Dialog State:</td><td></td><td></td></tr></table>
356
+
357
+ ![](images/29914032d00143a3858063c0b2f13de6be6b0c3775ddb131d4be80f9e43999f2.jpg)
358
+ Figure 6: Visualization of all attention heads in the last attention step $T _ { s } t a t e$ in the state decoder. The DST prediction is done for the $6 ^ { t h }$ turn in dialogue ID PMUL3759 in MultiWOZ2.1.
md/train/H1eqOnNYDH/H1eqOnNYDH.md ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DATA AUGMENTATION INSTEAD OFEXPLICIT REGULARIZATION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Modern deep artificial neural networks have achieved impressive results through models with orders of magnitude more parameters than training examples which control overfitting with the help of regularization. Regularization can be implicit, as is the case of stochastic gradient descent and parameter sharing in convolutional layers, or explicit. Explicit regularization techniques, most common forms are weight decay and dropout, have proven successful in terms of improved generalization, but they introduce sensitive hyper-parameters and, incongruously, often require deeper and wider architectures to compensate for the reduced capacity. In contrast, data augmentation techniques exploit domain knowledge to increase the number of training examples and improve generalization without reducing the representational capacity and without introducing model-dependent parameters, since it is applied on the training data. In this paper we systematically contrast data augmentation and explicit regularization on three popular architectures and three image object classification data sets. Our results demonstrate that data augmentation alone can achieve the same performance or higher as regularized models and exhibits much higher adaptability to changes in the architecture and the amount of training data.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ One of the central issues in machine learning research and application is finding ways of improving generalization. Regularization, loosely defined as any modification applied to a learning algorithm that helps prevent overfitting, plays therefore a key role in machine learning (Girosi et al., 1995; Müller, 2012). In the case of deep learning, where neural networks tend to have several orders of magnitude more parameters than training examples, statistical learning theory (Vapnik & Chervonenkis, 1971) indicates that regularization becomes even more crucial. Accordingly, a myriad of techniques have been proposed as regularizers: weight decay (Hanson & Pratt, 1989) and other $L ^ { p }$ penalties; dropout (Srivastava et al., 2014) and stochastic depth (Huang et al., 2016), to name a few examples. Moreover, whereas in simpler machine learning algorithms the regularizers can be easily identified as explicit terms in the objective function, in modern deep neural networks the sources of regularization are not only explicit, but implicit (Neyshabur et al., 2014). In this regard, many techniques have been studied for their regularization effect, despite not being explicitly intended as such. That is the case of unsupervised pre-training (Erhan et al., 2010), multi-task learning (Caruana, 1998), convolutional layers (LeCun et al., 1990), batch normalization (Ioffe & Szegedy, 2015) or adversarial training (Szegedy et al., 2013). In sum, there are multiple elements in deep learning that contribute to reduce overfitting and thus improve generalization.
12
+
13
+ Driven by the success of such techniques and the efficient use of GPUs, considerable research effort has been devoted to finding ways of training deeper and wider networks with larger capacity (Simonyan & Zisserman, 2014; He et al., 2016; Zagoruyko & Komodakis, 2016). Ironically, the increased representational capacity is eventually reduced in practice by the use of explicit regularization, most commonly weight decay and dropout. It is known, for instance, that the gain in generalization provided by dropout comes at the cost of using larger models and training for longer (Goodfellow et al., 2016). Hence, it seems that with these standard regularization methods deep networks are wasting capacity (Dauphin & Bengio, 2013).
14
+
15
+ Unlike explicit regularization, data augmentation improves generalization without reducing the capacity of the model. Data augmentation, that is synthetically expanding a data set by applying transformations on the available examples, has been long used in machine learning (Simard et al., 1992) and identified as a critical component of many recent successful models, like AlexNet (Krizhevsky et al., 2012), All-CNN (Springenberg et al., 2014) or ResNet (He et al., 2016), among others. Although it is most popular in computer vision, data augmentation has also proven effective in speech recognition (Jaitly & Hinton, 2013), music source separation (Uhlich et al., 2017) or text categorization (Lu et al., 2006). Today, data augmentation is an almost ubiquitous technique in deep learning, which can also be regarded as an implicit regularizer for it improves generalization.
16
+
17
+ Recently, the deep learning community has become more aware of the importance of data augmentation (Hernández-García & König, 2018b) and new techniques, such as cutout (DeVries & Taylor, 2017a) or augmentation in the feature space (DeVries & Taylor, 2017b), have been proposed. Very interestingly, a promising avenue for future research has been set by recently proposed models that automatically learn the data transformations (Hauberg et al., 2016; Lemley et al., 2017; Ratner et al., 2017; Antoniou et al., 2017). Nonetheless, another study by Perez & Wang (2017) analyzed the performance of different techniques for object recognition and concluded that one of the most successful techniques so far is still the traditional data augmentation carried out in most studies.
18
+
19
+ However, despite its popularity, the literature lacks, to our knowledge, a systematic analysis of the impact of data augmentation on convolutional neural networks compared to explicit regularization. It is a common practice to train the models with both explicit regularization, typically weight decay and dropout, and data augmentation, assuming they all complement each other. Zhang et al. (2017) included data augmentation in their analysis of generalization of deep networks, but it was questionably considered an explicit regularizer similar to weight decay and dropout. To our knowledge, the first time data augmentation and explicit regularization were systematically contrasted was the preliminary study by Hernández-García & König (2018b). The present work aims at largely extending that work both with more empirical results and a theoretical discussion.
20
+
21
+ Our specific contributions are the following:
22
+
23
+ • Propose definitions of explicit and implicit regularization that aim at solving the ambiguity in the literature (Section 2).
24
+ • A theoretical discussion based on statistical learning theory about the differences between explicit regularization and data augmentation, highlighting the advantages of the latter (Section 3).
25
+ • An empirical analysis of the performance of models trained with and without explicit regularization, and different levels of data augmentation on several benchmarks (Sections 4 and 5). Further, we study their adaptability to learning from fewer examples (Section 5.2) and to changes in the architecture (Section 5.3).
26
+ • A discussion on why encouraging data augmentation instead of explicit regularization can benefit both theory and practice in deep learning (Section 6).
27
+
28
+ # 2 EXPLICIT AND IMPLICIT REGULARIZATION
29
+
30
+ Zhang et al. (2017) raised the thought-provoking idea that “explicit regularization may improve generalization performance, but is neither necessary nor by itself sufficient for controlling generalization error.” The authors came to this conclusion from the observation that turning off the explicit regularizers of a model does not prevent the model from generalizing reasonably well. This contrasts with traditional machine learning involving convex optimization, where regularization is necessary to avoid overfitting and generalize (Vapnik & Chervonenkis, 1971). Such observation led the authors to suggest the need for “rethinking generalization” in order to understand deep learning.
31
+
32
+ We argue it is not necessary to rethink generalization if we instead rethink regularization and, in particular, data augmentation. Despite their thorough analysis and relevant conclusions, Zhang et al. (2017) arguably underestimated the role of implicit regularization and considered data augmentation an explicit form of regularization much like weight decay and dropout. This illustrates that the terms explicit and implicit regularization have been used subjectively and inconsistently in the literature before. In order to avoid the ambiguity and facilitate the discussion, we propose the following definitions of explicit and implicit regularization1:
33
+
34
+ • Explicit regularization techniques are those which reduce the representational capacity of the model they are applied on. That is, given a model class $\mathcal { H } _ { 0 }$ , for instance a neural network architecture, the introduction of explicit regularization will span a new hypothesis set $\mathcal { H } _ { 1 }$ , which is a proper subset of the original set, i.e. $\mathcal { H } _ { 1 } \subsetneq \mathcal { H } _ { 0 }$ .
35
+
36
+ • Implicit regularization is the reduction of the generalization error or overfitting provided by means other than explicit regularization techniques. Elements that provide implicit regularization do not reduce the representational capacity, but may affect the effective capacity of the model, that is the achievable set of hypotheses given the model, the optimization algorithm, hyperparameters, etc.
37
+
38
+ One of the most common explicit regularization techniques in machine learning is $L ^ { p }$ -norm regularization, of which weight decay is a particular case, widely used in deep learning. Weight decay sets a penalty on the $L ^ { 2 }$ norm of the learnable parameters, thus constraining the representational capacity of the model. Dropout is another common example of explicit regularization, where the hypothesis set is reduced by stochastically deactivating a number of neurons during training. Similar to dropout, stochastic depth, which drops whole layers instead of neurons, is also an explicit regularization technique.
39
+
40
+ There are multiple elements in deep neural networks that implicitly regularize the models. Note, in this regard, that the above definition, contrary to explicit regularization, does not refer to techniques, but to a regularization effect, as it can be provided by elements of very different nature. For instance, stochastic gradient descent (SGD) is known to have an implicit regularization effect without constraining the representational capacity. Batch normalization does not either reduce the capacity, but it improves generalization by smoothing the optimization landscape Santurkar et al. (2018). Of quite a different nature, but still implicit, is the regularization effect provided by early stopping, which does not reduce the representational, but the effective capacity.
41
+
42
+ By analyzing the literature, we identified some previous pieces of work which, lacking a definition of explicit and implicit regularization, made a distinction apparently based on the mere intention of the practitioner. Under such notion, data augmentation has been considered in some cases an explicit regularization technique, as in Zhang et al. (2017). Here, we have provided definitions for explicit and implicit regularization based on their effect on the representational capacity and argue that data augmentation is not explicit, but implicit regularization, since it does not affect the representational capacity of the model.
43
+
44
+ # 3 THEORETICAL INSIGHTS
45
+
46
+ The generalization of a model class $\mathcal { H }$ can be analyzed through complexity measures such as the VC-dimension or, more generally, the Rademacher complexity $\mathcal { \bar { R } } _ { n } ( \mathcal { H } ) = \mathbb { E } _ { S \sim D ^ { n } } \left[ \hat { \mathcal { R } } _ { S } ( \mathcal { H } ) \right]$ , where:
47
+
48
+ $$
49
+ \hat { \mathcal { R } } _ { S } ( \mathcal { H } ) = \mathbb { E } _ { \sigma } \left[ \operatorname* { s u p } _ { h \in \mathcal { H } } \left| \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \sigma _ { i } h ( x _ { i } ) \right| \right]
50
+ $$
51
+
52
+ is the empirical Rademacher complexity, defined with respect to a set of data samples $S = ( x _ { i } , . . . , x _ { n } )$ . Then, in the case of binary classification and the class of linear separators, the generalization error of a hypothesis, $\hat { \epsilon } _ { S } ( h )$ , can be bounded using the Rademacher complexity:
53
+
54
+ $$
55
+ \hat { \epsilon } _ { S } ( h ) \leq \mathcal { R } _ { n } ( \mathcal { H } ) + \mathcal { O } \left( \sqrt { \frac { \ln ^ { 1 } / \delta } { n } } \right)
56
+ $$
57
+
58
+ with probability $1 - \delta$ . Tighter bounds for some model classes, such as fully connected neural networks, can be obtained (Bartlett $\&$ Mendelson, 2002), but it is not trivial to formally analyze the influence on generalization of specific architectures or techniques.
59
+
60
+ Nonetheless, we can use these theoretical insights to discuss the differences between explicit regularization—particularly weight decay and dropout—and implicit regularization—particularly data augmentation. A straightforward yet very relevant conclusion from the analysis of any generalization bound is the strong dependence on the number of training examples $n$ . Increasing $n$ drastically improves the generalization guarantees, as reflected by the second term in RHS of Equation 1 and the dependence of the Rademacher complexity (LHS) on the sample size as well. Data augmentation exploits prior knowledge of the data domain $D$ to create new examples and its impact on generalization is related to an increment in $n$ , since stochastic data augmentation can generate virtually infinite different samples. Admittedly, the augmented samples are not independent and identically distributed and thus, the effective increment of samples does not strictly correspond to the increment in $n$ . This is why formally analyzing the impact of data augmentation on generalization is complex and out of the scope of this paper. Recently, some studies have taken steps in this direction by analyzing the effect of simplified data transformations on generalization from a theoretical point of view Chen et al. (2019); Rajput et al. (2019).
61
+
62
+ In contrast, explicit regularization methods aim, in general, at improving the generalization error by constraining the hypothesis class $\mathcal { H }$ , which hopefully should reduce its complexity, $\textstyle { \mathcal { R } } _ { n } ( { \mathcal { H } } )$ , and, in turn, the generalization error $\hat { \epsilon } _ { S } ( h )$ . Crucially, while data augmentation exploits domain knowledge, most explicit regularization methods only naively constrain the hypothesis class. For instance, weight decay constrains the learnable models $\mathcal { H }$ by setting a penalty on the weights norm. However, Bartlett et al. (2017) have recently shown that weight decay has little impact on the generalization bounds and confidence margins.
63
+
64
+ Dropout has been extensively used and studied as a regularization method for neural networks (Wager et al., 2013), but the exact way in which dropout may improve generalization is still an open question and it has been concluded that the effects of dropout on neural networks are somewhat mysterious, complicated and its penalty highly non-convex (Helmbold & Long, 2017). Recently, Mou et al. (2018) have established new generalization bounds on the variance induced by a particular type of dropout on feedforward neural network. Nevertheless, dropout can also be analyzed as a random form of data augmentation without domain knowledge Bouthillier et al. (2015), that is data-dependent regularization. Therefore, any generalization bound derived for dropout can be regarded as a pessimistic bound for domain-specific, standard data augmentation.
65
+
66
+ A similar argument applies for weight decay, which, as first shown by Bishop (1995), is equivalent to training with noisy examples if the noise amplitude is small and the objective is the sum-of-squares error function. In sum, many forms of explicit regularization are at least approximately equivalent to adding random noise to the training examples, which is the simplest form of data augmentation2. Thus, it is reasonable to argue that more sophisticated data augmentation can overshadow the benefits provided by explicit regularization.
67
+
68
+ In general, we argue that the reason why explicit regularization may not be necessary is that neural networks are already implicitly regularized by many elements—stochastic gradient descent (SGD), convolutional layers, normalization and data augmentation, to name a few—that provide a more successful inductive bias (Neyshabur et al., 2014). For instance, it has been shown that linear models optimized with SGD converge to solutions with small norm, without any explicit regularization (Zhang et al., 2017). In the remainder of the paper, we present a set of experiments that shed more light on the advantages of data augmentation over weight decay and dropout.
69
+
70
+ # 4 METHODS
71
+
72
+ This section describes the experimental setup for systematically analyzing the role of data augmentation in deep neural networks compared to weight decay and dropout and builds upon the methods used in preliminary studies (Hernández-García & König, 2018a;b; Zhang et al., 2017).
73
+
74
+ # 4.1 NETWORK ARCHITECTURES
75
+
76
+ We perform our experiments on three distinct, popular architectures that have achieved successful results in object recognition tasks: the all convolutional network, All-CNN (Springenberg et al.,
77
+
78
+ 2014); the wide residual network, WRN (Zagoruyko & Komodakis, 2016); and the densely connected network, DenseNet (Huang et al., 2017). Importantly, we keep the same training hyper-parameters (learning rate, training epochs, batch size, optimizer, etc.) as in the original papers in the cases they are reported. Below we present the main features of each network and more details can be found in the supplementary material.
79
+
80
+ • All-CNN: it consists only of convolutional layers with ReLU activation (Glorot et al., 2011), it is relatively shallow and has few parameters. For ImageNet, the network has 16 layers and 9.4 million parameters; for CIFAR, it has 12 layers and 1.3 million parameters. In our experiments to compare the adaptability of data augmentation and explicit regularization to changes in the architecture, we also test a shallower version, with 9 layers and 374,000 parameters, and a deeper version, with 15 layers and 2.4 million parameters.
81
+ WRN: a residual network, ResNet (He et al., 2016), that achieves better performance with fewer layers, but more units per layer. Here, we choose for our experiments the WRN-28-10 version (28 layers and about $3 6 . 5 \mathrm { ~ M ~ }$ parameters), which is reported to achieve the best results on CIFAR.
82
+ DenseNet: a network architecture arranged in blocks whose layers are connected to all previous layers, allowing for very deep architectures with few parameters. Specifically, for our experiments we use a DenseNet-BC with growth rate $k = 1 2$ and 16 layers in each block, which has a total of 0.8 million parameters.
83
+
84
+ # 4.2 DATA
85
+
86
+ We perform the experiments on the highly benchmarked data sets ImageNet (Russakovsky et al., 2015) ILSVRC 2012, CIFAR-10 and CIFAR-100 (Krizhevsky & Hinton, 2009). We resize the $1 . 3 { \bf M }$ images from ImageNet into $1 5 0 \times 2 0 0$ pixels, as a compromise between keeping a high resolution and speeding up the training. Both on ImageNet and on CIFAR, the pixel values are in the range [0, 1] and have 32 bits floating precision.
87
+
88
+ So as to analyze the role of data augmentation, we train every network architecture with two different augmentation schemes as well as with no data augmentation at all:
89
+
90
+ • Light augmentation: This scheme is common in the literature, for example (Goodfellow et al., 2013; Springenberg et al., 2014), and performs only horizontal flips and horizontal and vertical translations of $10 \%$ of the image size. • Heavier augmentation: This scheme performs a larger range of affine transformations such as scaling, rotations and shear mappings, as well as contrast and brightness adjustment. On ImageNet we additionally perform a random crop of $1 2 8 \times 1 2 8$ pixels. The choice of the allowed transformations is arbitrary and the only criterion was that the objects are still recognizable in general. We deliberately avoid designing a particularly successful scheme. The details of the heavier scheme can be consulted in the supplementary material.
91
+
92
+ # 4.3 TRAIN AND TEST
93
+
94
+ Every architecture is trained on each data set both with explicit regularization—weight decay and dropout as specified in the original papers—and with no explicit regularization. Furthermore, we train each model with the three data augmentation schemes. The performance of the models is computed on the held out test tests. As in previous works (Krizhevsky et al., 2012; Simonyan & Zisserman, 2014), we average the softmax posteriors over 10 random light augmentations, since slightly better results are obtained.
95
+
96
+ All the experiments are performed on Keras (Chollet et al., 2015) on top of TensorFlow (Abadi et al., 2015) and on a single GPU NVIDIA GeForce GTX 1080 Ti.
97
+
98
+ # 5 RESULTS
99
+
100
+ This section presents the most relevant results of the experiments comparing the roles of data augmentation and explicit regularization on convolutional neural networks. First, we present the experiments with the original architectures in section 5.1. Then, Sections 5.2 and 5.3 show the results of training the models with fewer training examples and with shallower and deeper versions of the All-CNN architecture.
101
+
102
+ The figures aim at facilitating the comparison between the models trained with and without explicit regularization, as well as between the different levels of data augmentation. The purple bars (top of each pair) correspond to the models trained without explicit regularization—weight decay and dropout—and the red bars (bottom) to the models trained with it. The different color shades correspond to the three augmentation schemes. The figures show the relative performance of each model with respect to a particular baseline in order to highlight the relevant comparisons. A detailed and complete report of all the results can be found in the supplementary material. The results on CIFAR refer to the top-1 test accuracy while on ImageNet we report the top-5.
103
+
104
+ ![](images/8b6cc42425af0db8d9cdf35f348694e53130994bd384e0169f755bbe068c0dd7.jpg)
105
+ 5.1 AN ALTERNATIVE TO EXPLICIT REGULARIZATION
106
+ Figure 1: Relative improvement of adding data augmentation and explicit regularization to the baseline models, $( a c c u r a c y - b a s e l i n e ) / a c c u r a c y * 1 0 0$ . The baseline accuracy is shown on the left. The results suggest that data augmentation alone (purple bars) can achieve even better performance than the models trained with both weight decay and dropout (red bars).
107
+
108
+ First, we contrast the regularization effect of data augmentation and weight decay and dropout on the original networks trained with the complete data sets. For that purpose, in Figure 1 we show the relative improvement in test performance achieved by adding each technique or combination of techniques to the baseline model, that is the model trained with neither explicit regularization nor data augmentation (see the left of the bars). Table 1 shows the mean and standard deviation of each combination.3
109
+
110
+ Table 1: Average accuracy improvement over the baseline model of each combination of data augmentation level and presence of weight decay and dropout.
111
+
112
+ <table><tr><td colspan="2">No explicit reg.</td><td>Weight decay+ dropout</td></tr><tr><td>None</td><td>baseline</td><td>3.02 (1.65)</td></tr><tr><td>Light</td><td>8.46 (3.80)</td><td>7.88 (2.60)</td></tr><tr><td>Heavier</td><td>8.68 (4.69)</td><td>7.92 (4.03)</td></tr></table>
113
+
114
+ Several conclusions can be extracted from Figure 1 and Table 1. Most importantly, training with data augmentation alone (top, purple bars) improves the performance in most cases as much as or even more than training with both augmentation and explicit regularization (bottom, red bars), on average
115
+
116
+ ![](images/72253326400dc7273b680e490df4f2ccb0e351b3a7abc1cf1e5046f8da53e30c.jpg)
117
+
118
+ ![](images/9fdc95a93ffd8fade21f6268f1a50dd95ca5e87c9efcab76f06358e07c61c4de.jpg)
119
+ (a) $50 \%$ of the available training data
120
+ Figure 2: Fraction of the baseline performance when the amount of available training data is reduced, accuracy/baseline $* 1 0 0$ . The models trained wit explicit regularization present a significant drop in performance as compared to the models trained with only data augmentation. The differences become larger as the amount of training data decreases.
121
+
122
+ 8.57 and $7 . 9 0 \%$ respectively. This is quite a surprising and remarkable result: note that the studied architectures achieved state-of-the-art results at the moment of their publication and the models included both light augmentation and weight decay and dropout, whose parameters were presumably finely tuned to achieve higher accuracy. The replication of these results corresponds to the middle red bars in Figure 1. We show here that simply removing weight decay and dropout—while even keeping all other hyperparameters intact, see Section 4.1—improves the formerly state-of-the-art accuracy in 4 of the 8 studied cases.
123
+
124
+ Second, it can also be observed that the regularization effect of weight decay and dropout, an average improvement of $3 . 0 2 \%$ with respect to the baseline,1 is much smaller than that of data augmentation. Simply applying light augmentation increases the accuracy in $8 . 4 6 \%$ on average.
125
+
126
+ Finally, note that even though the heavier augmentation scheme was deliberately not designed to optimize the performance, in both CIFAR-10 and CIFAR-100 it improves the test performance with respect to the light augmentation scheme. This is not the case on ImageNet, probably due to the increased complexity of the data set. It can be observed though that the effects are in general more consistent in the models trained without explicit regularization. In sum, it seems that the performance gain achieved by weight decay and dropout can be achieved and often improved by data augmentation alone.
127
+
128
+ # 5.2 FEWER AVAILABLE TRAINING EXAMPLES
129
+
130
+ We argue that one of the main drawbacks of explicit regularization techniques is their poor adaptability to changes in the conditions with which the hyperparameters were tuned. To test this hypothesis and contrast it with the adaptability of data augmentation, here we extend the analysis by training the same networks with fewer examples. The models are trained with the same random subset of data and evaluated in the same test set as the previous experiments. In order to better visualize how well each technique resists the reduction of training data, in Figure 2 we show the fraction of baseline accuracy achieved by each model when trained with $50 \%$ and $10 \%$ of the available data. In this case, the baseline is thus each corresponding model trained with the complete data set. Table 2 summarizes the mean and standard deviation of each combination. An extended report of results, including additional experiments with $80 \%$ and $1 \%$ of the data, is provided in the supplementary material.
131
+
132
+ Table 2: Average fraction of the original accuracy of each corresponding combination of data augmentation level and presence of weight decay and dropout.
133
+
134
+ <table><tr><td rowspan="2"></td><td colspan="2">50 % of the training data</td><td colspan="2">10 % of the training data</td></tr><tr><td>No explicit reg.</td><td>WD + dropout</td><td>No explicit reg.</td><td>WD + dropout</td></tr><tr><td>None</td><td>88.11 (6.27)</td><td>83.20 (9.83)</td><td>58.72 (14.93)</td><td>58.75 (16.92)</td></tr><tr><td>Light</td><td>91.47 (4.31)</td><td>88.27 (7.39)</td><td>67.55 (14.27)</td><td>60.89 (18.39)</td></tr><tr><td>Heavier</td><td>91.82 (4.63)</td><td>89.28 (6.63)</td><td>68.69 (13.61)</td><td>61.43 (15.90)</td></tr></table>
135
+
136
+ ![](images/a06cb94477dec2e8e682b5aca1bc93ba6d1cf81a0ee7bfc3577891a82d8f56ac.jpg)
137
+ Figure 3: Fraction of the original performance when the depth of the All-CNN architecture is increased or reduced in 3 layers. In the explicitly regularized models, the change of architecture implies a dramatic drop in the performance, while the models trained without explicit regularization present only slight variations with respect to the original architecture.
138
+
139
+ One of the main conclusions of this set of experiments is that if no data augmentation is applied, explicit regularization hardly resist the reduction of training data by itself. On average, with $50 \%$ of the available data, these models only achieve $8 3 . 2 0 \%$ of the original accuracy, which, remarkably, is worse than the models trained without any explicit regularization $( 8 8 . 1 1 \% )$ . On $10 \%$ of the data, the average fraction is the same (58.75 and $5 8 . 7 2 \%$ , respectively). This implies that training with explicit regularization is even detrimental for the performance.
140
+
141
+ When combined with data augmentation, the models trained with explicit regularization (bottom, red bars) also perform worse (88.78 and $6 1 . 1 6 \%$ with 50 and $10 \%$ of the data, respectively), than the models with just data augmentation (top, purple bars, 91.64 and $6 8 . 1 2 \%$ on average). Note that the difference becomes larger as the amount of available data decreases. Importantly, it seems that the combination of explicit regularization and data augmentation is only slightly better than training without data augmentation. We can think of two reasons that could explain this: first, the original regularization hyperparameters seem to adapt poorly to the new conditions. The hyperparameters are specifically tuned for the original setup and one would have to re-tune them to achieve comparable results. Second, since explicit regularization reduces the representational capacity, this might prevent the models from taking advantage of the augmented data.
142
+
143
+ In contrast, the models trained without explicit regularization more naturally adapt to the reduced availability of data. With $50 \%$ of the data, these models, trained with data augmentation achieve about $91 . 5 \%$ of the performance with respect to training with the complete data sets. With only $10 \%$ of the data, they achieve nearly $70 \%$ of the baseline performance, on average. This highlights the suitability of data augmentation to serve, to a great extent, as true, useful data (Vinyals et al., 2016).
144
+
145
+ # 5.3 SHALLOWER AND DEEPER ARCHITECTURES
146
+
147
+ Finally, in this section we test the adaptability of data augmentation and explicit regularization to changes in the depth of the All-CNN architecture (see Section 4.1). We show the fraction of the performance with respect to the original architecture in Figure 3.
148
+
149
+ A noticeable result from Figure 3 is that all the models trained with weight decay and dropout (bottom, red bars) suffer a dramatic drop in performance when the architecture changes, regardless of whether it becomes deeper or shallower and of the amount of data augmentation. As in the case of reduced training data, this may be explained by the poor adaptability of the regularization hyperparameters, which highly depend on the architecture.
150
+
151
+ This highly contrasts with the performance of the models trained without explicit regularization (top, purple bars). With a deeper architecture, these models achieve slightly better performance, effectively exploiting the increased capacity. With a shallower architecture, they achieve only slightly worse performance4. Thus, these models seem to more naturally adapt to the new architecture and data augmentation becomes beneficial.
152
+
153
+ It is worth commenting on the particular case of the CIFAR-100 benchmark, where the difference between the models with and without explicit regularization is even more pronounced, in general. It is a common practice in object recognition papers to tune the parameters for CIFAR-10 and then test the performance on CIFAR-100 with the same hyperparameters. Therefore, these are typically less suitable for CIFAR-100. We believe this is the reason why the benefits of data augmentation seem even more pronounced on CIFAR-100 in our experiments.
154
+
155
+ In sum, these results highlight another crucial advantage of data augmentation: the effectiveness of its hyperparameters, that is the type of image transformations, depend mostly on the type of data, rather than on the particular architecture or amount of available training data, unlike explicit regularization hyperparameters. Therefore, removing explicit regularization and training with data augmentation increases the flexibility of the models.
156
+
157
+ # 6 DISCUSSION
158
+
159
+ We have presented a systematic analysis of the role of data augmentation in deep convolutional neural networks for object recognition, focusing on the comparison with popular explicit regularization techniques—weight decay and dropout. In order to facilitate the discussion and the analysis, we first proposed in Section 2 definitions of explicit and implicit regularization, which have been ambiguously used in the literature. Accordingly, we have argued that data augmentation should not be considered an explicit regularizer, such as weight decay and dropout. Then, we provided some theoretical insights in Section 3 that highlight some advantages of data augmentation over explicit regularization. Finally, we have empirically shown that explicit regularization is not only unnecessary (Zhang et al., 2017), but also that its generalization gain can be achieved by data augmentation alone. Moreover, we have demonstrated that, unlike data augmentation, weight decay and dropout exhibit poor adaptability to changes in the architecture and the amount of training data.
160
+
161
+ Despite the limitations of our empirical study, we have chosen three significantly distinct network architectures and three data sets in order to increase the generality of our conclusions, which should ideally be confirmed by future work on a wider range of models, data sets and even other domains such text or speech. It is important to note, however, that we have taken a conservative approach in our experimentation: all the hyperparameters have been kept as in the original models, which included both weight decay and dropout, as well as light augmentation. This setup is clearly suboptimal for models trained without explicit regularization. Besides, the heavier data augmentation scheme was deliberately not optimized to improve the performance and it was not the scope of this work to propose a specific data augmentation technique. As future work, we plan to propose data augmentation schemes that can more successfully be exploited by any deep model.
162
+
163
+ The relevance of our findings lies in the fact that explicit regularization is currently the standard tool to enable the generalization of most machine learning methods and is included in most convolutional neural networks. However, we have empirically shown that simply removing the explicit regularizers often improves the performance or only marginally reduces it, if some data augmentation is applied. These results are supported by the theoretical insights provided in in Section 3.
164
+
165
+ Zhang et al. (2017) suggested that regularization might play a different role in deep learning, not fully explained by statistical learning theory (Vapnik & Chervonenkis, 1971). We have argued instead that the theory still naturally holds in deep learning, as long as one considers the crucial role of implicit regularization: explicit regularization seems to be no longer necessary because its contribution is already provided by the many elements that implicitly and successfully regularize the models: to name a few, stochastic gradient descent, convolutional layers and data augmentation.
166
+
167
+ # 6.1 RETHINKING DATA AUGMENTATION
168
+
169
+ Data augmentation is often regarded by authors of machine learning papers as cheating, something that should not be used in order to test the potential of a newly proposed architecture (Goodfellow et al., 2013; Graham, 2014; Larsson et al., 2016). In contrast, weight decay and dropout are almost ubiquitous and considered intrinsic elements of the algorithms. In view of the results presented here, we believe that the deep learning community would benefit if we rethink data augmentation and switch roles with explicit regularization: a good model should generalize well without the need for explicit regularization and successful methods should effectively exploit data augmentation.
170
+
171
+ In this regard it is worth highlighting some of the advantages of data augmentation: Not only does it not reduce the representational capacity of the model, unlike explicit regularization, but also, since the transformations reflect plausible variations of the real objects, it increases the robustness of the model and it can be seen as a data-dependent prior, similarly to unsupervised pre-training (Erhan et al., 2010). Novak et al. (2018) have shown that data augmentation consistently yields models with smaller sensitivity to perturbations. Interestingly, recent work has found that models trained with heavier data augmentation learn representations that are more similar to the inferior temporal (IT) cortex, highlighting the biological plausibility of data augmentation (Hernández-García et al., 2018).
172
+
173
+ Deep neural networks are especially well suited for data augmentation because they do not rely on pre-computed features and because the large number of parameters allows them to shatter the augmented training set. Moreover, unlike explicit regularization, data augmentation can be performed on the CPU, in parallel to the gradient updates. Finally, an important conclusion from Sections 5.2 and 5.3 is that data augmentation naturally adapts to architectures of different depth and amounts of available training data, whereas explicitly regularized models are highly sensitive to such changes and need specific fine-tuning of their hyperparameters. In sum, data augmentation seems to be a strong alternative to explicit regularization techniques.
174
+
175
+ Some argue that despite these advantages, data augmentation is a limited approach because it depends on some prior expert knowledge and it cannot be applied to all domains. However, we argue instead that expert knowledge should not be disregarded but exploited. A single data augmentation scheme can be designed for a broad family of data (for example, natural images) and effectively applied to a broad set of tasks (for example, object recognition, segmentation, localization, etc.). Besides, interesting recent works have shown that it is possible to automatically learn the data augmentation strategies (Lemley et al., 2017; Ratner et al., 2017). We hope that these insights encourage more research attention on data augmentation and that future work brings more sophisticated and effective data augmentation techniques, potentially applicable to different data modalities.
176
+
177
+ # REFERENCES
178
+
179
+ Martín Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S. Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, and et al. TensorFlow: Large-scale machine learning on heterogeneous systems, 2015. URL http://tensorflow.org/. Software available from tensorflow.org.
180
+
181
+ Antreas Antoniou, Amos Storkey, and Harrison Edwards. Data augmentation generative adversarial networks. arXiv preprint arXiv:1711.04340, 2017.
182
+
183
+ Peter L Bartlett and Shahar Mendelson. Rademacher and gaussian complexities: Risk bounds and structural results. Journal of Machine Learning Research, 3(Nov):463–482, 2002.
184
+
185
+ Peter L Bartlett, Dylan J Foster, and Matus J Telgarsky. Spectrally-normalized margin bounds for neural networks. In Advances in Neural Information Processing Systems, pp. 6240–6249, 2017.
186
+
187
+ Chris M Bishop. Training with noise is equivalent to tikhonov regularization. Neural computation, 7 (1):108–116, 1995.
188
+
189
+ Xavier Bouthillier, Kishore Konda, Pascal Vincent, and Roland Memisevic. Dropout as data augmentation. arXiv preprint arXiv:1506.08700, 2015.
190
+
191
+ Rich Caruana. Multitask learning. In Learning to learn, pp. 95–133. Springer, 1998.
192
+
193
+ Shuxiao Chen, Edgar Dobriban, and Jane H Lee. Invariance reduces variance: Understanding data augmentation in deep learning and beyond. arXiv preprint arXiv:1907.10905, 2019.
194
+
195
+ François Chollet et al. Keras. https://github.com/fchollet/keras, 2015.
196
+
197
+ Yann N Dauphin and Yoshua Bengio. Big neural networks waste capacity. In International Conference on Learning Representations, ICLR, arXiv:1301.3583, 2013.
198
+
199
+ Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017a.
200
+
201
+ Terrance DeVries and Graham W Taylor. Dataset augmentation in feature space. In International Conference on Learning Representations, ICLR, arXiv:1702.05538, 2017b.
202
+
203
+ Dumitru Erhan, Yoshua Bengio, Aaron Courville, Pierre-Antoine Manzagol, Pascal Vincent, and Samy Bengio. Why does unsupervised pre-training help deep learning? Journal of Machine Learning Research, JMLR, 11(Feb):625–660, 2010.
204
+
205
+ Federico Girosi, Michael Jones, and Tomaso Poggio. Regularization theory and neural networks architectures. Neural computation, 7(2):219–269, 1995.
206
+
207
+ Xavier Glorot and Yoshua Bengio. Understanding the difficulty of training deep feedforward neural networks. In JMLR W&CP: International Conference on Artificial Intelligence and Statistics, AISTATS, volume 9, pp. 249–256, 2010.
208
+
209
+ Xavier Glorot, Antoine Bordes, and Yoshua Bengio. Deep sparse rectifier neural networks. In JMLR W&CP: International Conference on Artificial Intelligence and Statistics, AISTATS, volume 15, pp. 315–323, 2011.
210
+
211
+ Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep learning. MIT press, 2016.
212
+
213
+ Ian J. Goodfellow, David Warde-Farley, Mehdi Mirza, Aaron C. Courville, and Yoshua Bengio. Maxout networks. In International Conference on Machine Learning, ICML, pp. 1319–1327, 2013.
214
+
215
+ Benjamin Graham. Fractional max-pooling. arXiv preprint arXiv:1412.6071, 2014.
216
+
217
+ Hongyu Guo, Yongyi Mao, and Richong Zhang. Mixup as locally linear out-of-manifold regularization. arXiv preprint arXiv:1809.02499, 2018.
218
+
219
+ Stephen José Hanson and Lorien Y Pratt. Comparing biases for minimal network construction with back-propagation. In Advances in Neural Information Processing Systems, NIPS, pp. 177–185, 1989.
220
+
221
+ Søren Hauberg, Oren Freifeld, Anders Boesen Lindbo Larsen, John Fisher, and Lars Hansen. Dreaming more data: Class-dependent distributions over diffeomorphisms for learned data augmentation. In Artificial Intelligence and Statistics, pp. 342–350, 2016.
222
+
223
+ 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.
224
+
225
+ 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.
226
+
227
+ David P Helmbold and Philip M Long. Surprising properties of dropout in deep networks. The Journal of Machine Learning Research, 18(1):7284–7311, 2017.
228
+
229
+ Alex Hernández-García and Peter König. Further advantages of data augmentation on convolutional neural networks. In International Conference on Artificial Neural Networks, pp. 95–103. Springer, 2018a.
230
+
231
+ Alex Hernández-García and Peter König. Do deep nets really need weight decay and dropout? arXiv preprint arXiv:1802.07042, 2018b.
232
+
233
+ Alex Hernández-García, Johannes Mehrer, Nikolaus Kriegeskorte, Peter König, and Tim C. Kietzmann. Deep neural networks trained with heavier data augmentation learn features closer to representations in hIT. In Conference on Cognitive Computational Neuroscience, 2018.
234
+
235
+ Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European Conference on Computer Vision, pp. 646–661. Springer, 2016.
236
+
237
+ Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2261–2269. IEEE, 2017.
238
+
239
+ Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International Conference on Machine Learning, ICML, pp. 448–456, 2015.
240
+
241
+ Navdeep Jaitly and Geoffrey E Hinton. Vocal tract length perturbation (vtlp) improves speech recognition. In Proc. ICML Workshop on Deep Learning for Audio, Speech and Language, pp. 625–660, 2013.
242
+
243
+ Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
244
+
245
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems, NIPS, pp. 1097–1105, 2012.
246
+
247
+ Jan Kukacka, Vladimir Golkov, and Daniel Cremers. Regularization for deep learning: A taxonomy. ˇ arXiv preprint arXiv:1710.10686, 2017.
248
+
249
+ Gustav Larsson, Michael Maire, and Gregory Shakhnarovich. Fractalnet: Ultra-deep neural networks without residuals. arXiv preprint arXiv:1605.07648, 2016.
250
+
251
+ Yann LeCun, Bernhard E Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne E Hubbard, and Lawrence D Jackel. Handwritten digit recognition with a back-propagation network. In Advances in Neural Information Processing Systems, NIPS, pp. 396–404, 1990.
252
+
253
+ Joseph Lemley, Shabab Bazrafkan, and Peter Corcoran. Smart augmentation-learning an optimal data augmentation strategy. IEEE Access, 2017.
254
+
255
+ Xinghua Lu, Bin Zheng, Atulya Velivelli, and ChengXiang Zhai. Enhancing text categorization with semantic-enriched representation and training data augmentation. Journal of the American Medical Informatics Association, 13(5):526–535, 2006.
256
+
257
+ Wenlong Mou, Yuchen Zhou, Jun Gao, and Liwei Wang. Dropout training, data-dependent regularization, and generalization bounds. In International Conference on Machine Learning, pp. 3642–3650, 2018.
258
+
259
+ Klaus-Robert Müller. Regularization techniques to improve generalization. In Neural Networks: Tricks of the Trade, pp. 49–51. Springer, 2012.
260
+
261
+ Behnam Neyshabur, Ryota Tomioka, and Nathan Srebro. In search of the real inductive bias: On the role of implicit regularization in deep learning. In International Conference on Learning Representations, ICLR, arXiv:1412.6614, 2014.
262
+
263
+ Roman Novak, Yasaman Bahri, Daniel A Abolafia, Jeffrey Pennington, and Jascha Sohl-Dickstein. Sensitivity and generalization in neural networks: an empirical study. In International Conference on Learning Representations, ICLR, arXiv:1802.08760, 2018.
264
+
265
+ Luis Perez and Jason Wang. The effectiveness of data augmentation in image classification using deep learning. arXiv preprint arXiv:1712.04621, 2017.
266
+
267
+ Shashank Rajput, Zhili Feng, Zachary Charles, Po-Ling Loh, and Dimitris Papailiopoulos. Does data augmentation lead to positive margin? arXiv preprint arXiv:1905.03177, 2019.
268
+
269
+ Alexander J Ratner, Henry R Ehrenberg, Zeshan Hussain, Jared Dunnmon, and Christopher Ré. Learning to compose domain-specific transformations for data augmentation. In Advances in Neural Information Processing Systems, NIPS, pp. 3239–3249, 2017.
270
+
271
+ Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision, IJCV, 115 (3):211–252, 2015.
272
+
273
+ Shibani Santurkar, Dimitris Tsipras, Andrew Ilyas, and Aleksander Madry. How does batch normalization help optimization? In Advances in Neural Information Processing Systems, pp. 2483–2493, 2018.
274
+
275
+ Patrice Simard, Bernard Victorri, Yann LeCun, and John Denker. Tangent prop-a formalism for specifying selected invariances in an adaptive network. In Advances in Neural Information Processing Systems, NIPS, pp. 895–903, 1992.
276
+
277
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
278
+
279
+ Jost Tobias Springenberg, Alexey Dosovitskiy, Thomas Brox, and Martin Riedmiller. Striving for simplicity: The all convolutional net. In International Conference on Learning Representations, ICLR, arXiv:1412.6806, 2014.
280
+
281
+ Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, JMLR, 15(1):1929–1958, 2014.
282
+
283
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
284
+
285
+ Stefan Uhlich, Marcello Porcu, Franck Giron, Michael Enenkl, Thomas Kemp, Naoya Takahashi, and Yuki Mitsufuji. Improving music source separation based on deep neural networks through data augmentation and network blending. IEEE International Conference on Acoustics, Speech and Signal Processing, ICASSP, 2017.
286
+
287
+ V. N. Vapnik and A. Y. Chervonenkis. On the uniform convergence of relative frequencies of events to their probabilities. Theory of Probab. and its Applications, 16(2):264–280, 1971.
288
+
289
+ Oriol Vinyals, Charles Blundell, Tim Lillicrap, koray kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In Advances in Neural Information Processing Systems, NIPS, pp. 3630–3638, 2016.
290
+
291
+ Stefan Wager, Sida Wang, and Percy S Liang. Dropout training as adaptive regularization. In Advances in neural information processing systems, pp. 351–359, 2013.
292
+
293
+ Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In British Machine Vision Conference, BMVC, pp. 87.1–87.12, 2016.
294
+
295
+ Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. In International Conference on Learning Representations, ICLR, arXiv:1611.03530, 2017.
296
+
297
+ # A DETAILS OF NETWORK ARCHITECTURES
298
+
299
+ This appendix presents the details of the network architectures used in the main experiments: AllCNN, Wide Residual Network (WRN) and DenseNet. All-CNN is a relatively simple, small network with a few number of layers and parameters, WRN is deeper, has residual connections and many more parameters and DenseNet is densely connected and is much deeper, but parameter effective.
300
+
301
+ # A.1 ALL CONVOLUTIONAL NETWORK
302
+
303
+ All-CNN consists exclusively of convolutional layers with ReLU activation (Glorot et al., 2011), it is relatively shallow and has few parameters. For ImageNet, the network has 16 layers and 9.4 million parameters; for CIFAR, it has 12 layers and about 1.3 million parameters. In our experiments to compare the adaptability of data augmentation and explicit regularization to changes in the architecture, we also test a shallower version, with 9 layers and 374,000 parameters, and a deeper version, with 15 layers and 2.4 million parameters. The four architectures can be described as in Table 3, where $K \mathbf { C } D ( S )$ is a $D \times D$ convolutional layer with $K$ channels and stride $S$ , followed by batch normalization and a ReLU non-linearity. $N . C l .$ is the number of classes and Gl.Avg. refers to global average pooling. The CIFAR network is identical to the All-CNN-C architecture in the original paper, except for the introduction of the batch normalization layers. The ImageNet version also includes batch normalization layers and a stride of 2 instead of 4 in the first layer to compensate for the reduced input size (see below).
304
+
305
+ ImageNet 96C11(2)–96C1(1)–96C3(2)–256C5(1) –256C1(1)–256C3(2)–384C3(1) –384C1(1)–384C3(2)–1024C3(1) –1024C1(1)–N.Cl.C1(1) –Gl.Avg.–Softmax
306
+ CIFAR 2×96C3(1)–96C3(2)–2×192C3(1) –192C3(2)–192C3(1)–192C1(1) –N.Cl.C1(1)–Gl.Avg.–Softmax
307
+ Shallower 2×96C3(1)–96C3(2)–192C3(1) –192C1(1)–N.Cl.C1(1)–Gl.Avg.–Softmax
308
+ Deeper $2 \times 9 6 \mathbf { C } 3 ( 1 ) { - } 9 6 \mathbf { C } 3 ( 2 ) { - } 2 { \times } 1 9 2 \mathbf { C } 3 ( 1 )$ ) $- 1 9 2 \mathbf { C } 3 ( 2 ) - 2 \times 1 9 2 \mathbf { C } 3 ( 1 ) - 1 9 2 \mathbf { C } 3 ( 2 )$ –192C3(1)–192C1(1) –N.Cl.C1(1)–Gl.Avg.–Softmax
309
+
310
+ Importantly, we keep the same training parameters as in the original paper in the cases they are reported. Specifically, the All-CNN networks are trained using stochastic gradient descent, with fixed Nesterov momentum 0.9, learning rate of 0.01 and decay factor of 0.1. The batch size for the experiments on ImageNet is 64 and we train during 25 epochs decaying the learning rate at epochs 10 and 20. On CIFAR, the batch size is 128, we train for 350 epochs and decay the learning rate at epochs 200, 250 and 300. The kernel parameters are initialized according to the Xavier uniform initialization (Glorot & Bengio, 2010).
311
+
312
+ # A.2 WIDE RESIDUAL NETWORK
313
+
314
+ WRN is a modification of ResNet (He et al., 2016) that achieves better performance with fewer layers, but more units per layer. Here we choose for our experiments the WRN-28-10 version (28 layers and about $3 6 . 5 \mathrm { ~ M ~ }$ parameters), which is reported to achieve the best results on CIFAR. It has the following architecture:
315
+
316
+ where $K \mathbf { \mathbf { \mathbf { k } } }$ is a residual block with residual function BN–ReLU–KC3(1)–BN–ReLU–KC 3(1). BN is batch normalization, Avg.(8) is spatial average pooling of size 8 and FC is a fully connected layer. On ImageNet, the stride of the first convolution is 2. The stride of the first convolution within the residual blocks is 1 except in the first block of the series of 4, where it is set to 2 in order to subsample the feature maps.
317
+
318
+ Similarly, we keep the training parameters of the original paper: we train with SGD, with fixed Nesterov momentum 0.9 and learning rate of 0.1. On ImageNet, the learning rate is decayed by 0.2 at epochs 8 and 15 and we train for a total of 20 epochs with batch size 32. On CIFAR, we train with a batch size of 128 during 200 epochs and decay the learning rate at epochs 60, 120 and 160. The kernel parameters are initialized according to the He normal initialization (He et al., 2015).
319
+
320
+ # A.3 DENSENET
321
+
322
+ The main characteristic of DenseNet (Huang et al., 2017) is that the architecture is arranged into blocks whose layers are connected to all the layers below, forming a dense graph of connections, which permits training very deep architectures with fewer parameters than, for instance, ResNet. Here, we use a network with bottleneck compression rate $\theta = 0 . 5$ (DenseNet-BC), growth rate $k = 1 2$ and 16 layers in each of the three blocks. The model has nearly 0.8 million parameters. The specific architecture can be descried as follows:
323
+
324
+ where $\mathrm { D B } ( c )$ is a dense block, that is a concatenation of $c$ convolutional blocks. Each convolutional block is of a set of layers whose output is concatenated with the input to form the input of the next convolutional block. A convolutional block with bottleneck structure has the following layers:
325
+
326
+ TB is a transition block, which downsamples the size of the feature maps, formed by the following layers:
327
+
328
+ Like with All-CNN and WRN, we keep the training hyper-parameters of the original paper. On the CIFAR data sets, we train with SGD, with fixed Nesterov momentum 0.9 and learning rate of 0.1, decayed by 0.1 on epochs 150 and 200 and training for a total of 300 epochs. The batch size is 64 and the are initialized with He initialization.
329
+
330
+ # B DETAILS OF THE HEAVIER DATA AUGMENTATION SCHEME
331
+
332
+ In this appendix we present the details of the heavier data augmentation scheme, introduced in Section 3.2:
333
+
334
+ • Affine transformations: $\left[ \begin{array} { c } { x ^ { \prime } } \\ { y ^ { \prime } } \\ { 1 } \end{array} \right] = \left[ \begin{array} { c c c } { f _ { h } z _ { x } \cos ( \theta ) } & { - z _ { y } \sin ( \theta + \phi ) } & { t _ { x } } \\ { z _ { x } \sin ( \theta ) } & { z _ { y } \cos ( \theta + \phi ) } & { t _ { y } } \\ { 0 } & { 0 } & { 1 } \end{array} \right] \left[ \begin{array} { c } { x } \\ { y } \\ { 1 } \end{array} \right]$ • Contrast adjustment: $x ^ { \prime } = \gamma ( x - \overline { { x } } ) + \overline { { x } }$ • Brightness adjustment: $x ^ { \prime } = x + \delta$
335
+
336
+ # C DETAILED AND EXTENDED EXPERIMENTAL RESULTS
337
+
338
+ This appendix details the results of the main experiments shown in Figures 1, 2 and 3 and provides the results of many other experiments not presented above in order not to clutter the visualization. Some of these results are the top-1 accuracy on ImageNet, the results of the models trained with dropout, but without weight decay; and the results of training with $80 \%$ and $1 \%$ of the data.
339
+
340
+ Table 4: Description and range of possible values of the parameters used for the heavier augmentation. $B ( p )$ denotes a Bernoulli distribution and $\textstyle { \mathcal { U } } ( a , b )$ a uniform distribution.
341
+
342
+ <table><tr><td>Parameter</td><td>Description</td><td>Range</td></tr><tr><td>fh</td><td>Horiz. flip</td><td>1- 2B(0.5)</td></tr><tr><td>tx</td><td>Horiz. translation</td><td>u(-0.1,0.1)</td></tr><tr><td>ty</td><td>Vert. translation</td><td>u(-0.1,0.1)</td></tr><tr><td>2x</td><td>Horiz. scale</td><td>U(0.85,1.15)</td></tr><tr><td>Zy</td><td>Vert. scale</td><td>U(0.85,1.15)</td></tr><tr><td>0</td><td>Rotation angle</td><td>U(-22.5°,22.5°)</td></tr><tr><td>?</td><td>Shear angle</td><td>u(-0.15,0.15)</td></tr><tr><td>?</td><td>Contrast</td><td>(0.5,1.5)</td></tr><tr><td>8</td><td>Brightness</td><td>U(-0.25,0.25)</td></tr></table>
343
+
344
+ Additionally, for many experiments we also train a version of the network without batch normalization. These results are provided within brackets in the tables. Note that the original All-CNN results published by Springenberg et al. (2014) did not include batch normalization. In the case of WRN, we remove all batch normalization layers except the top-most one, before the spatial average pooling, since otherwise many models would not converge.
345
+
346
+ Table 5: Test accuracy of All-CNN and WRN, comparing the performance with and without explicit regularizers and the different augmentation schemes. Results within brackets show the performance of the models without batch normalization
347
+
348
+ <table><tr><td>Network</td><td>WD</td><td>Dropout</td><td>Aug.</td><td>CIFAR-10</td><td>CIFAR-100</td><td>Acc. ImageNet</td></tr><tr><td rowspan="8">All-CNN</td><td>yes</td><td>yes</td><td>no</td><td>90.04 (88.35)</td><td>66.50 (60.54)</td><td>58.09</td></tr><tr><td>yes</td><td>yes</td><td>light</td><td>93.26 (91.97)</td><td>70.85 (65.57)</td><td>63.35</td></tr><tr><td>yes</td><td>yes</td><td>heavier</td><td>93.08 (92.44)</td><td>70.59 (68.62)</td><td>60.15</td></tr><tr><td>no</td><td>yes</td><td>no</td><td>77.99 (87.59)</td><td>52.39 (60.96)</td><td></td></tr><tr><td>no</td><td>yes</td><td>light</td><td>77.20 (92.01)</td><td>69.71 (68.01)</td><td></td></tr><tr><td>no</td><td>yes</td><td>heavier</td><td>88.29 (92.18)</td><td>70.56 (68.40)</td><td></td></tr><tr><td>no</td><td>no</td><td>no</td><td>84.53 (71.98)</td><td>57.99 (39.03)</td><td>56.53</td></tr><tr><td>no</td><td>no</td><td>light</td><td>93.26 (90.10)</td><td>69.26 (63.00)</td><td>63.79</td></tr><tr><td rowspan="8">WRN</td><td>no</td><td>no</td><td>heavier</td><td>93.55 (91.48)</td><td>71.25 (71.46)</td><td>61.37</td></tr><tr><td>yes</td><td>yes</td><td>no</td><td>91.44 (89.30)</td><td>71.67 (67.42)</td><td>54.67</td></tr><tr><td>yes</td><td>yes</td><td>light</td><td>95.01 ( 1(93.48)</td><td>77.58 (74.23)</td><td>68.84</td></tr><tr><td>yes</td><td>yes</td><td>heavier</td><td>95.60 (94.38)</td><td>76.96 (74.79)</td><td>66.82</td></tr><tr><td>no</td><td>yes</td><td>no</td><td>91.47 (89.38)</td><td>71.31 (66.85)</td><td></td></tr><tr><td>no</td><td>yes</td><td>light</td><td>94.76 (93.52)</td><td>77.42 (74.62)</td><td></td></tr><tr><td>no</td><td>yes</td><td>heavier</td><td>95.58 (94.52)</td><td>77.47 (73.96)</td><td></td></tr><tr><td>no</td><td>no</td><td>no</td><td>89.56 (85.45)</td><td>68.16 (59.90)</td><td>61.29</td></tr><tr><td></td><td>no</td><td>no</td><td>light</td><td>94.71 (93.69)</td><td>77.08 (75.27)</td><td>69.80</td></tr><tr><td></td><td>no</td><td>no</td><td>heavier</td><td>95.47 (94.95)</td><td>77.30 (75.69)</td><td>69.30</td></tr></table>
349
+
350
+ An important observation from Table 5 is that the interaction of weight decay and dropout is not always consistent, since in some cases better results can be obtained with both explicit regularizers active and in other cases, only dropout achieves better generalization. In contrast, the effect of data augmentation seems to be consistent: just some light augmentation achieves much better results than training only with the original data set and performing heavier augmentation almost always further improves the test accuracy, without the need for explicit regularization.
351
+
352
+ Not surprisingly, batch normalization also contributes to improve the generalization of All-CNN and it seems to combine well with data augmentation. On the contrary, when combined with explicit regularization the results are interestingly not consistent in the case of All-CNN: it seems to improve the generalization of the model trained with both weight decay and dropout, but it drastically reduces the performance with only dropout, in the case of CIFAR-10 and CIFAR-100 without augmentation.
353
+
354
+ A probable explanation is, again, that the regularization hyperparameters would need to be readjusted with a change of the architecture.
355
+
356
+ Furthermore, it seems that the gap between the performance of the models trained with and without batch normalization is smaller when they are trained without explicit regularization and when they include heavier data augmentation. This can be observed in Table 5, as well as in Table 6, which contains the results of the models trained with fewer examples. It is important to note as well the benefits of batch normalization for obtaining better results when training with fewer examples. However, it is surprising that there is only a small drop in the performance of WRN— $9 5 . 4 7 ~ \%$ to $9 4 . 9 5 \%$ without regularization— from removing the batch normalization layers of the residual blocks, given that they were identified as key components of ResNet (He et al., 2016; Zagoruyko & Komodakis, 2016).
357
+
358
+ Table 6: Test accuracy of All-CNN and WRN when training with only $80 \%$ , $50 \%$ , $10 \%$ and $1 \%$ of the available examples. Results within brackets correspond to the models without batch normalization
359
+
360
+ <table><tr><td colspan="2">Pct. Data Expl. Reg.</td><td>Aug. scheme</td><td colspan="2">Test CIFAR-10</td><td colspan="2">Test CIFAR-100</td></tr><tr><td rowspan="7">80 %</td><td></td><td></td><td>All-CNN</td><td>WRN</td><td>All-CNN</td><td>WRN</td></tr><tr><td>yes</td><td>no</td><td>89.41 (86.61)</td><td>90.27</td><td>63.93 (52.51)</td><td>70.41</td></tr><tr><td>yes</td><td>light</td><td>92.20 (91.25)</td><td>94.07</td><td>67.63 (63.24)</td><td>75.66</td></tr><tr><td>yes</td><td>heavier</td><td>92.83 (91.42)</td><td>94.57</td><td>68.01 (65.89)</td><td>75.51</td></tr><tr><td>no</td><td>no</td><td>83.04 (75.00)</td><td>88.98</td><td>55.78 (35.95)</td><td>66.10</td></tr><tr><td>no</td><td>light</td><td>92.25 (88.75)</td><td>93.97</td><td>69.05 (56.81)</td><td>75.07</td></tr><tr><td>no</td><td>heavier</td><td>92.80 (90.55)</td><td>94.84</td><td>69.40 (63.57)</td><td>75.38</td></tr><tr><td rowspan="6">50 %</td><td>yes</td><td>no</td><td>85.88 (82.33)</td><td>86.96</td><td>58.24 (44.94)</td><td>63.60</td></tr><tr><td>yes</td><td>light</td><td>90.30 (87.37)</td><td>92.65</td><td>61.03 (54.68)</td><td>70.83</td></tr><tr><td>yes</td><td>heavier</td><td>90.09 (88.94)</td><td>92.86</td><td>63.25 (57.91)</td><td>70.33</td></tr><tr><td>no</td><td>no</td><td>78.61 (69.46)</td><td>85.56</td><td>48.62 (31.81)</td><td>60.64</td></tr><tr><td>no</td><td>light</td><td>90.21 (84.38)</td><td>91.87</td><td>62.83 (47.84)</td><td>69.97</td></tr><tr><td>no</td><td>heavier</td><td>90.76 (87.44)</td><td>92.77</td><td>64.41 ( (55.27)</td><td>70.72</td></tr><tr><td rowspan="6">10 %</td><td>yes</td><td>no</td><td>67.19 (61.61)</td><td>70.73</td><td>33.77 (19.79)</td><td>34.11</td></tr><tr><td>yes</td><td>light</td><td>76.03 (69.18)</td><td>76.00</td><td>38.51 (22.79)</td><td>36.65</td></tr><tr><td>yes</td><td>heavier</td><td>78.69 (64.14)</td><td>78.10</td><td>38.34 (26.29)</td><td>38.93</td></tr><tr><td>no</td><td>no</td><td>60.97 (41.07)</td><td>60.39</td><td>26.05 (17.55)</td><td>23.65</td></tr><tr><td>no</td><td>light</td><td>78.29 (67.65)</td><td>79.19</td><td>37.84 (24.34)</td><td>39.24</td></tr><tr><td>no</td><td>heavier</td><td>79.87 (70.64)</td><td>80.29</td><td>39.85 (26.31)</td><td>41.44</td></tr><tr><td rowspan="6">1%</td><td>yes</td><td>no</td><td></td><td></td><td></td><td></td></tr><tr><td>yes</td><td></td><td>27.53 (29.90)</td><td>33.45</td><td>9.16 (3.60)</td><td>7.47</td></tr><tr><td>yes</td><td>light heavier</td><td>37.18 (26.85)</td><td>34.13 41.02</td><td>9.64 (3.65) 9.14 (2.52)</td><td>7.50 8.37</td></tr><tr><td>no</td><td>no</td><td>42.73 (26.87) 38.89 (35.68)</td><td>38.63</td><td>9.50 (5.51)</td><td>9.47</td></tr><tr><td>no</td><td>light</td><td>44.35 (29.29)</td><td>43.84</td><td>9.87 (5.36)</td><td>9.91</td></tr><tr><td>no</td><td>heavier</td><td>47.60 (33.72)</td><td>47.14</td><td>11.45 (3.57)</td><td>11.03</td></tr></table>
361
+
362
+ The results in Table 6 clearly support the conclusion presented in Section 4.2: data augmentation alone better resists the lack of training data compared to explicit regularizers. Already with $80 \%$ and $50 \%$ of the data better results are obtained in some cases, but the differences become much bigger when training with only $10 \%$ and $1 \%$ of the available data. It seems that explicit regularization prevents the model from both fitting the data and generalizing well, whereas data augmentation provides useful transformed examples. Interestingly, with only $1 \%$ of the data, even without data augmentation the models without explicit regularization perform better.
363
+
364
+ The same effect can be observed in Table 7, where both the shallower and deeper versions of AllCNN perform much worse when trained with explicit regularization, even when trained without data augmentation. This is another piece of evidence that explicit regularization needs to be used very carefully, it requires a proper tuning of the hyperparameters and is not always beneficial.
365
+
366
+ Table 7: Test accuracy of the shallower and deeper versions of All-CNN on CIFAR-10 and CIFAR-100. Results in parentheses show the difference with respect to the original model.
367
+
368
+ <table><tr><td>Expl. Reg.</td><td>Aug.</td><td colspan="2">Test CIFAR-10</td><td colspan="2">Test CIFAR-100</td></tr><tr><td></td><td></td><td>Shallower</td><td>Deeper</td><td>Shallower</td><td>Deeper</td></tr><tr><td>yes</td><td>no</td><td>76.45 (-13.59)</td><td>86.26 (-3.78)</td><td>51.31 (-9.23)</td><td>49.06 (-11.48)</td></tr><tr><td>yes</td><td>light</td><td>82.02 (-11.24)</td><td>85.04 (-8.22)</td><td>56.81 (-8.76)</td><td>52.03 (-13.54)</td></tr><tr><td>yes</td><td>heavier</td><td>86.66 (-6.42)</td><td>88.46 (-4.62)</td><td>58.64 (-9.98)</td><td>51.78 (-16.84)</td></tr><tr><td>no</td><td>no</td><td>85.22 (+0.69)</td><td>83.30 (-1.23)</td><td>58.95 (+0.96)</td><td>54.22 (-3.77)</td></tr><tr><td>no</td><td>light</td><td>90.02 (-3.24)</td><td>93.46 (+0.20)</td><td>65.51 (-3.75)</td><td>72.16 (+2.90)</td></tr><tr><td>no</td><td>heavier</td><td>90.34 (-3.21)</td><td>94.19 (+0.64)</td><td>65.87 (-5.38)</td><td>73.30 (+2.35)</td></tr></table>
369
+
370
+ # D NORM OF THE WEIGHT MATRIX
371
+
372
+ In this appendix we provide the computations of the Frobenius norm of the weight matrices of the models trained with different levels of explicit regularization and data augmentation, as a rough estimation of the complexity of the learned models. Table 8 shows the Frobenius norm of the weight matrices of the models trained with different levels of explicit regularization and data augmentation. The clearest conclusion is that heavier data augmentation seems to yield solutions with larger norm. This is always true except in some All-CNN models trained without batch normalization. Another observation is that, as expected, weight decay constrains the norm of the learned function. Besides, the models trained without batch normalization exhibit smaller differences between different levels of regularization and augmentation and, in the case of All-CNN, less consistency.
373
+
374
+ Table 8: Frobenius norm of the weight matrices learned by the networks All-CNN and WRN on CIFAR-10 and CIFAR-100, trained with and without explicit regularizers and the different augmentation schemes. Norms within brackets correspond to the models without batch normalization
375
+
376
+ <table><tr><td>WD</td><td>Dropout</td><td>Aug.</td><td colspan="2">Norm CIFAR-10</td><td colspan="2">Norm CIFAR-100</td></tr><tr><td></td><td></td><td></td><td>All-CNN</td><td>WRN</td><td>All-CNN</td><td>WRN</td></tr><tr><td>yes</td><td>yes</td><td>no</td><td>48.7 (64.9)</td><td>101.4 (122.6)</td><td>76.5 (97.9)</td><td>134.8 (126.5)</td></tr><tr><td>yes</td><td>yes</td><td>light</td><td>52.7 (63.2)</td><td>106.1 (123.9)</td><td>77.6 (86.8)</td><td>140.8 (129.3)</td></tr><tr><td>yes</td><td>yes</td><td>heavier</td><td>57.6 (62.8)</td><td>119.3 (125.3)</td><td>78.1 (83.1)</td><td>164.2 (132.5)</td></tr><tr><td>no</td><td>yes</td><td>no</td><td>52.4 (70.5)</td><td>153.3 (122.5)</td><td>79.7 (103.3)</td><td>185.1 (126.5)</td></tr><tr><td>no</td><td>yes</td><td>light</td><td>57.0 (67.9)</td><td>160.6 (123.9)</td><td>83.6 (93.0)</td><td>199.0 (129.4)</td></tr><tr><td>no</td><td>yes</td><td>heavier</td><td>62.8 (67.5)</td><td>175.1 (125.2)</td><td>84.0 (88.0)</td><td>225.4 (132.5)</td></tr><tr><td>no</td><td>no</td><td>no</td><td>37.3 (63.7)</td><td>139.0 (120.4)</td><td>47.6 (102.7)</td><td>157.9 (122.0)</td></tr><tr><td>no</td><td>no</td><td>light</td><td>47.0 (69.5)</td><td>153.6 (123.2)</td><td>80.0 (108.9)</td><td>187.0 (127.2)</td></tr><tr><td>no</td><td>no</td><td>heavier</td><td>62.0 (71.7)</td><td>170.4 (125.4)</td><td>91.7 (91.7)</td><td>217.6 (132.9)</td></tr></table>
377
+
378
+ One of the relevant results presented in this paper is the poor performance of the regularized models on the shallower and deeper versions of All-CNN, compared to the models without explicit regularization (see Table 7). One hypothesis is that the amount of regularization is not properly adjusted through the hyperparameters. This could be reflected in the norm of the learned weights, shown in Table 9. However, the norm alone does not seem to fully explain the large performance differences between the different models. Finding the exact reasons why the regularized models not able to generalize well might require a much thorough analysis and we leave it as future work.
379
+
380
+ # E ON THE TAXONOMY OF REGULARIZATION
381
+
382
+ Although it is out of the scope of this paper to elaborated on the taxonomy of regularization techniques for deep neural networks, an important contribution of this work is providing definitions of explicit and implicit regularization, which have been used ambiguously in the literature before. It is therefore worth mentioning here some of the previous works that have used these terms and to point to literature that has specifically elaborated on the regularization taxonomy or proposed other related terms.
383
+
384
+ Table 9: Frobenius norm of the weight matrices learned by the shallower and deeper versions of the All-CNN network on CIFAR-10 and CIFAR-100.
385
+
386
+ <table><tr><td>Explicit Reg.</td><td>Aug. s .scheme</td><td colspan="2">Norm CIFAR-10</td><td colspan="2">Norm CIFAR-100</td></tr><tr><td></td><td></td><td>Shallower</td><td>Deeper</td><td>Shallower</td><td>Deeper</td></tr><tr><td>yes</td><td>no</td><td>47.9</td><td>62.3</td><td>68.9</td><td>92.1</td></tr><tr><td>yes</td><td>light</td><td>49.7</td><td>66.5</td><td>67.1</td><td>95.7</td></tr><tr><td>yes</td><td>heavier</td><td>51.9</td><td>71.5</td><td>66.2</td><td>96.9</td></tr><tr><td>no</td><td>no</td><td>34.8</td><td>45.4</td><td>64.7</td><td>53.4</td></tr><tr><td>no</td><td>light</td><td>45.6</td><td>57.3</td><td>68.8</td><td>77.3</td></tr><tr><td>no</td><td>heavier</td><td>53.1</td><td>70.7</td><td>68.3</td><td>97.5</td></tr></table>
387
+
388
+ Neyshabur et al. (2014) observed that the size of neural networks could not explain and control by itself the effective capacity of neural networks and proposed that other elements should implicitly regularize the models. However, no definitions or clear distinction between explicit and implicit regularization was provided. Later, Zhang et al. (2017) compared different regularization techniques and mentioned the role of implicit regularization, but did not provide definitions either, and, importantly, they considered data augmentation an explicit form of regularization. We have argued against that view throughout this paper, especially in Sections 2 and 6.1.
389
+
390
+ An extensive review of the taxonomy of regularization techniques was carried out by Kukacka et al. ˇ (2017). Although no distinction is made between explicit and implicit regularization, they define the class regularization via optimization, which is somehow related to implicit regularization. However, regularization via optimization is more specific than our definition and data augmentation, among others, would not fall into that category.
391
+
392
+ Recently, Guo et al. (2018) provided a distinction between data-independent and data-dependent regularization. They define data-independent regularization as those techniques that impose certain constraint on the hypothesis set, thus constraining the optimization problem. Examples are weight decay and dropout. We believe this is closely related to our definition of explicit regularization. Then, they define data-dependent regularization as those techniques that make assumptions on the hypothesis set with respect to the training data, as is the case of data augmentation.
393
+
394
+ While we acknowledge the usefulness of such taxonomy, we believe the division between dataindependent and dependent regularization leaves some ambiguity about other techniques, such as batch-normalization, which neither imposes an explicit constraint on H nor on the training data. The taxonomy of explicit vs. implicit regularization is however complete, since implicit regularization refers to any regularization effect that does not come from explicit (or data-independent) techniques.
395
+
396
+ Finally, we argue it would be useful to distinguish between domain-specific, perceptually-motivated data augmentation and other kinds of data-dependent regularization. Data augmentation ultimately aims at creating new examples that could be plausible transformations of the real-world objects. In other words, the augmented samples should be no different in nature than the available data. In statistical terms, they should belong to the same underlying probability distribution. In contrast, one can think of data manipulations that would not mimic any plausible transformation of the data, which still can improve generalization and thus fall into the category of data-dependent regularization (and implicit regularization). One example is mixup, which is the subject of study of Guo et al. (2018).
md/train/H1xk8jAqKQ/H1xk8jAqKQ.md ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BACKPLAY: ‘MAN MUSS IMMER UMKEHREN’
2
+
3
+ Cinjon Resnick∗ NYU cinjon@nyu.edu
4
+
5
+ Roberta Raileanu∗ NYU rr3009@nyu.edu
6
+
7
+ Sanyam Kapoor NYU sanyam@nyu.edu
8
+
9
+ Alexander Peysakhovich FAIR alexpeys@fb.com
10
+
11
+ Kyunghyun Cho
12
+ NYU, FAIR
13
+ kyunghyun.cho@nyu.edu
14
+ Joan Bruna
15
+ NYU, FAIR
16
+ bruna@cims.nyu.edu
17
+
18
+ # ABSTRACT
19
+
20
+ Model-free reinforcement learning (RL) requires a large number of trials to learn a good policy, especially in environments with sparse rewards. We explore a method to improve the sample efficiency when we have access to demonstrations. Our approach, Backplay, uses a single demonstration to construct a curriculum for a given task. Rather than starting each training episode in the environment’s fixed initial state, we start the agent near the end of the demonstration and move the starting point backwards during the course of training until we reach the initial state. Our contributions are that we analytically characterize the types of environments where Backplay can improve training speed, demonstrate the effectiveness of Backplay both in large grid worlds and a complex four player zero-sum game (Pommerman), and show that Backplay compares favorably to other competitive methods known to improve sample efficiency. This includes reward shaping, behavioral cloning, and reverse curriculum generation.
21
+
22
+ # 1 INTRODUCTION
23
+
24
+ An important goal of AI research is to construct agents that can learn well in new environments (Levine et al., 2016). An increasingly popular paradigm for this task is deep reinforcement learning (deep RL, Silver et al. (2016); Moravcík et al. (2017); Silver et al. (2017)). However, training an RL agent can take a very long time, particularly in environments with sparse rewards. In these settings, the agent typically requires a large number of episodes to stumble upon positive rewards and learn even a moderately effective policy that can then be refined. This is often resolved via hand-engineering a dense reward function. Such reward shaping, while effective, can also change the set of optimal policies and have unintended side effects $\mathrm { N g }$ et al., 1999; Clark & Amodei, 2016).
25
+
26
+ We consider an alternative technique for accelerating RL in sparse reward settings. The idea is to create a curriculum for the agent via reversing a single trajectory (i.e. state sequence) of reasonably good, but not necessarily optimal, behavior. We start our agent at the end of a demonstration and let it learn a policy in this easier setup. We then move the starting point backward until the agent is training only on the initial state of the task. We call this technique Backplay.
27
+
28
+ Our contributions are threefold:
29
+
30
+ 1. We characterize analytically and qualitatively which environments Backplay will aid. 2. We demonstrate Backplay’s effectiveness on both a grid world task (to gain intuition) as well as the four player stochastic zero-sum game Pommerman (MultiAgentLearning, 2018). 3. We empirically show that Backplay compares favorably to other methods that improve sample complexity.
31
+
32
+ Besides requiring vastly fewer number of samples to learn a good policy, an agent trained with Backplay can outperform its demonstrator and even learn an optimal policy following a sub-optimal demonstration. Our experiments further show Backplay’s strong performance relative to reward shaping (involves hand tuning reward functions), behavioral cloning (not intended for use with sub-optimal experts), and other forms of automatic curriculum generation (Florensa et al. (2017), requires a reversable environment).
33
+
34
+ # 2 RELATED WORK
35
+
36
+ The most related work to ours is a blog post describing a method similar to Backplay used to obtain state-of-theart performance on the challenging Atari game Montezuma’s Revenge (Salimans & Chen, 2018). This work was independent of and concurrent to our own. In addition to reporting results on a different, complex stochastic multi-agent environment, we provide an analytic characterization of the method as well as an in depth discussion of what kinds of environments a practitioner can expect Backplay to out or underperform other existing methods.
37
+
38
+ ![](images/cf7f8ad6e3c67f2fc2b5865e835dace28432e332ff9f7bdff2f7f869818e8747.jpg)
39
+ Figure 1. Backplay: We first collect a demonstration, from which we build a curriculum over the states. We then sample a state according to that curriculum and initialize our agent accordingly.
40
+
41
+ A popular method for improving RL with
42
+ access to expert demonstrations is behavioral cloning/imitation learning. These methods explicitly encourage the learned policy to mimic an expert policy (Bain & Sommut, 1999; Ross et al., 2011; Daumé et al., 2009; Zhang & Cho, 2016; Laskey et al., 2016; Nair et al., 2017; Hester et al., 2017; Ho & Ermon, 2016; Aytar et al., 2018; Lerer & Peysakhovich, 2018; Peng et al., 2018). Imitation learning requires access to both state and expert actions (whereas Backplay only requires states) and is designed to copy an expert, thus it cannot, without further adjustments (e.g. as proposed by Gao et al. (2018)), surpass a suboptimal expert. We discuss the pros and cons of an imitation learning $^ +$ adjustment vs. a Backplay-based approach in the main analysis section.
43
+
44
+ Other algorithms (Ranzato et al., 2015; Li et al., 2016; Das et al., 2017a;b), primarily in dialog, use a Backplay-like curriculum, albeit they utilize behavioral cloning for the first part of the trajectory. This is a major difference as we show that for many classes of problems, we only need to change the initial state distribution and do not see any gains from warm-starting with imitation learning. Backplay is more similar to Conservative Policy Iteration (Kakade & Langford, 2002), a theoretical paper which presents an algorithm designed to operate with an explicit restart distribution.
45
+
46
+ Also related to Backplay is the method of automatic reverse curriculum generation Florensa et al. (2017). These approaches assumes that the final goal state is known and that the environment is both resettable and reversible. The curricula are generated by taking random walks in the state space to generate starting states or by taking random actions starting at the goal state McAleer et al. (2018). These methods do not require an explicit ‘good enough’ demonstration as Backplay does. However, they require the environment to be reversible, an assumption that doesn’t hold in many realistic tasks such as a robot manipulating breakable objects or complex video games such as Starcraft. In addition, they may fare poorly when random walks reach parts of the state space that are not actually relevant for learning a good policy. Thus, whether a practitioner wants to generate curricula from a trajectory or a random walk depends on the environment’s properties. We discuss this in more detail in our analysis section and show empirical results suggesting that Backplay is superior.
47
+
48
+ Hosu & Rebedea (2016) use uniformly random states of an expert demonstration as starting states for a policy. Like Backplay, they show that using a single loss function to learn a policy from both demonstrations and rewards can outperform the demonstrator and is robust to sub-optimal demonstrations. However, they do not impose a curriculum over the demonstration and are equivalent to the Uniform baseline in our experiments.
49
+
50
+ Zhu et al. (2018) use a curriculum but manually tune it for each ‘stage’ of the environment. Within each stage, they use what we call Uniform training, which fails in our most challenging environments.
51
+
52
+ Goyal et al. (2018) and Edwards et al. (2018) simultaneously proposed the use of a learned backtracking model to generate traces that lead to high value states. Their methods rely on either having the agent visit high reward states or learning a model of the environment capable of generating the states. Both of these are challenging in environments in which the dynamics near starting states are very different from those near goal states.
53
+
54
+ Finally, Ivanovic et al. (2018) use a known (approximate) dynamics model to create a backwards curriculum for continuous control tasks. Their approach requires a physical prior which is not always available and often not applicable in multi-agent scenarios. In contrast, Backplay automatically creates a curriculum fit for any resettable environment with accompanying demonstrations.
55
+
56
+ # 3 BACKPLAY
57
+
58
+ Consider the standard formalism of a single agent Markov Decision Process (MDP) defined by a set of states $s$ , a set of actions $\mathcal { A }$ , and a transition function $\mathcal { T } : \mathcal { S } \times \mathcal { A } \mathcal { S }$ which gives the probability distribution of the next state given a current state and action. If $\mathcal { P } ( A )$ denotes the space of probability distributions over actions, the agent chooses actions by sampling from a stochastic policy $\pi : { \mathcal { S } } { \mathcal { P } } ( { \mathcal { A } } )$ , and receives reward $r : S \times \mathcal { A } \mathbb { R }$ at every time step. The agent’s goal is to construct a policy which minimizes its discounted expected return $\begin{array} { r } { R _ { t } = \bar { \mathbb { E } } \left[ \sum _ { k = 0 } ^ { \infty } \bar { \gamma } ^ { k } r _ { t + k + 1 } \right] } \end{array}$ where $r _ { t }$ is the reward at time $t$ and $\gamma \in [ 0 , 1 ]$ is the discount factor, and the expectation is taken with respect to both the policy and the environment.
59
+
60
+ The final component of an MDP is the distribution of initial starting states $s _ { 0 }$ . The key idea in demonstration which reaches a sequence of states Backplay is that we do not initialize the MDP in only a fixed $\{ s _ { 0 } ^ { \dot { d } } , s _ { 1 } ^ { d } , \ldots , s _ { T } ^ { d } \}$ $s _ { 0 }$ . Instead, we assume access to a . For each training episode, we uniformly sample starting states from the sub-sequence $\{ s _ { T - k } ^ { d } , s _ { T - k + 1 } ^ { d } , . . . , s _ { T - j } ^ { d } \}$ for some window $[ j , k ]$ . Note that this training regime requires the ability to reset the environment to any state. As training continues, we ‘advance’ the window according to a curriculum by increasing the values of $j$ and $k$ until we are training on the initial state in every episode $( j = k = T )$ ). In this manner, our hyperparameters for Backplay are the windows and the training epochs at which we advance them.
61
+
62
+ # 3.1 QUANTITATIVE ANALYSIS
63
+
64
+ Next, we consider a simple environment in which we can analytically show that Backplay will improve the sample-efficiency of RL training.
65
+
66
+ Consider a connected, undirected graph $G = ( V , E )$ . An agent is placed at a fixed node $v _ { 0 } \in V$ and moves to neighboring nodes at a negative reward of $- 1$ for each step. Its goal is to reach a target node $v _ { * } \in V$ , terminating the episode. This corresponds to an MDP $\overset { \cdot } { \mathcal { M } } = \overset { \cdot } { ( } S , \overset { \cdot } { \mathcal { A } } , P , R )$ with state space $s \sim V$ , action space $A \sim E$ , deterministic transition kernel corresponding to
67
+
68
+ $$
69
+ P ( s _ { t + 1 } = j \mid s _ { t } = i , a _ { t } = ( l , k ) ) = \delta ( j = k ) \delta ( l = i ) + \delta ( j = i ) \delta ( l \neq i )
70
+ $$
71
+
72
+ and uniform reward $R ( s _ { t } , a _ { t } ) = - 1$ for $s _ { t + 1 } \neq v _ { * }$ . Assume that $\pi$ is a fixed policy on $\mathcal { M }$ , such that the underlying Markov chain is irreducible and aperiodic:
73
+
74
+ $$
75
+ K _ { \pi } ( s ^ { \prime } , s ) = \sum _ { a \in \cal { A } } P ( s _ { t + 1 } = s ^ { \prime } \mid s _ { t } = s , a _ { t } = a ) \pi ( a \mid s )
76
+ $$
77
+
78
+ $K _ { \pi }$ has a single absorbing state at $s = s _ { * } : = v _ { * }$ . Our goal is to estimate the value function of this policy, equivalent to the expected first-passage time of the Markov chain $K _ { \pi }$ from $s _ { 0 } = s$ to $s _ { * }$ :
79
+
80
+ $$
81
+ V _ { \pi } ( s ) = \mathbb { E } \tau ( s , s _ { * } ) = \mathbb { E } \operatorname* { m i n } \{ j \geq 0 \ ; \ s . t . s _ { j } = s _ { * } , s _ { 0 } = s , s _ { i + 1 } \sim K _ { \pi } ( \cdot , s _ { i } ) \} .
82
+ $$
83
+
84
+ We consider a special tractable case where the value function can be well approximated by looking at the distance of a state from the goal state. Formally:
85
+
86
+ Assumption 1. For all $\theta$ $\begin{array} { r } { \mathrm { ~ , ~ } V _ { \theta } ( s ) = V _ { \theta } ( s ^ { \prime } ) \ w h e n e \nu e r d i s t _ { G } ( s ^ { \prime } , s _ { \ast } ) = d i s t _ { G } ( s , s _ { \ast } ) . } \end{array}$
87
+
88
+ We wish to analyze the process which is the projection of our Markov policy $\pi$ only in terms of the distance $z _ { t }$ . However, now the transition probabilities will not only be a function of only $z _ { t }$ and so
89
+
90
+ this projection will be non-Markovian. Its Markov approximation $\bar { z } _ { t }$ is defined as the Markov chain $\overline { { K } }$ given by the expected transition probabilities
91
+
92
+ $$
93
+ \begin{array} { r c l } { { \mathrm { P r } ( \bar { z } _ { t + 1 } = l - 1 | \bar { z } _ { t } = l ) } } & { { = } } & { { \alpha _ { l } : = \mathrm { P r } _ { \mu } ( z _ { t + 1 } = l - 1 | z _ { t } = l ) , } } \\ { { \mathrm { P r } ( \bar { z } _ { t + 1 } = l | \bar { z } _ { t } = l ) } } & { { = } } & { { \beta _ { l } : = \mathrm { P r } _ { \mu } ( z _ { t + 1 } = l | z _ { t } = l ) , l = 0 \ldots M } } \end{array}
94
+ $$
95
+
96
+ and thus Pr(¯zt+1 = l + 1|z¯ $\ L _ { t } = l ) = 1 - \alpha _ { l } - \beta _ { l } = \operatorname* { P r } _ { \mu } ( z _ { t + 1 } = l + 1 \mid z _ { t } = l$ ) under the stationary distribution $\mu$ of $K _ { \pi }$ .
97
+
98
+ Assumption 2. The projected process is well described by its Markovian approximation.
99
+
100
+ Though these assumptions are relatively strong, they makes the analysis of Backplay in this graph complex but analytically tractable. Given a demonstration $\mathbf { d } = ( d _ { 0 } = s _ { 0 } , \ldots , d _ { L } = { \dot { s } } _ { * } )$ , $d _ { l } \in S$ we will perform Backplay
101
+
102
+ Theorem 1. When assumptions 1 and 2 hold, the sample complexity gains from using Backplay rather than standard RL are exponential in the diameter of the graph. $\begin{array} { r } { O ( \frac { M ^ { 2 } } { m } \alpha ^ { - m } ) } \end{array}$ vs $\Omega ( M \alpha ^ { - M / 2 } )$
103
+
104
+ 3) to obtain Proof. we sample it using a step size $\bar { d } _ { l } : = \mathrm { d i s t } _ { G } ( \breve { d } _ { L - m l } , s _ { * } )$ , l = 0, 1, . . . , Lm , which satisfies (such that mod $\bar { d } _ { l } \leq l m \bar { }$ , where $j$ for all is defined in Section $l$ .
105
+
106
+ For fixed $l$ , we initialize the chain $\overline { { K } }$ at $\bar { d } _ { l }$ : $\bar { z } _ { 0 } = \bar { d } _ { l }$ . Since $\begin{array} { r } { P r ( \bar { z } _ { m } = 0 ) \geq \prod _ { j = 0 } ^ { m - 1 } \alpha _ { j } : = \gamma _ { 0 , m } } \end{array}$ , after $O ( \gamma _ { 0 , m } ^ { - 1 } )$ trials of length $\leq M$ , we will reach the absorbing state and finally have a signal-carrying update for the Q-function at the originating state.
107
+
108
+ We can consequently merge that state into the absorbing state and reduce the length of the chain by one. Repeat the argument $m$ times so that after $O ( \sum _ { j = 0 } ^ { m } \gamma _ { j , m } ^ { - 1 } ) = O ( m \gamma _ { 0 , m } ^ { - 1 } )$ trials, the Q-function is updated at $\bar { z } _ { 0 }$ . Repeat at Backplay steps $\begin{array} { r } { m , l = 1 , \dots \frac { M } { m } } \end{array}$ m , and we reach a sample complexity of
109
+
110
+ $$
111
+ T _ { m } = \sum _ { k = 0 } ^ { \frac { M } { m } - 1 } { \cal O } \left( M \sum _ { j = 0 } ^ { m } \gamma _ { k m , ( k + 1 ) m - j } ^ { - 1 } \right) \ .
112
+ $$
113
+
114
+ In the case where $\alpha _ { l } = \alpha$ for all $l$ , we obtain $\gamma _ { k m , ( k + 1 ) m - j } ^ { - 1 } = \gamma _ { 0 , m - j } = \alpha ^ { - m + j }$ and therefore $\begin{array} { r } { T _ { m } = O \left( \frac { M ^ { 2 } ( 1 - \alpha ^ { m + 1 } ) } { m ( 1 - \alpha ) } \alpha ^ { - m } \right) } \end{array}$ , where the important term is the rate $\textstyle { \frac { M ^ { 2 } } { m } } \alpha ^ { - m }$ .
115
+
116
+ On the other hand, Hong & Zhou (2017) shows that the first-passage time $\tau ( 0 , M )$ in a skip-free finite Markov chain of $M$ states with a single absorbing state is a random variable whose momentgenerating function $\varphi ( s ) = \mathbb { E } s ^ { \tau ( s , s _ { * } ) }$ is given by
117
+
118
+ $$
119
+ \varphi ( s ) = \prod _ { j = 1 } ^ { M } \frac { ( 1 - \lambda _ { j } ) s } { 1 - \lambda _ { j } s } ,
120
+ $$
121
+
122
+ where $\lambda _ { 1 } , \dots , \lambda _ { M }$ are the non-unit eigenvalues of the transition probability matrix. It follows that $\begin{array} { r } { \mathbb { E } \tau ( 0 , M ) = \varphi ^ { \prime } ( 1 ) = \sum _ { j = 1 } ^ { M } \frac { 1 } { 1 - \lambda _ { j } } \approx ( 1 - \lambda _ { 1 } ) ^ { - 1 } } \end{array}$ , which corresponds to the reciprocal spectral gap.1 Chen & Saloff-Coste (2013) further shows that this reciprocal spectral gap is $\Omega ( \alpha ^ { - M / 2 } )$ in our case, and therefore the model without Backplay will on average take $T _ { M } = \Omega ( \alpha ^ { - M / 2 } )$ trials to reach the absorbing state and receive information. □
123
+
124
+ We can analyze the uniform strategy similarly. The probability that a trajectory initialized at one of the uniform samples will reach the absorbing state is lower bounded by
125
+
126
+ $$
127
+ \sum _ { j = 1 } ^ { M } \alpha ^ { j } P ( \bar { z } _ { 0 } = j ) = \frac { 1 } { M } \sum _ { j = 1 } ^ { M } \alpha ^ { j } = \frac { \alpha - \alpha ^ { M + 1 } } { M ( 1 - \alpha ) } ,
128
+ $$
129
+
130
+ which is approximately $\frac { \alpha } { M }$ when $\alpha$ is small, leading to a sample complexity of $O ( M ^ { 2 } \alpha ^ { - 1 } )$ to update the value function at the originating state, and $O ( M ^ { 3 } \alpha ^ { - 1 } )$ at the starting state. Comparing this rate to Backplay with $m = 1$ , observe that the uniform strategy is slower by a factor of $M$ (and one can verify that the same is true for generic step size $m$ by imagining that we first sampled a window of size $m$ and then sub-sampled our state from that window), suggesting that it loses efficiency on environments with large diameter.
131
+
132
+ The preceding analysis suggests that a full characterization of Backplay is a fruitful direction for reinforcement and imitation learning theory, albeit beyond the scope of this paper.
133
+
134
+ # 3.2 QUALITATIVE ANALYSIS
135
+
136
+ We now provide intuition regarding the conditions under which Backplay can improve sampleefficiency or lead to a better policy than that of the demonstrator. In addition, we discuss the differences between Backplay and other methods of reducing sample complexity for deep RL as well as when practitioners would choose to use one or the other.
137
+
138
+ Figure 2 contains three grid worlds. In each, the agent begins at $s _ { 0 }$ , receives $+ 1$ when it reaches $s _ { * }$ , and otherwise incurs a per step cost. They each pose a challenge to model free RL and highlight advantages and disadvantages of Backplay compared to other approaches like behavioral cloning (BC, Bain & Sommut (1999)), generative adversarial imitation learning (GAIL, Ho & Ermon (2016)), and reverse curriculum generation (RCG, Florensa et al. (2017)). See Table 1 for a direct comparison of these algorithms.
139
+
140
+ ![](images/80c6f889e484645e180e67926e04933eee7f28c2ac4c3c88a6bf44468b8a2017.jpg)
141
+ Figure 2. Three environments illustrating when Backplay can help or hinder learning an optimal policy. Backplay is expected to learn faster than standard RL on the first and second mazes, but perform worse on the third maze.
142
+
143
+ The left grid world shows a sparse reward environment in which Backplay can decrease the requisite training time compared to standard RL. Using the sub-optimal demonstration will position the Backplay agent close to high value states. In addition, the agent will likely surpass the expert policy because, unlike in BC approaches, Backplay does not encourage the agent to imitate expert actions. Rather, the curriculum forces the agent to first explore states with large associated value and, consequently, estimating the value function suffers less from the curse of dimensionality. And finally, we expect it to also surpass results from RCG because random movements from the goal state will progress very haphazardly in such an open world.
144
+
145
+ The middle grid illustrates a maze with bottlenecks. Backplay will vastly decrease the exploration time relative to standard RL, because the agent will be less prone to exploring the errant right side chamber where it can get lost if it traverses to the right instead of going up to the goal. If we used BC, then the agent will sufficiently learn the optimal policy, however it will suffer when placed in nearby spots on the grid as they will be out of distribution; Backplay-trained agents will not have this problem as they also explore nearby states. When an RCG agent reaches the first fork, it has an even chance of exploring the right side of the grid and wasting lots of sample time.
146
+
147
+ On the rightmost grid world, while Backplay is still likely to surpass its demonstrator, it will have trouble doing better than standard RL because the latter always starts at $s _ { 0 }$ and consequently is more likely to stumble upon the optimal solution of going up and right. In contrast, Backplay will spend the dominant amount of its early training starting in states in the sub-optimal demonstration. Note that BC will be worse off than Backplay because by learning the demonstration, it will follow the trajectory into the basin instead of going up the right side. Finally, observe that RCG will likely outperform here given that it has a high chance of discovering the left side shortcut and, if not, it would more likely discover the right side shortcut than be trapped in the basin.
148
+
149
+ In summary, Backplay is not a universal strategy to improve sample complexity. Even in the navigation setting, if the task randomizes the initial state $s _ { 0 }$ , a single demonstration trajectory does not generally improve the coverage of the state-space outside an exponentially small region around said trajectory. For example, imagine a binary tree and a navigation task that starts at a random leaf and needs to reach the root. A single expert trajectory will be disjoint from half of the state space (because the root is absorbing), thus providing no sample complexity gains on average.
150
+
151
+ Table 1: Comparison of Backplay with related work: Behavioral Cloning (BC), Generative Adversarial Imitation Learning (GAIL), and Reverse Curriculum Generation (RCG).
152
+
153
+ <table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Requirements</td><td rowspan=1 colspan=1>Main Idea</td><td rowspan=1 colspan=1>MainWeakness</td></tr><tr><td rowspan=1 colspan=1>BC</td><td rowspan=1 colspan=1>(State,Action) pairs fromexpert trajectory.</td><td rowspan=1 colspan=1>Learn policy that imitates theexpert demonstration.</td><td rowspan=1 colspan=1>Sub-optimal expert can yield avery poor learned policy.</td></tr><tr><td rowspan=1 colspan=1>GAIL</td><td rowspan=1 colspan=1>(State,Action) pairs fromexpert trajectory.</td><td rowspan=1 colspan=1>Learn a policythat matchesthe distribution of expert tra-jectory pairs.</td><td rowspan=1 colspan=1>Difficult to tune; Requires moreworld interactions; Can performworse than BC.</td></tr><tr><td rowspan=1 colspan=1>RCG</td><td rowspan=1 colspan=1>Reversable transition func-tion of environment; Reset-table environment.</td><td rowspan=1 colspan=1>Take randomwalks from goalstate to build curriculum of ini-tial starting states.</td><td rowspan=1 colspan=1>Complexitymay increase if ran-dom walks reach parts of statespace irrelevant to a good policy.</td></tr><tr><td rowspan=1 colspan=1>Backplay</td><td rowspan=1 colspan=1>State sequence froma‘good enough’ trajectory;Resettable environment.</td><td rowspan=1 colspan=1>Sample starting state fromgiven trajectory by walkingbackward along trajectory.</td><td rowspan=1 colspan=1>If states in‘good enough&#x27;tra- jectory are not optimal, then canslow learning the optimal policy.</td></tr></table>
154
+
155
+ # 4 EXPERIMENTS
156
+
157
+ We now move to evaluating Backplay empirically in two environments: a grid world maze and a four-player free-for-all game. The questions we study across both environments are the following:
158
+
159
+ • Is Backplay more efficient than training an RL agent from scratch? • How does the quality of the given demonstration affect the effectiveness of Backplay? • Can Backplay agents surpass the demonstrator when it is non-optimal? • Can Backplay agents generalize?
160
+
161
+ # 4.1 TRAINING DETAILS
162
+
163
+ We compare several training regimes. The first is Backplay, which uses the Backplay algorithm corresponding to a particular sequence of windows and epochs as specified in A.1. The second, Standard is vanilla model-free RL with the agent always starting at the initial state $s _ { 0 }$ . The last, Uniform, is an ablation that considers how important is the curriculum aspect of Backplay by sampling initial states randomly from the entire demonstration. In all these regimes, we use Proximal Policy Optimization (PPO, Schulman et al. (2017)) to train an agent with policy and value functions parameterized by convolutional neural networks.
164
+
165
+ On the Maze environment (detailed below), we also ran comparisons against Behavioral Cloning and Reverse Curriculum Generation. We chose BC over GAIL (Ho & Ermon, 2016) for three reasons. First, GAIL requires careful hyperparameter tuning and is thus difficult to train. Second, GAIL requires more environment interactions. And third, GAIL has recently been shown to perform significantly worse than BC (Behbahani et al., 2018).
166
+
167
+ Training details and network architectures for all the environments can be found in A.3 and A.6, while A.9 contains empirical observations for using Backplay in practice.
168
+
169
+ # 4.2 MAZE
170
+
171
+ We generated mazes of size $2 4 \times 2 4$ with 120 randomly placed walls, a random start position, and a random goal position. We then used $\mathbf { A } ^ { * }$ to generate trajectories. These included both Optimal demonstrations (true shortest path) and N-Optimal demonstrations (N steps longer than the shortest path). More details on this setup are given in A.2.
172
+
173
+ <table><tr><td rowspan=1 colspan=1>Algorithm</td><td rowspan=1 colspan=1>Map Set</td><td rowspan=1 colspan=1>% Optimal</td><td rowspan=1 colspan=1>% 0-5 Optimal</td><td rowspan=1 colspan=1>Avg Suboptimality</td><td rowspan=1 colspan=1> Std Suboptimality</td></tr><tr><td rowspan=1 colspan=1>Standard</td><td rowspan=1 colspan=1>All</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>N/A</td><td rowspan=1 colspan=1>N/A</td></tr><tr><td rowspan=1 colspan=1>Uniform</td><td rowspan=1 colspan=1>Optimal</td><td rowspan=1 colspan=1>27</td><td rowspan=1 colspan=1>91</td><td rowspan=1 colspan=1>8.26</td><td rowspan=1 colspan=1>32.92</td></tr><tr><td rowspan=1 colspan=1>Uniform</td><td rowspan=1 colspan=1>5-Optimal</td><td rowspan=1 colspan=1>51</td><td rowspan=1 colspan=1>98</td><td rowspan=1 colspan=1>2.04</td><td rowspan=1 colspan=1>17.39</td></tr><tr><td rowspan=1 colspan=1>Uniform</td><td rowspan=1 colspan=1>10-Optimal</td><td rowspan=1 colspan=1>49</td><td rowspan=1 colspan=1>98</td><td rowspan=1 colspan=1>2.04</td><td rowspan=1 colspan=1>16.79</td></tr><tr><td rowspan=1 colspan=1>Florensa</td><td rowspan=1 colspan=1>Optimal</td><td rowspan=1 colspan=1>20</td><td rowspan=1 colspan=1>51</td><td rowspan=1 colspan=1>63.36</td><td rowspan=1 colspan=1>78.08</td></tr><tr><td rowspan=1 colspan=1>Florensa</td><td rowspan=1 colspan=1>5-Optimal</td><td rowspan=1 colspan=1>48</td><td rowspan=1 colspan=1>77</td><td rowspan=1 colspan=1>25.44</td><td rowspan=1 colspan=1>56.89</td></tr><tr><td rowspan=1 colspan=1>Florensa</td><td rowspan=1 colspan=1>10-Optimal</td><td rowspan=1 colspan=1>49</td><td rowspan=1 colspan=1>69</td><td rowspan=1 colspan=1>39.75</td><td rowspan=1 colspan=1>70.92</td></tr><tr><td rowspan=1 colspan=1>Backplay</td><td rowspan=1 colspan=1>Optimal</td><td rowspan=1 colspan=1>31</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>0.64</td><td rowspan=1 colspan=1>4.96</td></tr><tr><td rowspan=1 colspan=1>Backplay</td><td rowspan=1 colspan=1>5-Optimal</td><td rowspan=1 colspan=1>37</td><td rowspan=1 colspan=1>94</td><td rowspan=1 colspan=1>7.94</td><td rowspan=1 colspan=1>33.35</td></tr><tr><td rowspan=1 colspan=1>Backplay</td><td rowspan=1 colspan=1>10-Optimal</td><td rowspan=1 colspan=1>54</td><td rowspan=1 colspan=1>99</td><td rowspan=1 colspan=1>0.37</td><td rowspan=1 colspan=1>3.49</td></tr></table>
174
+
175
+ Table 2: Results after 2000 epochs on 100 mazes. Note that for Backplay and Uniform, the Map Set is also the type of demonstrator, where N-optimal has demonstrations $\mathbf { N }$ steps longer than the shortest path. From left to right, the table shows: the percentage of mazes on which the agent optimally reaches the goal, percentage on which it reaches in at most five steps more than optimal, and the average and standard deviation of extra steps over optimal. Both Backplay and Uniform succeed on almost all mazes and, importantly, can outperform the experts’ demonstrations. On the other hand, Standard does not learn a useful policy and Florensa fails to learn more than $5 0 - 7 0 \%$ of the maps, which is why its sub-optimality mean and std is so high. Results for Backplay were generally consistent across all seeds. For others, we report their best score. See A.4 for further details.
176
+
177
+ Our model receives as input four $2 4 \times 2 4$ binary maps. They contain ones at the positions of, respectively, the agent, the goal, passages, and walls. It outputs one of five options: Pass, Up, Down, Left, or Right. The game ends when the agent has reached its goal or after a maximum of 200 steps, whereupon the agent receives reward of $+ 1$ if it reaches the goal and a per step penalty of -0.03.
178
+
179
+ Backplay, Uniform, Standard. Table 2 shows that Standard has immense trouble learning in this sparse reward environment while both Backplay and Uniform find an optimal path approximately 30- $50 \%$ of the time and a path within five of the optimal path almost always. Thus, in this environment, demonstrations of even sub-optimal experts are extremely useful, while the curriculum created by Backplay is not necessary. That curriculum does, however, aid convergence speed (A.4). We will see in 4.3 that the curriculum becomes vital as the environment increases in complexity.
180
+
181
+ Behavioral Cloning. We trained an agent using behavioral cloning from the same trajectories as the ones used for Backplay. While the agent learns to perfectly imitate those trajectories, we had immense difficult doing better than the expert. All of our attempts to use reward signal to improve the agent’s performance (over that of the behaviorally cloned agent) were unsuccessful, even after incorporating tricks in the literature such as those found in Schmitt et al. (2018). One possible reason is that the agent has no information about states outside of the demonstration trajectory.
182
+
183
+ Reverse Curriculum Generation. We also compared Backplay to the method proposed by Florensa et al. (2017). As illustrated in Table 2 and Section A.4, Florensa agents perform significantly worse with higher sample complexity variance compared to Backplay (or Uniform). This suggests that having demonstrations helps inordinately. Further details can be found in A.3.
184
+
185
+ # 4.3 POMMERMAN
186
+
187
+ Pommerman is a stochastic environment (Resnick et al., 2018) based on the classic console game Bomberman and will be a competition at NeurIPS 2018. It is played on an 11x11 grid where on every turn, each of four agents either move in a cardinal direction, pass, or lay a bomb. The agents begin fenced in their own area by two different types of walls - rigid and wooden. The former are indestructible while bombs destroy the latter. Upon blowing up wooden walls, there is a uniform chance at yielding one of three power-ups: an extra bomb, an extra unit of range in the agent’s bombs, or the ability to kick bombs. The maps are designed randomly, albeit there is always a guaranteed path between any two agents. For a visual aid of the start state, see Figure 8 in A.5.
188
+
189
+ In our experiments, we use the purely adversarial Free-For-All (FFA) environment. This environment is introduced in (MultiAgentLearning, 2018; Resnick et al., 2018) and we point the reader there for more details. The winner of the game is the last agent standing. It is played from the perspective of one agent whose starting position is uniformly picked among the four. The three opponents are copies of the winner of the June 3rd 2018 FFA competition, a stochastic agent using a Finite State Machine Tree-Search approach (FSMTS, Zhou et al. (2018)). We also make use of the FSMTS agent as the ‘expert’ in the Backplay demonstrations.
190
+
191
+ The observation state is represented by 19 11x11 maps, and we feed the concatenated last two states to our agent as input. A detailed description of this mapping is given in A.5. The game ends either when the learning agent wins or dies, or when 800 steps have passed. Upon game end, the agent receives $+ 1$ for winning and $- 1$ otherwise (Sparse). We also run experiments where the agent additionally receives $+ 0 . 1$ whenever it collects an item (Dense).
192
+
193
+ ![](images/6fb655e834f82f1f2fc914d07474766c75d5578066da4028f1af9df41f349a66.jpg)
194
+ Figure 3. Pommerman results (5 seeds) when training with sparse rewards. Plots a and $\mathbf { b }$ are trained from the perspective of the winning agent, while c is trained from that of the runner up. The red bar indicates when the Backplay models begin training only on the initial state. Plot a is our starkest result and displays results on games starting from the initial state only regardless of when training occurs. you can see here that Backplay attains strong results where Uniform and Standard fail to learn anything of note.
195
+
196
+ ![](images/9075ba624117740d560bc365ca0cba6177e44e0898a5d3c9a64593cbaa86e0f3.jpg)
197
+ Figure 4. Pommerman results (5 seeds) when training with dense rewards. Again, a and $\mathbf { b }$ are trained from the perspective of the winning agent, while c is trained from that of the runner up. The cause of the higher variance in a was one of the seeds was worse than the others. Nonetheless, they all still did much better than either Standard or Uniform.
198
+
199
+ Our first three scenarios follow the Sparse setup. We independently consider three Backplay trajectories, one following the winner over 100 maps, one following the winner over four maps, and one following the runner up over four maps, with the latter two set of maps being the same. Figure 3 shows that Backplay can soundly defeat the FSMTS agents in sparse settings when following the winner, even when there are 100 maps to consider, while other methods struggle in this setup. Modulo higher variance in Backplay’s result, we see a similar comparison in the runner-up case. Visit this link for an example gif of our trained Backplay agent (top left - red). Note that our agent learned to ‘throw’ bombs, a unique playing style that no prior Pommerman competitor had exhibited, including the FSMTS demonstrator.
200
+
201
+ Moreover, by training on 100 maps, Backplay generalizes (to some extent) on unseen boards. Backplay wins 416 / 1000 games on a held out set of ten maps, with the following success rates on each: $8 5 . 3 \%$ , $8 4 . 1 \%$ , $8 1 . 6 \%$ , $7 9 . 5 \%$ , $5 2 . 4 \%$ , $4 7 . 4 \%$ , $3 8 . 1 \%$ , $2 2 . 6 \%$ , $20 \%$ , and $1 8 . 3 \%$ . This was in contrast to our Maze experiments where no approach generalized. Given this discrepancy, we believe that the lack of generalization was a consequence of not including enough mazes during training.
202
+
203
+ # 5 CONCLUSION
204
+
205
+ We have introduced and analyzed Backplay, a technique which improves the sample efficiency of model-free RL by constructing a curriculum around a demonstration. We showed that Backplay agents can learn in complex environments where standard model-free RL fails, that they can outperform the ‘expert’ whose trajectories they use while training, and that they compare very favorably to related methods such as reversible curriculum generation. We also presented a theoretical analysis of its sample complexity gains in a simplified setting.
206
+
207
+ An important future direction is combining Backplay with more complex and complementary methods such as Monte Carlo Tree Search (MCTS, (Browne et al., 2012; Vodopivec et al., 2017)). There are many potential ways to do so, for example by using Backplay to warm-start MCTS.
208
+
209
+ Another direction is to use Backplay to accelerate self-play learning in zero-sum games. However, special care needs to be taken to avoid policy correlation during training (Lanctot et al., 2017) and thus to make sure that learned strategies are safe and not exploitable (Brown & Sandholm, 2017).
210
+
211
+ A third direction is towards non-zero sum games. It is well known that standard independent multiagent learning does not produce agents that are able to cooperate in social dilemmas (Leibo et al., 2017; Lerer & Peysakhovich, 2017; Peysakhovich & Lerer, 2017; Foerster et al., 2017) or risky coordination games (Yoshida et al., 2008; Peysakhovich & Lerer, 2018). In contrast, humans are much better at finding these coordinating and cooperating equilibria (Bó, 2005; Kleiman-Weiner et al., 2016). Thus, we conjecture that human demonstrations can be combined with Backplay to construct agents that perform well in such situations.
212
+
213
+ Other future priorities are to gain further understanding into when Backplay works well, when it fails, and how we can make the procedure more efficient. Could we speed up Backplay by ascertaining confidence estimates of state values? Do the gains in sample complexity come from value estimation like our analysis suggests, from policy iteration, or from both? Is there an ideal rate for advancing the curriculum window and is there a better approach than a hand-tuned schedule?
214
+
215
+ # REFERENCES
216
+
217
+ Yusuf Aytar, Tobias Pfaff, David Budden, Tom Le Paine, Ziyu Wang, and Nando de Freitas. Playing hard exploration games by watching youtube. arXiv preprint arXiv:1805.11592, 2018.
218
+ Michael Bain and Claude Sommut. A framework for behavioural claning. Machine intelligence, 15 (15):103, 1999.
219
+ Feryal Behbahani, Kyriacos Shiarlis, Xi Chen, Vitaly Kurin, Sudhanshu Kasewa, Ciprian Stirbu, João Gomes, Supratik Paul, Frans A Oliehoek, João Messias, et al. Learning from demonstration in the wild. arXiv preprint arXiv:1811.03516, 2018.
220
+ Pedro Dal Bó. Cooperation under the shadow of the future: experimental evidence from infinitely repeated games. American economic review, 95(5):1591–1604, 2005.
221
+ Noam Brown and Tuomas Sandholm. Safe and nested subgame solving for imperfect-information games. In Advances in Neural Information Processing Systems, pp. 689–699, 2017.
222
+ Cameron B Browne, Edward Powley, Daniel Whitehouse, Simon M Lucas, Peter I Cowling, Philipp Rohlfshagen, Stephen Tavener, Diego Perez, Spyridon Samothrakis, and Simon Colton. A survey of monte carlo tree search methods. IEEE Transactions on Computational Intelligence and AI in games, 4(1):1–43, 2012.
223
+ Guan-Yu Chen and Laurent Saloff-Coste. On the mixing time and spectral gap for birth and death chains. arXiv preprint arXiv:1304.4346, 2013.
224
+ J. Clark and D. Amodei. Faulty reward functions in the wild. https://blog.openai.com/ faulty-reward-functions/, 2016.
225
+ Abhishek Das, Samyak Datta, Georgia Gkioxari, Stefan Lee, Devi Parikh, and Dhruv Batra. Embodied question answering. CoRR, abs/1711.11543, 2017a.
226
+
227
+ Abhishek Das, Satwik Kottur, José M. F. Moura, Stefan Lee, and Dhruv Batra. Learning cooperative visual dialog agents with deep reinforcement learning. CoRR, abs/1703.06585, 2017b.
228
+
229
+ Hal Daumé, John Langford, and Daniel Marcu. Search-based structured prediction. Machine learning, 75(3):297–325, 2009.
230
+
231
+ Ashley D Edwards, Laura Downs, and James C Davidson. Forward-backward reinforcement learning. arXiv preprint arXiv:1803.10227, 2018.
232
+
233
+ Carlos Florensa, David Held, Markus Wulfmeier, and Pieter Abbeel. Reverse curriculum generation for reinforcement learning. arXiv preprint arXiv:1707.05300, 2017.
234
+
235
+ Jakob N Foerster, Richard Y Chen, Maruan Al-Shedivat, Shimon Whiteson, Pieter Abbeel, and Igor Mordatch. Learning with opponent-learning awareness. arXiv preprint arXiv:1709.04326, 2017.
236
+
237
+ Yang Gao, Ji Lin, Fisher Yu, Sergey Levine, Trevor Darrell, et al. Reinforcement learning from imperfect demonstrations. arXiv preprint arXiv:1802.05313, 2018.
238
+
239
+ Anirudh Goyal, Philemon Brakel, William Fedus, Timothy Lillicrap, Sergey Levine, Hugo Larochelle, and Yoshua Bengio. Recall traces: Backtracking models for efficient reinforcement learning. arXiv preprint arXiv:1804.00379, 2018.
240
+
241
+ Todd Hester, Matej Vecerik, Olivier Pietquin, Marc Lanctot, Tom Schaul, Bilal Piot, Dan Horgan, John Quan, Andrew Sendonaris, Gabriel Dulac-Arnold, et al. Deep q-learning from demonstrations. arXiv preprint arXiv:1704.03732, 2017.
242
+
243
+ Jonathan Ho and Stefano Ermon. Generative adversarial imitation learning. In Advances in Neural Information Processing Systems, pp. 4565–4573, 2016.
244
+
245
+ Wenming Hong and Ke Zhou. A note on the passage time of finite-state markov chains. Communications in Statistics-Theory and Methods, 46(1):438–445, 2017.
246
+
247
+ Ionel-Alexandru Hosu and Traian Rebedea. Playing atari games with deep reinforcement learning and human checkpoint replay. arXiv preprint arXiv:1607.05077, 2016.
248
+
249
+ Boris Ivanovic, James Harrison, Apoorva Sharma, Mo Chen, and Marco Pavone. Barc: Backward reachability curriculum for robotic reinforcement learning. arXiv preprint arXiv:1806.06161, 2018.
250
+
251
+ Sham Kakade and John Langford. Approximately optimal approximate reinforcement learning. In Claude Sammut and Achim G. Hoffmann (eds.), ICML, pp. 267–274. Morgan Kaufmann, 2002. ISBN 1-55860-873-7. URL http://dblp.uni-trier.de/db/conf/icml/ icml2002.html#KakadeL02.
252
+
253
+ Max Kleiman-Weiner, Mark K Ho, Joseph L Austerweil, Michael L Littman, and Joshua B Tenenbaum. Coordinate to cooperate or compete: abstract goals and joint intentions in social interaction. In COGSCI, 2016.
254
+
255
+ Marc Lanctot, Vinicius Zambaldi, Audrunas Gruslys, Angeliki Lazaridou, Julien Perolat, David Silver, Thore Graepel, et al. A unified game-theoretic approach to multiagent reinforcement learning. In Advances in Neural Information Processing Systems, pp. 4190–4203, 2017.
256
+
257
+ Michael Laskey, Sam Staszak, Wesley Yu-Shu Hsieh, Jeffrey Mahler, Florian T Pokorny, Anca D Dragan, and Ken Goldberg. Shiv: Reducing supervisor burden in dagger using support vectors for efficient learning from demonstrations in high dimensional state spaces. In Robotics and Automation (ICRA), 2016 IEEE International Conference on, pp. 462–469. IEEE, 2016.
258
+
259
+ Joel Z Leibo, Vinicius Zambaldi, Marc Lanctot, Janusz Marecki, and Thore Graepel. Multi-agent reinforcement learning in sequential social dilemmas. In Proceedings of the 16th Conference on Autonomous Agents and MultiAgent Systems, pp. 464–473. International Foundation for Autonomous Agents and Multiagent Systems, 2017.
260
+
261
+ Adam Lerer and Alexander Peysakhovich. Maintaining cooperation in complex social dilemmas using deep reinforcement learning. arXiv preprint arXiv:1707.01068, 2017.
262
+
263
+ Adam Lerer and Alexander Peysakhovich. Learning social conventions in markov games. arXiv preprint arXiv:1806.10071, 2018.
264
+
265
+ Sergey Levine, Chelsea Finn, Trevor Darrell, and Pieter Abbeel. End-to-end training of deep visuomotor policies. Journal of Machine Learning Research, 17(39):1–40, 2016. URL http: //jmlr.org/papers/v17/15-522.html.
266
+
267
+ Jiwei Li, Will Monroe, Alan Ritter, Michel Galley, Jianfeng Gao, and Dan Jurafsky. Deep reinforcement learning for dialogue generation. CoRR, abs/1606.01541, 2016.
268
+
269
+ Stephen McAleer, Forest Agostinelli, Alexander Shmakov, and Pierre Baldi. Solving the rubik’s cube without human knowledge. arXiv preprint arXiv:1805.07470, 2018.
270
+
271
+ Matej Moravcík, Martin Schmid, Neil Burch, Viliam Lisý, Dustin Morrill, Nolan Bard, Trevor Davis, Kevin Waugh, Michael Johanson, and Michael H. Bowling. Deepstack: Expert-level artificial intelligence in no-limit poker. CoRR, abs/1701.01724, 2017. URL http://arxiv.org/abs/ 1701.01724.
272
+
273
+ MultiAgentLearning. Pommerman. https://github.com/MultiAgentLearning/ playground, 2018.
274
+
275
+ Ashvin Nair, Bob McGrew, Marcin Andrychowicz, Wojciech Zaremba, and Pieter Abbeel. Overcoming exploration in reinforcement learning with demonstrations. arXiv preprint arXiv:1709.10089, 2017.
276
+
277
+ Andrew Y Ng, Daishi Harada, and Stuart Russell. Policy invariance under reward transformations: Theory and application to reward shaping. In ICML, volume 99, pp. 278–287, 1999.
278
+
279
+ Xue Bin Peng, Pieter Abbeel, Sergey Levine, and Michiel van de Panne. Deepmimic: Example-guided deep reinforcement learning of physics-based character skills. arXiv preprint arXiv:1804.02717, 2018.
280
+
281
+ Alexander Peysakhovich and Adam Lerer. Consequentialist conditional cooperation in social dilemmas with imperfect information. arXiv preprint arXiv:1710.06975, 2017.
282
+
283
+ Alexander Peysakhovich and Adam Lerer. Prosocial learning agents solve generalized stag hunts better than selfish ones. Proceedings of the 17th Conference on Autonomous Agents and MultiAgent Systems, 2018.
284
+
285
+ Marc’Aurelio Ranzato, Sumit Chopra, Michael Auli, and Wojciech Zaremba. Sequence level training with recurrent neural networks. CoRR, abs/1511.06732, 2015.
286
+
287
+ Cinjon Resnick, Wes Eldridge, David Ha, Denny Britz, Jakob Foerster, Julian Togelius, Kyunghyun Cho, and Joan Bruna. Pommerman: A multi-agent playground, 2018.
288
+
289
+ Stéphane Ross, Geoffrey Gordon, and Drew Bagnell. A reduction of imitation learning and structured prediction to no-regret online learning. In Proceedings of the fourteenth international conference on artificial intelligence and statistics, pp. 627–635, 2011.
290
+
291
+ Tim Salimans and Richard Chen. Learning montezuma’s revenge from a single demonstration. https://blog.openai.com/ learning-montezumas-revenge-from-a-single-demonstration/, 2018. Accessed: 2018-07-12.
292
+
293
+ Simon Schmitt, Jonathan J Hudson, Augustin Zidek, Simon Osindero, Carl Doersch, Wojciech M Czarnecki, Joel Z Leibo, Heinrich Kuttler, Andrew Zisserman, Karen Simonyan, et al. Kickstarting deep reinforcement learning. arXiv preprint arXiv:1803.03835, 2018.
294
+
295
+ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
296
+
297
+ David Silver, Aja Huang, Chris J. Maddison, Arthur Guez, Laurent Sifre, George van den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, Sander Dieleman, Dominik Grewe, John Nham, Nal Kalchbrenner, Ilya Sutskever, Timothy Lillicrap, Madeleine Leach, Koray Kavukcuoglu, Thore Graepel, and Demis Hassabis. Mastering the game of Go with deep neural networks and tree search. Nature, 529(7587):484–489, 2016.
298
+
299
+ David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, Timothy P. Lillicrap, Karen Simonyan, and Demis Hassabis. Mastering chess and shogi by self-play with a general reinforcement learning algorithm. CoRR, abs/1712.01815, 2017. URL http://arxiv.org/ abs/1712.01815.
300
+
301
+ Tom Vodopivec, Spyridon Samothrakis, and Branko Šter. On monte carlo tree search and reinforcement learning. J. Artif. Int. Res., 60(1):881–936, September 2017. ISSN 1076-9757. URL http://dl.acm.org/citation.cfm?id $\equiv$ 3207692.3207712.
302
+
303
+ Wako Yoshida, Ray J Dolan, and Karl J Friston. Game theory of mind. PLoS computational biology, 4(12):e1000254, 2008.
304
+
305
+ Jiakai Zhang and Kyunghyun Cho. Query-efficient imitation learning for end-to-end autonomous driving. arXiv preprint arXiv:1605.06450, 2016.
306
+
307
+ Hongwei Zhou, Yichen Gong, Luvneesh Mugrai, Ahmed Khalifa, Andy Nealen, and Julian Togelius. A hybrid search agent in pommerman. In Proceedings of the 13th International Conference on the Foundations of Digital Games, FDG ’18, pp. 46:1–46:4, New York, NY, USA, 2018. ACM. ISBN 978-1-4503-6571-0. doi: 10.1145/3235765.3235812. URL http://doi.acm.org/10. 1145/3235765.3235812.
308
+
309
+ Yuke Zhu, Ziyu Wang, Josh Merel, Andrei A. Rusu, Tom Erez, Serkan Cabi, Saran Tunyasuvunakool, János Kramár, Raia Hadsell, Nando de Freitas, and Nicolas Heess. Reinforcement and imitation learning for diverse visuomotor skills. CoRR, abs/1802.09564, 2018.
310
+
311
+ # A APPENDIX
312
+
313
+ # A.1 BACKPLAY HYPERPARAMETERS
314
+
315
+ As mentioned in Section 3, the Backplay hyperparameters are the window bounds and the frequency with which they are shifted. When we get to a training epoch represented in the sequence of epochs, we advance to the corresponding value in the sequence of windows. For example, consider training an agent with Backplay in the Maze environment (Table 3) and assume we are at epoch 1000. We will select a maze at random, an $N \in [ 1 6 , 3 2 )$ , and start the agent in that game $N$ steps from the end. Whenever a pair is chosen such that the game’s length is smaller than $N$ , we use the initial state.
316
+
317
+ There isn’t any downside to having the model continue training in a window for too long, albeit the ideal is that this method increases the speed of training. There is however a downside to advancing the window too quickly. A scenario common to effective training is improving success curves punctured by step drops whenever the window advances.
318
+
319
+ Table 3: Backplay hyperparameters for Maze.
320
+
321
+ <table><tr><td>Starting at training epoch</td><td>Uniform window</td></tr><tr><td>0</td><td>[0,4)</td></tr><tr><td>350</td><td>[4,8)</td></tr><tr><td>700</td><td>[8,16)</td></tr><tr><td>1050</td><td>[16,32)</td></tr><tr><td>1400</td><td>[32, 64)</td></tr><tr><td>1750</td><td>[64,64)</td></tr></table>
322
+
323
+ Table 4: Backplay hyperparameters for Pommerman 4 maps.
324
+
325
+ <table><tr><td>Starting at training epoch</td><td>Uniform window</td></tr><tr><td>0</td><td>[0,32)</td></tr><tr><td>50</td><td>[24,64)</td></tr><tr><td>100</td><td>[56,128)</td></tr><tr><td>150</td><td>[120,256)</td></tr><tr><td>200</td><td>[248, 512)</td></tr><tr><td>250</td><td>[504,800)</td></tr><tr><td>300</td><td>[800,800]</td></tr></table>
326
+
327
+ Table 5: Backplay hyperparameters for Pommerman 100 maps.
328
+
329
+ <table><tr><td>Starting at training epoch</td><td>Uniformwindow</td></tr><tr><td>0</td><td>[0,32)</td></tr><tr><td>85</td><td>[24,64)</td></tr><tr><td>170</td><td>[56,128)</td></tr><tr><td>255</td><td>[120,256)</td></tr><tr><td>340</td><td>[248,512)</td></tr><tr><td>425</td><td>[504, 800)</td></tr><tr><td>510</td><td>[800,800]</td></tr></table>
330
+
331
+ # A.2 MAZE: DEMONSTRATION DETAILS
332
+
333
+ For N-Optimal demonstrations, we used a noisy $\mathbf { A } ^ { * }$ where at each step, we follow $\mathbf { A } ^ { * }$ with probability $p$ or choose a random action otherwise. We considered $N \in \{ 5 , 1 0 \}$ . In all scenarios, we only selected maps in which there exists at least a path from the the initial state to the goal state, we filtered any path that was less than 35 in length and stopped when we found a hundred valid training games. Note that we held the demonstration length invariant rather than the optimal length (i.e. all N-optimal paths have the same length regardless of N, which means that the length of the optimal path of a N-optimal demonstration decreases with N). This could explain why the results in Table 2 (column 1) show that Backplay’s performance increases with $_ \mathrm { N }$ (since the larger the N, the smaller the true optimal path, so the easier it is to learn an optimal policy for that maze configuration).
334
+
335
+ A.3 MAZE: NETWORK ARCHITECTURE AND TRAINING PARAMETERS
336
+
337
+ We use a standard deep RL setup for our agents. The agent’s policy and value functions are parameterized by a convolutional neural network with 2 layers each of 32 output channels, followed by two linear layers with 128 dimensions. Each of the layers are followed by ReLU activations. This body then feeds two heads, a scalar value function and a softmax policy function over the five actions. All of the CNN kernels are 3x3 with stride and padding of one.
338
+
339
+ We train our agent using Proximal Policy Optimization (PPO, Schulman et al. (2017)) with $\gamma = 0 . 9 9$ , learning rate $\mathrm { \check { 1 } } \times 1 0 ^ { - 3 }$ , batch size 102400, 60 parallel workers, clipping parameter 0.2, generalized advantage estimation with $\tau = 0 . 9 5$ , entropy coefficient 0.01, value loss coefficient 0.5, mini-batch size 5120, horizon 1707, and 4 PPO updates at each iteration. The number of interactions per epoch is equal to the batch size (102400).
340
+
341
+ The hyperparameters used for training the agent with Reverse Curriculum Generation (Florensa et al., 2017) are: $1 0 ^ { 4 }$ rollout states for nearby sampling, 50 Brownian steps, 200 samples from new starts, 100 samples from old starts, interval for the expected return [0.1, 0.9].
342
+
343
+ # A.4 MAZE: LEARNING CURVES
344
+
345
+ Below are our learning curves for the Maze challenge over five seeds. Note that we do not show any results for Standard as it failed to learn much of anything in the time allotted (3500 epochs). Also note that Backplay occasionally sees the actual grid starting position from epoch 1400, but it becomes the default starting state at epoch 1750. To align with this, our Florensa baseline switches to training from the actual start position at epoch 1750, and we show results for Uniform only over the initial starting state. Correspondingly, we show the graphs from epoch 1000 as all of the methods have commensurately poor results before that time.
346
+
347
+ ![](images/9683ae6ed274a6f5a198d8346d1fc4c297be1738c3474374ec9f07db24dcb867.jpg)
348
+ Figure 5. Maze results when training with demonstrations of length equal to the optimal path length. Note that Backplay has a very small variance and a very high success rate as early as epoch 1800. On the other hand, Florensa fails to break $70 \%$ and has a high variance, and Uniform doesn’t achieve a strong success rate until epoch 3000.
349
+
350
+ ![](images/6c9d50dd06c913c8b6a47a3e64624e2b4635303e1ce588f85fbb562e7dda40ba.jpg)
351
+ Figure 6. Maze results when training with demonstrations that are five steps longer than the optimal path length. Compared to the prior graph, Backplay doesn’t do as well, albeit it still performs favorably compared to Florensa, with a consistently higher expected return. Its advantage over Uniform is a reduced amount of necessary samples.
352
+
353
+ ![](images/27cbb6f8732e3a701353a515becbf95c1b3b9eddcd0f02bbed31cb4c37149d2e.jpg)
354
+ Figure 7. Maze results when training with demonstrations that are ten steps longer than the optimal path length. We again see that Backplay does very well compared to the Florensa baseline, with a much stronger expected return and lower variance. We also see, however, that Uniform is an able competitor to both of these as the expert becomes more suboptimal.
355
+
356
+ # A.5 POMMERMAN: OBSERVATION STATE
357
+
358
+ ![](images/1d4a42cfa8224d99a5d25bf7cf28bb43b8e5fda4938db59e2d2add13320321ab.jpg)
359
+ Figure 8. Pommerman start state. Each agent begins in one of four positions. Yellow squares are wood, brown are rigid, and gray are passages.
360
+
361
+ There are 19 feature maps that encompass each observation. They consist of the following: the agents’ identities and locations, the locations of the walls, power-ups, and bombs, the bombs’ blast strengths and remaining life counts, and the current time step.
362
+
363
+ The first map contains the integer values of each bomb’s blast strength at the location of that bomb. The second map is similar but the integer value is the bomb’s remaining life. At all other positions, the first two maps are zero. The next map is binary and contains a single one at the agent’s location. If the agent is dead, this map is zero everywhere. The following two maps are similar. One is full with the agent’s integer current bomb count, the other with its blast radius. We then have a full binary map that is one if the agent can kick and zero otherwise.
364
+
365
+ The next maps deal with the other agents. The first contains only ones if the agent has a teammate and zeros otherwise. This is useful for building agents that can play both team and solo matches. If the agent has a teammate, the next map is binary with a one at the teammate’s location (and zero if she is not alive). Otherwise, the agent has three enemies, so the next map contains the position of the enemy that started in the diagonally opposed corner from the agent. The following two maps contain the positions of the other two enemies, which are present in both solo and team games.
366
+
367
+ We then include eight feature maps representing the respective locations of passages, rigid walls, wooden walls, flames, extra-bomb power-ups, increase-blast-strength power-ups, and kicking-ability power-ups. All are binary with ones at the corresponding locations.
368
+
369
+ Finally, we include a full map with the float ratio of the current step to the total number of steps. This information is useful for distinguishing among observation states that are seemingly very similar, but in reality are very different because the game has a fixed ending step where the agent receives negative reward for not winning.
370
+
371
+ # A.6 POMMERMAN: NETWORK ARCHITECTURE AND TRAINING PARAMETERS
372
+
373
+ We use a similar setup to that used in the Maze game. The architecture differences are that we have an additional two convolutional layers at the beginning, use 256 output channels, and have output dimensions of 1024 and 512, respectively, for the linear layers. This architecture was not tuned at all duringrate of $3 \times 1 0 ^ { - 4 }$ of our experiments. Further hyperparameter differences are that wand a gamma of 1.0. These models trained for 72 hours, which is ${ \sim } 5 0 \mathrm { M }$ a learning frames. 2
374
+
375
+ ![](images/a92a40429cbdf3082c148b0c130b7d79543e398b569c02ef95298a350467e734.jpg)
376
+ Figure 9. Typical histograms for how the Pommerman action selections change over time. From left to right are the concatenated counts of the actions (Pass, Up, Down, Left, Right, Bomb), delineated on the y-axis by the epoch. Note how the Standard agent learns to not use bombs.
377
+
378
+ Pommerman can be difficult for reinforcement learning agents. The agent must learn to effectively wield the bomb action in order to win against competent opponents. However, bombs destroy agents indiscriminately, so placing one without knowing how to retreat often results in negative reward for that agent. Since agents begin in an isolated area, they are prone to converging to policies which do not use the bomb action (as seen in the histograms in Figure 9), which leads them to sub-optimal policies in the long-term.
379
+
380
+ # A.8 POMMERMAN: WIN RATES
381
+
382
+ Here we show the per-map win rates obtained by the agent trained with Backlpay on the 100 Pommerman maps.
383
+
384
+ <table><tr><td rowspan=1 colspan=1>Win</td><td rowspan=1 colspan=1>Maps</td></tr><tr><td rowspan=1 colspan=1>90%</td><td rowspan=1 colspan=1>24</td></tr><tr><td rowspan=1 colspan=1>80%</td><td rowspan=1 colspan=1>26</td></tr><tr><td rowspan=1 colspan=1>70%</td><td rowspan=1 colspan=1>6</td></tr><tr><td rowspan=1 colspan=1>60%</td><td rowspan=1 colspan=1>5</td></tr><tr><td rowspan=1 colspan=1>50%</td><td rowspan=1 colspan=1>5</td></tr></table>
385
+
386
+ Table 6: Aggregate per-map win rates of the model trained with Backplay on 100 Pommerman maps. The model was run over 5000 times in total, with at least 32 times on each of the 100 maps. The Maps column shows the number of maps on which the Backplay agent had a success rate of at least the percent in the Win column. Note that this model has a win rate of $> 8 0 \%$ on more than half of the maps and a win rate of $> 5 0 \%$ on all maps.
387
+
388
+ # A.9 PRACTICAL FINDINGS
389
+
390
+ We trained a large number of models through our research into Backplay. Though these findings are tangential to our main points (and are mainly qualitative), we list some observations here that may be helpful for other researchers working with Backplay.
391
+
392
+ First, we found that Backplay does not perform well when the curriculum is advanced too quickly, however it does not fail when the curriculum is advanced ‘too slowly.’ Thus, researchers interested in using Backplay should err on the side of advancing the window too slowly rather than too quickly.
393
+
394
+ Second, we found that Backplay does not need to hit a high success rate before advancing the starting state window. Initially, we tried using adaptive approaches that advanced the window when the agent reached a certain success threshold. This worked but was too slow. Our hypothesis is that what is more important is that the agent gets sufficiently exposed to enough states to attain a reasonable barometer of their value rather than that the agent learns a perfectly optimal policy for a particular set of starting states.
395
+
396
+ Third, Backplay can still recover if success goes to zero. This surprising and infrequent result occurred at the juncture where the window moved back to the initial state and even if the policy’s entropy over actions became maximal. We are unsure what differentiates these models from the ones that did not recover.
397
+
398
+ We also explored using DAgger (Ross et al. (2011)) for training our agent, but found that it achieved approximately the same win rate $( \sim 2 0 \% )$ ) as what we would expect when four FSMTS agents played each other (given that there are also ties).
md/train/HJBhEMbRb/HJBhEMbRb.md ADDED
@@ -0,0 +1,557 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A SPECTRAL APPROACH TO GENERALIZATION ANDOPTIMIZATION IN NEURAL NETWORKS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ The recent success of deep neural networks stems from their ability to generalize well on real data; however, Zhang et al. (Zhang et al., 2016) have observed that neural networks can easily overfit random labels. This observation demonstrates that with the existing theory, we cannot adequately explain why gradient methods can find generalizable solutions for neural networks. In this work, we use a Fourierbased approach to study the generalization properties of gradient-based methods over 2-layer neural networks with sinusoidal activation functions. We prove that if the underlying distribution of data has nice spectral properties such as bandlimitedness, then the gradient descent method will converge to generalizable local minima. We also establish a Fourier-based generalization bound for bandlimited spaces, which generalizes to other activation functions. Our generalization bound motivates a grouped version of path norms for measuring the complexity of 2-layer neural networks with ReLU activation functions. We demonstrate numerically that regularization of this group path norm results in neural network solutions that can fit true labels without losing test accuracy while not overfitting random labels.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Deep neural networks (DNNs) have achieved state-of-the-art performance on a wide array of diverse tasks (LeCun et al., 2015). A given DNN architecture represents a highly rich space of hypotheses. However, numerous empirical results have demonstrated that a simple stochastic gradient descent (SGD) learner can efficiently search over this space to find a solution that achieves high performance on both training and test data. Despite many successful applications of DNNs to practical tasks such as computer vision (Krizhevsky et al., 2012), natural language processing (Collobert & Weston, 2008) and speech recognition (Hinton et al., 2012), our basic understanding of the factors that drive DNN generalization is still lacking.
12
+
13
+ Addressing generalization for DNNs is hard for two fundamental reasons: 1) Empirical risk minimization for neural networks is a non-convex optimization problem with possibly many local minima, and 2) Two different local minima with the same training performance can achieve significantly different performance on test data. For these reasons, the neural network optimization method plays an important role in the generalizability of the local minima found. For example, SGD has been empirically shown to outperform large-batch gradient descent (Keskar et al., 2016). Also, the performance of gradient methods can be improved upon by incorporating the geometry of observed data (Duchi et al., 2011; Neyshabur et al., 2015a).
14
+
15
+ For DNNs, however, a good optimization method is not sufficient for guaranteeing good generalization. Zhang et al. (Zhang et al., 2016) empirically demonstrate that a neural network trained by SGD can easily overfit random labels on the CIFAR-10 (Krizhevsky & Hinton, 2009) data. Yet, the same neural network fitted by the same SGD algorithm achieves good generalization performance for the original CIFAR-10 labels. This observation challenges the ability of traditional learning theory to explain why SGD learns generalizable hypotheses over neural networks. To shed light on this phenomenon, two recent works have developed generalization bounds and complexity measures for neural networks which can distinguish the local minima found for true and random labels. (Bartlett et al., 2017) proves a margin-based generalization bound and shows how it correlates with the generalization risk of DNNs when fitting true and random labels. (Neyshabur et al., 2017) explores different complexity scores for DNNs and how they behave differently for true and random labels. The complexity measures investigated in these works can effectively distinguish generalizable from poorly-generalizable local minima. They do not explain, however, why SGD converges to generalizable local minima when there exist poorly-generalizable local minima which can also perfectly fit the training set.
16
+
17
+ ![](images/eae1e91408a7d3edf31f6a8267c65fa3430e2b118f63f5b6bee8650d1cc10a30.jpg)
18
+ Figure 1: (a) A 2-layer neural network with activation function $\phi$ , (b) Training and test accuracy on CIFAR10 with true and random labels on a 2-layer neural network with 512 ReLU hidden units, regularized with an additive penalty: (b1) no penalty, (b2) $\ell _ { 2 }$ -norm, (b3) $\chi _ { 2 }$ -group path norm, (b4) $\ell _ { 1 }$ -path norm. The $\chi _ { 2 }$ -group path norm and $\ell _ { 1 }$ -path norm were successful to close the generalization gap for both true and random labels.
19
+
20
+ To approach this question, one needs to understand the key characteristic of CIFAR-10’s original labeling which differentiates it from random labels and how it is exploited by SGD to achieve good generalization performance. In this work, we approach this problem in the Fourier domain where non-random labeling schemes behave completely differently from random labeling schemes. While signals recoverable from few measurements possess nice spectral properties such as bandlimitedness, fully random stochastic processes are not bandlimited and not recoverable from any finite number of measurements.
21
+
22
+ Using spectral analysis, we focus on characterizing spectral properties of an underlying distribution which can be exploited by gradient-based methods to converge to generalizable local minima. We address this problem for 2-layer neural networks (see Figure 1a) with sinusoidal activation functions, where we show that if the underlying labeling scheme has limited bandwidth and Fourier $\ell _ { 1 }$ -norm (i.e. "nice" Fourier properties), we expect a gradient-based method to achieve good generalization performance. To arrive at this result, we first develop a Fourier-based generalization bound for 2-layer neural networks in terms of bandwidth and Fourier $\ell _ { 1 }$ -norm. Next, we prove that the local minima found by the gradient descent method over a 2-layer neural network with sine activation have bandwidth and Fourier $\ell _ { 1 }$ -norm bounded in terms of the spectral properties of the underlying labeling scheme.
23
+
24
+ As a byproduct of our Fourier analysis, we derive generalization bounds for 2-layer neural networks with general activation functions. For bandlimited activation functions with finite Fourier $\ell _ { 1 }$ -norm, such as sinusoidal or Gaussian activation1, our bound is tighter than the generalization bound obtained using only the Lipschitz constant of the activation function. For ReLU-type activation functions, our generalization bound is comparable to Lipschitz-based bounds; however, it leads to a grouped version of the path norms developed in (Neyshabur et al., 2015a). We therefore call this capacity norm group path norm which can be used as an additive penalty to regularize 2-layer neural networks with ReLU activation. Our numerical experiments suggest that the generalization gap can be effectively tightened by regularizing the group path norm. Figure 1b demonstrates how group path norm regularization can help close the generalization gap for both true and random labels.
25
+
26
+ # 2 RELATED WORK
27
+
28
+ Generalization has been a topic of central interest in statistical learning theory (Vapnik, 1999; ShalevShwartz & Ben-David, 2014). Generalization bounds have been derived using the stability of a learning algorithm (Bousquet & Elisseeff, 2002) and various complexity measures of a function space such as VC-dimension (Vapnik, 2013) and Rademacher complexity (Bartlett & Mendelson, 2002). (Hardt et al., 2015) develops a stability-based generalization result for SGD as the learning algorithm, which holds for both convex and non-convex loss functions.
29
+
30
+ We note that spectral analysis has provided a powerful framework for studying neural networks. (Barron, 1993) uses a Fourier-based approach to prove the universal approximation theorem for 2-layer neural networks. Similarly, (Lee et al., 2017) applies Fourier analysis to extend Barron’s result to a general feedforward neural network. (Rippel et al., 2015) uses a spectral approach to model and analyze convolutional neural networks (CNNs) and introduce the spectral pooling scheme for CNNs. Also, our Fourier-based approach to analyze SGD’s performance for 2-layer neural networks follows the same prinicples as the analysis performed in (Shamir, 2016) to prove the hardness of fitting periodic labeling schemes via gradient-based methods. We should note that in this work we use only periodic activation functions and not periodic labeling schemes. Therefore, the hardness result shown in (Shamir, 2016) does not affect our numerical experiments.
31
+
32
+ In general, theoretical studies of neural networks can be categorized into three main categories: 1) Approximation: Neural networks have been proven to be powerful in expressing a very rich class of functions (Cybenko, 1989) and in general deeper networks need fewer neurons to express the same class of functions (Eldan & Shamir, 2016; Liang & Srikant, 2016). 2) Generalization: Tight bounds have been shown on the VC dimesnion of feedforward neural networks (Anthony & Bartlett, 2009; Harvey et al., 2017). Also, norm-based Rademacher complexity bounds have been developed at (Bartlett & Mendelson, 2002; Neyshabur et al., 2015b). Sharpness of local minima and its connection to their generalizibility have been the focus of several recent works (Keskar et al., 2016; Dinh et al., 2017; Neyshabur et al., 2017) 3) Optimization: theoretical studies have shown both positive (Andoni et al., 2014; Daniely, 2017) and negative (Shalev-Shwartz et al., 2017) results about the performance of gradient-based methods in training neural networks.
33
+
34
+ # 3 PRELIMINARIES
35
+
36
+ # 3.1 SUPERVISED LEARNING AND GENERALIZATION
37
+
38
+ Suppose that we are given $n$ samples $( { \bf x } _ { i } , y _ { i } ) _ { i = 1 } ^ { n }$ drawn i.i.d. from a population distribution $P _ { \mathbf { X } , Y }$ Here $\mathbf { X }$ denotes the random vector of features and $Y$ denotes the target variable. Using these $n$ samples, the goal of a supervised learner is to find a prediction rule $f$ from a function space $\mathcal { F }$ which can predict $Y$ for an unseen test sample $\mathbf { X }$ . Therefore, given loss function $\ell$ the supervised learner wants to find $f ^ { * } \in { \mathcal { F } }$ minimizing the population risk, defined as $\mathbb { E } \big [ \ell \big ( f ( \mathbf { X } ) , Y \big ) \big ]$ averaged under the population distribution.
39
+
40
+ However, the supervised learner does not know the population distribution $P _ { \mathbf { X } , Y }$ and has only access to the $n$ training samples. The supervised learner can minimize the empirical risk, defined as $\textstyle 1 / n \sum _ { i = 1 } ^ { n } \ell \bigl ( f ( \mathbf { x } _ { i } ) , \mathbf { \bar { y } } _ { i } \bigr )$ and find $f _ { n } ^ { \mathrm { e m p } }$ . Since we only observe a limited number of samples, the empirical risk would be different from the population risk. The generalization risk, defined for $f \in { \mathcal { F } }$ as $\begin{array} { r l } { } & { { \mathbb E } [ \ell ( f ( \mathbf { X } ) , Y ) ] - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \ell ( f ( \mathbf { x } _ { i } ) , y _ { i } ) } \end{array}$ , is the difference among the population risk and empirical risk for $f$ . Studying the behavior of $f _ { n } ^ { \mathrm { e m p } }$ ’s generalization risk for different function spaces and learning algorithms is a topic of central interest in statistical learning theory.
41
+
42
+ # 3.2 FOURIER TRANSFORM AND BANDLIMITED FUNCTIONS
43
+
44
+ Consider a real-valued function $f : \mathbb { R } ^ { k } \mathbb { R }$ . The Fourier transform of this function, which we denote by $\hat { f }$ , is defined as
45
+
46
+ $$
47
+ { \widehat { f } } ( \pmb { \xi } ) = \int f ( \mathbf { x } ) \exp \left( - 2 \pi i \pmb { \xi } ^ { T } \mathbf { x } \right) \mathrm { d } \mathbf { x } .
48
+ $$
49
+
50
+ Some important examples of Fourier transform are:
51
+
52
+ • Sinusoidal function: $f ( \mathbf { x } ) = \exp ( 2 \pi i \omega ^ { T } \mathbf { x } )$ , then ${ \widehat { f } } ( \pmb { \xi } ) = \delta ( \pmb { \xi } - \omega )$ where $\delta$ denotes the Dirac delta function, which also implies
53
+
54
+ • Gaussian function: $f ( \mathbf { x } ) = ( \sqrt { 2 \pi } \sigma ) ^ { k } \exp \bigl ( - \| \mathbf { x } \| _ { 2 } ^ { 2 } / 2 \sigma ^ { 2 } \bigr )$ , then $\widehat { f } ( \pmb { \xi } ) = \exp \left( - \sigma ^ { 2 } \| \pmb { \xi } \| _ { 2 } ^ { 2 } / 2 \right)$ . Thus, the Fourier transform of a Gaussian function preserves the Gaussian shape.
55
+
56
+ A function $f$ is called $B$ -bandlimited if ${ \widehat { f } } ( \pmb { \xi } ) = 0$ for every $\boldsymbol { \xi }$ where $\| { \pmb \xi } \| _ { 2 } > B$ . The smallest $B$ for which this property holds is called the bandwidth of $f$ . We use $B ( f )$ to denote the bandwidth of function $f$ . We also use $\| { \widehat { f } } \| _ { 1 }$ to denote the $\ell _ { 1 }$ -norm of $f$ ’s Fourier transform,
57
+
58
+ $$
59
+ \| { \widehat { f } } \| _ { 1 } = \int | { \widehat { f } } ( \pmb { \xi } ) | \mathrm { d } \pmb { \xi }
60
+ $$
61
+
62
+ which we call the Fourier $\ell _ { 1 }$ -norm of $f$ . Fourier $\ell _ { 1 }$ -norm can be interpreted as the absolute volume under $f$ ’s Fourier transform, and is an approximate measure of $\widehat { f }$ ’s sparsity. Fourier $\ell _ { 1 }$ -norm is both scale and shift invariant, i.e. if we define $g ( \mathbf { x } ) = f ( \mathbf { W } \mathbf { x } + \mathbf { b } )$ for a real-valued $f$ and $\mathbf { W } \in \mathbb { R } ^ { r \times k }$ and $\mathbf { b } \in \mathbb { R } ^ { r }$ for some $r \leq k$ , then $\| { \widehat { g } } \| _ { 1 } = \| { \widehat { f } } \| _ { 1 }$ . Some other useful properties of Fourier transform are:
63
+
64
+ • Synthesis: $\begin{array} { r } { f ( \mathbf { x } ) = \int \widehat { f } ( \pmb { \xi } ) \exp \left( 2 \pi i \pmb { \xi } ^ { T } \mathbf { x } \right) \mathrm { d } \pmb { \xi } } \end{array}$ , which also implies $\| { \widehat { f } } \| _ { 1 } = f ( 0 )$ if $\widehat { f }$ is real and non-negative.
65
+ • Shift: $\widehat { f } _ { \mathbf { b } } ( \pmb { \xi } ) = \exp ( 2 \pi i \mathbf { b } ^ { T } \pmb { \xi } ) \widehat { f } ( \pmb { \xi } )$ where $f _ { \mathbf { b } } ( \mathbf { x } ) : = f ( \mathbf { x } - \mathbf { b } )$ , which implies $\| { \widehat { f _ { \mathbf { b } } } } \| _ { 1 } = \| { \widehat { f } } \| _ { 1 }$ and $B ( f _ { \mathbf { b } } ) = B ( f )$ .
66
+ • Derivative: ${ \widehat { \nabla f } } ( \pmb { \xi } ) = 2 \pi i ~ { \widehat { f } } ( \pmb { \xi } ) \pmb { \xi }$ , where $\nabla f$ denotes the gradient of $f$ .
67
+ • Isometry: $\begin{array} { r } { \int f ( \mathbf { x } ) \overline { { g ( \mathbf { x } ) } } \mathrm { d } \mathbf { x } = \int \widehat { f } ( \pmb { \xi } ) \overline { { \widehat { g } ( \pmb { \xi } ) } } \mathrm { d } \pmb { \xi } } \end{array}$ where $\overline { z }$ denotes the complex conjugate of $z$ .
68
+ • Convolution: $\widehat { f g } = \widehat { f } \star \widehat { g }$ where $\star$ denotes the convolution operator i.e. ${ \widehat { f } } \star { \widehat { g } } ( \xi ) : = $ $\begin{array} { r } { \int \widehat { f } ( \pmb { \eta } ) \widehat { g } ( \pmb { \xi } - \pmb { \eta } ) \mathrm { d } \pmb { \eta } } \end{array}$ . Therefore, $B ( f g ) \le B ( f ) + B ( g )$ and $\| \widehat { f g } \| _ { 1 } \leq \| \widehat { f } \| _ { 1 } \| \widehat { g } \| _ { 1 }$ .
69
+
70
+ # 4 A FOURIER-BASED GENERALIZATION BOUND
71
+
72
+ Consider a supervised learning task with n training samples xi, yini=1 and function space $\mathcal { F }$ . We are interested in uniform convergence bounds on the generalization risk. A standard approach to bound the generalization risk is based on the notion of Rademacher complexity. Given samples $\left( \mathbf { x } _ { i } , y _ { i } \right) _ { i = 1 } ^ { n }$ , the empirical Rademacher complexity of $\mathcal { F }$ is defined as
73
+
74
+ $$
75
+ \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } ) : = \mathbb { E } _ { \pmb { \sigma } } \bigg [ \operatorname* { s u p } _ { f \in \mathcal { F } } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \sigma _ { i } f ( \mathbf { x } _ { i } ) \bigg ]
76
+ $$
77
+
78
+ where $\sigma _ { i }$ ’s are i.i.d. random variables uniformly distributed over $\{ - 1 , + 1 \}$ . In fact, the Rademacher complexity of $\mathcal { F }$ measures how well $\mathcal { F }$ can fit some random labels over input $\mathbf { x } _ { i }$ ’s. The following result shows how to bound the generalization risk over $\mathcal { F }$ through its Rademacher complexity.
79
+
80
+ Theorem 1 (Bartlett & Mendelson (2002)). Consider a $\rho$ -Lipschitz loss function $\ell ( f ( \mathbf { x } ) , y )$ bounded as $| \ell ( z , y ) | \leq c .$ . Then, for any $\delta > 0$ , with probability at least $1 - \delta$
81
+
82
+ $$
83
+ \forall f \in \mathcal { F } : \quad \mathbb { E } \big [ \ell ( f ( \mathbf { X } ) , Y ) \big ] - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \ell ( f ( \mathbf { x } _ { i } ) , y _ { i } ) \leq 2 \rho \mathcal { R } _ { n } ^ { \mathrm { e n p } } ( \mathcal { F } ) + 4 c \sqrt { \frac { 2 \log ( 4 / \delta ) } { n } } .
84
+ $$
85
+
86
+ Since the Rademacher complexity of norm-bounded linear functions can be appropriately bounded (Kakade et al., 2009), one can effectively apply Theorem 1 to bound generalization risk over normbounded linear functions. To use Theorem 1 in the Fourier domain, here we provide a Rademacher complexity bound for bandlimited functions with bounded Fourier $\ell _ { 1 }$ -norm. We apply the following Rademacher complexity bound to bound generalization risk for 2-layer neural networks in Section 5, and also to analyze the performance of gradient-based methods with sinusoidal activation functions in Section 6.
87
+
88
+ Theorem 2. Consider function space $\mathcal { F } = \{ \boldsymbol { f } : \mathbb { R } ^ { k } \mathbb { R } $ s.t. $B ( f ) \leq B , \| { \widehat { f } } \| _ { 1 } \leq V \}$ of $B$ - bandlimited functions with $V$ -bounded Fourier $\mathbf { \dot { \ell } } _ { 1 }$ -norm. Then, the empirical Rademacher complexity for samples $( { \bf x } _ { i } , y _ { i } ) _ { i = 1 } ^ { n }$ is bounded as
89
+
90
+ $$
91
+ \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } ) \leq V \sqrt { \frac { 4 k \log \left( 6 4 n B \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } \right) } { n } } .
92
+ $$
93
+
94
+ Proof. We defer the proof to the Appendix.
95
+
96
+ Corollary 1. Assume that $\| \mathbf { X } \| _ { 2 } \leq C$ holds almost surely and the loss function $\ell$ is $\rho$ -Lipschitz. Then, for any $\delta > 0$ with probability at least $1 - \delta$ the following generalization bound holds for any $B$ -bandlimited function $f$ with $V$ -bounded Fourier $\ell _ { 1 }$ -norm:
97
+
98
+ $$
99
+ \mathbb { E } \big [ \ell ( f ( \mathbf { X } ) , Y ) \big ] - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \ell ( f ( \mathbf { x } _ { i } ) , y _ { i } ) \leq O \bigg ( \rho V \sqrt { \frac { k \log ( n B C / \delta ) } { n } } \bigg ) .
100
+ $$
101
+
102
+ Proof. The corrollary is a direct result of applying the bound in Theorem 2 to Theorem 1.
103
+
104
+ The above corollary bounds the generalization risk uniformly over all bandlimited $f$ ’s such that $B ( f ) \le B$ and $\| { \widehat { f } } \| _ { 1 } \leq V$ . Next, we apply the above results to 2-layer neural networks.
105
+
106
+ # 5 APPLICATION OF THEOREM 2 TO 2-LAYER NEURAL NETWORKS
107
+
108
+ Consider a 2-layer neural network including $d$ neurons with activation function $\phi$ in the hidden layer (See Figure 1a). The output of this neural network is
109
+
110
+ $$
111
+ f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { x } ) = \mathbf { a } ^ { T } \phi ( \mathbf { W } \mathbf { x } + \mathbf { b } ) .
112
+ $$
113
+
114
+ If $\phi$ has bounded bandwidth and Fourier $\ell _ { 1 }$ -norm, we can apply Theorem 2 to bound the Rademacher complexity and hence generalization risk over the 2-layer neural network. Here, we use $\| \mathbf { W } \| _ { 2 , \infty }$ to denote the maximum $\ell _ { 2 }$ -norm $\left\| \mathbf { w } _ { i } \right\| _ { 2 }$ among all rows of $\mathbf { W }$ .
115
+
116
+ Corollary 2. Let $\mathcal { F } _ { \phi } = \left\{ f ( \mathbf { x } ) = \mathbf { a } ^ { T } \phi ( \mathbf { W } \mathbf { x } + \mathbf { b } ) : ~ \| \mathbf { W } \| _ { 2 , \infty } \leq W , ~ \| \mathbf { a } \| _ { 1 } \leq A \right\}$ be the class of 2-layer neural networks where $B ( \phi ) = B$ and $\| \widehat { \phi } \| _ { 1 } = V$ . Then, the empirical Rademacher complexity of $\mathcal { F } _ { \phi }$ for samples $( { \bf x } _ { i } , y _ { i } ) _ { i = 1 } ^ { n }$ is bounded as follows
117
+
118
+ $$
119
+ \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } _ { \phi } ) \leq O \biggl ( A V \sqrt { \frac { k \log \bigl ( n B W \operatorname* { m a x } \| \mathbf { x } _ { i } \| _ { 2 } \bigr ) } { n } } \biggr ) .
120
+ $$
121
+
122
+ Proof. We defer the proof to the Appendix.
123
+
124
+ Notice that for bandlimited activation functions with bounded Fourier $\ell _ { 1 }$ -norm, the above generalization bound is increasing logarithmically with $\| \mathbf { W } \| _ { 2 , \infty }$ . For example, this result holds for sinusoidal activation $\phi ( x ) = \sin ( 2 \pi x )$ where $\| \widehat { \phi } \| _ { 1 } = 1$ , $B ( \phi ) = 1$ . On the other hand, the existing Rademacher complexity bounds which use only the Lipschitz constant of the activation function are linear in W’s norm (Bartlett & Mendelson, 2002). Therefore, by exploiting the spectral properties of $\phi$ , Corollary 2 results in a tighter generalization bound than the bounds using only the Lipschitz constant of $\phi$ .
125
+
126
+ However, an unbounded function such as ReLU $\phi ( x ) = \operatorname* { m a x } ( x , 0 )$ has an infinite Fourier $\ell _ { 1 }$ -norm. Therefore, Corollary 2 does not directly apply to these functions. The following theorem uses a boundedness assumption on input $\mathbf { X }$ to apply Theorem 2 to ReLU-type activation functions. Although the following bound is growing faster than logarithmically with W’s norm, it introduces new capacity norms for 2-layer ReLU-based networks.
127
+
128
+ Theorem 3. Suppose that $\phi _ { \alpha } ( x ) = \operatorname* { m a x } \{ x , \alpha x \}$ where $\alpha \in [ 0 , 1 ]$ is an arbitrary constant. Consider the pair of dual norms $( \| \cdot \| _ { p } , \| \cdot \| _ { q } )$ where $1 \leq p , q \leq \infty$ and $1 / p + 1 / q = 1$ . Assume that $\| \mathbf { x } _ { i } \| _ { p } \leq C$ holds for all $\mathbf { x } _ { i } \mathbf { \ ' } _ { s . }$ . Then, for $\begin{array} { r } { \mathcal { F } _ { \phi _ { \alpha } } = \left\{ f _ { \mathbf { a } , \mathbf { W } } ( \mathbf { x } ) = \mathbf { a } ^ { T } \phi _ { \alpha } ( \mathbf { W } \mathbf { x } ) : \sum _ { i = 1 } ^ { d } | a _ { i } | \| \mathbf { w } _ { i } \| _ { q } \leq V \right\} } \end{array}$
129
+
130
+ $$
131
+ \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } _ { \phi _ { \alpha } } ) \leq O \bigg ( V C \sqrt { \frac { k \log ( n k C ) } { n } } \bigg ) .
132
+ $$
133
+
134
+ Proof. We relegate the proof to the Appendix.
135
+
136
+ The above bound uses the complexity score $\begin{array} { r } { \sum _ { i = 1 } ^ { d } | a _ { i } | \| \mathbf { w } _ { i } \| _ { q } } \end{array}$ for each $f _ { \mathbf { a } , \mathbf { W } } ( \mathbf { x } ) = \mathbf { a } ^ { T } \phi _ { \alpha } ( \mathbf { W } \mathbf { x } )$ . We can rewrite this complexity score in the following way, which is an $\ell _ { 1 , q }$ -group norm on the product of weights for each path from the input nodes to the output node of the 2-layer neural network,
137
+
138
+ $$
139
+ \chi _ { q } \big ( f _ { \mathbf { a } , \mathbf { W } } \big ) = \sum _ { i = 1 } ^ { d } \biggl ( \sum _ { j = 1 } ^ { k } \bigl ( | a _ { i } | | w _ { i , j } | \bigr ) ^ { q } \biggr ) ^ { 1 / q } .
140
+ $$
141
+
142
+ Here $w _ { i , j }$ denotes the weight on the link from the $j$ th node of the input layer to the ith node of the hidden layer. Based on the path-norm function defined at (Neyshabur et al., 2015a), we call $\chi _ { q } \left( f _ { \mathbf { a } , \mathbf { w } } \right)$ the group path norm. For $q = 1$ , $\chi _ { 1 }$ -group path norm leads to the $\ell _ { 1 }$ -path norm for 2-layer neural networks. We can use group path norms as an additive regularization penalty to learn over 2-layer neural networks. In our numerical experiments, we test the performance of $\chi _ { 2 }$ -group path norm and $\ell _ { 1 }$ -path norm regularization to control the generalization risk over 2-layer neural networks.
143
+
144
+ # 6 FOURIER ANALYSIS OF GRADIENT-BASED METHODS FOR 2-LAYER NEURAL NETWORKS WITH SINE ACTIVATION
145
+
146
+ In this section, we apply Fourier analysis for a 2-layer neural network with sinusoidal activation. We aim to understand the connection between generalizibility of local minima found by gradient-based methods and spectral properties of the population distribution $P _ { \mathbf { X } , Y }$ . As a simplifying assumption, let’s assume that target variable $Y$ is a deterministic function $Y ( \mathbf { \dot { x } } )$ of input $\mathbf { X }$ , which we call the labeling scheme. In our analysis, we consider the squared-error loss $\ell ( y , y ^ { \prime } ) = ( y - y ^ { \prime } ) ^ { 2 }$ .
147
+
148
+ We specifically ask this question: how can spectral properties of labeling scheme $Y ( \mathbf { x } )$ and population density function $P _ { \mathbf { X } } ( \mathbf { x } )$ affect the generalization performance of a gradient-based method? To address this question, we use a similar strategy to the analysis performed in (Mei et al., 2016) by establishing generalization results for both the empirical risk and the gradient of empirical risk. First, we show that the bandwidth and Fourier $\ell _ { 1 }$ -norm for the local minima of the population risk can be bounded in terms of the bandwidth and Fourier $\ell _ { 1 }$ -norm of $Y ( \mathbf { x } )$ and $P _ { \mathbf { X } } ( \mathbf { x } )$ . Next, we establish a generalization result for the gradient of the empirical risk, proving that the gradient of empirical risk would stay close to the gradient of population risk given that $Y ( \mathbf { x } )$ has limited bandwidth and Fourier $\ell _ { 1 }$ -norm. These two results show that by assuming a labeling scheme with limited bandwidth and Fourier $\ell _ { 1 }$ -norm, the local minima found by the gradient descent (in general large-batch gradient descent) method will generalize well.
149
+
150
+ # 6.1 POPULATION RISK WITH SINUSOIDAL ACTIVATION
151
+
152
+ Consider sinusoida $\begin{array} { r } { f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { x } ) = \sum _ { j = 1 } ^ { d } a _ { j } \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { x } + b _ { j } ) } \end{array}$ ing from a 2-layer neural network with the population risk will be $d$ $Y ( \mathbf { x } )$
153
+
154
+ $$
155
+ \mathbb { E } _ { P _ { \mathbf { X } } } \left[ \ell \big ( f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { x } ) , Y ( \mathbf { x } ) \big ) \right] = \mathbb { E } _ { P _ { \mathbf { X } } } \big [ \big ( Y ( \mathbf { x } ) - \sum _ { j = 1 } ^ { d } a _ { j } \mathrm { s i n } ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { x } + b _ { j } ) \big ) ^ { 2 } \big ] ,
156
+ $$
157
+
158
+ where the expectation is according to the population density function $P _ { \mathbf { X } } ( \mathbf { x } )$ .
159
+
160
+ Lemma 1. Consider the population risk in (11). Assume $\mathbf { w } _ { j }$ satisfies $\forall i \neq j : \operatorname* { m i n } \{ \| \mathbf { w } _ { i } - { }$ $\mathbf { w } _ { j } \| _ { 2 } , \| \mathbf { w } _ { i } + \mathbf { w } _ { j } \| _ { 2 } \big \} > B ( P _ { \mathbf { X } } )$ . Then, $i f ( \mathbf { a } , \mathbf { W } , \mathbf { b } )$ is assumed to be a local minimum of the population risk,
161
+
162
+ $$
163
+ \big | a _ { j } \big | \leq 2 \big | \widehat { Y } \star \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { j } ) \big | .
164
+ $$
165
+
166
+ Proof. We defer the proof to the Appendix.
167
+
168
+ Lemma 1 says that if the component $a _ { j } \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { x } )$ becomes isolated for a local minimum, by which we mean there are no other component $a _ { i } \sin ( 2 \pi \mathbf { w } _ { i } ^ { T } \mathbf { x } )$ with $\operatorname* { m i n } \{ \| \mathbf { w } _ { i } - \mathbf { w } _ { j } \| _ { 2 } , \| \mathbf { w } _ { i } + \mathbf { w } _ { j } \| _ { 2 } \}$ less than $P _ { \mathbf { X } }$ ’s bandwidth, then the value of $a _ { j }$ for that local minimum is nicely bounded in terms of the population distribution. This result leads to the following Theorem which describes the Fourier properties of the local minima of the population risk.
169
+
170
+ Theorem 4. Consider the minimization problem of the population risk (11). If a local minimum $( \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } )$ satisfies the isolated components condition, i.e. for any two different $i , j$ we have $\operatorname* { m i n } \bigl \{ \| \mathbf { w } _ { i } ^ { * } - \mathbf { w } _ { j } ^ { * } \| _ { 2 } , \| \mathbf { w } _ { i } ^ { * } + \mathbf { w } _ { j } ^ { * } \| _ { 2 } \bigr \} > 2 B ( P _ { \mathbf { X } } )$ , then for the local minimum function $f _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } }$
171
+
172
+ $$
173
+ \begin{array} { r l } & { \bullet \mathcal { B } ( f _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } } ) \leq \mathcal { B } ( Y ) + \mathcal { B } ( P _ { \mathbf { X } } ) , } \\ & { \bullet \| \widehat { f } _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } } \| _ { 1 } \leq 2 \| \widehat { Y } \| _ { 1 } . } \end{array}
174
+ $$
175
+
176
+ Proof. We defer the proof to the Appendix.
177
+
178
+ Theorem 4 implies that the bandwidth of the local minima of the population risk is less than the sum of bandwidths for $Y$ and $P _ { \mathbf { X } }$ . Also, the Fourier $\ell _ { 1 }$ -norm for the local minima of the population distribution is bounded by twice the Fourier $\ell _ { 1 }$ -norm of $Y$ .
179
+
180
+ Remark 1. To apply Theorem 4, the bandwidth of $P _ { \mathbf { X } }$ needs to be smaller than half the distance among $\mathbf { w } _ { i } ^ { * }$ ’s. For example, suppose that $\mathbf { X } \sim { \mathcal { N } } ( { \pmb { \mu } } , \sigma ^ { 2 } \mathbf { I } _ { k \times k } )$ has a multivariate Gaussian distribution with mean $\pmb { \mu }$ and diagonal covariance matrix with standard deviation $\sigma$ . Then, the above theorem shows that if for any $i , j$ we have $\operatorname* { m i n } \bigr \{ \| \mathbf { w } _ { i } ^ { * } - \mathbf { w } _ { j } ^ { * } \| _ { 2 } , \| \mathbf { w } _ { i } ^ { * } + \mathbf { w } _ { j } ^ { * } \| _ { 2 } \bigr \} > 2 C / \sigma$ for some constant $C$ then
181
+
182
+ $$
183
+ \begin{array} { r l } & { \bullet \mathcal { B } ( f _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } } ) \leq \mathcal { B } ( Y ) + O \big ( \sqrt { k } / \sigma \big ) , } \\ & { \bullet \| \widehat { f } _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } } \| _ { 1 } \leq 2 ( 1 + d \exp ( - C ^ { 2 } / 2 ) ) \| \widehat { Y } \| _ { 1 } . } \end{array}
184
+ $$
185
+
186
+ Proof. See the proof of Theorem 4 in the Appendix.
187
+
188
+ # 6.2 GENERALIZATION TO THE EMPIRICAL RISK
189
+
190
+ Theorem 4 characterizes the Fourier properties of the local minima for the population risk. However, we want to investigate the generalization performance of the local minima of the empirical risk defined for training samples $\mathbf { \bar { \rho } } ( \mathbf { x } _ { i } , Y ( \mathbf { x } _ { i } ) ) _ { i = 1 } ^ { n }$ as
191
+
192
+ $$
193
+ \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \ell \big ( f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { x } _ { i } ) , Y ( \mathbf { x } _ { i } ) \big ) = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \bigg ( Y ( \mathbf { x } _ { i } ) - \sum _ { j = 1 } ^ { d } a _ { j } \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { x } _ { i } + b _ { j } ) \bigg ) ^ { 2 } .
194
+ $$
195
+
196
+ To address this question, note that the bandwidth and Fourier $\ell _ { 1 }$ -norm of the loss’s gradient with respect to each $a _ { j }$ are bounded in terms of the bandwidth and Fourier $\ell _ { 1 }$ -norm of $Y ( \mathbf { x } )$ as
197
+
198
+ $$
199
+ \begin{array} { r l } & { \quad \big \| \nabla _ { a _ { j } } \ell \big ( \widehat { f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } } ( \mathbf { x } ) , Y ( \mathbf { x } ) \big ) \big \| _ { 1 } \leq \| \widehat { Y } \| _ { 1 } + \| \mathbf { a } \| _ { 1 } , } \\ & { \mathcal { B } \big ( \nabla _ { a _ { j } } \ell \big ( f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { x } ) , Y ( \mathbf { x } ) \big ) \big ) \leq \mathcal { B } ( Y ) + 2 \| \mathbf { W } \| _ { 2 , \infty } . } \end{array}
200
+ $$
201
+
202
+ We can apply Corollary 1 to show that not only the empirical risk uniformly converges to the population risk but also the gradient of the empirical risk will stay close to the gradient of the population risk.
203
+
204
+ Corollary 3. Consider $\begin{array} { r } { f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { x } ) = \sum _ { j = 1 } ^ { d } a _ { j } \sin ( \mathbf { w } _ { j } ^ { T } \mathbf { x } + b _ { j } ) } \end{array}$ and squared error loss \`. Then, given that $\| \mathbf { X } \| _ { 2 } \leq C$ , for any $\delta > 0$ with probability at least $1 - \delta$ we have
205
+
206
+ $\forall j , \mathbf { a } , \mathbf { W } , \mathbf { b }$ s.t. $\| \mathbf { a } \| _ { 1 } + \| { \widehat { Y } } \| _ { 1 } \leq V , \ 2 \| \mathbf { W } \| _ { 2 , \infty } + B ( Y ) \leq B \ :$
207
+
208
+ $$
209
+ \begin{array} { r l } & { \displaystyle \mathbb { E } [ \nabla _ { a _ { j } } \ell ( f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { X } ) , Y ( \mathbf { X } ) ) ) ] - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } [ \nabla _ { a _ { j } } \ell ( f _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { x } _ { i } ) , Y ( \mathbf { x } _ { i } ) ) ) ] \Big \vert \leq O \big ( V \sqrt { \frac { k \log ( n B C / \delta ) } { n } } \big ) . } \end{array}
210
+ $$
211
+
212
+ Proof. The corollary is a direct result of Corollary (1) given (14) and (15). Note that the generalization bound holds with probability $1 - \delta$ for the derivative with respect to all $a _ { j }$ ’s, since the bounds in (14) and (15) hold for all $j$ ’s. □
213
+
214
+ We emphasize that to prove Theorem 4 we need to analyze the risk function’s derivative only with respect to $a _ { j }$ ’s. Hence, generalization of the empirical risk’s gradient with respect to $a _ { j }$ ’s, which is shown in the above corollary under certain assumptions, is sufficient to apply an approximate version of Theorem 4 in section 8.6 to a local minimum $( { \bf a } ^ { * } , { \bf W } ^ { * } , { \bf b } ^ { * } )$ satisfying the isolated components assumption and found by the gradient descent approach initialized at a low $\left\| \mathbf { a } \right\| _ { 1 }$ and $\lVert \mathbf { W } \rVert _ { 2 , \infty } ^ { - }$ . We can conclude that with probability at least $1 - \delta$ the $\ell _ { 1 }$ -norm of $f _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } }$ ’s Fourier transform outside the bandwidth $\mathcal { B } ( Y ) + \mathcal { B } ( P _ { \mathbf { X } } )$ is bounded by $O \big ( d V \sqrt { \frac { k \log \big ( n B C / \delta \big ) } { n } } \big )$ , and also
215
+
216
+ ![](images/914686f543f146ed0aa239713cbfcd289a4969ea062bc0a533bafbbb1b15a0f0.jpg)
217
+ Figure 2: Training an test performance on cat and airplane CIFAR10 images with true and random labels. Sine activation and mean-squared-error loss were used.
218
+
219
+ ![](images/3a0eb3a058ec45fed9e212dca7302bb4d59e8eba4b3a5b5bba3855e8b79b0e81.jpg)
220
+ Figure 3: Training and test performance on cat and airplane CIFAR10 images with true and random labels. ReLU activation and cross-entropy loss were used.
221
+
222
+ $$
223
+ \| \widehat { f } _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } } \| _ { 1 } \leq 2 \| \widehat { Y } \| _ { 1 } + O \big ( d V \sqrt { \frac { k \log ( n B C / \delta } { n } } \big ) .
224
+ $$
225
+
226
+ Based on the above discussion, if a large-batch gradient descent method starts learning from $f _ { \mathbf { a } , \mathbf { w } , \mathbf { b } }$ with low $\lVert \mathbf { a } \rVert _ { 1 }$ and $\| \mathbf { W } \| _ { 2 , \infty }$ and also we assume that the bandwidth and the Fourier $\ell _ { 1 }$ -norm for $Y ( \mathbf { x } )$ are properly bounded, Theorem 4 combined with Corollary 1 will guarantee good generalization performance for the local minima found by the gradient descent method.
227
+
228
+ # 7 NUMERICAL EXPERIMENTS
229
+
230
+ For all experiments described in this section, we implemented and trained the two-layer neural network described in Figure 1a using TensorFlow 1.3.0. We used SGD to train the model for 2000 epochs with an initial learning rate of 0.01. The learning rate decayed slightly each epoch at a rate of 0.95 every 390 epochs. We used $h = 5 1 2$ hidden units and a batch size of 128. When working with CIFAR10 data, we preprocessed the data as described in (Zhang et al., 2016), resulting in each training sample having dimension $d = 2 3 5 2$ . Initial weights from the first layer were sampled from $\mathcal { N } ( 0 , \bar { 0 . 0 1 } / \bar { d } )$ and initial weights from the second layer were sampled from $\dot { \mathcal { N } } ( 0 , 0 . 0 1 / h )$ .
231
+
232
+ 7.1 SGD GRADUALLY LEARNS HIGHER FOURIER $\ell _ { 1 }$ -NORM, BANDWIDTH HYPOTHESES
233
+
234
+ We first numerically demonstrate that how Fourier $\ell _ { 1 }$ -norm and bandwidth both increases during training via SGD. Motivated by the analysis from Section 6, we use the squared-error as our loss function and sine as our activation function. Our samples consist of cats and airplanes from the CIFAR10 dataset with the labels mapped to $- 1$ and 1. We use 5000 and 2000 samples from each category for training and test, respectively. We arbitrarily chose two of the ten classes to accommodate our choice of loss function. We evaluate the network’s performance for both random and true labels.
235
+
236
+ Figure 2a shows that without regularization, SGD learns to perfectly fit both the true and random labels, which is consistent with the results from Zhang et al. (2016). Additionally, the random labels are harder to learn, requiring more epochs before achieving a perfect fit. Figures 2b and 2c confirm that both Fourier $\ell _ { 1 }$ -norm and bandwidth consistently increase with training, highlighting how SGD gradually finds more complex hypotheses in order to fit the data. Finally, we see in figures 2d and 2e how both Fourier $\ell _ { 1 }$ -norm and bandwidth increase with generalization risk (the difference between test mean squared-error (MSE) and training MSE) with almost perfect correlation. This suggests that, as implied by the theory above, regularizing Fourier $\ell _ { 1 }$ -norm and bandwidth could improve generalizability of the final learned model.
237
+
238
+ # 7.2 GROUP PATH NORM REGULARIZATION FOR RELU ACTIVATION
239
+
240
+ We regularize group path norm for ReLU activation as motivated by Theorem 3. Although $\chi _ { 2 }$ -group path norm is not convex, it is differentiable and we can use it as an additive penalty and find a local minimum via SGD. Using the same experimental setup as from section 7.1, we swap sine for ReLU and test the network’s performance for both random and true labels.
241
+
242
+ Figure 3a confirms that, like before, the network can fit both true and random labels. The generalization gap, however, remains large for random labels. By regularizing the $\ell _ { 2 }$ -norm of all the weights, we see that the generalization gap closes for both the true labels and the random labels without compromising test accuracy significantly (Figure 3b). This result is further improved when we use the $\chi _ { 2 }$ -group path norm and $\ell _ { 1 }$ -path norm (Figure 3c and 3d), demonstrating that direct regularization of Fourier $\ell _ { 1 }$ -norm leads to better generalization.
243
+
244
+ We cross-validated the value of $\lambda$ for each regularization technique, and we chose the $\lambda$ that resulted in the smallest generalization gap with comparable validation performance. To fairly compare different regularization strategies, we tested five lambda values for each strategy and then reported the performance on the test set for the lambda value that resulted in the best performance on the validation set.
245
+
246
+ We repeated the experiment using all 50000 CIFAR10 training samples (and 10000 test samples). We included all 10 classes and switched to cross-entropy loss. The results are shown in Figure 1b. Again, we see that while all regularization techniques give similar test performance, the generalization gap is closed significantly for the $\chi _ { 2 }$ -group path norm and $\ell _ { 1 }$ -path norm.
247
+
248
+ # REFERENCES
249
+
250
+ Alexandr Andoni, Rina Panigrahy, Gregory Valiant, and Li Zhang. Learning polynomials with neural networks. In International Conference on Machine Learning, pp. 1908–1916, 2014.
251
+ Martin Anthony and Peter L Bartlett. Neural network learning: Theoretical foundations. cambridge university press, 2009.
252
+ Andrew R Barron. Universal approximation bounds for superpositions of a sigmoidal function. IEEE Transactions on Information theory, 39(3):930–945, 1993.
253
+ Peter Bartlett, Dylan J Foster, and Matus Telgarsky. Spectrally-normalized margin bounds for neural networks. arXiv preprint arXiv:1706.08498, 2017.
254
+ Peter L Bartlett and Shahar Mendelson. Rademacher and gaussian complexities: Risk bounds and structural results. Journal of Machine Learning Research, 3(Nov):463–482, 2002.
255
+ Olivier Bousquet and André Elisseeff. Stability and generalization. Journal of Machine Learning Research, 2 (Mar):499–526, 2002.
256
+
257
+ 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, 2008.
258
+
259
+ George Cybenko. Approximation by superpositions of a sigmoidal function. Mathematics of Control, Signals, and Systems (MCSS), 2(4):303–314, 1989.
260
+
261
+ Amit Daniely. Sgd learns the conjugate kernel class of the network. arXiv preprint arXiv:1702.08503, 2017.
262
+
263
+ Laurent Dinh, Razvan Pascanu, Samy Bengio, and Yoshua Bengio. Sharp minima can generalize for deep nets. arXiv preprint arXiv:1703.04933, 2017.
264
+
265
+ 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.
266
+
267
+ Ronen Eldan and Ohad Shamir. The power of depth for feedforward neural networks. In Conference on Learning Theory, pp. 907–940, 2016.
268
+
269
+ Moritz Hardt, Benjamin Recht, and Yoram Singer. Train faster, generalize better: Stability of stochastic gradient descent. arXiv preprint arXiv:1509.01240, 2015.
270
+
271
+ Nick Harvey, Chris Liaw, and Abbas Mehrabian. Nearly-tight vc-dimension bounds for piecewise linear neural networks. arXiv preprint arXiv:1703.02930, 2017.
272
+
273
+ Geoffrey Hinton, Li Deng, Dong Yu, George E Dahl, Abdel-rahman Mohamed, Navdeep Jaitly, Andrew Senior, Vincent Vanhoucke, Patrick Nguyen, Tara N 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.
274
+
275
+ Sham M Kakade, Karthik Sridharan, and Ambuj Tewari. On the complexity of linear prediction: Risk bounds, margin bounds, and regularization. In Advances in neural information processing systems, pp. 793–800, 2009.
276
+
277
+ Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, and Ping Tak Peter Tang. On large-batch training for deep learning: Generalization gap and sharp minima. arXiv preprint arXiv:1609.04836, 2016.
278
+
279
+ Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. 2009.
280
+
281
+ 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.
282
+
283
+ Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. Nature, 521(7553):436–444, 2015.
284
+
285
+ Holden Lee, Rong Ge, Andrej Risteski, Tengyu Ma, and Sanjeev Arora. On the ability of neural nets to express distributions. arXiv preprint arXiv:1702.07028, 2017.
286
+
287
+ Shiyu Liang and R Srikant. Why deep neural networks? arXiv preprint arXiv:1610.04161, 2016.
288
+
289
+ Song Mei, Yu Bai, and Andrea Montanari. The landscape of empirical risk for non-convex losses. arXiv preprint arXiv:1607.06534, 2016.
290
+
291
+ Behnam Neyshabur, Ruslan R Salakhutdinov, and Nati Srebro. Path-sgd: Path-normalized optimization in deep neural networks. In Advances in Neural Information Processing Systems, pp. 2413–2421, 2015a.
292
+
293
+ Behnam Neyshabur, Ryota Tomioka, and Nathan Srebro. Norm-based capacity control in neural networks. In COLT, pp. 1376–1401, 2015b.
294
+
295
+ Behnam Neyshabur, Srinadh Bhojanapalli, David McAllester, and Nathan Srebro. Exploring generalization in deep learning. arXiv preprint arXiv:1706.08947, 2017.
296
+
297
+ Oren Rippel, Jasper Snoek, and Ryan P Adams. Spectral representations for convolutional neural networks. In Advances in Neural Information Processing Systems, pp. 2449–2457, 2015.
298
+
299
+ Shai Shalev-Shwartz and Shai Ben-David. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014.
300
+
301
+ Shai Shalev-Shwartz, Ohad Shamir, and Shaked Shammah. Failures of gradient-based deep learning. In International Conference on Machine Learning, pp. 3067–3075, 2017.
302
+
303
+ Ohad Shamir. Distribution-specific hardness of learning neural networks. arXiv preprint arXiv:1609.01037, 2016.
304
+
305
+ Vladimir Vapnik. The nature of statistical learning theory. Springer science & business media, 2013.
306
+
307
+ Vladimir N Vapnik. An overview of statistical learning theory. IEEE transactions on neural networks, 10(5): 988–999, 1999.
308
+
309
+ Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv preprint arXiv:1611.03530, 2016.
310
+
311
+ # 8 APPENDIX
312
+
313
+ # 8.1 PROOF OF THEOREM 2
314
+
315
+ We use a high-dimensional grid in the Fourier domain to approximate the Fourier transform of a $B$ -bandlimited function. Consider the ball $\displaystyle \mathbf { \bar { \boldsymbol { \{ \xi } } } \colon \| \pmb { \xi } \| _ { 2 } \leq B \}$ . Using the bounds on the covering number for $\ell _ { 2 }$ -norm, for any $0 < \epsilon < B$ we can find a set of points $\{ \pmb { \xi } _ { j } : 1 \le j \le ( 3 B / \epsilon ) ^ { k } \}$ such that for any $\pmb { \xi }$ with $\| { \pmb { \xi } } \| _ { 2 } \le B$ , there exists some $\xi _ { j }$ with $\| \pmb { \xi } - \pmb { \xi } _ { j } \| _ { 2 } \le \epsilon$ .
316
+
317
+ Let $S _ { j } = \{ \pmb { \xi } : \| \pmb { \xi } - \pmb { \xi } _ { j } \| _ { 2 } \leq \epsilon \}$ for each $1 \le j \le ( 3 B / \epsilon ) ^ { k }$ . Note that $\{ \pmb { \xi } : \ \| \pmb { \xi } \| _ { 2 } \le B \} \subset \cup _ { j } S _ { j }$ . We then define $S _ { j } ^ { \prime } = S _ { j } \setminus \cup _ { t = 1 } ^ { j - 1 } S _ { t }$ to have a group of disjoint sets $S _ { j } ^ { \prime }$ covering $\{ \pmb { \xi } : \ \| \pmb { \xi } \| _ { 2 } \leq B \}$ . Since any $f \in { \mathcal { F } }$ is assumed to be $B$ -bandlimited, for $f \in { \mathcal { F } }$
318
+
319
+ $$
320
+ \begin{array} { l } { f ( \mathbf { x } ) = \displaystyle \int \widehat { f } ( \pmb { \xi } ) \exp ( 2 \pi i \pmb { \xi } ^ { T } \mathbf { x } ) \mathrm { d } \pmb { \xi } } \\ { = \displaystyle \sum _ { j = 1 } ^ { ( 3 B / \epsilon ) ^ { k } } \int _ { \pmb { \xi } \in S _ { j } ^ { \prime } } \widehat { f } ( \pmb { \xi } ) \exp ( 2 \pi i \pmb { \xi } ^ { T } \mathbf { x } ) \mathrm { d } \pmb { \xi } . } \end{array}
321
+ $$
322
+
323
+ Then, for any $f \in { \mathcal { F } } = \{ f : { \mathcal { B } } ( f ) \leq B , \| { \widehat { f } } \| _ { 1 } \leq V \}$ we have
324
+
325
+ $$
326
+ \begin{array} { r l } | | \begin{array} { l l } { f ( \Phi ) } & { - \frac { \lambda ( \xi ) \xi } { 2 } [ \exp ( \xi ) \log ( \xi ) ] | _ { \xi = \xi } | \langle \Phi \rangle | } \\ & { + | \frac { \lambda ( \xi ) \xi } { 2 } [ \exp ( \xi ) \log ( \xi ) ] | _ { \xi = \xi } | \langle \Phi \rangle | _ { \xi = \xi } | } \\ & { - | \frac { \lambda ( \xi ) \xi } { 2 } [ \frac { \lambda ( \xi ) } { 2 } [ \xi \xi ] [ \log ( \xi ) ) + \frac { \lambda ( \xi ) } { 2 } [ \xi ] [ \xi ] ] | _ { \xi = \xi } ^ { \xi } } \\ & { \le \frac { \lambda ( \xi ) } { 2 } [ \frac { \lambda ( \xi ) } { 2 } [ \xi ] [ \xi ] [ \xi ] [ \lambda ( \xi ) ) [ \xi ] [ \xi ] ] ] | _ { \xi = \xi } ^ { \xi } [ \xi ] [ \xi ] | _ { \xi = \xi } ^ { \xi } } \\ & { \overset { \mathrm { B ( a ) } } { \le } \frac { \lambda ( \xi ) } { 2 } \int _ { \xi \in \xi } [ \frac { \lambda ( \xi ) } { 2 } [ \xi ] [ \xi ] [ \xi ] \xi ] [ \xi - \xi ] \xi ] \le \frac { \lambda ( \xi ) } { 2 } [ \xi ] [ \xi ] \frac { \lambda ( \xi ) } { 2 } } \\ & { \le \frac { \lambda ( \xi ) } { 2 } [ \frac { \lambda ( \xi ) } { 2 } [ \xi ] [ \xi ] \xi ] [ \xi ] \xi [ \xi ] \xi [ \xi ] \xi [ \xi ] \xi ] \ } \\ & { \overset { \mathrm { C ( I ) } } { \le } \frac { \lambda ( \xi ) } { 2 } [ \frac { \lambda ( \xi ) } { 2 } \int _ { \xi \in \xi } [ \frac { \lambda ( \xi ) } { 2 } [ \xi ] \xi ] [ \xi ] \xi [ \xi ] \xi ] \xi } \\ & \overset { \mathrm { B ( a ) } } { \le } \frac { \lambda ( \xi ) } { 2 } \int _ { \xi \in \xi } \frac { \lambda ( \xi ) } { 2 } \int _ \xi \ \end{array} \end{array}
327
+ $$
328
+
329
+ Here, (a) is a direct application of (17). (b) holds as $\exp ( i b z ) = \cos ( b z ) + i \sin ( b z )$ is $^ { b }$ -Lipschitz as a function of $z \in \mathbb { R }$ for any real number $b > 0$ . (c) holds because according to our definitions $\bar { S _ { j } ^ { \prime } } \subseteq S _ { j }$ and $S _ { j } = \{ \pmb { \xi } : \ \| \pmb { \xi } - \pmb { \xi } _ { j } \| _ { 2 } \leq \epsilon \}$ .
330
+
331
+ Therefore, the following function space $\mathcal { F } _ { \epsilon }$ can approximate any $f \in { \mathcal { F } } = \left\{ f : { \mathcal { B } } ( f ) \leq B , \| { \widehat { f } } \| _ { 1 } \leq V \right\}$ within $2 \pi \epsilon C V$ accuracy for any $\| \mathbf { x } \| _ { 2 } \leq C$ . Here a is, in general, a vector of complex numbers, and $\begin{array} { r } { \| \dot { \bf a } \| _ { 1 } : = \sum _ { j } | a _ { j } | } \end{array}$
332
+
333
+ where $| z |$ denotes the absolute value of complex number $z$
334
+
335
+ $$
336
+ \mathcal { F } _ { \epsilon } = \Bigg \{ f ( \mathbf { x } ) = \sum _ { j = 1 } ^ { ( 3 B / \epsilon ) ^ { k } } a _ { j } \exp ( 2 \pi i \pmb { \xi } _ { j } ^ { T } \mathbf { x } ) : \| \mathbf { a } \| _ { 1 } \leq V \Bigg \} .
337
+ $$
338
+
339
+ Then, $\mathcal { F } _ { \epsilon }$ is the space of $\ell _ { 1 }$ -norm bounded linear functions in terms of the input vector $\left[ \exp ( 2 \pi i \pmb { \xi } _ { j } ^ { T } \mathbf { x } ) \right] _ { j }$ . Now, we can apply a well-known bound (Shalev-Shwartz & Ben-David, 2014) on the Rademacher complexity of $\ell _ { 1 }$ -norm bounded linear space $\mathcal { F } _ { \mathrm { l i n } , 1 } = \{ \boldsymbol { f } : \mathbb { R } ^ { k } \mathbb { R } $ s.t. $f ( \mathbf { x } ) = \mathbf { a } ^ { T } \mathbf { x }$ , $\| \mathbf { a } \| _ { 1 } \leq A \}$ as
340
+
341
+ $$
342
+ \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } _ { \mathrm { l i n } , 1 } ) \leq A \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { \infty } \sqrt { \frac { 2 \log ( 2 k ) } { n } } .
343
+ $$
344
+
345
+ Applying the above bound, we can bound the Rademacher complexity of $\mathcal { F } _ { \epsilon }$ as
346
+
347
+ $$
348
+ \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } _ { \epsilon } ) \leq V \sqrt { \frac { 2 k \log ( 6 B / \epsilon ) } { n } } .
349
+ $$
350
+
351
+ Since for each $f \in { \mathcal { F } }$ there exists $\tilde { f } \in \mathcal { F } _ { \epsilon }$ such that $\forall \| \mathbf { x } \| _ { 2 } \leq C : | f ( \mathbf { x } ) - \tilde { f } ( \mathbf { x } ) | \leq 2 \pi \epsilon C V$ ,
352
+
353
+ $$
354
+ \begin{array} { r l } { { \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } ) = \mathbb { E } _ { \sigma } \bigg [ \operatorname* { s u p } _ { f \in \mathcal { F } } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \sigma _ { i } f ( \mathbf { x } _ { i } ) \bigg ] } \quad } & { } \\ & { \leq \mathbb { E } _ { \sigma } \bigg [ \operatorname* { s u p } _ { \tilde { f } \in \mathcal { F } _ { \epsilon } } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \sigma _ { i } \tilde { f } ( \mathbf { x } _ { i } ) \bigg ] + 2 \pi \epsilon V \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } } \\ & { = \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } _ { \epsilon } ) + 2 \pi \epsilon V \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } . } \end{array}
355
+ $$
356
+
357
+ Finally, combining (20) and (21) we obtain:
358
+
359
+ $$
360
+ \forall \epsilon > 0 : \quad \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } ) \leq V \sqrt { \frac { 2 k \log ( 6 B / \epsilon ) } { n } } + 2 \pi \epsilon V \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } .
361
+ $$
362
+
363
+ If we choose the value $\begin{array} { r } { \epsilon = \frac { 1 } { 2 \pi n \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } } } \end{array}$ , then we get
364
+
365
+ $$
366
+ \begin{array} { r l } & { \mathcal { R } _ { n } ^ { \mathrm { e m p } } ( \mathcal { F } ) \leq V \bigg ( \sqrt { \frac { 2 k \log \left( 1 2 \pi n B \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } \right) } { n } } + \frac { 1 } { n } \bigg ) } \\ & { \qquad \leq V \sqrt { \frac { 4 k \log \left( 1 2 \pi n B \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } \right) + 2 / n } { n } } } \\ & { \qquad \leq V \sqrt { \frac { 4 k \log \left( 6 4 n B \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } \right) } { n } } , } \end{array}
367
+ $$
368
+
369
+ where the last inequality follows from the fact that $1 \leq k , n$ . Therefore, the proof is complete.
370
+
371
+ # 8.2 PROOF OF COROLLARY 2
372
+
373
+ First, we prove the following lemma.
374
+
375
+ Lemma 2. Given function $f : \mathbb { R } ^ { k } \mathbb { R }$ and matrix $\mathbf { W } \in \mathbb { R } ^ { k \times k }$ , we define $g ( \mathbf { x } ) = f ( \mathbf { W } \mathbf { x } )$ . Then,
376
+
377
+ • $B ( g ) \leq \| \mathbf { W } \| _ { 2 } B ( f )$ with $\| \mathbf { W } \| _ { 2 }$ denoting the spectral norm of $\mathbf { W }$ , • $\| { \widehat { g } } \| _ { 1 } = \| { \widehat { f } } \| _ { 1 }$ .
378
+
379
+ Proof. From the properties of the Fourier transform we know
380
+
381
+ $$
382
+ \widehat { g } ( \pmb { \xi } ) = \frac { 1 } { | \operatorname* { d e t } ( \mathbf { W } ) | } \widehat { f } \big ( \mathbf { W } ^ { - T } \pmb { \xi } \big ) .
383
+ $$
384
+
385
+ Therefore, $\begin{array} { r } { \widehat { g } ( \mathbf { W } ^ { T } \pmb { \xi } ^ { \prime } ) = \frac { 1 } { | \operatorname* { d e t } ( \mathbf { W } ) | } \widehat { f } \big ( \pmb { \xi } ^ { \prime } \big ) } \end{array}$ and if $\| \pmb { \xi } ^ { \prime } \| _ { 2 } \le B ( f )$ , then $\| \mathbf { W } ^ { T } \pmb { \xi } ^ { \prime } \| _ { 2 } \le \| \mathbf { W } \| _ { 2 } B ( f )$ gives an upperbound on $B ( g )$ . Also,
386
+
387
+ $$
388
+ \begin{array} { r l } & { \| \hat { g } \| _ { 1 } = \int \big | \hat { g } ( \xi ) \big | \mathrm { d } \xi } \\ & { \quad = \int \frac { 1 } { \big | \operatorname* { d e t } ( \mathbf { W } ) \big | } \big | \widehat { f } ( \mathbf { W } ^ { - T } \xi ) \big ) \big | \mathrm { d } \xi } \\ & { \quad = \frac { 1 } { \big | \operatorname* { d e t } ( \mathbf { W } ) \big | } \int \big | \widehat { f } ( \mathbf { W } ^ { - T } \xi ) \big | \mathrm { d } \xi } \\ & { \quad = \frac { 1 } { \big | \operatorname* { d e t } ( \mathbf { W } ) \big | } \int \big | \widehat { f } ( \xi ^ { \prime } ) \big ) \big | \frac { 1 } { \big | \operatorname* { d e t } ( \mathbf { W } ^ { - T } \setminus j ) \big | } \mathrm { d } \xi ^ { \prime } } \\ & { \quad = \int \big | \widehat { f } ( \xi ^ { \prime } ) \big | \mathrm { d } \xi ^ { \prime } } \\ & { \quad = \| \widehat { f } \| _ { 1 } . } \end{array}
389
+ $$
390
+
391
+ It can be seen that this result remains valid even if $\mathbf { W }$ is not an invertible matrix, which will complete the proof for Corollary 2. However, we continue proving Corollary 2 without using this fact.
392
+
393
+ As shown in the above lemma, Fourier $\ell _ { 1 }$ -norm and bandwidth are invariant to an orthonormal transformation $\mathbf { W }$ . Given $f _ { i } ( \mathbf { x } ) = a _ { i } \phi ( \mathbf { w } _ { i } ^ { T } \mathbf { x } )$ , we define $g _ { i } ( { \bf x } ) = f _ { i } ( { \bf A } _ { i } { \bf x } )$ where $A _ { i }$ is an orthonormal matrix with ${ \bf w } _ { i }$ as an eigenvector. Note that $\lVert \widehat { f } _ { i } \rVert _ { 1 } = \lVert \widehat { g _ { i } } \rVert _ { 1 }$ and $B ( f _ { i } ) \ : = \ : B ( g _ { i } )$ . However, $g _ { i } ( \mathbf { x } )$ is a function of only bone of the coordinates, which we can assume, without loss of generality, to be the first coordinate. Hence, $g _ { i } ( \mathbf { x } ) = a _ { i } \phi ( \| \mathbf { w } _ { i } \| _ { 2 } x _ { 1 } )$ for the first coordinate $x _ { 1 }$ , implying $\begin{array} { r } { \widehat { g _ { i } } ( \pmb { \xi } ) = \frac { a _ { i } } { \| \mathbf { w } _ { i } \| _ { 2 } } \widehat { \phi } ( \frac { \xi _ { 1 } } { \| \mathbf { w } _ { i } \| _ { 2 } } ) . \delta _ { 2 } ( \xi _ { 2 } ) \ldots \delta _ { k } ( \xi _ { k } ) } \end{array}$ $\delta _ { j }$ is the Dirac delta function across the $j$ th dimension. Hence, we can use the above lemma in the 1-dimensional case to show $\| \widehat { g _ { i } } \| _ { 1 } = | a _ { i } | \| \widehat { \phi } \| _ { 1 }$ and $B ( g _ { i } ) = \| \mathbf { w } _ { i } \| _ { 2 } B ( \phi )$ . As a result,
394
+
395
+ $$
396
+ \| \widehat { f } _ { i } \| _ { 1 } = | a _ { i } | \| \widehat { \phi } \| _ { 1 } , \quad \mathcal { B } ( f _ { i } ) \leq \| \mathbf { w } _ { i } \| _ { 2 } \mathcal { B } ( \phi ) .
397
+ $$
398
+
399
+ Hence, for $\begin{array} { r } { f ( \mathbf { x } ) = \mathbf { a } ^ { T } \boldsymbol { \phi } ( \mathbf { W } \mathbf { x } + \mathbf { b } ) = \sum _ { i = 1 } ^ { d } a _ { i } \boldsymbol { \phi } ( \mathbf { w } _ { i } ^ { T } \mathbf { x } + b _ { i } ) } \end{array}$ we have
400
+
401
+ $$
402
+ \| \widehat { f } \| _ { 1 } \leq \| \mathbf { a } \| _ { 1 } \| \widehat { \phi } \| _ { 1 } , \quad \mathcal { B } ( f ) \leq \| \mathbf { W } \| _ { 2 , \infty } \mathcal { B } ( \phi ) .
403
+ $$
404
+
405
+ The corollary is then a direct application of Theorem 2.
406
+
407
+ # 8.3 PROOF OF THEOREM 3
408
+
409
+ Given a ReLU-type activation function $\phi _ { \alpha } ( z ) = \operatorname* { m a x } \{ z , \alpha z \}$ ,
410
+
411
+ $$
412
+ \phi _ { \alpha } \big ( \mathbf { w } ^ { T } \mathbf { x } \big ) = \| \mathbf { w } \| _ { q } \phi _ { \alpha } \big ( ( \frac { \mathbf { w } } { \| \mathbf { w } \| _ { q } } ) ^ { T } \mathbf { x } \big ) .
413
+ $$
414
+
415
+ Since ${ \left\| \frac { \mathbf { w } } { \left\| \mathbf { w } \right\| _ { q } } \right\| } _ { q } = 1$ , if $\| \mathbf { x } \| _ { p } \leq C$ , then ${ \Big | } { \big ( } { \frac { \mathbf { w } } { \| \mathbf { w } \| _ { q } } } { \big ) } ^ { T } \mathbf { x } { \Big | } \leq C$ and hence the input to $\phi _ { \alpha }$ in the R.H.S. of (28) is always between $- C$ and $C$ .
416
+
417
+ Suppose that function $\psi _ { \alpha }$ satisfies $\psi _ { \alpha } ( z ) = \phi _ { \alpha } ( z )$ for $z \in [ - C , C ]$ . Then, based on the above discussion, we can bound the Rademacher complexity of ${ \mathcal F } _ { \phi _ { \alpha } }$ by finding a bound on the Rademacher complexity of $\mathcal { F } _ { \psi _ { \alpha } } = \left\{ f _ { \mathbf { v } , \mathbf { U } } ( \mathbf { x } ) = \mathbf { v } ^ { T } \psi _ { \alpha } ( \mathbf { U } \mathbf { x } ) : ~ \| \mathbf { v } \| _ { 1 } \leq V , \forall i : ~ \| \mathbf { u } _ { i } \| _ { q } = 1 \right\}$ .
418
+
419
+ To find a good candidate for $\psi _ { \alpha }$ , we use a symmetrization trick to define
420
+
421
+ $$
422
+ \psi _ { \alpha } ( z ) = \left\{ \begin{array} { c l } { - \alpha C } & { \mathrm { i f } z < - C , } \\ { \phi _ { \alpha } ( z ) } & { \mathrm { i f } - C \le z < C , } \\ { \phi _ { \alpha } ( 2 C - z ) } & { \mathrm { i f } C \le z < 3 C , } \\ { - \alpha C } & { \mathrm { i f } 3 C \le z . } \end{array} \right.
423
+ $$
424
+
425
+ Note that $\begin{array} { r } { \psi _ { \alpha } ( z ) = ( 1 - \alpha ) C h ( \frac { z - C } { C } ) + 2 \alpha C h ( \frac { z - C } { 2 C } ) - \alpha C } \end{array}$ where $h ( z ) = \operatorname* { m a x } \{ 0 , 1 - | z | \} .$ . It can be seen that $\begin{array} { r } { { \widehat { h } } ( \xi ) = \big ( \frac { \sin ( \pi \xi ) } { \pi \xi } \big ) ^ { 2 } } \end{array}$ which is real and positive everywhere. Therefore, $\| \widehat { h } \| _ { 1 } = h ( 0 ) = 1$ which means that $\| \widehat { \psi _ { \alpha } } \| _ { 1 } \leq C ( 1 + 2 \alpha ) \leq 3 C .$ .
426
+
427
+ Since $\vert \widehat { h } ( \xi ) \vert \le \frac { 1 } { \xi ^ { 2 } }$ , we have $\widehat { | \psi _ { \alpha } ( \xi ) | } \le \frac { 1 } { \xi ^ { 2 } }$ . For $B > 0$ , we let the $B$ -filtered $\psi _ { \alpha , B }$ be a function with the following Fourier transform:
428
+
429
+ $$
430
+ \widehat { \psi _ { \alpha , B } } ( \xi ) = \left\{ \begin{array} { l l } { \widehat { \psi _ { \alpha } } ( \xi ) } & { \mathrm { i f ~ } | \xi | \leq B } \\ { 0 } & { \mathrm { o t h e r w i s e } . } \end{array} \right.
431
+ $$
432
+
433
+ Then, since $\bigl | \widehat { \psi _ { \alpha } } ( \xi ) \bigr | \le \frac { 1 } { \xi ^ { 2 } }$ we have
434
+
435
+ $$
436
+ \forall z \in \mathbb { R } : \quad \left| \psi _ { \alpha } ( z ) - \psi _ { \alpha , B } ( z ) \right| \leq \int _ { | \xi | \geq B } \left| \widehat { \psi _ { \alpha } } ( \xi ) \right| \mathrm { d } \xi \leq \frac { 2 } { B } .
437
+ $$
438
+
439
+ Thus, for any $B > 0$ the defined $\psi _ { \alpha , B }$ approximates $\phi _ { \alpha }$ with a maximum error of $\frac { 2 } { B }$ uniformly over $[ - C , C ]$ . $\psi _ { \alpha , B }$ also satisfies $\| \widehat { \psi _ { \alpha , B } } \| _ { 1 } \leq 3 C$ and $\begin{array} { r } { B ( \psi _ { \alpha , B } ) = B } \end{array}$ . Applying Corollary 2, we get
440
+
441
+ $$
442
+ \forall B > 0 : \quad \mathcal { R } _ { n } ^ { \mathrm { e m p } } \big ( \mathcal { F } _ { \phi _ { \alpha } } \big ) \leq O \Bigg ( V C \sqrt { \frac { k \log \left( n B \operatorname* { m a x } \| \mathbf { x } _ { i } \| _ { 2 } \right) } { n } } \Bigg ) + \frac { 2 } { B } .
443
+ $$
444
+
445
+ Here we can bound m $\begin{array} { r } { \mathrm { a x } _ { i } \| \mathbf { x } _ { i } \| _ { 2 } \leq \sqrt { k } \operatorname* { m a x } _ { i } \| \mathbf { x } _ { i } \| _ { \infty } \leq \sqrt { k } C } \end{array}$ , and choose $B = n$ to get
446
+
447
+ $$
448
+ \mathcal { R } _ { n } ^ { \mathrm { e m p } } \big ( \mathcal { F } _ { \phi _ { \alpha } } \big ) \leq O \bigg ( V C \sqrt { \frac { k \log \big ( n k C \big ) } { n } } + \frac { 1 } { n } \bigg ) ,
449
+ $$
450
+
451
+ which completes the proof.
452
+
453
+ # 8.4 PROOF OF LEMMA 1
454
+
455
+ Note that
456
+
457
+ $$
458
+ \begin{array} { r l } { \overset { \_ } { \nabla } _ { \mathbf { X } _ { 3 } } \left[ \ell \big ( f _ { \mathrm { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { X } ) , Y ( \mathbf { X } ) \big ) \right] = \mathbb { E } _ { P _ { \mathbf { X } } } \left[ \nabla _ { a _ { j } } \ell \big ( f _ { \mathrm { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { X } ) , Y ( \mathbf { X } ) \big ) \right] } & { } \\ & { = \mathbb { E } _ { P _ { \mathbf { X } } } \left[ \nabla _ { a _ { j } } \big ( f _ { \mathrm { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { X } ) - Y ( \mathbf { X } ) \big ) ^ { 2 } \right] } \\ & { = \mathbb { E } _ { P _ { \mathbf { Y } } } \left[ 2 \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { X } + b _ { j } ) \big ( \underset { t = 1 } { \overset { d } { \sum } } a _ { t } \sin ( 2 \pi \mathbf { w } _ { t } ^ { T } \mathbf { X } + b _ { t } ) - Y ( \mathbf { X } ) \big ) \right] } \\ & { = \mathbb { E } _ { P _ { \mathbf { X } } } \left[ 2 a _ { j } \sin ^ { 2 } ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { X } + b _ { j } ) \right] - \mathbb { E } _ { P _ { \mathbf { X } } } \left[ 2 \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { X } + b _ { j } ) Y ( \mathbf { X } ) \right] } \\ & { \ + \mathbb { E } _ { P _ { \mathbf { X } } } \left[ \underset { t \neq j } { \sum } 2 a _ { t } \sin ( 2 \pi \mathbf { w } _ { t } ^ { T } \mathbf { X } + b _ { t } ) \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { X } + b _ { j } ) \right] } \\ & { = a _ { j } - 2 \left[ \cos ( b _ { j } ) \ln \big \{ \hat { Y } * \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { j } ) \big \} + \sin ( b _ { j } ) \mathrm { R e } \big \{ \hat { Y } * \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { j } ) \big \} \right] . } \end{array}
459
+ $$
460
+
461
+ To show the last equality, we use the isolatedness assumption for $\mathbf { w } _ { j }$ , i.e. $\forall t \neq j : \operatorname* { m i n } \{ \| \mathbf { w } _ { t } - \mathbf { w } _ { j } \| _ { 2 } , \| \mathbf { w } _ { t } +$ $\mathbf { w } _ { j } \| _ { 2 } \big \} > B ( P \mathbf { x } )$ , and also $\| \mathbf { w } _ { j } \| _ { 2 } \geq B ( P \mathbf { x } ) / 2$ . Then, for each $t$
462
+
463
+ $$
464
+ \begin{array} { r l } { \mathbb { E } _ { P \mathbf x } \left[ 2 \sin ( 2 \pi \mathbf w _ { t } ^ { T } \mathbf X + b _ { t } ) \sin ( 2 \pi \mathbf w _ { j } ^ { T } \mathbf X + b _ { t } ) \right] = 2 \int P \mathbf x ( \mathbf x ) \sin ( 2 \pi \mathbf w _ { t } ^ { T } \mathbf x + b _ { t } ) \sin ( 2 \pi \mathbf w _ { j } ^ { T } \mathbf x + b _ { t } ) \mathrm { d } \mathbf x } & { } \\ { = } & { \int P \mathbf x ( \mathbf x ) \biggl [ \cos ( 2 \pi ( \mathbf w _ { t } - \mathbf w _ { s } ) ^ { T } \mathbf x + b _ { t } - b _ { s } ) } \\ & { \phantom { 2 } - \cos ( 2 \pi ( \mathbf w _ { t } + \mathbf w _ { s } ) ^ { T } \mathbf x + b _ { t } + b _ { s } ) \biggr ] \mathrm { d } \mathbf x } \\ { = } & { 0 . 5 \exp ( j ( b _ { t } - b _ { s } ) ) \widehat { P } \widetilde { \mathbf x } ( \mathbf w _ { 1 } - \mathbf w _ { s } ) } \\ { + 0 . 5 \exp ( j ( b _ { t } - b _ { t } ) ) \widehat { P } \widetilde { \mathbf x } ( \mathbf w _ { j } - \mathbf w _ { t } ) } \\ & { \phantom { 2 } - 0 . 5 \exp ( j ( b _ { t } + b _ { s } ) ) \widehat { P } \widetilde { \mathbf x } ( \mathbf w _ { 1 } + \mathbf w _ { s } ) } \\ { - 0 . 5 \exp ( j ( b _ { t } + b _ { s } ) ) \widehat { P } \widetilde { \mathbf x } ( \mathbf w _ { 1 } + \mathbf w _ { s } ) } \\ & { \phantom { 2 } - 0 . 5 \exp ( j ( b _ { t } + b _ { t } ) ) \widehat { P } \widetilde { \mathbf x } ( - \mathbf w _ { t } - \mathbf w _ { j } ) } \\ { = \left\{ \begin{array} { l l } { 0 } & { \mathrm { i f ~ } t < j _ { s } } \\ { 1 } & { \mathrm { i f ~ } t = j _ { s } } \end{array} \right. } \end{array}
465
+ $$
466
+
467
+ Also, by applying the convolution property of Fourier transform we can show
468
+
469
+ $$
470
+ \begin{array} { r l } { \mathbb { E } _ { P _ { \mathbf { X } } } \left[ \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { X } + b _ { j } ) Y ( \mathbf { X } ) \right] = \displaystyle \int P _ { \mathbf { X } } ( \mathbf { x } ) Y ( \mathbf { x } ) \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { x } + b _ { j } ) \mathrm { d } \mathbf { x } } & { } \\ { = \displaystyle \int ( P _ { \mathbf { X } } \times Y ) ( \mathbf { x } ) \left[ \cos ( b _ { j } ) \sin ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { X } ) + \sin ( b _ { j } ) \cos ( 2 \pi \mathbf { w } _ { j } ^ { T } \mathbf { X } ) \right] \mathrm { d } \mathbf { x } } & { } \\ { = \cos ( b _ { j } ) \mathrm { I m } \{ \widehat { Y } \star \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { j } ) \} + \sin ( b _ { j } ) \mathrm { R e } \{ \widehat { Y } \star \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { j } ) \} . } & { } \end{array}
471
+ $$
472
+
473
+ Finally if $( \mathbf { a } , \mathbf { W } , \mathbf { b } )$ is a local minimum for the population risk, for all $t$ ’s we have $\nabla _ { a _ { t } } \bar { \mathbb { E } } _ { P _ { \mathbf { X } } } \big [ \ell \big ( \dot { f } _ { \mathbf { a } , \mathbf { W } , \mathbf { b } } ( \mathbf { X } ) , Y ( \mathbf { X } ) \big ) \big ] \ = \ 0$ . Therefore, due to the isolatedness assumption of $\mathbf { w } _ { j }$ we have
474
+
475
+ $$
476
+ | a _ { j } | = 2 \left| \cos ( b _ { j } ) \operatorname { I m } \bigl \{ \widehat { Y } \star \widehat { P } _ { \mathbf { X } } ( { \mathbf { w } } _ { j } ) \bigr \} + \sin ( b _ { j } ) \operatorname { R e } \bigl \{ \widehat { Y } \star \widehat { P } _ { \mathbf { X } } ( { \mathbf { w } } _ { j } ) \bigr \} \right| \leq 2 \bigl | \widehat { Y } \star \widehat { P } _ { \mathbf { X } } ( { \mathbf { w } } _ { j } ) \bigr | .
477
+ $$
478
+
479
+ # 8.5 PROOF OF THEOREM 4
480
+
481
+ Since the isolatedness assumption holds for all $j$ ’s, by Lemma 1,
482
+
483
+ $$
484
+ \forall j : \quad | a _ { j } ^ { * } | \leq 2 \bigl | \widehat { Y } \star \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { j } ^ { * } ) \bigr | .
485
+ $$
486
+
487
+ If $\| \mathbf { w } _ { t } ^ { * } \| _ { 2 } > B ( Y ) + B ( P _ { \mathbf { X } } )$ holds for some $t$ , (37) implies
488
+
489
+ $$
490
+ | a _ { t } ^ { * } | \leq 2 \bigl | \widehat { Y } \star \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { t } ^ { * } ) \bigr | = 0 .
491
+ $$
492
+
493
+ Hence, $a _ { t } ^ { * }$ will be 0, implying there will be no component in $f _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } }$ with $\| \mathbf { w } _ { t } ^ { * } \| _ { 2 } > B ( Y ) + B ( P _ { \mathbf { X } } )$ . This discussion proves the first part of Theorem, i.e. $B ( f _ { \mathbf { a } ^ { * } } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } ) \leq B ( Y ) + B ( P _ { \mathbf { X } } )$ .
494
+
495
+ To show the second part, note that
496
+
497
+ $$
498
+ \begin{array} { r l } { \| A _ { \varepsilon } ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 2 } } & { = | \alpha | ^ { 3 } \| _ { \infty } ^ { 3 } } \\ & { \stackrel { \mathrm { i . e . } } { = } 2 \displaystyle \sum _ { u = 1 } ^ { 3 } \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 3 } } \\ & { = 2 \displaystyle \sum _ { u = 1 } ^ { 3 } \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ { \varepsilon } ( s ) \hat { \rho } _ { u } ^ { \varepsilon } ( u ) ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 3 } } \\ & { \stackrel { \mathrm { i . e . } } { = } 2 \displaystyle \sum _ { u = 1 } ^ { 3 } \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ { \varepsilon } ( u ) ^ { \varepsilon } ( s ) \hat { \rho } _ { u } ^ { \varepsilon } ( u ) ^ { \varepsilon } ( s ) } \\ & { = 2 \displaystyle \sum _ { u = 1 } ^ { 3 } \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ { \varepsilon } ( u ) ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 3 } } \\ & { = 2 \displaystyle \sum _ { u = 1 } ^ { 3 } \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ { \varepsilon } ( u ) ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 3 } \mathrm { d } u \varepsilon } \\ & { = 2 \displaystyle \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 3 } \mathrm { d } u \varepsilon } \\ & { \stackrel { \mathrm { i . e . } } { = } 2 \displaystyle \sum _ { u = 1 } ^ { 3 } \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ { \varepsilon } ( u ) ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 4 } } \\ & { = 2 \displaystyle \sum _ { u = 1 } ^ { 3 } \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ { \varepsilon } ( u ) ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 3 } } \\ & { = 2 \displaystyle \sum _ { u = 1 } ^ { 3 } \int _ { u } ^ { 1 } | \hat { \rho } _ { u } ^ { \varepsilon } ( u ) ^ { \varepsilon } ( s ) \| _ { \infty } ^ { 3 } } \\ & - 2 \displaystyle \int _ { u } ^ { 1 } \hat { \rho } _ { u } ^ \ \end{array}
499
+ $$
500
+
501
+ Here, (a) comes from Lemma 1. Also, since $\operatorname* { m i n } \Bigl \{ \| \mathbf { w } _ { t } ^ { * } - \mathbf { w } _ { r } ^ { * } \| _ { 2 } , \| \mathbf { w } _ { t } ^ { * } + \mathbf { w } _ { r } ^ { * } \| _ { 2 } \Bigr \} > 2 B ( P _ { \mathbf { X } } )$ is assumed for any $t \neq r$ , for any $\boldsymbol { \xi }$ at most one element in $\left[ \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { t } ^ { * } - \pmb { \xi } ) \right] _ { t = 1 } ^ { d }$ can be nonzero. Because if both $\widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { t } ^ { * } - \pmb { \xi } )$ and $\widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { r } ^ { * } - \pmb { \xi } )$ are nonzero for $r \neq t$ , then $\| \mathbf { w } _ { t } ^ { * } - \pmb { \xi } \| \leq B ( P _ { \mathbf { X } } )$ and also $\| \mathbf { w } _ { r } ^ { * } - \pmb { \xi } \| \leq B ( P _ { \mathbf { X } } )$ which results in $\| \mathbf { w } _ { t } ^ { * } - \mathbf { w } _ { r } ^ { * } \| \leq 2 B ( P _ { \mathbf { X } } )$ which is a contradiction. Hence,
502
+
503
+ $$
504
+ \sum _ { t = 1 } ^ { d } \left| \widehat { P } \mathbf { x } ( \mathbf { w } _ { t } ^ { * } - \pmb { \xi } ) \right| \leq \operatorname* { m a x } _ { \pmb { \xi } ^ { \prime } } \left| \widehat { P } \mathbf { x } ( \pmb { \xi } ^ { \prime } ) \right| \leq \int \left| P \mathbf { x } ( \mathbf { x } ) \right| \mathrm { d } \mathbf { x } = 1 ,
505
+ $$
506
+
507
+ which proves (b) and completes the proof.
508
+
509
+ # 8.5.1 APPLYING THEOREM 4 TO MULTIVARIATE GAUSSIAN X
510
+
511
+ Assume $\mathbf { X } \sim { \mathcal { N } } ( \mu , \sigma ^ { 2 } \mathbf { I } _ { k \times k } )$ has a multivariate Gaussian distribution with mean $\pmb { \mu }$ and standard deviation $\sigma$ . Then, the Fourier transform $\hat { P } _ { \mathbf { X } }$ has a Gaussian shape with mean 0 and standard deviation $1 / \sigma$ . Hence, if for any $i , j$ we have $\operatorname* { m i n } \bigr \{ \| \mathbf { w } _ { i } ^ { * } - \mathbf { w } _ { j } ^ { * } \| _ { 2 } , \| \mathbf { w } _ { i } ^ { * } + \mathbf { w } _ { j } ^ { * } \| _ { 2 } \bigr \} \stackrel { } { > } 2 C / \sigma$ for some constant $C$ , the approximation error term which should be added to the upperbound in Equation (39) is $2 \| \widehat { Y } \| _ { 1 } d \exp ( - C ^ { 2 } / 2 )$ . Also, given any $\epsilon > 0$ the Fourier $\ell _ { 1 }$ norm outside the bandwidth $O ( \sqrt { k } \log ( 1 / \epsilon ) / \sigma )$ is at most $\epsilon$ . Therefore, Theorem 4 implies
512
+
513
+ $$
514
+ \begin{array} { r l } & { \bullet \mathcal { B } ( f _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } } ) \leq \mathcal { B } ( Y ) + O \big ( \sqrt { k } / \sigma \big ) , } \\ & { \bullet \| \widehat { f } _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } } \| _ { 1 } \leq 2 ( 1 + d \exp ( - C ^ { 2 } / 2 ) ) \| \widehat { Y } \| _ { 1 } . } \end{array}
515
+ $$
516
+
517
+ # 8.6 APPROXIMATE VERSION OF THEOREM 4
518
+
519
+ Here we show an approximate version of Theorem 4 which applies to approximate population local minima.
520
+
521
+ Theorem 5. Consider minimizing the population risk (11). Consider an approximate local minimum $( \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } )$ where $| \nabla _ { a _ { j } } \mathbb { E } \big [ \ell \big ( f _ { { \mathbf a } ^ { * } , { \mathbf W } ^ { * } , { \mathbf b } ^ { * } } ( { \mathbf { \dot { X } } } ) , Y ( { \mathbf { X } } ) \big ) \big ) \big ] | \ \leq \ \epsilon$ for all $j$ ’s. If for any two different $i , j$ we
522
+
523
+ have $\operatorname* { m i n } \bigl \{ \| \mathbf { w } _ { i } ^ { * } - \mathbf { w } _ { j } ^ { * } \| _ { 2 } , \| \mathbf { w } _ { i } ^ { * } + \mathbf { w } _ { j } ^ { * } \| _ { 2 } \bigr \} > 2 B ( P _ { \mathbf { X } } )$ , then the Fourier $\ell _ { 1 }$ -norm of $f _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } }$ outside the bandwidth $\mathcal { B } ( Y ) + \mathcal { B } ( P _ { \mathbf { X } } )$ is bounded by $d \epsilon$ and
524
+
525
+ $$
526
+ \begin{array} { r } { \| \widehat { f } _ { \mathbf { a } ^ { * } , \mathbf { W } ^ { * } , \mathbf { b } ^ { * } } \| _ { 1 } \leq 2 \| \widehat { Y } \| _ { 1 } + d \epsilon . } \end{array}
527
+ $$
528
+
529
+ Proof. Since the isolated components condition holds, we can apply Lemma 1’s proof to show under the above assumptions
530
+
531
+ $$
532
+ \forall j : \quad | a _ { j } ^ { * } | \leq 2 \big | \hat { Y } \star \hat { P } _ { \mathbf { X } } ( \mathbf { w } _ { j } ^ { * } ) \big | + \epsilon .
533
+ $$
534
+
535
+ Then, a simple modification of Theorem 4’s proof according to the above inequality proves the above theorem. □
536
+
537
+ # 8.7 PROOF OF THEOREM 4 WITHOUT THE ISOLATED COMPONENTS ASSUMPTION
538
+
539
+ What happens if a component $\mathbf { w } _ { i }$ is not isolated from the other components which has been assumed in Theorem 4? As a simplifying assumption, we assume that $\mathbf b = \mathbf 0$ and $\widehat { P _ { \mathbf { X } } }$ is real. We can write
540
+
541
+ $$
542
+ \begin{array} { r l } { \displaystyle \forall i : \nabla _ { a _ { i } } \mathbb { E } _ { P _ { \mathbf { X } } } \left[ \ell \Big ( f _ { \mathbf { a } , \mathbf { w } } ( \mathbf { x } ) , Y ( \mathbf { x } ) \Big ) \right] = \sum _ { j = 1 } ^ { d } \left[ a _ { j } \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { i } - \mathbf { w } _ { j } ) \right] - \operatorname { I m } \left\{ \widehat { Y } \star \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { i } ) \right\} } & { } \\ { \displaystyle } & { \approx \sum _ { j = 1 } ^ { d } \left[ \left( a _ { j } - \int _ { \xi \in S _ { \mathbf { w } _ { j } } } \operatorname { I m } \{ \widehat { Y } ( \xi ) \} { \mathrm { d } } \xi \right) \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { i } - \mathbf { w } _ { j } ) \right] } \end{array}
543
+ $$
544
+
545
+ Here $S _ { \mathbf { w } _ { i } }$ ’s, which are centered around $\mathbf { w } _ { j }$ ’s, are disjoint sets covering the bandwidth region for $\widehat { Y }$ , i.e. $\{ \pmb { \xi } : \| \pmb { \xi } \| _ { 2 } ^ { \prime } \leq B ( Y ) \} \subseteq \bigcup _ { j } S _ { \mathbf { w } _ { j } }$ . Note that in (41) we have approximated the convolution integral as
546
+
547
+ $$
548
+ \begin{array} { r l } { \widehat { Y } \star \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { i } ) = \displaystyle \int _ { \pm : \| \xi \| _ { 2 } \leq B ( Y ) } \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { i } - \pmb { \xi } ) \widehat { Y } ( \pmb { \xi } ) \mathrm { d } \xi } & { } \\ { = \displaystyle \sum _ { j = 1 } ^ { d } \displaystyle \int _ { \pmb { \xi } \in S _ { \mathbf { w } _ { j } } } \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { i } - \pmb { \xi } ) \widehat { Y } ( \pmb { \xi } ) \mathrm { d } \xi } & { } \\ { \approx \displaystyle \sum _ { j = 1 } ^ { d } \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { i } - \mathbf { w } _ { j } ) \displaystyle \int _ { \pmb { \xi } \in S _ { \mathbf { w } _ { j } } } \widehat { Y } ( \pmb { \xi } ) \mathrm { d } \xi . } \end{array}
549
+ $$
550
+
551
+ Letting the gradient element in (41) be zero for all $a _ { i }$ ’s at a local minimum $( \mathbf { a } ^ { * } , \mathbf { W } ^ { * } )$ of the population risk, the following approximation holds in general case:
552
+
553
+ $$
554
+ \forall j : a _ { j } ^ { * } \approx \int _ { \pmb { \xi } \in S _ { \mathbf { w } _ { j } } } \mathrm { I m } \{ \widehat { Y } ( \pmb { \xi } ) \} \mathrm { d } \pmb { \xi } ,
555
+ $$
556
+
557
+ Here, the matrix $\left[ \widehat { P _ { \mathbf { X } } } ( \mathbf { w } _ { i } - \mathbf { w } _ { j } ) \right] _ { 1 \leq i , j \leq d }$ is positive-definite and hence invertible, because $\widehat { P \mathbf { x } }$ is the Fourier transform of $P \mathbf { x }$ and due to Bochner’s theorem a positive-definite kernel function. Therefore, the system of linear equations -PcX(w∗i − w∗j ) -a∗j − Rξ∈Sw $\begin{array} { r } { \left[ \widehat { P _ { { \bf X } } } ( { \bf w } _ { i } ^ { * } - { \bf w } _ { j } ^ { * } ) \right] \left[ a _ { j } ^ { * } - \int _ { \pmb { \xi } \in S _ { { \bf w } _ { j } } } \mathrm { I m } \{ \widehat { Y } ( \pmb { \xi } ) \} \mathrm { d } \pmb { \xi } \right] \approx \mathbf { 0 } } \end{array}$ would imply (42). This discussion indicates that the result of Theorem 4 would remain valid even if the isolated components condition does not hold.
md/train/HJWHIKqgl/HJWHIKqgl.md ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GENERATIVE MODELS AND MODEL CRITICISM VIA OPTIMIZED MAXIMUM MEAN DISCREPANCY
2
+
3
+ Danica J. Sutherland∗ † Aaditya Ramdas‡
4
+
5
+ Hsiao-Yu Tung† Alex Smola†
6
+
7
+ Heiko Strathmann∗ Soumyajit De∗ Arthur Gretton∗
8
+
9
+ ∗ Gatsby Computational Neuroscience Unit, University College London † School of Computer Science, Carnegie Mellon University ‡ Departments of EECS and Statistics, University of California at Berkeley djs@djsutherland.ml htung@cs.cmu.edu
10
+
11
+ # ABSTRACT
12
+
13
+ We propose a method to optimize the representation and distinguishability of samples from two probability distributions, by maximizing the estimated power of a statistical test based on the maximum mean discrepancy (MMD). This optimized MMD is applied to the setting of unsupervised learning by generative adversarial networks (GAN), in which a model attempts to generate realistic samples, and a discriminator attempts to tell these apart from data samples. In this context, the MMD may be used in two roles: first, as a discriminator, either directly on the samples, or on features of the samples. Second, the MMD can be used to evaluate the performance of a generative model, by testing the model’s samples against a reference data set. In the latter role, the optimized MMD is particularly helpful, as it gives an interpretable indication of how the model and data distributions differ, even in cases where individual model samples are not easily distinguished either by eye or by classifier.
14
+
15
+ This post-publication revision corrects some errors in constants of the estimator (5). The appendix deriving the estimator has been replaced by Sutherland (2019).
16
+
17
+ # 1 INTRODUCTION
18
+
19
+ Many problems in testing and learning require evaluating distribution similarity in high dimensions, and on structured data such as images or audio. When a complex generative model is learned, it is necessary to provide feedback on the quality of the samples produced. The generative adversarial network (Goodfellow et al., 2014; Gutmann et al., 2014) is a popular method for training generative models, where a rival discriminator attempts to distinguish model samples from reference data. Training of the generator and discriminator is interleaved, such that a saddle point is eventually reached in the joint loss.
20
+
21
+ A useful insight into the behavior of GANs is to note that when the discriminator is properly trained, the generator is tasked with minimizing the Jensen-Shannon divergence measure between the model and data distributions. When the model is insufficiently powerful to perfectly simulate the test data, as in most nontrivial settings, the choice of divergence measure is especially crucial: it determines which compromises will be made. A range of adversarial divergences were proposed by Huszar (2015), using a weight to interpolate between KL, inverse KL, and Jensen-Shannon. This weight may be interpreted as a prior probability of observing samples from the model or the real world: when there is a greater probability of model samples, we approach reverse KL and the model seeks out modes of the data distribution. When there is a greater probability of drawing from the data distribution, the model approaches the KL divergence, and tries to cover the full support of the data, at the expense of producing some samples in low probability regions.
22
+
23
+ This insight was further developed by Nowozin et al. (2016), who showed that a much broader range of $f$ -divergences can be learned for the discriminator in adversarial models, based on the variational formulation of $f$ -divergences of Nguyen et al. (2008). For a given $f$ -divergence, the model learns the composition of the density ratio (of data to model density) with the derivative of $f$ , by comparing generator and data samples. This provides a lower bound on the “true” divergence that would be obtained if the density ratio were perfectly known. In the event that the model is in a smaller class than the true data distribution, this broader family of divergences implements a variety of different approximations: some focus on individual modes of the true sample density, others try to cover the support. It is straightforward to visualize these properties in one or two dimensions (Nowozin et al., 2016, Figure 5), but in higher dimensions it becomes difficult to anticipate or visualize the behavior of these various divergences.
24
+
25
+ An alternative family of divergences are the integral probability metrics (Müller, 1997), which find a witness function to distinguish samples from $P$ and $Q$ .1 A popular such class of witness functions in GANs is the maximum mean discrepancy (Gretton et al., 2012a), simultaneously proposed by Dziugaite et al. (2015) and Li et al. (2015). The architecture used in these two approaches is actually quite different: Dziugaite et al. use the MMD as a discriminator directly at the level of the generated and test images, whereas Li et al. apply the MMD on input features learned from an autoencoder, and share the decoding layers of the autoencoder with the generator network (see their Figure 1(b)). The generated samples have better visual quality in the latter method, but it becomes difficult to analyze and interpret the algorithm given the interplay between the generator and discriminator networks. In a related approach, Salimans et al. (2016) propose to use feature matching, where the generator is tasked with minimizing the squared distance between expected discriminator features under the model and data distributions, thus retaining the adversarial setting.
26
+
27
+ In light of these varied approaches to discriminator training, it is important to be able to evaluate quality of samples from a generator against reference data. An approach used in several studies is to obtain a Parzen window estimate of the density and compute the log-likelhiood (Goodfellow et al., 2014; Nowozin et al., 2016; Breuleux et al., 2011). Unfortunately, density estimates in such high dimensions are known to be very unreliable both in theory (Wasserman, 2006, Ch. 6) and in practice (Theis et al., 2016). We can instead ask humans to evaluate the generated images (Denton et al., 2015; Salimans et al., 2016), but while evaluators should be able to distinguish cases where the samples are over-dispersed (support of the model is too large), it may be more difficult to find under-dispersed samples (too concentrated at the modes), or imbalances in the proportions of different shapes, since the samples themselves will be plausible images. Recall that different divergence measures result in different degrees of mode-seeking: if we rely on human evaluation, we may tend towards always using divergences with under-dispersed samples.
28
+
29
+ We propose to use the MMD to distinguish generator and reference data, with features and kernels chosen to maximize the test power of the quadratic-time MMD of Gretton et al. (2012a). Optimizing MMD test power requires a sophisticated treatment due to the different form of the null and alternative distributions (Section 2). We also develop an efficient approach to obtaining quantiles of the MMD distribution under the null (Section 3). We demonstrate on simple artificial data that simply maximizing the MMD (as in Sriperumbudur et al., 2009) provides a less powerful test than our approach of explicitly maximizing test power. Our procedure applies even when our definition of the MMD is computed on features of the inputs, since these can also be trained by power maximization.
30
+
31
+ When designing an optimized MMD test, we should choose a kernel family that allows us to visualize where the probability mass of the two samples differs most. In our experiments on GAN performance evaluation, we use an automatic relevance determination (ARD) kernel over the output dimensions, and learn which coordinates differ meaningfully by finding which kernels retain significant bandwidth when the test power is optimized. We may further apply the method of Lloyd & Ghahramani (2015, Section 5) to visualize the witness function associated with this MMD, by finding those model and data samples occurring at the maxima and minima of the witness function (i.e., the samples from one distribution least likely to be in high probability regions of the other). The optimized witness function gives a test with greater power than a standard RBF kernel, suggesting that the associated witness function peaks are an improved representation of where the distributions differ. We also propose a novel generative model based on the feature matching idea of Salimans et al. (2016), using MMD rather than their “minibatch discrimination” heuristic, for a more principled and more stable enforcement of sample diversity, without requiring labeled data.
32
+
33
+ # 2 MAXIMIZING TEST POWER OF A QUADRATIC MMD TEST
34
+
35
+ Our methods rely on optimizing the power of a two-sample test over the choice of kernel. We first describe how to do this, then review alternative kernel selection approaches.
36
+
37
+ # 2.1 MMD AND TEST POWER
38
+
39
+ We will begin by reviewing the maximum mean discrepancy and its use in two-sample tests. Let $k$ be the kernel of a reproducing kernel Hilbert space (RKHS) $\mathcal { H } _ { k }$ of functions on a set $\mathcal { X }$ . We assume that $k$ is measurable and bounded, $\textstyle \operatorname* { s u p } _ { x \in { \mathcal { X } } } k ( x , x ) < \infty$ . Then the MMD in $\mathcal { H } _ { k }$ between two distributions $P$ and $Q$ over $\mathcal { X }$ is (Gretton et al., 2012a):
40
+
41
+ $$
42
+ \mathbf { M M D } _ { k } ^ { 2 } ( P , Q ) : = \mathbb { E } _ { x , x ^ { \prime } } \left[ k ( x , x ^ { \prime } ) \right] + \mathbb { E } _ { y , y ^ { \prime } } \left[ k ( y , y ^ { \prime } ) \right] - 2 \mathbb { E } _ { x , y } \left[ k ( x , y ) \right]
43
+ $$
44
+
45
+ where $x , x ^ { \prime } \overset { i i d } { \sim } P$ and $y , y ^ { \prime } \stackrel { i i d } { \sim } Q$ . Many kernels, including the popular Gaussian RBF, are characteristic (Fukumizu et al., 2008; Sriperumbudur et al., 2010), which implies that the MMD is a metric, and in particular that $\boldsymbol { \mathrm { M M D } } _ { k } ( P , Q ) = 0$ if and only if $P = Q$ , so that tests with any characteristic kernel are consistent. That said, different characteristic kernels will yield different test powers for finite sample sizes, and so we wish to choose a kernel $k$ to maximize the test power. Below, we will usually suppress explicit dependence on $k$ .
46
+
47
+ Given $X = \{ X _ { 1 } , \ldots , X _ { m } \} \stackrel { i i d } { \sim } P$ and $Y = \{ Y _ { 1 } , \dots , Y _ { m } \} \overset { i i d } { \sim } Q , ^ { 2 }$ one estimator of $\mathbf { M M D } ( P , Q )$ is
48
+
49
+ $$
50
+ { \widehat { \mathrm { M M D } } } _ { \mathrm { U } } ^ { 2 } ( X , Y ) : = { \frac { 1 } { { \binom { m } { 2 } } } } \sum _ { i \neq i ^ { \prime } } k ( X _ { i } , X _ { i ^ { \prime } } ) + { \frac { 1 } { { \binom { m } { 2 } } } } \sum _ { j \neq j ^ { \prime } } k ( Y _ { j } , Y _ { j ^ { \prime } } ) - { \frac { 2 } { { \binom { m } { 2 } } } } \sum _ { i \neq j } k ( X _ { i } , Y _ { j } ) .
51
+ $$
52
+
53
+ This estimator is unbiased, and has nearly minimal variance among unbiased estimators (Gretton et al., 2012a, Lemma 6).
54
+
55
+ Following Gretton et al. (2012a), we will conduct a hypothesis test with null hypothesis $H _ { 0 } : P = Q$ and alternative $H _ { 1 } : P \neq Q$ , using test statistic $m \widehat { \mathrm { M M D } } _ { \mathrm { U } } ^ { 2 } ( X , Y )$ . For a given allowable probability of false rejection $\alpha$ , we choose a test threshold $c _ { \alpha }$ and reject $H _ { 0 }$ if $m \widehat { \mathrm { M M D } } _ { \mathrm { U } } ^ { 2 } ( X , Y ) > c _ { \alpha }$ .
56
+
57
+ Under $H _ { 0 } : P = Q$ , $m \widehat { \mathrm { M M D } } _ { \mathrm { U } } ^ { 2 } ( X , Y )$ converges asymptotically to a distribution that depends on the unknown distribution $P$ (Gretton et al., 2012a, Theorem 12); we thus cannot evaluate the test threshold $c _ { \alpha }$ in closed form. We instead estimate a data-dependent threshold $\hat { c } _ { \alpha }$ via permutation: randomly partition the data $X \cup Y$ into $X ^ { \prime }$ and $Y ^ { \prime }$ many times, evaluate $m \widehat { \mathrm { M M D } } _ { \mathrm { U } } ^ { 2 } ( X ^ { \prime } , Y ^ { \prime } )$ on each split, and estimate the $( 1 - \alpha )$ th quantile $\hat { c } _ { \alpha }$ from these samples. Section 3 discusses efficient computation of this process.
58
+
59
+ We now describe a mechanism to choose the kernel $k$ so as to maximize the power of its associated test. First, note that under the alternative $H _ { 1 } : P \neq Q$ , $\widehat { \overline { { { \bf M } { \bf M } { \bf D } } } _ { \mathrm { U } } ^ { 2 } }$ is asymptotically normal,
60
+
61
+ $$
62
+ \frac { \widehat { \mathrm { { M M D } } } _ { \mathrm { { U } } } ^ { 2 } ( X , Y ) - \mathrm { { M M D } } ^ { 2 } ( P , Q ) } { \sqrt { V _ { m } ( P , Q ) } } \stackrel { D } { } { \mathcal { N } } ( 0 , 1 ) ,
63
+ $$
64
+
65
+ where $V _ { m } ( P , Q )$ denotes the asymptotic variance of the $\widehat { \overline { { { \bf M } { \bf M } { \bf D } } } _ { \mathrm { U } } ^ { 2 } }$ estimator for samples of size $m$ from $P$ and $Q$ (Serfling, 1980). The power of our test is thus, using $\mathrm { P r } _ { 1 }$ to denote probability under $H _ { 1 }$ ,
66
+
67
+ $$
68
+ \begin{array} { r l r } & { } & { \mathrm { P r } _ { 1 } \left( m \widehat { \mathbf { M } \mathbf { M } \mathbf { D } } _ { \mathrm { U } } ^ { 2 } ( X , Y ) > \widehat { c } _ { \alpha } \right) = \mathrm { P r } _ { 1 } \left( \frac { \widehat { \mathbf { M } \mathbf { M } \mathbf { D } } _ { \mathrm { U } } ^ { 2 } ( X , Y ) - \mathbf { M } \mathbf { M } \mathbf { D } ^ { 2 } ( P , Q ) } { \sqrt { V _ { m } ( P , Q ) } } > \frac { \widehat { c } _ { \alpha } / m - \mathbf { M } \mathbf { M } \mathbf { D } ^ { 2 } ( P , Q ) } { \sqrt { V _ { m } ( P , Q ) } } \right) } \\ & { } & { \to \Phi \left( \frac { \mathbf { M } \mathbf { M } \mathbf { D } ^ { 2 } ( P , Q ) } { \sqrt { V _ { m } ( P , Q ) } } - \frac { c _ { \alpha } } { m \sqrt { V _ { m } ( P , Q ) } } \right) \qquad ( 4 ) } \end{array}
69
+ $$
70
+
71
+ where $\Phi$ is the CDF of the standard normal distribution. The second step follows by (3) and the convergence of $\hat { c } _ { \alpha } \to c _ { \alpha }$ (Alba Fernández et al., 2008). Test power is therefore maximized by maximizing the argument of $\Phi$ : i.e. increasing the ratio of $\mathbf { M } \mathbf { M } \mathbf { D } ^ { 2 } ( \boldsymbol { P } , \boldsymbol { Q } )$ to $\sqrt { V _ { m } ( P , Q ) }$ , and reducing the ratio of $c _ { \alpha }$ to $m \sqrt { V _ { m } ( P , Q ) }$ .
72
+
73
+ For a given kernel $k$ , $V _ { m }$ is $O ( m ^ { - 1 } )$ , while both $c _ { \alpha }$ and $\mathrm { { \bf M M D } ^ { 2 } }$ are constants. Thus the first term is $O ( { \sqrt { m } } )$ , and the second is $O ( 1 / \sqrt { m } )$ . Two situations therefore arise: when $m$ is small relative to the difference in $P$ and $Q$ (i.e., we are close to the null), both terms need to be taken into acccount to maximize test power. Here, we propose to maximize (4) using the efficient computation of $\hat { c } _ { \alpha }$ in Section 3. As $m$ grows, however, we can asymptotically maximize the power of the test by choosing a kernel $k$ that maximizes the $t { \cdot }$ -statistic $t _ { k } ( P , Q ) : = \mathbf { M M D } _ { k } ^ { 2 } ( P , Q ) / \sqrt { V _ { m } ^ { ( k ) } ( P , Q ) }$ . In practice, we maximize an estimator of $t _ { k } ( P , Q )$ given by $\widehat { t } _ { k } ( X , Y ) : = \widehat { \mathrm { M M D } } _ { \mathrm { U } } ^ { 2 } ( X , Y ) / \sqrt { \widehat { V } _ { m } ( X , Y ) }$ , with ${ \widehat { V } } _ { m } ( X , Y )$ discussed shortly.
74
+
75
+ To maintain the validity of the hypothesis test, we will need to divide the observed data $X$ and $Y$ into a “training sample,” used to choose the kernel, and a “testing sample,” used to perform the final hypothesis test with the learned kernel.
76
+
77
+ We next consider families of kernels over which to optimize. The most common kernels used for MMD tests are standard kernels from the literature, e.g. the Gaussian RBF, Matérn, or Laplacian kernels. It is the case, however, that for any function $z : \mathcal { X } _ { 1 } \mathcal { X } _ { 2 }$ and any kernel $\kappa : \mathcal { X } _ { 2 } \times \mathcal { X } _ { 2 } \to \mathbb { R }$ , the composition $\kappa \circ z$ is also a kernel on $\mathcal { X } _ { 1 }$ .3 We can thus choose a function $z$ to extract meaningful features of the inputs, and use a standard kernel $\kappa$ to compare those features. We can select such a function $z$ (as well as $\kappa$ ) by performing kernel selection on the family of kernels $\kappa \circ z$ . To do so, we merely need to maximize $\bar { t } _ { \kappa \circ z } ( \boldsymbol { X } , \boldsymbol { Y } )$ through standard optimization techniques based on the gradient of $\hat { t } _ { \kappa \circ z }$ with respect to the parameterizations of $z$ and $\kappa$ .
78
+
79
+ We now give an expression for an empirical estimate $\widehat { V } _ { m }$ of the variance $V _ { m } ( P , Q )$ that appears in our test power. This estimate is similar to that given by Bounliphone et al. (2016, Appendix A.1), but incorporates second-order terms and corrects some small sources of bias. Though the expression is somewhat unwieldy, it is defined by various sums of the kernel matrices and is differentiable with respect to the kernel $k$ .
80
+
81
+ $V _ { m } ( P , Q )$ is given in terms of expectations of $k$ under $P$ and $Q$ in Appendix A. We replace these expectations with finite-sample averages, giving us the required estimator. Define matrices $K _ { X Y }$ , $\tilde { K } _ { X X }$ , and $\tilde { K } _ { Y Y }$ by $( K _ { X Y } ) _ { i , j } \ : = \ : k ( X _ { i } , Y _ { j } ) , \ : ( \tilde { K } _ { X X } ) _ { i i } \ : = \ : 0 , \ : ( \tilde { K } _ { X X } ) _ { i j } \ : = \ : k ( X _ { i } , X _ { j } )$ for $i \neq j$ , and $\tilde { K } _ { Y Y }$ similarly to $\tilde { K } _ { X X }$ . Let $e$ be an $m$ -vector of ones, and use the falling factorial notation $( m ) _ { r } : = m ( m - 1 ) \cdot \cdot \cdot ( m - r + 1 )$ . Then an unbiased estimator for $V _ { m } ( P , Q )$ is:
82
+
83
+ $$
84
+ \begin{array} { l } { \widehat { V } _ { m } : = \frac { 4 } { ( m ) _ { 4 } } \left[ \left\| \tilde { K } _ { X X } e \right\| ^ { 2 } + \left\| \tilde { K } _ { Y Y } e \right\| ^ { 2 } \right] + \frac { 4 ( m ^ { 2 } - m - 1 ) } { m ^ { 3 } ( m - 1 ) ^ { 2 } } \left[ \left\| K _ { X Y } e \right\| ^ { 2 } + \left\| K _ { X Y } ^ { \top } e \right\| ^ { 2 } \right] } \\ { \displaystyle \qquad \otimes } \\ { \displaystyle \qquad - \frac { 8 } { m ^ { 2 } ( m ^ { 2 } - 3 m + 2 ) } \left[ e ^ { \top } \tilde { K } _ { X X } K _ { X Y } e + e ^ { \top } \tilde { K } _ { Y Y } K _ { X Y } ^ { \top } e \right] } \\ { \displaystyle \qquad + \frac { 8 } { m ^ { 2 } ( m ) _ { 3 } } \left[ \left( e ^ { \top } \tilde { K } _ { X X } e + e ^ { \top } \tilde { K } _ { Y Y } e \right) \left( e ^ { \top } K _ { X Y } e \right) \right] } \\ { \displaystyle \qquad - \frac { 2 ( 2 m - 3 ) } { ( m ) _ { 2 } ( m ) _ { 4 } } \left[ \left( e ^ { \top } \tilde { K } _ { X X } e \right) ^ { 2 } + \left( e ^ { \top } \tilde { K } _ { Y Y } e \right) ^ { 2 } \right] - \frac { 4 ( 2 m - 3 ) } { m ^ { 3 } ( m - 1 ) ^ { 3 } } \left[ \left( e ^ { \top } K _ { X Y } e \right) ^ { 2 } \right] } \\ { \displaystyle \qquad - \frac { 2 } { m ( m ^ { 3 } - 6 m ^ { 2 } + 1 1 m - 6 ) } \left[ \left\| \tilde { K } _ { X X } \right\| _ { F } ^ { 2 } + \left\| \tilde { K } _ { Y Y } \right\| _ { F } ^ { 2 } \right] + \frac { 4 ( m - 2 ) } { m ^ { 2 } ( m - 1 ) ^ { 3 } } \left\| K _ { X Y } \right\| _ { F } ^ { 2 } . } \end{array}
85
+ $$
86
+
87
+ # 2.2 OTHER APPROACHES TO MMD KERNEL SELECTION
88
+
89
+ The most common practice in performing two-sample tests with MMD is to use a Gaussian RBF kernel, with bandwidth set to the median pairwise distance among the joint data. This heuristic often works well, but fails when the scale on which $P$ and $Q$ vary differs from the scale of their overall variation (as in the synthetic experiment of Section 4). Ramdas et al. (2015a;b) study the power of the median heuristic in high-dimensional problems, and justify its use for the case where the means of $P$ and $Q$ differ.
90
+
91
+ An early heuristic for improving test power was to simply maximize $\widehat { \overline { { { \bf M } { \bf M } { \bf D } } } _ { \mathrm { U } } ^ { 2 } }$ . Sriperumbudur et al. (2009) proved that, for certain classes of kernels, this yields a consistent test. As further shown by Sriperumbudur et al., however, maximizing MMD amounts to minimizing training classification error under linear loss. Comparing with (4), this is plainly not an optimal approach for maximizing test power, since variance is ignored.4 One can also consider maximizing criteria based on cross validation (Sugiyama et al., 2011; Gretton et al., 2012b; Strathmann, 2012). This approach is not differentiable, and thus difficult to maximize among more than a fixed set of candidate kernels. Moreover, where this cross-validation is used to maximize the MMD on a validation set (as in Sugiyama et al., 2011), it again amounts to maximizing classification performance rather than test performance, and is suboptimal in the latter setting (Gretton et al., 2012b, Figure 1). Finally, Gretton et al. (2012b) previously studied direct optimization of the power of an MMD test for a streaming estimator of the MMD, for which optimizing the ratio of the empirical statistic to its variance also optimizes test power. This streaming estimator uses data very inefficiently, however, often requiring $m ^ { 2 }$ samples to achieve power comparable to tests based on $\widehat { \overline { { { \bf M } { \bf M } { \bf D } } } _ { \mathrm { U } } ^ { 2 } }$ with $m$ samples (Ramdas et al., 2015a).
92
+
93
+ # 3 EFFICIENT IMPLEMENTATION OF PERMUTATION TESTS FOR $\widehat { \mathrm { M M D } } _ { \mathrm { U } } ^ { 2 }$
94
+
95
+ Practical implementations of tests based on $\widehat { \overline { { { \bf M } { \bf M } { \bf D } } } _ { \mathrm { U } } ^ { 2 } }$ require efficient estimates of the test threshold $\hat { c } _ { \alpha }$ . There are two known test threshold estimates that lead to a consistent test: the permutation test mentioned above, and a more sophisticated null distribution estimate based on approximating the eigenspectrum of the kernel, previously reported to be faster than the permutation test (Gretton et al., 2009). In fact, the relatively slow reported performance of the permutation approach was due to the naive Matlab implementation of the permutation test in the code accompanying Gretton et al. (2012a), which creates a new copy of the kernel matrix for every permutation. We show here that, by careful design, permutation thresholds can be computed substantially faster – even when compared to parallelized state-of-the-art spectral solvers (not used by Gretton et al.).
96
+
97
+ First, we observe that we can avoid copying the kernel matrix simply by generating permutation indices for each null sample and accessing the precomputed kernel matrix in permuted order. In practice, however, this does not give much performance gain due to the random nature of memoryaccess which conflicts with how modern CPUs implement caching. Second, if we rather maintain an inverse map of the permutation indices, we can easily traverse the matrix in a sequential fashion. This approach exploits the hardware prefetchers and reduces the number of CPU cache misses from almost $100 \%$ to less than $10 \%$ . Furthermore, the sequential access pattern of the kernel matrix enables us to invoke multiple threads for computing the null samples, each traversing the matrix sequentially, without compromising the locality of reference in the CPU cache.
98
+
99
+ We consider an example problem of computing the test using 200 null distribution samples on $m = 2 0 0 0$ two-dimensional samples, comparing a Gaussian to a Laplace distribution with matched moments. We compare our optimized permutation test against a spectral test using the highlyoptimized (and proprietary) state-of-the-art spectral solver of Intel’s MKL library (Intel, 2003–17). All results are averaged over 30 runs; the variance across runs was negligible.
100
+
101
+ Figure 1 (left) shows the obtained speedups as the number of computing threads grow for $m = 2 0 0 0$ Our implementation is not only faster on a single thread, but also saturates more slowly as the number of threads increases. Figure 1 (right) shows timings for increasing problem sizes (i.e. $m$ ) when using all available system threads (here 24). For larger problems, our permutation implementation (scaling as $\mathcal { O } ( m ^ { 2 } ) )$ is an order of magnitude faster than the spectral test (scaling as $\bar { \mathcal { O } } ( m ^ { 3 } ) )$ . For smaller problems (for which Gretton et al. suggested the spectral test), there is still a significant performance increase.
102
+
103
+ ![](images/fe5c6469236793f0c15616b92699b1c7de4442302950c111a8023f5178efa19b.jpg)
104
+ Figure 1: Runtime comparison for sampling the null distribution. We compare our optimized permutation approach to the spectral method using Intel’s MKL spectral solver. Time spent precomputing the kernel matrix is not included. Left: Increasing number of threads for fixed problem size $m = 2 0 0 0$ . Single-threaded times of other implementations: Matlab reference spectral 381s, Python permutation 182s, Shogun spectral (eigen3) 87s. Right: Increasing problem sizes using the maximum number of 24 system threads.
105
+
106
+ For further reference, we also report timings of available non-parallelized implementations for $m = 2 0 0 0$ , compared to our version’s 12s in Figure 1 (left): 87s for an open-sourced spectral test in Shogun using eigen3 (Sonnenburg et al., 2016; Guennebaud et al., 2010), 381s for the reference Matlab spectral implementation (Gretton et al., 2012a), and 182s for a naive Python permutation test that partly avoids copying via masking. (All of these times also exclude kernel computation.)
107
+
108
+ # 4 EXPERIMENTS
109
+
110
+ Code for these experiments is available at github.com/djsutherland/opt-mmd.
111
+
112
+ Synthetic data We consider the problem of bandwidth selection for Gaussian RBF kernels on the Blobs dataset of Gretton et al. (2012b). $P$ here is a $5 \times 5$ grid of two-dimensional standard normals, with spacing 10 between the centers. $Q$ is laid out identically, but with covariance $\frac { \varepsilon - 1 } { \varepsilon + 1 }$ between the coordinates (so that the ratio of eigenvalues in the variance is $\varepsilon$ .) Figure 2a shows two samples from $X$ and $Y$ with $\varepsilon = 6$ . Note that when $\varepsilon = 1$ , $P = Q$ .
113
+
114
+ For $\varepsilon ~ \in ~ \{ 1 , 2 , 4 , 6 , 8 , 1 0 \}$ , we take $m \ = \ 5 0 0$ samples from each distribution and compute ${ \widehat { \bf M M D } } _ { \mathrm { U } } ^ { 2 } ( X , Y )$ , ${ \widehat { V } } _ { m } ( X , Y )$ , and $\hat { c } _ { 0 . 1 }$ using 1 000 permutations, for Gaussian RBF kernels with each of 30 bandwidths. We repeat this process 100 times. Figure 2b shows that the median heuristic always chooses too large a bandwidth. When maximizing MMD alone, we see a bimodal distribution of bandwidths, with a significant number of samples falling into the region with low test power. The variance of $\widehat { \overline { { { \bf M } { \bf M } { \bf D } } } _ { \mathrm { U } } ^ { 2 } }$ is much higher in this region, however, hence optimizing the ratio $\hat { t }$ never returns these bandwidths. Figure 2c shows that maximizing $\hat { t }$ outperforms maximizing the MMD across a variety of problem parameters, and performs near-optimally.
115
+
116
+ Model criticism As an example of a real-world two-sample testing problem, we will consider distinguishing the output of a generative model from the reference distribution it attempts to reproduce. We will use the semi-supervised GAN model of Salimans et al. (2016), trained on the MNIST dataset of handwritten images.5 True samples from the dataset are shown in Figure 3a; samples from the learned model are in Figure 3b. Salimans et al. (2016) called their results “completely indistinguishable from dataset images,” and reported that annotators on Mechanical Turk were able to distinguish samples only in $5 2 . 4 \%$ of cases. Comparing the results, however, there are several pixel-level artifacts that make distinguishing the datasets trivial; our methods can pick up on these quickly.
117
+
118
+ ![](images/98c515445af039a26c3d0356824eb9ba49cf9330c65f8ad17230dcd4f246d90f.jpg)
119
+ Figure 2: Results for the Blobs problem. Maximizing $\hat { t }$ performs near-optimally.
120
+
121
+ To make the problem more interesting, we discretized the sampled pixels into black or white (which barely changes the images visually). The samples are then in $\dot { \{ 0 , 1 \} } ^ { 2 8 \times 2 8 }$ . We trained an automatic relevance determination (ARD)-type kernel: in the notation of Section 2.1, $z$ scales each pixel by some learned value, and $k$ is a Gaussian RBF kernel with a learned global bandwidth. We optimized $\mathbf { \widetilde { \Gamma } } _ { \hat { t } }$ on 2 000 samples in batches of size 500 using the Adam optimizer (Kingma & Ba, 2015), where the learned weights are visualized in Figure 3c. This network has essentially perfect discriminative power: testing it on 100 different samples with 1000 permutations for each test, in 98 cases we obtained $p$ -values of 0.000 and twice got 0.001. By contrast, using an RBF kernel with a bandwidth optimized by maximizing the $t$ statistic gave a less powerful test: the worst $p$ -value in 100 repetitions was 0.135, with power $5 7 \%$ at the $\alpha = 0 . 0 1$ threshold. An RBF kernel based on the median heuristic, which here found a bandwidth five times the size of the $t$ -statistic-optimized bandwidth, performed worse still: three out of 100 repetitions found a $p$ -value of exactly 1.000, and power at the .01 threshold was $42 \%$ . The learned weights show that the model differs from the true dataset along the outsides of images, as well as along a vertical line in the center.
122
+
123
+ We can investigate these results in further detail using the approach of Lloyd & Ghahramani (2015), considering the witness function associated with the MMD, which has largest amplitude where the probability mass of the two samples is most different. Thus, samples falling at maxima and minima of the witness function best represent the difference in the distributions. The value of the witness function on each sample is plotted in Figure 3d, along with some images with different values of the witness function. Apparently, the GAN is slightly overproducing images resembling the /-like digits on the left, while underproducing vertical 1s. It is not the case that the GAN is simply underproducing 1s in general: the $p$ -values of a $\chi ^ { 2 }$ contingency test between the outputs of digit classifiers on the two distributions are uniform. This subtle difference in proportions among types of digits would be quite difficult for human observers to detect. Our testing framework allows the model developer to find such differences and decide whether to act on them. One could use a more complex representation function $z$ to detect even more subtle differences between distributions.
124
+
125
+ GAN criterion We now demonstrate the use of MMD as a training criterion in GANs. We consider two basic approaches, and train on MNIST.6 First, the generative moment matching network (GMMN; Figure 4a) approach (Li et al., 2015; Dziugaite et al., 2015) uses an MMD statistic computed with an
126
+
127
+ ![](images/f7c7aa33b1ea67b1a32dae78a7009435a9cf654beace86068b806c52dc66073b.jpg)
128
+ distribution means; the distance between them is small but highly consistent.
129
+ Figure 3: Model criticism of Salimans et al. (2016)’s semi-supervised GAN on MNIST.
130
+
131
+ RBF kernel directly on the images as the discriminator of a GAN model. The $t$ -GMMN (Figure 4b) has the generator minimize the $\hat { t } _ { k }$ statistic for a fixed kernel.7 Compared to standard GMMNs, the $t$ -GMMN more directly attempts to make the distributions indistinguishable under the kernel function; it avoids a situation like that of Figure 3d, where although the MMD value is quite small, the two distributions are perfectly distinguishable due to the small variance.
132
+
133
+ Next, feature matching GANs (Figure 4c) train the discriminator as a classifier like a normal GAN, but train the generator to minimize the MMD between generator samples and reference samples with a kernel computed on intermediate features of the discriminator. Salimans et al. (2016) proposed feature matching using the mean features at the top of the discriminator (effectively using an MMD with a linear kernel); we instead use MMD with a mixture of RBF kernels, ensuring that the full feature distributions match, rather than just their means. This helps avoid the common failure mode of GANs where the generator collapses to outputting a small number of samples considered highly realistic by the discriminator. Using the MMD-based approach, however, no single point can approximate the feature distribution. The minibatch discrimination approach of Salimans et al. (2016) attempts to solve the same problem, by introducing features measuring the similarity of each sample to a selection of other samples, but we were unable to get it to work without labels to force the discriminator in a reasonable direction; Figure 4d demonstrates some of those failures, with each row showing six samples from each of six representative runs of the model.
134
+
135
+ # ACKNOWLEDGEMENTS
136
+
137
+ We would like to thank Tim Salimans, Ian Goodfellow, and Wojciech Zaremba for providing their code and for gracious assistance in using it, as well as Jeff Schneider for helpful discussions.
138
+
139
+ ![](images/93232b430bbd8dfdaf9f60be7276feac59d36c2e89cb7cb0941278bb584d8e46.jpg)
140
+ Figure 4: MNIST digits from various models. Part d shows six runs of the minibatch discrimination model of Salimans et al. (2016), trained without labels — the same model that, with labels, generated Figure 3b. (The third row is the closest we got the model to generating digits without any labels.)
141
+
142
+ # REFERENCES
143
+
144
+ V. Alba Fernández, M. Jiménez-Gamero, and J. Muñoz Garcia. A test for the two-sample problem based on empirical characteristic functions. Computational Statistics & Data Analysis, 52:3730– 3748, 2008.
145
+
146
+ Wacha Bounliphone, Eugene Belilovsky, Matthew B. Blaschko, Ioannis Antonoglou, and Arthur Gretton. A test of relative similarity for model selection in generative models. In International Conference on Learning Representations, 2016. arXiv:1511.04581.
147
+
148
+ Olivier Breuleux, Yoshua Bengio, and Pascal Vincent. Quickly generating representative samples from an rbm-derived process. Neural Computation, 23(8):2053–2073, 2011.
149
+
150
+ Emily Denton, Soumith Chintala, Arthur Szlam, and Rob Fergus. Deep generative image models using a laplacian pyramid of adversarial networks. In Advances in Neural Information Processing Systems, pp. 1486–1494. 2015.
151
+
152
+ Gintare Karolina Dziugaite, Daniel M. Roy, and Zoubin Ghahramani. Training generative neural networks via maximum mean discrepancy optimization. In Uncertainty in Artificial Intelligence, 2015. arXiv:1505.03906.
153
+
154
+ Kenji Fukumizu, Arthur Gretton, Xiaohai Sun, and Bernhard Schölkopf. Kernel measures of conditional dependence. In Advances in Neural Information Processing Systems, 2008.
155
+
156
+ Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in Neural Information Processing Systems, 2014. arXiv:1406.2661.
157
+
158
+ Arthur Gretton, Kenji Fukumizu, Zaid Harchaoui, and Bharath K. Sriperumbudur. A fast, consistent kernel two-sample test. In Advances in Neural Information Processing Systems, pp. 673–681, 2009.
159
+
160
+ Arthur Gretton, Karsten M. Borgwardt, Malte J Rasch, Bernhard Schölkopf, and Alex J. Smola. A kernel two-sample test. The Journal of Machine Learning Research, 13, 2012a.
161
+
162
+ Arthur Gretton, Bharath Sriperumbudur, Dino Sejdinovic, Heiko Strathmann, and Massimiliano Pontil. Optimal kernel choice for large-scale two-sample tests. In Advances in Neural Information Processing Systems, 2012b.
163
+
164
+ Gaël Guennebaud, Benoît Jacob, et al. Eigen v3. http://eigen.tuxfamily.org, 2010.
165
+
166
+ Michael U. Gutmann, Ritabrata Dutta, Samuel Kaski, and Jukka Corander. Statistical inference of intractable generative models via classification. 2014. arXiv:1407.4981.
167
+
168
+ Ferenc Huszar. How (not) to train your generative model: Scheduled sampling, likelihood, adversary? 2015. arXiv:1511.05101.
169
+
170
+ MKL Intel. Intel math kernel library, 2003–17.
171
+
172
+ Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations, 2015. arXiv:1412.6980.
173
+
174
+ Yujia Li, Kevin Swersky, and Richard Zemel. Generative moment matching networks. In Uncertainty in Artificial Intelligence, 2015. arXiv:1502.02761.
175
+
176
+ James Robert Lloyd and Zoubin Ghahramani. Statistical model criticism using kernel two sample tests. In Advances in Neural Information Processing Systems, pp. 829–837, 2015.
177
+
178
+ Alfred Müller. Integral probability metrics and their generating classes of functions. Advances in Applied Probability, 29(2):429–443, 1997.
179
+
180
+ XuanLong Nguyen, Martin J. Wainwright, and Michael I. Jordan. On optimal quantization rules in some problems in sequential decentralized detection. IEEE Transactions on Information Theory, 54(7):3285–3295, 2008.
181
+
182
+ Sebastian Nowozin, Botond Cseke, and Ryota Tomioka. $f$ -GAN: Training generative neural samplers using variational divergence minimization. In Advances in Neural Information Processing Systems, 2016.
183
+
184
+ Aaaditya Ramdas, Sashank Reddi, Barnabás Póczos, Aarti Singh, and Larry Wasserman. Adaptivity and Computation-Statistics Tradeoffs for Kernel and Distance based High Dimensional Two Sample Testing, 2015a. arXiv:1508.00655.
185
+
186
+ Aaditya Ramdas, Sashank J. Reddi, Barnabás Póczos, Aarti Singh, and Larry Wasserman. On the decreasing power of kernel and distance based nonparametric hypothesis tests in high dimensions. In AAAI Conference on Artificial Intelligence, 2015b. arXiv:1406.2083.
187
+
188
+ Aaditya Ramdas, Aarti Singh, and Larry Wasserman. Classification accuracy as a proxy for two sample testing, 2016. arXiv:1602.02210.
189
+
190
+ Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training GANs. In Advances in Neural Information Processing Systems, 2016. arXiv:1606.03498.
191
+
192
+ Robert J. Serfling. Approximation Theorems of Mathematical Statistics. John Wiley & Sons, 1980.
193
+
194
+ Soeren Sonnenburg, Heiko Strathmann, Sergey Lisitsyn, Viktor Gal, Fernando J. Iglesias García, Wu Lin, Chiyuan Zhang, Soumyajit De, frx, tklein23, Evgeniy Andreev, JonasBehr, sploving, Parijat Mazumdar, Christian Widmer, Abhijeet Kislay, Kevin Hughes, Roman Votyakov, khalednasr, Saurabh Mahindre, Alesis Novik, Abinash Panda, Evangelos Anagnostopoulos, Liang Pang, serialhex, Alex Binder, Sanuj Sharma, Michal Uˇricᡠˇr, Björn Esser, and Daniel Pyrathon. shogun: Shogun 4.1.0 - tajinohi no agatamori, May 2016.
195
+
196
+ Bharath K. Sriperumbudur, Kenji Fukumizu, Arthur Gretton, Gert R. G. Lanckriet, and Bernhard Schölkopf. Kernel choice and classifiability for RKHS embeddings of probability distributions. In Advances in Neural Information Processing Systems, 2009.
197
+
198
+ Bharath K. Sriperumbudur, Arthur Gretton, Kenji Fukumizu, Gert R. G. Lanckriet, and Bernhard Schölkopf. Hilbert space embeddings and metrics on probability measures. Journal of Machine Learning Research, 11:1517–1561, 2010.
199
+
200
+ Bharath K. Sriperumbudur, Kenji Fukumizu, Arthur Gretton, Bernhard Schölkopf, and Gert R. G. Lanckriet. On the empirical estimation of integral probability metrics. Electronic Journal of Statistics, 6:1550–1599, 2012.
201
+
202
+ Heiko Strathmann. Adaptive Large-Scale Kernel Two-Sample Testing. M.Sc. thesis, University College London, 2012.
203
+
204
+ Masashi Sugiyama, Taiji Suzuki, Yuta Itoh, Takafumi Kanamori, and Manabu Kimura. Least-squares two-sample test. Neural Networks, 24(7):735–751, sep 2011.
205
+
206
+ Danica J. Sutherland. Unbiased estimators for the variance of MMD estimators, 2019. arXiv:1906.02104.
207
+
208
+ Lucas Theis, Aäron van den Oord, and Matthias Bethge. A note on the evaluation of generative models. In International Conference on Learning Representations, 2016. arXiv:1511.01844.
209
+
210
+ Larry Wasserman. All of Nonparametric Statistics. Springer, 2006.
211
+
212
+ # A VARIANCE OF THE PAIRWISE MMD ESTIMATOR
213
+
214
+ The publication version of this appendix contained some small mistakes. Please refer instead to Sutherland (2019); in particular, the estimator (5) is equivalent to (4) of that document.
md/train/HJem3yHKwH/HJem3yHKwH.md ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EMPIR: ENSEMBLES OF MIXED PRECISION DEEP NETWORKS FOR INCREASED ROBUSTNESS AGAINST ADVERSARIAL ATTACKS
2
+
3
+ # Sanchari Sen
4
+
5
+ Center for Brain-Inspired Computing
6
+ School of Electrical and Computer Engineering
7
+ Purdue University
8
+ West Lafayette, IN, USA
9
+ sen9@purdue.edu
10
+ Balaraman Ravindran
11
+ Department of Computer Science and Engineering
12
+ Robert Bosch Centre for Data Science and AI
13
+ Indian Institute of Technology (IIT) Madras
14
+ Chennai, TN, India
15
+ ravi@cse.iitm.ac.in
16
+ Anand Raghunathan
17
+ Center for Brain-Inspired Computing
18
+ School of Electrical and Computer Engineering
19
+ Purdue University
20
+ West Lafayette, IN, USA
21
+ raghunathan@purdue.edu
22
+
23
+ # ABSTRACT
24
+
25
+ Ensuring robustness of Deep Neural Networks (DNNs) is crucial to their adoption in safety-critical applications such as self-driving cars, drones, and healthcare. Notably, DNNs are vulnerable to adversarial attacks in which small input perturbations can produce catastrophic misclassifications. In this work, we propose EMPIR, ensembles of quantized DNN models with different numerical precisions, as a new approach to increase robustness against adversarial attacks. EMPIR is based on the observation that quantized neural networks often demonstrate much higher robustness to adversarial attacks than full precision networks, but at the cost of a substantial loss in accuracy on the original (unperturbed) inputs. EMPIR overcomes this limitation to achieve the “best of both worlds”, i.e., the higher unperturbed accuracies of the full precision models combined with the higher robustness of the low precision models, by composing them in an ensemble. Further, as low precision DNN models have significantly lower computational and storage requirements than full precision models, EMPIR models only incur modest compute and memory overheads compared to a single full-precision model $4 \%$ in our evaluations). We evaluate EMPIR across a suite of DNNs for 3 different image recognition tasks (MNIST, CIFAR-10 and ImageNet) and under 4 different adversarial attacks. Our results indicate that EMPIR boosts the average adversarial accuracies by $4 2 . 6 \%$ , $1 5 . 2 \%$ and $1 0 . 5 \%$ for the DNN models trained on the MNIST, CIFAR-10 and ImageNet datasets respectively, when compared to single full-precision models, without sacrificing accuracy on the unperturbed inputs.
26
+
27
+ # 1 INTRODUCTION
28
+
29
+ The success of Deep Neural Networks (DNNs) in different machine learning tasks has fueled their use in safety-critical applications like autonomous cars, unmanned aerial vehicles and healthcare, wherein errors (misclassifications) made by DNNs can lead to severe — in the extreme case, fatal — consequences. Therefore, robustness, i.e., the ability to cope with erroneous or malicious inputs fed to an application, is emerging as an important requirement for DNNs.
30
+
31
+ Several efforts have in fact shown that DNNs behave in unexpected and incorrect ways for small, specifically designed input perturbations (Goodfellow et al. (2014)). An attacker can take advantage of this behavior to intentionally modify the inputs in a manner that forces the DNN model to mis-classify, and the overall system that uses the DNN to fail. A variety of methods for launching adversarial attacks on DNNs have been proposed over the years. These adversarial attacks systematically modify a given original input to cause a misclassification while keeping the input distortion minimal. A few examples of adversarial attacks that have been successfully applied to various DNN models are the Fast Gradient Sign Method (FGSM) (Goodfellow et al. (2014)), Jacobian-based Saliency Map Attack (JSMA) (Papernot et al. (2015)), Carlini-Wagner (CW) (Carlini & Wagner (2016)) and the Basic Iterative Method (BIM) (Kurakin et al. (2016)).
32
+
33
+ Prior works have tried to overcome these vulnerabilities by proposing various defense mechanisms against adversarial attacks. Adversarial training (Goodfellow et al. (2014)), defensive distillation (Papernot et al. (2015)) and input gradient regularization (Ross & Doshi-Velez (2017)) are a few representative defense techniques. Each of these approaches, albeit promising, has limitations with respect to the kind of attacks they can defend against, the increase in training complexity, as well as their effect on the model’s accuracy on the original unperturbed inputs. To address these shortcomings, we propose EMPIR, an ensemble of mixed precision 1 DNN models, as a new form of defense against adversarial attacks and demonstrate that it can significantly improve the robustness of a variety of DNN models across a wide range of adversarial attacks.
34
+
35
+ Ensembles have been widely explored as an approach to improve the performance of machine learning models and classifiers (Hansen & Salamon (1990)). Examples of various successful ensembling methods include averaging, bagging (Breiman (1996)), boosting (Dietterich (2000)), etc. Recently, it has also been suggested that ensembles may help boost the robustness of DNNs (Strauss et al. (2017); Pang et al. (2019); He et al. (2017); Tramer et al. (2017)). The individual models in these \` ensembles are restricted to full precision DNN models, i.e., models utilizing 32 bits of numerical precision to represent different data-structures. Such ensembles are very expensive in terms of the computational and memory overhead (e.g., $1 0 \times$ the baseline for an ensemble with 10 models (Strauss et al. (2017))). In contrast, the use of quantized models in EMPIR, which entail the use of significantly lower number of bits in storage and compute, ensures that the overhead is modest (less than $2 5 \%$ in our evaluations).
36
+
37
+ Quantized DNNs are characterized by the use of lower numbers of bits to represent DNN datastructures like weights and activations (Venkataramani et al. (2014); Hubara et al. (2017); Zhou et al. (2016); Courbariaux et al. (2015)). They have been widely explored as an approach to reduce the high computational and memory demands of DNNs. Recent studies have also observed that these quantized models demonstrate higher robustness to adversarial attacks (Galloway et al. (2017); Siraj Rakin et al. (2018); Panda et al. (2019)). However, the loss in information associated with the quantization process often makes these quantized models perform significantly worse than their fullprecision counterparts while classifying the original unperturbed inputs. This motivates the design of EMPIR, which successfully combines the higher robustness of low-precision models with the higher unperturbed accuracy of the full-precision models. In the general case, EMPIR comprises of $M$ full-precision models and $\mathbf { N }$ low-precision models with the final prediction determined by an ensembling technique such as averaging the probabilities or counting the number of predictions for each class. In practice, we find that $M = 1$ and $N = 2$ or 3 provides a significant improvement in adversarial accuracy with small overheads.
38
+
39
+ In summary, the key contributions of this work are
40
+
41
+ • We propose the use of ensembles of mixed precision models as a defense against adversarial attacks on DNNs.
42
+ • We analyze the effect of ensemble size and ensembling techniques on the overall robustness as well as the computational and storage overheads of the ensemble.
43
+ • Across a suite of 3 different DNN models under 4 different adversarial attacks, we demonstrate that EMPIR exhibits significantly higher robustness when compared to individual models as well as ensembles of full-precision models.
44
+
45
+ # 2 ADVERSARIAL ATTACKS: BACKGROUND
46
+
47
+ Adversarial attacks modify inputs in a manner that force a DNN model to misclassify, while ensuring that the input changes are small and imperceptible to human eyes. In the context of DNNs that operate on images, which are the focus of most prior work, various attack methods have been proposed to systematically modify pixel values in the input image so as to result in a mis-classification. A few such methods are described below.
48
+
49
+ Fast Gradient Sign Method (FGSM) (Goodfellow et al. (2014)). FGSM is a single-step attack that operates by calculating the gradient of the loss function with respect to the input pixels $( \nabla _ { x } L ( \theta , X , Y ) )$ . Based on the sign of the loss, the input pixels are increased or decreased by a small constant, $\epsilon$ , to help move the image towards the direction of increased loss. The adversarial input, $X _ { a d v }$ can be computed as:
50
+
51
+ $$
52
+ X _ { a d v } = X + \epsilon S i g n ( \nabla _ { x } L ( \theta , X , Y ) )
53
+ $$
54
+
55
+ Here, $X$ is the original input image associated with an output $Y$ and $\theta$ refers to the weights of the network.
56
+
57
+ Basic Iterative Method (BIM) (Kurakin et al. (2016)). BIM is an iterative version of the FGSM attack which performs a finer optimization by modifying pixels by small values in each iteration. Further, the image generated in each iteration has its pixel values clipped to ensure minimal distortion. Mathematically, this attack can be described as:
58
+
59
+ $$
60
+ \begin{array} { r } { X _ { a d v } ^ { 0 } = X , \quad X _ { a d v } ^ { N + 1 } = C l i p _ { X , \epsilon } \{ X _ { a d v } ^ { N } + \alpha S i g n ( \nabla _ { x } L ( \theta , X _ { a d v } ^ { N } , y ) ) \} } \end{array}
61
+ $$
62
+
63
+ Here, the terms $X , Y , \theta$ and $\epsilon$ have the same meaning as in Equation 1 and $X _ { a d v } ^ { N }$ refers to the adversarial input generated at the iteration and is the step size in each iteration.
64
+
65
+ Carlini-Wagner (CW) (Carlini & Wagner (2016)). CW is another iterative attack that employs optimizers to create strong adversarial inputs by simultaneously minimizing the input distortion and maximizing the misclassification error. It can be described mathematically as:
66
+
67
+ $\operatorname* { m i n } _ { \delta } \| \delta \| _ { 2 } ^ { 2 } + c \cdot f ( X + \delta )$ such that $( X + \delta ) \in [ 0 , 1 ] ^ { n }$
68
+
69
+ $$
70
+ f ( X ) = \mathrm { { m a x } } ( \underset { i \neq t } { \operatorname* { m a x } } \{ Z ( X ) _ { i } \} - Z ( X ) _ { t } , 0 )
71
+ $$
72
+
73
+ $$
74
+ X _ { a d v } = X + \delta
75
+ $$
76
+
77
+ where $\delta$ is the input distortion, $c$ is the Lagrangian multiplier, $Z ( X )$ is the logit output for the input $X$ , $t$ is the target class and $f ( X )$ is an objective function that satisfies the condition $f ( X + \delta ) \leq 0$ for all misclassifications.
78
+
79
+ Projected Gradient Descent (PGD) (Madry et al. (2017)). PGD is a third type of iterative attack very similar in nature to the BIM attack. Unlike BIM, which starts with the original image itself, PGD starts with a random perturbation of the original input image. PGD can be described by the following equations:
80
+
81
+ $$
82
+ \begin{array} { l } { { X _ { a d v } ^ { 0 } = X + r a n d o m U n i f o r m ( s h a p e ( X ) , \{ - \epsilon , \epsilon \} ) } } \\ { { X _ { a d v } ^ { N + 1 } = C l i p _ { X , \epsilon } \{ X _ { a d v } ^ { N } + \alpha S i g n ( \bigtriangledown _ { x } L ( \theta , X _ { a d v } ^ { N } , y ) ) \} } } \end{array}
83
+ $$
84
+
85
+ Here, the terms $X , Y , X _ { a d v } ^ { N }$ , $\theta$ , $\epsilon$ and $\alpha$ have the same meaning as in Equation 2.
86
+
87
+ To summarize, different adversarial attacks have been proposed that expose the lack of robustness in current DNN models by constructing adversarial inputs that force a misclassification. Developing defenses to these adversarial attacks is critical to enable the deployment of DNNs in safety-critical systems.
88
+
89
+ # 3 EMPIR: ENSEMBLES OF MIXED PRECISION DEEP NETWORKS FOR INCREASED ROBUSTNESS AGAINST ADVERSARIAL ATTACKS
90
+
91
+ To improve the robustness of DNN models, we propose EMPIR, or ensembles of mixed precision models. In this section, we will detail the design of EMPIR models and discuss the overheads associated with them.
92
+
93
+ # 3.1 ADVERSARIAL ROBUSTNESS OF LOW-PRECISION NETWORKS
94
+
95
+ DNNs have conventionally been designed as full precision models utilizing 32-bit floating point numbers to represent different data-structures like weights, activations and errors. However, the high compute and memory demands of these full-precision models have driven efforts to move towards quantized or low-precision DNNs (Venkataramani et al. (2014); Hubara et al. (2017); Zhou et al. (2016); Courbariaux et al. (2015); Wang et al. (2018)). A multitude of quantization schemes have been proposed to minimize the loss of information associated with the quantization process. While our proposal is agnostic to the quantization method used, for the purpose of demonstration we adopt the quantization scheme proposed in DoReFaNet (Zhou et al. (2016)), which has been shown to produce low-precision models with competitive accuracy values. The quantization scheme can be described by Equation 5.
96
+
97
+ $$
98
+ \begin{array} { c } { q u a n t i z e _ { k } ( x ) = \displaystyle \frac { 1 } { 2 ^ { k } - 1 } r o u n d ( ( 2 ^ { k } - 1 ) \cdot x ) } \\ { w _ { k } = 2 \cdot q u a n t i z e _ { k } ( \displaystyle \frac { \operatorname { t a n h } ( w ) } { 2 \cdot m a x ( | \operatorname { t a n h } ( w ) | ) } + \displaystyle \frac { 1 } { 2 } ) - 1 , \quad a _ { k } = q u a n t i z e _ { k } ( a ) } \end{array}
99
+ $$
100
+
101
+ where $k$ refers to the number of quantization bits in the low precision network, $w$ and $w _ { k }$ refer to weight values before and after quantization, and $a$ and $a _ { k }$ refer to activation values before and after quantization.
102
+
103
+ ![](images/0ee838ecb563cab90ca269bab4ce5fc5e86dde4716863af006716b4e1eddd702.jpg)
104
+ Figure 1: Unperturbed accuracies and adversarial accuracies of low-precision models trained for the MNIST dataset
105
+
106
+ ![](images/33d7667b2ae7aa54f11201a9e0461fb9e4d3c9cbe8c9cbe7211665a96999dfa2.jpg)
107
+ Figure 2: Overview of EMPIR
108
+
109
+ In addition to the widely known advantages of reduced model size and reduced complexity of arithmetic computations, recent research efforts have also brought to light another lesser known advantage of low-precision models in the form of increased robustness to adversarial attacks. It has been observed that low-precision models in general exhibit higher values of adversarial accuracy than full-precision models with identical network structures (Galloway et al. (2017); Panda et al. (2019)). One possible explanation for this property is that higher quantization introduces higher amounts of non-linearity, which prevents small changes in the input from drastically altering the output and forcing a misclassification (Galloway et al. (2017)). Figure 1 shows the adversarial accuracies of different low precision models trained on the MNIST dataset under the FGSM attack. Unlike the activations and weights, the gradients utilized in the attack generation process were not quantized, allowing the adversary to launch a stronger attack. From the figure, it is apparent that models with lower numbers of bits used for representing weights and activations exhibit significantly higher levels of adversarial accuracy.
110
+
111
+ However, increasing the robustness of a system by simply replacing the full-precision model with its low-precision variant can negatively impact its accuracy on the original unperturbed inputs (unperturbed accuracy). In other words, the model may now start to mis-classify inputs that were not adversarially perturbed. Figure 1 also shows the unperturbed accuracies of low-precision models. As expected, models with weights and activations represented using lower numbers of bits exhibit lower unperturbed accuracies.
112
+
113
+ Based on the above observations, we propose the use of ensembles of mixed-precision models to achieve the best of both worlds, i.e., increase robustness against adversarial attacks without sacrificing the accuracy on unperturbed inputs.
114
+
115
+ # 3.2 EMPIR: OVERVIEW
116
+
117
+ Figure 2 presents an overview of EMPIR. In the general case, an EMPIR model comprises of M fullprecision (FP) models and N low-precision (LP) models. The full-precision models help in boosting the unperturbed accuracy of the overall model, while the low-precision models contribute towards higher robustness. All the individual models are fed the same input and their predicted classes or probabilities are combined with the help of an ensembling technique at the end to determine the final prediction of the EMPIR model. In practice, we found that a single full-precision model $( \mathbf { M } = \mathbf { l } )$ ) and a small number of low-precision models $\mathrm { N } { = } 2$ or 3) are sufficient to achieve high adversarial accuracies without any noticeable compromises in the unperturbed accuracies.
118
+
119
+ The ensembling function plays a vital role in the overall performance of the model as it determines the final classification boundary. In this work, we consider two of the most commonly used ensembling functions, namely, averaging and max voting. The averaging function averages the output probabilities of each model and identifies the class with the maximum average probability as the final predicted class. On the other hand, max voting considers the predictions of each model as votes and determines the class with the maximum number of votes to be the final class. In our experiments, we found that averaging achieves better adversarial accuracies on ensembles of size 2 while max voting achieves better adversarial accuracies on ensembles of size greater than 2.
120
+
121
+ In order to allow an ensemble model to work better than a single model, the individual models should also be designed to be diverse (Hansen & Salamon (1990)). This ensures that the models dont produce similar errors and hence, that the probability of two models misclassifying the same input is lower. We introduce diversity in the individual models of EMPIR by training them with different random initializations of weights.
122
+
123
+ # 3.3 COMPUTATIONAL AND MEMORY COMPLEXITY OF EMPIR
124
+
125
+ The ensembling of multiple full-precision and low-precision models in EMPIR increases its computational and storage requirements as these models need to be stored and evaluated. In this work, we keep these memory and computational complexities within reasonable limits by restricting the precision of weights and activations in the low-precision models of EMPIR to a maximum of 4 bits.
126
+
127
+ The increasing popularity of low-precision DNN models has prompted recent hardware platforms including GPUs and neural network accelerators to add native hardware support for operating on low precision data (Fleischer et al. (2018); Kilgariff et al. (2019)). These hardware platforms reconfigure a common datapath to perform computations on full-precision data (32 or 64 bits) as well as lowprecision data (4, 8 or 16 bits). Low-precision operations can achieve higher throughputs than full-precision operations on these platforms as the same number of compute elements and the same amount of memory bandwidth can support a larger number of concurrent operations. Consequently, the additional execution time required to evaluate the low-precision models in EMPIR is much less than that of a full-precision model. Overall, we quantify the execution time and storage overhead of an EMPIR model using the formula described by Equation 6.
128
+
129
+ $$
130
+ \begin{array} { c l c r } { { \displaystyle T i m e O v e r h e a d \{ E M P I R ( M , N ) \} = M + \sum _ { i = 1 } ^ { N } \frac { O p s \_ p e r _ { - } s e c ( F P ) } { O p s \_ p e r _ { - } s e c ( k _ { i } ) } } } \\ { { \displaystyle S t o r a g e O v e r h e a d \{ E M P I R ( M , N ) \} = M + \sum _ { i = 1 } ^ { N } \frac { k _ { i } } { F P } } } \end{array}
131
+ $$
132
+
133
+ where $k _ { i }$ is the precision of the $i ^ { t h }$ low-precision model, $F P$ is the precision of the full-precision models, and $O p s \_ p e r \_ s e c ( b )$ is the throughput of $b$ bit operations on the underlying hardware platform.
134
+
135
+ # 4 EXPERIMENTS
136
+
137
+ In this section, we describe the experiments performed to evaluate the advantages of EMPIR models over baseline full-precision models.
138
+
139
+ # 4.1 BENCHMARKS
140
+
141
+ We studied the robustness of EMPIR models across three different image recognition DNNs, namely, MNISTconv, CIFARconv and AlexNet. The individual full-precision and-low precision networks within the EMPIR models were designed to have identical network topologies. The details of the individual networks in these benchmarks are listed in Table 3 within Appendix A. The benchmarks differ in the number of convolutional layers, fully connected layers as well as the datasets. We consider three different datasets, namely, MNIST (Lecun et al. (1998)), CIFAR-10 (Krizhevsky (2009)) and ImageNet (Deng et al. (2009)) which vary significantly in their complexity. The low precision networks were obtained using the quantization scheme proposed in DoReFa-Net (Zhou et al. (2016)). The full precision models were trained using 32 bit floating point representations for all data-structures.
142
+
143
+ # 4.2 EVALUATION OF ROBUSTNESS
144
+
145
+ We implemented EMPIR within TensorFlow (Abadi et al. (2015)) and have released the source code for our implementation 2. The robustness of the EMPIR models was measured in terms of their adversarial accuracies under a variety of white-box attacks within the Cleverhans library (Papernot et al. (2018)). We specifically consider the four adversarial attacks described in Section 2. The adversarial parameters for the attacks on the different benchmarks are presented in Table 1. The attacks were generated on the entire test dataset for each of the benchmarks. Generating these white-box attacks involves computation of the gradient $\nabla _ { x } L ( \theta , X , Y )$ (Section 2), which is not directly defined for ensembles. For the EMPIR models, we compute this gradient as an average over all individual models for an averaging ensemble and as an average over the individual models that voted for the final identified class for a max-voting ensemble.
146
+
147
+ Table 1: Attack parameters
148
+
149
+ <table><tr><td>Network</td><td>Cw</td><td>FGSM</td><td>BIM</td><td>PGD</td></tr><tr><td>MNISTconv</td><td>Attack iterations = 50</td><td>∈= 0.3</td><td>∈= 0.3, α=0.01 No. of iterations = 40</td><td>e= 0.3, α=0.01 No. of iterations = 40</td></tr><tr><td>CIFARconv</td><td>Attack iterations = 50</td><td>∈= 0.1</td><td>∈= 0.1, α=0.01 No. of iterations = 40</td><td>∈= 0.1, α=0.01 No. of iterations = 40</td></tr><tr><td>AlexNet</td><td>Attack iterations = 50</td><td>∈= 0.1</td><td>∈= 0.1, α=0.01 No. of iterations = 40</td><td>e=0.1, α=0.01 No. of iterations = 5</td></tr></table>
150
+
151
+ # 5 RESULTS
152
+
153
+ In this section, we present the results of our experiments highlighting the advantages of EMPIR models.
154
+
155
+ # 5.1 ROBUSTNESS OF EMPIR MODELS ACROSS ALL ATTACKS
156
+
157
+ Table 2 presents the results of our experiments across different benchmarks. The EMPIR models presented in the table are the ones exhibiting highest average adversarial accuracies under the constraints of ${ < } 2 5 \%$ compute and memory overhead and $< 2 \%$ loss in unperturbed accuracy. We observed that across all the benchmarks, ensembles comprised of two low-precision and one full-precision model combined with the max-voting ensembling technique satisfy these constraints. However, the individual configurations of the low-precision models, i.e., the precisions of weights and activations in the ensembles, differ across the benchmarks. For example, both low-precision models in the EMPIR model for MNISTconv have weight precisions of 2 bits and activation precisions of 4 bits. On the other hand, the two low-precision models in the AlexNet EMPIR model have $\mathrm { \{ w e i g h t , a c t i v a t i o n \} }$ bit-precisions of $\{ 2 , 2 \}$ and $\{ 4 , 4 \}$ , respectively. In general, we observe that the EMPIR models exhibit substantially higher adversarial accuracies across all attacks for the three benchmarks.
158
+
159
+ Table 2: Unperturbed and adversarial accuracies of the baseline and EMPIR models across different attacks
160
+
161
+ <table><tr><td rowspan="2">Network</td><td rowspan="2">Approach</td><td rowspan="2">Unperturbed Accuracy (%)</td><td colspan="5">Adversarial Accuracy (%)</td></tr><tr><td>Cw</td><td>FGSM</td><td>BIM</td><td>PGD</td><td>Average</td></tr><tr><td rowspan="7">MNISTconv</td><td>Baseline FP</td><td>98.87</td><td>3.69</td><td>14.32</td><td>0.9</td><td>0.77</td><td>4.92</td></tr><tr><td>EMPIR</td><td>98.89</td><td>86.73</td><td>67.06</td><td>18.61</td><td>17.51</td><td>47.48</td></tr><tr><td>Defensive Distill.</td><td>98.12</td><td>2.34</td><td>40.22</td><td>7.61</td><td>3.28</td><td>13.36</td></tr><tr><td>Inp. Grad. Reg.</td><td>99.01</td><td>6.83</td><td>30.15</td><td>1.14</td><td>1.20</td><td>9.83</td></tr><tr><td>FGSM Adv. Train</td><td>99.06</td><td>3.09</td><td>76.56</td><td>0.87</td><td>0.39</td><td>20.23</td></tr><tr><td>EMPIR (FGSM</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Adv. Train)</td><td>99.09</td><td>90.54</td><td>75.98</td><td>33.16</td><td>5.17</td><td>51.21</td></tr><tr><td rowspan="6">CIFARconv</td><td>Baseline FP</td><td>74.54</td><td>13.38</td><td>10.28</td><td>11.97</td><td>10.69</td><td>11.58</td></tr><tr><td>EMPIR</td><td>72.56</td><td>48.51</td><td>20.45</td><td>24.59</td><td>13.55</td><td>26.78</td></tr><tr><td>FGSM Adv. Train</td><td>72.36</td><td>14.36</td><td>41.58</td><td>12.92</td><td>11.24</td><td>20.03</td></tr><tr><td>EMPIR(FGSM</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Adv. Train)</td><td>73.62</td><td>45.73</td><td>31.67</td><td>29.55</td><td>14.74</td><td>30.42</td></tr><tr><td>PGD Adv. Train</td><td>73.55</td><td>12.62</td><td>12.45</td><td>10.97</td><td>8.52</td><td>11.14</td></tr><tr><td rowspan="2">AlexNet</td><td>Baseline FP</td><td>53.23</td><td>9.94</td><td>10.29</td><td>10.81</td><td>10.30</td><td>10.34</td></tr><tr><td>EMPIR</td><td>55.09</td><td>29.36</td><td>21.65</td><td>20.67</td><td>11.76</td><td>20.86</td></tr></table>
162
+
163
+ We also compare the benefits of EMPIR with four other popular approaches for increasing robustness, namely, defensive distillation (Papernot et al. (2015)), input gradient regularization (Ross & Doshi-Velez (2017)), FGSM based adversarial training (Goodfellow et al. (2014)) and PGD based adversarial training (Madry et al. (2017)). The distillation process was implemented with a softmax temperature of $T = 1 0 0$ , the gradient regularization was realized with a regularization penalty of $\lambda = 1 0 0$ , while the adversarial training mechanisms utilized adversarial examples generated with a maximum possible perturbation of $\epsilon = 0 . 3$ . Table 2 presents the results for the approaches that were able to achieve ${ < } 5 \%$ loss in unperturbed accuracy for a particular benchmark. We observe that FGSM based adversarial training significantly boosts the adversarial accuracies of the MNISTconv and CIFARconv models under the FGSM attack but is unable to increase the accuracies under the other three attacks, often hurting them in the process. A similar result is observed for the MNISTconv model trained with defensive distillation and gradient regularization. In contrast, EMPIR successfully increases the robustness of the models under all four attacks. In fact, it can even be combined with the other approaches to further boost the robustness, as evident from the adversarial accuracies of an EMPIR model comprising of adversarially trained models for the MNISTconv and CIFARconv benchmarks. EMPIR also achieves a higher adversarial accuracy than PGD based adversarial training for the CIFARconv benchmark. Overall, EMPIR increases robustness with zero training overhead, as opposed to considerable training overheads associated with the other defense strategies like adversarial training, defensive distillation and input gradient regularization.
164
+
165
+ # 5.2 COMPARISON WITH INDIVIDUAL MODELS
166
+
167
+ Figure 3(a) illustrates the tradeoff between the adversarial and unperturbed accuracies of the individual DNN models and EMPIR models for two of the benchmarks under the CW attack. The circular blue points correspond to individual models with varying weight and activation precisions while the red diamond points correspond to the EMPIR models presented in Section 5.1. The figure clearly indicates that the EMPIR models in both the benchmarks are notably closer to the desirable top right corner with high unperturbed as well as high adversarial accuracies. Among the individual models, the ones demonstrating higher adversarial accuracies but lower unperturbed accuracies (towards the top left corner) correspond to lower activation and weight precisions while those demonstrating lower adversarial accuracies and higher unperturbed accuracies (towards the bottom right corner) correspond to higher activation and weight precisions.
168
+
169
+ ![](images/fd49e0d1f6a26ce7a897444acd4836b09cb6a0e38269033a9c2fcc1e6377827d.jpg)
170
+ Figure 3: (a) Tradeoff between unperturbed and adversarial accuracies of the individual and EMPIR models across 2 benchmarks. (b) Confusion matrices of the baseline FP and EMPIR model for the MNISTconv benchmark.
171
+
172
+ ![](images/ba687c90ee0600a7c31af5b8d203808e632b7dba1fa834f3e670ed9f266b6b3f.jpg)
173
+ Figure 4: Effects of varying the number of LP and FP models in EMPIR (a) Unperturbed accuracies, (b) Adversarial accuracies, (c) Execution time overheads and (d) Storage overheads
174
+
175
+ # 5.3 ANALYSIS OF CONFUSION MATRICES
176
+
177
+ Figure 3(b) presents the confusion matrices of the baseline FP model and the EMPIR model for the MNISTconv benchmark under the FGSM attack. The actual ground truth class labels are listed vertically while the predicted labels are listed horizontally. The colors represent the number of images in the test dataset that correspond to the combination of actual and predicted class labels. The diagonal nature of EMPIR’s confusion matrix clearly illustrates its superiority over the FP model, which frequently misclassifies the generated adversarial images.
178
+
179
+ # 5.4 IMPACT OF VARYING THE NUMBER OF LOW-PRECISION AND FULL-PRECISION MODELS
180
+
181
+ In this subsection, we vary the number of low-precision and full-precision models in EMPIR between 0 and 3 to observe its effect on the unperturbed and adversarial accuracies of the MNISTconv benchmark under the FGSM attack. We also measure the execution time and memory footprint of the EMPIR models to quantify their overheads with respect to a baseline single full-precision model. We restrict the low-precision models to have weight and activation precisions between 2 and 4 bits and choose the configurations that maximize the adversarial accuracies of the EMPIR models while introducing ${ < } 1 \%$ drop in unperturbed accuracies.
182
+
183
+ Figure 4 presents the results of this experiment. Figure 4(a) and (b) clearly indicates that a higher number of low-precision models in EMPIR helps in boosting the adversarial accuracies while a higher number of full-precision models help in boosting the unperturbed accuracies. For instance, an EMPIR model comprising of only three low-precision models demonstrates unperturbed and adversarial accuracies of $9 8 . 8 \%$ and $5 6 . 9 \%$ respectively while an EMPIR model comprising of only three full-precision models demonstrates unperturbed and adversarial accuracies of $9 9 . 2 \%$ and $31 \%$ , respectively. The execution time and memory footprint associated with the former are only $0 . 3 8 \times$ and $0 . 2 5 \times$ over the baseline, as opposed to $3 \times$ in case of the latter. Overall, we observe that an EMPIR model comprising of a single full-precision model and two low-precision models (configuration presented in Table 2) achieves a good balance between adversarial and unperturbed accuracies with modest execution time and storage overheads.
184
+
185
+ # 6 RELATED WORK
186
+
187
+ Popular defense strategies against adversarial attacks include adversarial training, defensive distillation and input gradient regularization. Adversarial training (Goodfellow et al. (2014); Madry et al. (2017)) involves modifying the loss function to include the adversarial loss term, which tries to reduce the effect of input perturbations. Defensive distillation (Papernot et al. (2015)), on the other hand, is based on the technique of distillation that was originally proposed to efficiently transfer knowledge across different DNN models. It involves training networks on the output probabilities of classes instead of the conventional approach of training on hard output class labels. As shown in Table 2, the benefits of these techniques are limited to only one or a couple of adversarial attacks. In contrast, EMPIR is able to boost the adversarial accuracies of DNNs across all four white-box attacks considered here.
188
+
189
+ Recent efforts have also proposed the use of ensembles of full precision models for defending DNNs against adversarial attacks (Strauss et al. (2017); Pang et al. (2019); He et al. (2017); Tramer et al. \` (2017)) However, the presence of multiple full-precision models in these ensembles increases the compute and memory requirements significantly ( $1 0 \times$ for an ensemble with 10 models in Strauss et al. (2017)), which prevents the application of this approach to larger state-of-the art models. In contrast, with the use of low precision models in the ensemble, we are able to reduce the overhead significantly and restrict it to ${ < } 2 5 \%$ . Also, as shown in Figure 4, mixed-precision ensembles demonstrate higher adversarial accuracies than the full-precision ensembles for identical number of models in the ensemble.
190
+
191
+ In addition to the above efforts, there have been a parallel set of efforts studying the robustness of low-precision or quantized DNNs. For example, binary neural networks with single bit precisions for weights and activations have been shown to exhibit higher adversarial robustness than their fullprecision counterparts on different white-box attacks (Galloway et al. (2017); Panda et al. (2019)). Stochastic quantization of activations has also been proposed as an approach to make DNNs more robust (Siraj Rakin et al. (2018)). However, as shown in Figure 1, the individual quantized models in these efforts often demonstrate lower accuracies on unperturbed or clean examples due to the loss in information associated with the quantization process. On the other hand, the combination of fullprecision models along with low-precision models in EMPIR helps to overcome this limitation and achieve the best of both worlds — higher robustness combined with high unperturbed accuracy.
192
+
193
+ # 7 CONCLUSION
194
+
195
+ As deep neural networks get deployed in applications with stricter safety requirements, there is a dire need to identify new approaches that make them more robust to adversarial attacks. In this work, we boost the robustness of DNNs by designing ensembles of mixed-precision DNNs. In its most generic form, EMPIR comprises of M full-precision DNNs and N low-precision DNNs combined through ensembling techniques like max voting or averaging. EMPIR combines the higher robustness of low-precision DNNs with the higher unperturbed accuracies of the full-precision models. Our experiments on 3 different image recognition benchmarks under 4 different adversarial attacks reveal that EMPIR is able to significantly increase the robustness of DNNs without sacrificing the accuracies of the models on unperturbed inputs.
196
+
197
+ # ACKNOWLEDGMENTS
198
+
199
+ This work was supported by C-BRIC, one of six centers in JUMP, a Semiconductor Research Corporation (SRC) program, sponsored by DARPA.
200
+
201
+ REFERENCES
202
+ Mart´ın Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S. Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Ian Goodfellow, Andrew Harp, Geoffrey Irving, Michael Isard, Yangqing Jia, Rafal Jozefowicz, Lukasz Kaiser, Manjunath Kudlur, Josh Levenberg, Dandelion Mane, Rajat Monga, Sherry Moore, Derek Murray, Chris ´ Olah, Mike Schuster, Jonathon Shlens, Benoit Steiner, Ilya Sutskever, Kunal Talwar, Paul Tucker, Vincent Vanhoucke, Vijay Vasudevan, Fernanda Viegas, Oriol Vinyals, Pete Warden, Martin Wat- ´ tenberg, Martin Wicke, Yuan Yu, and Xiaoqiang Zheng. TensorFlow: Large-scale machine learning on heterogeneous systems, 2015. URL https://www.tensorflow.org/. Software available from tensorflow.org.
203
+ Leo Breiman. Bagging predictors. Mach. Learn., 24(2):123–140, August 1996. ISSN 0885-6125. doi: 10.1023/A:1018054314350. URL http://dx.doi.org/10.1023/A:1018054314350.
204
+ Nicholas Carlini and David A. Wagner. Towards evaluating the robustness of neural networks. CoRR, abs/1608.04644, 2016. URL http://arxiv.org/abs/1608.04644.
205
+ Matthieu Courbariaux, Yoshua Bengio, and Jean-Pierre David. Binaryconnect: Training deep neural networks with binary weights during propagations. In Advances in Neural Information Processing Systems 28, pp. 3123–3131. Curran Associates, Inc., 2015.
206
+ J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A Large-Scale Hierarchical Image Database. In CVPR09, 2009.
207
+ Thomas G. Dietterich. Ensemble methods in machine learning. In Multiple Classifier Systems, pp. 1–15, Berlin, Heidelberg, 2000. Springer Berlin Heidelberg. ISBN 978-3-540-45014-6.
208
+ Bruce M. Fleischer, Sunil Shukla, Matthew M. Ziegler, Joel Silberman, Jinwook Oh, Vijayalakshmi Srinivasan, Jungwook Choi, Silvia Mueller, Ankur Agrawal, Tina Babinsky, Nianzheng Cao, Chia-Yu Chen, Pierce Chuang, Thomas W. Fox, George Gristede, Michael Guillorn, Howard Haynie, Michael Klaiber, Dongsoo Lee, Shih-Hsien Lo, Gary W. Maier, Michael Scheuermann, Swagath Venkataramani, Christos Vezyrtzis, Naigang Wang, Fanchieh Yee, Ching Zhou, PongFei Lu, Brian W. Curran, Leland Chang, and Kailash Gopalakrishnan. A Scalable Multi- TeraOPS Deep Learning Processor Core for AI Trainina and Inference. 2018 IEEE Symposium on VLSI Circuits, pp. 35–36, 2018.
209
+ Angus Galloway, Graham W. Taylor, and Medhat Moussa. Attacking Binarized Neural Networks. arXiv e-prints, art. arXiv:1711.00449, Nov 2017.
210
+ Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and Harnessing Adversarial Examples. arXiv e-prints, art. arXiv:1412.6572, Dec 2014.
211
+ L. K. Hansen and P. Salamon. Neural network ensembles. IEEE Transactions on Pattern Analysis and Machine Intelligence, 12(10):993–1001, Oct 1990. ISSN 0162-8828.
212
+ Warren He, James Wei, Xinyun Chen, Nicholas Carlini, and Dawn Song. Adversarial example defenses: Ensembles of weak defenses are not strong. In Proceedings of the 11th USENIX Conference on Offensive Technologies, WOOT’17, pp. 15–15, Berkeley, CA, USA, 2017. USENIX Association. URL http://dl.acm.org/citation.cfm?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ 3154768.3154783.
213
+ Itay Hubara, Matthieu Courbariaux, Daniel Soudry, Ran El-Yaniv, and Yoshua Bengio. Quantized neural networks: Training neural networks with low precision weights and activations. J. Mach. Learn. Res., 18(1):6869–6898, January 2017. ISSN 1532-4435.
214
+ E. Kilgariff, H. Moreton, N. Stam, and B. Bell. NVIDIA Turing Architecture InDepth — NVIDIA Developer Blog. [online] NVIDIA Developer Blog, 2019. URL https://devblogs.nvidia.com/nvidia-turing-architecture-in-depth/.
215
+ Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, 2009.
216
+ Alexey Kurakin, Ian J. Goodfellow, and Samy Bengio. Adversarial examples in the physical world. CoRR, abs/1607.02533, 2016. URL http://arxiv.org/abs/1607.02533.
217
+
218
+ 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.
219
+
220
+ Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards Deep Learning Models Resistant to Adversarial Attacks. arXiv e-prints, art. arXiv:1706.06083, Jun 2017.
221
+
222
+ Priyadarshini Panda, Indranil Chakraborty, and Kaushik Roy. Discretization based solutions for secure machine learning against adversarial attacks. CoRR, abs/1902.03151, 2019. URL http://arxiv.org/abs/1902.03151.
223
+
224
+ Tianyu Pang, Kun Xu, Chao Du, Ning Chen, and Jun Zhu. Improving adversarial robustness via promoting ensemble diversity. In ICML, 2019.
225
+
226
+ Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, and Ananthram Swami. Distillation as a Defense to Adversarial Perturbations against Deep Neural Networks. arXiv e-prints, art. arXiv:1511.04508, Nov 2015.
227
+
228
+ Nicolas Papernot, Patrick D. McDaniel, Somesh Jha, Matt Fredrikson, Z. Berkay Celik, and Ananthram Swami. The limitations of deep learning in adversarial settings. CoRR, abs/1511.07528, 2015. URL http://arxiv.org/abs/1511.07528.
229
+
230
+ Nicolas Papernot, Fartash Faghri, Nicholas Carlini, Ian Goodfellow, Reuben Feinman, Alexey Kurakin, Cihang Xie, Yash Sharma, Tom Brown, Aurko Roy, Alexander Matyasko, Vahid Behzadan, Karen Hambardzumyan, Zhishuai Zhang, Yi-Lin Juang, Zhi Li, Ryan Sheatsley, Abhibhav Garg, Jonathan Uesato, Willi Gierke, Yinpeng Dong, David Berthelot, Paul Hendricks, Jonas Rauber, and Rujun Long. Technical report on the cleverhans v2.1.0 adversarial examples library. arXiv preprint arXiv:1610.00768, 2018.
231
+
232
+ Andrew Slavin Ross and Finale Doshi-Velez. Improving the adversarial robustness and interpretability of deep neural networks by regularizing their input gradients. In AAAI, 2017.
233
+
234
+ Adnan Siraj Rakin, Jinfeng Yi, Boqing Gong, and Deliang Fan. Defend Deep Neural Networks Against Adversarial Examples via Fixed and Dynamic Quantized Activation Functions. arXiv e-prints, art. arXiv:1807.06714, Jul 2018.
235
+
236
+ Thilo Strauss, Markus Hanselmann, Andrej Junginger, and Holger Ulmer. Ensemble Methods as a Defense to Adversarial Perturbations Against Deep Neural Networks. arXiv e-prints, art. arXiv:1709.03423, Sep 2017.
237
+
238
+ Florian Tramer, Alexey Kurakin, Nicolas Papernot, Dan Boneh, and Patrick D. McDaniel. Ensemble \` adversarial training: Attacks and defenses. ArXiv, abs/1705.07204, 2017.
239
+
240
+ Swagath Venkataramani, Ashish Ranjan, Kaushik Roy, and Anand Raghunathan. AxNN: Energyefficient neuromorphic systems using approximate computing. In Proceedings of the 2014 International Symposium on Low Power Electronics and Design, ISLPED 14, pp. 2732, New York, NY, USA, 2014. Association for Computing Machinery. ISBN 9781450329750. doi: 10.1145/2627369.2627613. URL https://doi.org/10.1145/2627369.2627613.
241
+
242
+ Naigang Wang, Jungwook Choi, Daniel Brand, Chia-Yu Chen, and Kailash Gopalakrishnan. Training deep neural networks with 8-bit floating point numbers. In NeurIPS, 2018.
243
+
244
+ Shuchang Zhou, Zekun Ni, Xinyu Zhou, He Wen, Yuxin Wu, and Yuheng Zou. DoReFaNet: Training low bitwidth convolutional neural networks with low bitwidth gradients. CoRR, abs/1606.06160, 2016. URL http://arxiv.org/abs/1606.06160.
245
+
246
+ A BENCHMARK DETAILS
247
+ Table 3: Benchmarks
248
+
249
+ <table><tr><td>Network</td><td>Dataset</td><td>Configuration</td></tr><tr><td>MNISTconv</td><td>MNIST</td><td>Conv(8×8×64),ReLU, Conv(6×6×128),ReLU, Conv(5×5×128),ReLU,Fully_Connected(10),SoftMax</td></tr><tr><td>CIFARconv</td><td>CIFAR-10</td><td>Conv(5×5×32), ReLU, MaxPool(3×3), Conv(8×8 ×64),ReLU AvgPool(3×3), Conv(8×8 ×64), ReLU, AvgPool(3 × 3), Fully_Connected(64), Fully_Connected(10), SoftMax</td></tr><tr><td>AlexNet</td><td>ImageNet</td><td>Conv(12×12×96), ReLU, Conv(5×5×256), BatchNorm, ReLU, MaxPool(3×3), Conv(3×3×384), BatchNorm, ReLU, MaxPool(3×3), Conv(3×3×384), BatchNorm, ReLU, Conv(3×3×256), BatchNorm,ReLU, MaxPool(3 ×3), Fully_Conn(4096), BatchNorm, ReLU, Fully_Conn(4096), BatchNorm,ReLU,Fully_Conn(100O), SoftMax</td></tr></table>
250
+
251
+ # B ROBUSTNESS TO ATTACKS OF VARYING STRENGTHS
252
+
253
+ To further illustrate the benefits of EMPIR, we observed its robustness under attacks of varying strength. We specifically varied the $\epsilon$ value in the FGSM attack between 0.1 and 0.8 and the number of attack iterations in the CW attack between 10 and 90, and measured the adversarial accuracies of the EMPIR model as well as the baseline FP model for the MNISTconv benchmark. Figure 5 clearly illustrates that EMPIR exhibits higher adversarial accuracies across attacks of different strengths for both FGSM and CW.
254
+
255
+ ![](images/ce03aafd71f0a52811b4fc528282178ec148ee8ac35a27a27eef83d49b6e0d47.jpg)
256
+ Figure 5: (a) Adversarial accuracies under FGSM attack of varying strength (b) Adversarial accuracies under CW attack of varying strength
md/train/HJx8HANFDH/HJx8HANFDH.md ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FOUR THINGS EVERYONE SHOULD KNOW TO IMPROVE BATCH NORMALIZATION
2
+
3
+ Cecilia Summers
4
+ Department of Computer Science
5
+ University of Auckland
6
+ cecilia.summers.07@gmail.com
7
+
8
+ Michael J. Dinneen Department of Computer Science University of Auckland mjd@cs.auckland.ac.nz
9
+
10
+ # ABSTRACT
11
+
12
+ A key component of most neural network architectures is the use of normalization layers, such as Batch Normalization. Despite its common use and large utility in optimizing deep architectures, it has been challenging both to generically improve upon Batch Normalization and to understand the circumstances that lend themselves to other enhancements. In this paper, we identify four improvements to the generic form of Batch Normalization and the circumstances under which they work, yielding performance gains across all batch sizes while requiring no additional computation during training. These contributions include proposing a method for reasoning about the current example in inference normalization statistics, fixing a training vs. inference discrepancy; recognizing and validating the powerful regularization effect of Ghost Batch Normalization for small and medium batch sizes; examining the effect of weight decay regularization on the scaling and shifting parameters $\gamma$ and $\beta$ ; and identifying a new normalization algorithm for very small batch sizes by combining the strengths of Batch and Group Normalization. We validate our results empirically on six datasets: CIFAR-100, SVHN, Caltech-256, Oxford Flowers-102, CUB-2011, and ImageNet.
13
+
14
+ # 1 INTRODUCTION
15
+
16
+ Neural networks have transformed machine learning, forming the backbone of models for tasks in computer vision, natural language processing, and robotics, among many other domains (Krizhevsky & Hinton, 2009; He et al., 2017; Levine et al., 2016; Sutskever et al., 2014; Graves et al., 2013). A key component of many neural networks is the use of normalization layers such as Batch Normalization (Ioffe & Szegedy, 2015), Group Normalization (Wu & He, 2018), or Layer Normalization (Ba et al., 2016), with Batch Normalization the most commonly used for vision-based tasks. While the true reason why these methods work is still an active area of research (Santurkar et al., 2018), normalization techniques typically serve the purpose of making neural networks more amenable to optimization, allowing the training of very deep networks without the use of careful initialization schemes (Simonyan & Zisserman, 2015; Zhang et al., 2019), custom nonlinearities (Klambauer et al., 2017), or other more complicated techniques (Xiao et al., 2018). Even in situations where training without normalization layers is possible, their usage can still aid generalization (Zhang et al., 2019). In short, normalization layers make neural networks train faster and generalize better.
17
+
18
+ Despite this, it has been challenging to improve normalization layers. In the general case, a new approach would need to be uniformly better than existing normalization methods, which has proven difficult. It has even been difficult to tackle a simpler task: characterizing when specific changes to common normalization approaches might yield benefits. In all, this has created an environment where approaches such as Batch Normalization are still used as-is, unchanged since their creation.
19
+
20
+ In this work we identify four techniques that everyone should know to improve their usage of Batch Normalization, arguably the most common method for normalization in neural networks. Taken together, these techniques apply in all circumstances in which Batch Normalization is currently used, ranging from large to very small batch sizes, including one method which is even useful when the batch size $B = 1$ , and for each technique we identify the circumstances under which it is expected to be of use. In summary, our contributions are:
21
+
22
+ 1. A way to more effectively use the current example during inference, fixing a discrepancy between training and inference that had been previously overlooked, 2. Identifying Ghost Batch Normalization, a technique designed for very large-batch multiGPU training (Hoffer et al., 2017), as surprisingly effective even in the medium-batch, single-GPU regime, 3. Recognizing weight decay of the scaling and centering variables $\gamma$ and $\beta$ as a valuable source of regularization, an unstudied detail typically neglected, and 4. Proposing a generalization of Batch and Group Normalization in the small-batch setting, effectively making use of cross-example information present in the minibatch even when such information is not enough for effective normalization on its own.
23
+
24
+ Experimentally, we study the most common use-case of Batch Normalization, image classification, which is fundamental to most visual problems in machine learning. In total, these four techniques can have a surprisingly large effect, improving accuracy by over $6 \%$ on one of our benchmark datasets while only changing the usage of Batch Normalization layers.
25
+
26
+ We have released code at https://github.com/ceciliaresearch/four_things_ batch_norm.
27
+
28
+ # 2 RELATED WORK/BACKGROUND ON NORMALIZATION METHODS
29
+
30
+ Most normalization approaches in neural networks, including Batch Normalization, have the general form of normalizing their inputs $x _ { i }$ to have a learnable mean and standard deviation:
31
+
32
+ $$
33
+ \hat { x } _ { i } = \gamma \frac { x _ { i } - \mu _ { i } } { \sqrt { \sigma _ { i } ^ { 2 } + \epsilon } } + \beta
34
+ $$
35
+
36
+ where $\gamma$ and $\beta$ are the learnable parameters, typically initialized to 1 and 0, respectively. Where approaches typically differ is in how the mean $\mu _ { i }$ and variance $\sigma _ { i } ^ { 2 }$ are calculated.
37
+
38
+ Batch Normalization (Ioffe & Szegedy, 2015), the pioneering work in normalization layers, defined $\mu _ { i }$ and $\sigma _ { i } ^ { 2 }$ to be calculated for each channel or feature map separately across a minibatch of data. For example, in a convolutional layer, the mean and variance are computed across all spatial locations and training examples in a minibatch. During inference, these statistics are replaced with an exponential moving average of the mean and variance, making inference behavior independent of inference batch statistics. The effectiveness of Batch Normalization is undeniable, playing a key role in nearly all state-of-the-art convolutional neural networks since its discovery (Szegedy et al., 2016; 2017; He et al., 2016a;b; Zoph & Le, 2017; Zoph et al., 2018; Hu et al., 2018; Howard et al., 2017; Sandler et al., 2018). Despite this, there is still a fairly limited understanding of Batch Normalization’s efficacy — while Batch Normalization’s original motivation was to reduce internal covariate shift during training (Ioffe & Szegedy, 2015), recent work has instead proposed that its true effectiveness stems from making the optimization landscape smoother (Santurkar et al., 2018).
39
+
40
+ One weakness of Batch Normalization is its critical dependence on having a reasonably large batch size, due to the inherent approximation of estimating the mean and variance with a single batch of data. Several works propose methods without this limitation: Layer Normalization (Ba et al., 2016), which has found use in many natural language processing tasks (Vaswani et al., 2017), tackles this by calculating $\mu _ { i }$ and $\sigma _ { i } ^ { 2 }$ over all channels, rather than normalizing each channel independently, but does not calculate statistics across examples in each batch. Instance Normalization (Ulyanov et al., 2016), in contrast, only calculates $\mu _ { i }$ and $\sigma _ { i } ^ { 2 }$ using the information present in each channel, relying on the content of each channel at different spatial locations to provide effective normalization statistics. Group Normalization (Wu & He, 2018) generalizes Layer and Instance Normalization, calculating statistics in “groups” of channels, allowing for stronger normalization power than Instance Normalization, but still allowing for each channel to contribute significantly to the statistics used for its own normalization. The number of normalization groups per normalization layer is typically set to a global constant in group normalization, though alternatives such as specifying the number of channels per group have also been tried (Wu & He, 2018).
41
+
42
+ Besides these most common approaches, many other forms of normalization also exist: Weight Normalization (Salimans & Kingma, 2016) normalizes the weights of each layer instead of the inputs, parameterizing them in terms of a vector giving the direction of the weights and an explicit scale, which must be initialized very carefully. Decorrelated Batch Normalization (Huang et al., 2018) performs ZCA whitening in its normalization layer, and Iterative Normalization (Huang et al., 2019) makes it more efficient via a Newton iteration approach. Cho & Lee (2017) analyze the weights in Batch Normalization from the perspective of a Riemannian manifold, yielding new optimization and regularization methods that utilize the manifold’s geometry.
43
+
44
+ Targeting the small batch problem, Batch Renormalization (Ioffe, 2017) uses the moving average of batch statistics to normalize during training, parameterized in such a way that gradients still propagate through the minibatch mean and standard deviation, but introduces two new hyperparameters and still suffers somewhat diminished performance in the small-batch setting. Guo et al. (2018) tackle the small batch setting by aggregating normalization statistics over multiple forward passes.
45
+
46
+ Recently, Switchable Normalization (Luo et al., 2019) aims to learn a more effective normalizer by calculating $\mu _ { i }$ and $\sigma _ { i } ^ { 2 }$ as learned weighted combinations of the statistics computed from other normalization methods. While flexible, care must be taken for two reasons: First, as the parameters are learned differentiably, they are fundamentally aimed at minimizing the training loss, rather than improved generalization, which typical hyperparameters are optimized for on validation sets. Second, the choice of which normalizers to include in the weighted combination remains important, manifesting in Switchable Normalization’s somewhat worse performance than Group Normalization for small batch sizes. Differentiable Dynamic Normalization (Luo et al., 2019) fixes the latter point, learning an even more flexible normalization layer. Beyond these, there are many approaches we omit for lack of space (Littwin & Wolf, 2018; Deecke et al., 2019; Hoffer et al., 2018; Klambauer et al., 2017; Xiao et al., 2018; Zhang et al., 2019).
47
+
48
+ # 3 IMPROVING NORMALIZATION: WHAT EVERYONE SHOULD KNOW
49
+
50
+ In this section we detail four methods for improving Batch Normalization. We also refer readers to the Appendix for a discussion of methods which do not improve normalization layers (sometimes surprisingly so). For clarity, we choose to interleave descriptions of the methods with experimental results, which aids in understanding each of the approaches as they are presented. We experiment with four standard image-centric datasets in this section: CIFAR-100, SVHN, Caltech-256, and ImageNet, and report results on validation datasets in order to fully describe each approach without contaminating test-set results. We give results on test sets, and experimental details in Sec. 4.
51
+
52
+ # 3.1 INFERENCE EXAMPLE WEIGHING
53
+
54
+ Batch Normalization has a disparity in function between training and inference: As previously noted, Batch Normalization calculates its normalization statistics over each minibatch of data separately while training, but during inference a moving average of training statistics is used, simulating the expected value of the normalization statistics. Resolving this disparity is a common theme among methods that have sought to replace Batch Normalization (Ba et al., 2016; Ulyanov et al., 2016; Salimans & Kingma, 2016; Wu & He, 2018; Ioffe, 2017). Here we identify a key component of this training versus inference disparity which can be fixed within the context of Batch Normalization itself, improving it in the general case: when using a moving average during inference, each example does not contribute to its own normalization statistics.
55
+
56
+ To give an example of the effect this has, we consider the output range of Batch Normalization. During training, due to the inclusion of each example in its own normalization statistics, it can be shown1 that the minimum possible output of a Batch Normalization layer is:
57
+
58
+ $$
59
+ \operatorname* { m i n } _ { x _ { 0 } , \ldots , x _ { B - 1 } } \gamma \frac { x _ { 0 } - \mu _ { i } } { \sqrt { \sigma _ { i } ^ { 2 } + \epsilon } } + \beta = - \gamma \sqrt { B - 1 } + \beta
60
+ $$
61
+
62
+ with a corresponding maximum value of $\gamma \sqrt { B - 1 } + \beta$ , where $B$ is the batch size, and we assume for simplicity that Batch Norm is being applied non-convolutionally. In contrast, during inference the output range of Batch Normalization is unbounded, creating a discrepancy. Morever, this actually happens for real networks: the output range of a network with Batch Normalization is wider during inference than during training (see Sec. B in Appendix).
63
+
64
+ ![](images/fbb1da4cba95e5936cdbaee6970f5412ffecede1e12e9307ba3dac1e169efe75.jpg)
65
+ Figure 1: Effect of the example-weighing hyperparameter $\alpha$ on ImageNet for ResNet-152, MobileNetV2, and NASNet-A, measuring top-1 and top-5 accuracies and the cross-entropy loss.
66
+
67
+ Fortunately, once this problem has been realized, it is possible to fix — we need only figure out how to incorporate example statistics during inference. Denoting $m _ { x }$ as the moving average over $x$ and $m _ { x ^ { 2 } }$ the corresponding moving average over $x ^ { 2 }$ , we apply the following normalization:
68
+
69
+ $$
70
+ \begin{array} { l } { \mu _ { i } = \alpha E [ x _ { i } ] + ( 1 - \alpha ) m _ { x } } \\ { \sigma _ { i } ^ { 2 } = ( \alpha E [ x _ { i } ^ { 2 } ] + ( 1 - \alpha ) m _ { x ^ { 2 } } ) - \mu _ { i } ^ { 2 } } \\ { \hat { x } _ { i } = \gamma \displaystyle \frac { x _ { i } - \mu _ { i } } { \sqrt { \sigma _ { i } ^ { 2 } + \epsilon } } + \beta } \end{array}
71
+ $$
72
+
73
+ where $\alpha$ is the contribution of $x _ { i }$ to the normalization statistics, and we have reparameterized the variance as $\sigma _ { i } ^ { 2 } = E [ x _ { i } ^ { 2 } ] - E [ x _ { i } ] ^ { 2 }$ .
74
+
75
+ Given this formulation, a natural question is the choice of the parameter $\alpha$ , where $\alpha = 0$ corresponds to the classical inference setting of Batch Normalization and $\alpha = 1$ replicates the setting of techniques which do not use cross-image information in calculating normalization statistics. Intuitively, it would make sense for the optimal value to be $\textstyle \alpha = { \frac { 1 } { B } }$ . However, this turns out to not be the case — instead, $\alpha$ is a hyperparameter best optimized on a validation set, whose optimal value may depend the model, dataset, and metric being optimized. While counterintuitive, this can be explained by the remaining set of differences between training and inference: for a basic yet fundamental example, the fact that the model has been fit on the training set (also typically with data augmentation) may produce systematically different normalization statistics between training and inference.
76
+
77
+ An advantage of this technique is that we can apply it retroactively to any model trained with Batch Normalization, allowing us to verify its efficacy on a wide variety of models. In Fig. 1 we show the effect of $\alpha$ on the ImageNet ILSVRC 2012 validation set (Russakovsky et al., 2015) for three diverse models: ResNet-152 (He et al., 2016b), MobileNetV2 (Sandler et al., 2018), and NASNet-A Large (Zoph et al., $2 0 1 8 ) ^ { 2 }$ . On ResNet-152, for example, proper setting of $\alpha$ can increase accuracy by up to $0 . 6 \%$ , top-5 accuracy by $0 . 1 6 \%$ , and loss by a relative $4 . 7 \%$ , which are all quite significant given the simplicity of the approach, the competitiveness of ImageNet as a benchmark, and the fact that the improvement is essentially “free” — it involves only modifying the inference behavior of Batch Normalization layers, and does not require any re-training. Across models, the optimal value for $\alpha$ was largest for NASNet-A, the most memory-intensive (and therefore smallest batch size) model of the three. We refer the reader to the Appendix for additional plots with larger ranges of $\alpha$ .
78
+
79
+ Surprisingly, it turns out that this approach can have positive effects on models trained without any cross-image normalization at all, such as models trained with Group Normalization (Wu & He, 2018). We demonstrate this in Fig. 2, where we find that adding a tiny amount of information from the moving average statistics can actually result in small improvements, with relatively larger improvements in accuracy on Caltech-256 and cross entropy loss on CIFAR-100 and SVHN. This finding is extremely surprising, since adding in any information from the moving averages at all represents a clear difference from the training setting of Group Normalization. Similar to the unintuitive optimal value for $\alpha$ , we hypothesize that this effect is due to other differences in the settings of training and inference: for example, models are generally trained on images with the application of data augmentation, such as random cropping. During inference, though, images appear unperturbed, and it might be the case that incorporating information from the moving averages is a way of influencing the model’s intermediate activations to be more similar to those of data augmented images, which it has been trained on. This mysterious behavior may also point to more general approaches for resolving training-inference discrepancies, and is worthy of further study.
80
+
81
+ ![](images/91a0e20c3b635451d7f134236fe23e1ccfff184a466cf2b66a710e4152d1e91b.jpg)
82
+ Figure 2: Effect of the example-weighing hyperparameter $\alpha$ for models trained with Group Normalization on CIFAR-100, SVHN, and Caltech-256.
83
+
84
+ Last, we also note very recent work (Singh & Shrivastava, 2019) which examines a similar approach for incorporating the statistics of an example during inference time, using per-layer weights and optimizing with a more involved procedure that encourages similar outputs to the training distribution.
85
+
86
+ Summary: Inference example weighing resolves one disparity between training and inference for Batch Normalization, is uniformly beneficial across all models and very easy to tune to metrics of interest, and can be used with any model trained with Batch Normalization, even retroactively.
87
+
88
+ # 3.2 GHOST BATCH NORMALIZATION FOR MEDIUM BATCH SIZES
89
+
90
+ Ghost Batch Normalization, a technique originally developed for training with very large batch sizes across many accelerators (Hoffer et al., 2017), consists of calculating normalization statistics on disjoint subsets of each training batch. Concretely, with an overall batch size of $B$ and a “ghost” batch size of $B ^ { \prime }$ such that $B ^ { \prime }$ evenly divides $B$ , the normalization statistics for example $i$ are calculated as
91
+
92
+ $$
93
+ \begin{array} { l } { \displaystyle \mu _ { i } = \frac { 1 } { B ^ { \prime } } \sum _ { j = 1 } ^ { B } { x _ { j } [ \left\lfloor \frac { j B ^ { \prime } } { B } \right\rfloor = \left\lfloor \frac { i B ^ { \prime } } { B } \right\rfloor } ] } \\ { \displaystyle \sigma _ { i } ^ { 2 } = \frac { 1 } { B ^ { \prime } } \sum _ { j = 1 } ^ { B } { x _ { j } ^ { 2 } [ \left\lfloor \frac { j B ^ { \prime } } { B } \right\rfloor = \left\lfloor \frac { i B ^ { \prime } } { B } \right\rfloor - \mu _ { i } ^ { 2 } } } \end{array}
94
+ $$
95
+
96
+ where $[ \cdot ]$ is the Iverson bracket, with value 1 if its argument is true and 0 otherwise. Ghost Batch Normalization was previously found to be an important factor in reducing the generalization gap between large-batch and small-batch models (Hoffer et al., 2017), and has since been used by subsequent research rigorously studying the large-batch regime (Shallue et al., 2018). Here, we show that it can also be useful in the medium-batch setting3.
97
+
98
+ Why might Ghost Batch Normalization be useful? One reason is its power as a regularizer: due to the stochasticity in normalization statistics caused by the random selection of minibatches during training, Batch Normalization causes the representation of a training example to randomly change every time it appears in a different batch of data. Ghost Batch Normalization, by decreasing the number of examples that the normalization statistics are calculated over, increases the strength of this stochasticity, thereby increasing the amount of regularization. Based on this hypothesis, we would expect to see a unimodal effect of the Ghost Batch Normalization size $B ^ { \prime }$ on model performance — a large value of $B ^ { \prime }$ would offer somewhat diminished performance as a weaker regularizer, a very low value of $B ^ { \prime }$ would have excess regularization and lead to poor performance, and an intermediate value would offer the best tradeoff of regularization strength.
99
+
100
+ We confirm this intuition in Fig. 3. Surprisingly, just using this one simple technique was capable of improving performance by $5 . 8 \%$ on Caltech-256 and $0 . 8 4 \%$ on CIFAR-100, which is remarkable given it has no additional cost during training. On SVHN, though, where baseline performance is already a very high $9 8 . 7 9 \%$ and models do not overfit much, usage of Ghost Batch Normalization did not result in an improvement, giving evidence that at least part of its effect is regularization in nature. In practice, $B ^ { \prime }$ may be treated as an additional hyperparameter to optimize.
101
+
102
+ ![](images/6d3078e02a3ef552801d13c8e7a78c2381c693c42b2c1d4d895f48f22b653f4a.jpg)
103
+ Figure 3: Accuracy vs. Ghost Batch Normalization size for CIFAR-100, SVHN, and Caltech-256.
104
+
105
+ ![](images/482060d12db47487926c41427bb957087bb44c323aa2168a7c9333df1538419a.jpg)
106
+ Figure 4: The complementary effects of Inference Example Weighing (Sec. 3.1) and Ghost Batch Normalization (Sec. 3.2) on CIFAR-100, SVHN, and Caltech-256.
107
+
108
+ As a bonus, Ghost Batch Normalization has a synergistic effect with inference example weighing — it has the effect of making each example more important in calculating its own normalization statistics $\mu _ { i }$ and $\sigma _ { i } ^ { 2 }$ , with greater effect the smaller $B ^ { \prime }$ is, precisely the setting that inference example weighing corrects for. We show these results in Fig. 4, where we find increasing gain from inference example weighing as $B ^ { \prime }$ is made smaller, a gain that compounds from the benefits of Ghost Batch Normalization itself. Interestingly, these examples also demonstrate that accuracy and cross-entropy, the most commonly-used classification loss, are only partially correlated, with the optimal values for the inference example weight $\alpha$ sometimes differing wildly between the two (e.g. for SVHN).
109
+
110
+ Summary: Ghost Batch Normalization is beneficial for all but the smallest of batch sizes, has no computational overhead, is straightforward to tune, and can be used in combination with inference example weighing to great effect.
111
+
112
+ # 3.3 BATCH NORMALIZATION AND WEIGHT DECAY
113
+
114
+ Weight decay (Krogh & Hertz, 1992) is a regularization technique that scales the weight of a neural network after each update step by a factor of $1 - \delta$ , and has a complex interaction with Batch Normalization. At first, it may even seem paradoxical that weight decay has any effect in a network trained with Batch Normalization, as scaling the weights immediately before a normalization layer by any non-zero constant has mathematically almost no effect on the output of the normalization layer (and no effect at all when $\epsilon = 0$ ). However, weight decay actually has a subtle effect on the effective learning rate of networks trained with Batch Normalization — without weight decay, the weights in a batch-normalized network grow to have large magnitudes, which has an inverse effect on the effective learning rate, hampering training (Hoffer et al., 2018; van Laarhoven, 2017).
115
+
116
+ Here we turn our attention to the less studied scale and bias parameters common in most normalization methods, $\gamma$ and $\beta$ . As far as we are aware, the effect of regularization on $\gamma$ and $\beta$ has not been studied to any great extent — Wu & He (2018) briefly mention weight decay with these parameters, where weight decay was used when training from scratch, but not fine-tuning, two other papers (Goyal et al., 2017; He et al., 2016a) have this form of weight decay explicitly turned off, and He et al. (2019) encourage disabling weight decay on $\gamma$ and $\beta$ , but ultimately find diminished performance by doing so.
117
+
118
+ Unlike weight decay on weights in e.g. convolutional layers, which typically directly precede normalization layers, weight decay on $\gamma$ and $\beta$ can have a regularization effect so long as there is a path in the network between the layer in question and the ultimate output of the network, as if such paths do not pass through another normalization layer, then the weight decay is never “undone” by normalization. This structure is only common in certain types of architectures; for example, Residual Networks (He et al., 2016a;b) have such paths for many of their normalization layers due to the chaining of skip-connections. However, Inception-style networks (Szegedy et al., 2016; 2017) have no residual connections, and despite the fact that each “Inception block” branches into multiple paths, every Batch Normalization layer other than those in the very last block do not have a direct path to the network’s output.
119
+
120
+ We evaluated the effects of weight decay on $\gamma$ and $\beta$ on CIFAR-100 across 10 runs, where we found that incorporating it improved accuracy by a small but significant $0 . 3 \%$ $P = 0 . 0 0 2$ ). Interestingly, even though $\gamma$ has a multiplicative effect, we did not find it mattered whether $\gamma$ was regularized to 0 or 1 $( P = 0 . 4 6 )$ — what was important was whether it had weight decay applied at all.
121
+
122
+ We did the same comparison on Caltech-256 with Inception-v3 and ResNet-50 networks, where we found evidence that the network architecture plays a crucial effect: for Inception-v3, incorporating weight decay on $\gamma$ and $\beta$ actually hurt performance by $0 . 1 3 \%$ (mean across 3 trials), while it improved performance for the ResNet-50 network by $0 . 9 1 \%$ , supporting the hypothesis that the structure of paths between layers and the network’s output are what matter in determining its utility.
123
+
124
+ On SVHN, where the baseline ResNet-18 already had a performance of $9 8 . 7 9 \%$ , we found a similar pattern as with Ghost Batch Normalization — introducing this regularization produced no change.
125
+
126
+ Summary: Regularization in the form of weight decay on the normalization parameters $\gamma$ and $\beta$ can be applied to any normalization layer, but is only effective in architectures with particular connectivity properties like ResNets and in tasks for which models are already overfitting.
127
+
128
+ # 3.4 GENERALIZING BATCH AND GROUP NORMALIZATION FOR SMALL BATCHES
129
+
130
+ While Batch Normalization is very effective in the medium to large-batch setting, it still suffers when not enough examples are available to calculate reliable normalization statistics. Although we have shown that techniques such as Inference Example Weighing (Sec. 3.1) can help significantly with this, it is still only a partial solution. At the same time, Group Normalization (Wu & He, 2018) was designed for a batch size of $B = 1$ or greater, but ignores all cross-image information.
131
+
132
+ In order to generalize Batch and Group Normalization in the batch size $B > 1$ case, we propose to expand the grouping mechanism of Group Normalization from being over only channels to being over both channels and examples — that is, normalization statistics are calculated both within groups of channels of each example and across examples in groups within each batch 4.
133
+
134
+ In principle, this would appear to introduce an additional hyperparameter on top of the number of channel groups used by Group Normalization, both of which would need to be optimized by expensive end-to-end runs of model training. However, in this case we can actually take advantage of the fact that the target batch size is small: if the batch size $B$ is ever large enough that having multiple groups in the example dimension is useful, then it is also large enough to eschew usage of the channel groups from Group Normalization, in a regime where either vanilla Batch Normalization or Ghost Batch Normalization is more effective. Thus, when dealing with a small batch size, in practice we only need to optimize over the same set of hyperparameters as Group Normalization.
135
+
136
+ To demonstrate, we target the extreme setting of $B = 2$ , and incorporate Inference Example Weighing to all approaches. For CIFAR-100, this approach improves validation set performance over a tuned Group Normalization by $0 . 6 9 \%$ in top-1 accuracy (from $7 3 . 9 1 \%$ to $7 4 . 6 0 \%$ , average over three runs), and on Caltech-256, performance dramatically improved by $5 . 0 \%$ (from $4 8 . 2 \%$ to $5 3 . 2 \%$ , average over two runs). However, this approach has one downside: due to differences in feature statistics across examples, when using only two examples the variability in the normalization statistics can still be quite high, even when using multiple channels within each normalization group. As a result, a regularization effect can occur, which may be undesirable for tasks which models are not overfitting much. As in Sec. 3.2 and Sec. 3.3, we see this effect in SVHN, where this approach is actually ever so slightly worse than Group Normalization on the validation set (from $9 8 . 7 5 \%$ to $9 8 . 7 3 \%$ ). On such datasets and tasks, it may be more fruitful to invest in higher-capacity models.
137
+
138
+ Summary: Combining Group and Batch Normalization leads to more accurate models in the setting of batch sizes $B > 1$ , and can have a regularization effect due to Batch Normalization’s variability in statistics when calculated over small batch sizes.
139
+
140
+ # 4 ADDITIONAL EXPERIMENTS
141
+
142
+ # 4.1 EXPERIMENTAL DETAILS
143
+
144
+ All results in Sec. 3 were performed on the validation datasets of each respective dataset (this section examines test set performance after hyperparameters have been optimized). Of the six datasets we experiment with, only ImageNet (Russakovsky et al., 2015) and Flowers-102 (Nilsback & Zisserman, 2008) have their own pre-defined validation split, so we constructed validation splits for the other datasets as follows: for CIFAR-100 (Krizhevsky & Hinton, 2009), we randomly took 40,000 of the 50,000 training images for the training split, and the remaining 10,000 as a validation split. For SVHN (Netzer et al., 2011), we similarly split the 604,388 non-test images in a $80 \%$ split for training and validation. For Caltech-256, no canonical splits of any form are defined, so we used 40 images of each of the 256 categories for training, 10 images for validation, and 30 for testing. For CUB-2011, we used $2 5 \%$ of the given training data as a validation set.
145
+
146
+ The model used for CIFAR-100 and SVHN was ResNet-18 (He et al., 2016b;a) with 64, 128, 256, and 512 filters across blocks. For Caltech-256, a much larger Inception-v3 (Szegedy et al., 2016) model was used, and we additionally experiment with ResNet-152 (He et al., 2016b) on Flowers-102 and CUB-2011 in Sec. 4.3. All experiments were done on two Nvidia Geforce GTX 1080 Ti GPUs.
147
+
148
+ 4.2 COMBINING ALL FOUR: IMPROVEMENTS ACROSS BATCH SIZES
149
+
150
+ Here we show the end-to-end effect of these four improvements on the test sets of each dataset, comparing against both Batch and Group Normalization, with a batch size $B \ = \ 1 2 8$ . We plot results for CIFAR-100 and Caltech-256 in Fig. 5 (a), comparing against Group Normalization and an idealized Batch Normalization with constant performance across batch sizes (simulating if the problematic dependence of Batch Norm on the batch size were completely solved). On CIFAR-100, we see improvements against the best available baseline across all batch sizes.
151
+
152
+ For medium to large batch sizes $B \geq 4 ,$ ), improvements are driven by the combination of Ghost Batch Normalization (Sec. 3.2), Inference Example Weighing (Sec. 3.1), and weight decay introduced on $\gamma$ and $\beta$ (Sec. 3.3). To aid in distinguishing between these effects, we also plot the impact of Ghost Batch Normalization alone, which we find particularly impactful as long as long as the batch size isn’t too small $( B > 2 )$ ). Turning to very small batch sizes, for $B = 1$ improvements are due to the introduced weight decay, and for $B \ = \ 2$ the generalization of Batch and Group Normalization leads to the improvement (Sec. 3.4), with some additional effect from weight decay.
153
+
154
+ ![](images/3f20fadce4f9178c276c88374ff0abe84fae5f881b6818605f704c3d0f2e643e.jpg)
155
+ Figure 5: Total performance changes across batch sizes for CIFAR-100 and Caltech-256 (a) when training from scratch, incorporating all proposed improvements to Batch Normalization. On the bottom (b) is the same on Flowers-102 and CUB-2011, which employs transfer learning via fine-tuning from ImageNet. Also shown within each plot is the performance of Group Normalization, an idealized Batch Normalization that scales perfectly across batch sizes, and Ghost Batch Normalization (Sec. 3.2) by itself, for which the $\mathbf { X }$ -axis represents the Ghost Batch Size $B ^ { \prime }$ .
156
+
157
+ Improvements on Caltech-256 follow the same trends, but to greater magnitude, with a total increase in performance of $6 . 5 \%$ over Batch Normalization and an increase of $5 . 9 \%$ over Group Normalization for $B = 2$ .
158
+
159
+ # 4.3 TRANSFER LEARNING
160
+
161
+ We also show the applicability of these approaches in the context of transfer learning, which we demonstrate on the Flowers-102 (Nilsback & Zisserman, 2008) and CUB-2011 (Wah et al., 2011) datasets via fine-tuning a ResNet-152 model from ImageNet. These tasks presents several challenges: 1) the Flowers-102 data only contains 10 images per category in the training set (and CUB2011 only 30 examples per class), 2) pre-training models on ImageNet is a very strong form of prior knowledge, and despite the small dataset size may heavily reduce the regularization effects of some of the techniques, and 3) we examine the setting of pre-training with generic ImageNet models trained without any of these modifications, which gives an advantage to both the generic Batch Normalization and Group Normalization, for which pre-trained models exist.
162
+
163
+ We plot results in Fig. 5 (b), where we find remarkable qualitative agreement of our non-transfer learning results to this setting, despite the challenges. In total, on Flowers-102 our techniques were able to improve upon Batch Normalization by $2 . 4 \%$ (from $9 1 . 0 \%$ to $9 3 . 4 \%$ top-1 accuracy, a $27 \%$ relative reduction in error), and upon Group Normalization by $6 . 1 \%$ (from $8 7 . 3 \%$ , a $48 \%$ relative reduction in error). On CUB-2011, which has more training data, we improved upon Batch Normalization by $1 . 4 \%$ (from $8 1 . 1 \%$ to $8 2 . 4 \%$ ) and Group Normalization by $3 . 8 \%$ (from $7 8 . 6 \%$ ).
164
+
165
+ We anticipate that even further improvements might arise by additionally pre-training models with some of these techniques (particularly Ghost Batch Normalization), as we were able to see a large impact (roughly $5 \%$ ) on Group Normalization by pre-training with a Group Normalization-based model instead of Batch Normalization.
166
+
167
+ Table 1: Accuracy on CIFAR-100 with non-i.i.d. minibatches. $B ^ { \prime }$ refers to the Ghost Batch Normalization size (equivalent to the batch size for Batch Normalization and Batch Renormalization), and “Batch Group Norm.” refers to our approach in Sec. 3.4. “Inf. Ex. Weight: Off” refers to using only the moving averages for normalization statistics (i.e. $\alpha = 0$ ), while $\mathbf { \ddot { \omega } } _ { \mathrm { O n } } \mathbf { \vec { \omega } } ^ { \mathrm { , } \bullet }$ refers to tuning $\alpha$ based on the validation set.
168
+
169
+ <table><tr><td>Method</td><td>B&#x27;</td><td>Inf. Ex.Weight: OffInf.Ex.Weight: On</td></tr><tr><td>Batch Norm</td><td>128</td><td>40.1 62.2</td></tr><tr><td>Batch ReNorm</td><td>128</td><td>69.0 69.0</td></tr><tr><td rowspan="6">GhostBatch Norm</td><td>64</td><td>42.3 50.8</td></tr><tr><td>32</td><td>57.8 70.9</td></tr><tr><td>16</td><td>64.3 72.2</td></tr><tr><td>8</td><td>68.7 72.0</td></tr><tr><td>4</td><td>70.4 71.5</td></tr><tr><td></td><td>68.4 71.4</td></tr><tr><td>Batch Group Norm.</td><td>75.2</td><td>76.1</td></tr></table>
170
+
171
+ # 4.4 NON-I.I.D. MINIBATCHES
172
+
173
+ An implicit assumption in Batch Normalization is that training examples are sampled independently, so that minibatch normalization statistics all follow roughly the same distribution and training statistics are faithfully represented in the moving averages. However, in applications where training batches are not sampled i.i.d., such as metric learning (Oh Song et al., 2016; Movshovitz-Attias et al., 2017) or hard negative mining (Shrivastava et al., 2016), violating this assumption may lead to undesired consequences in the model. Here, we test our approaches in this challenging setting.
174
+
175
+ Following Batch Renormalization (Ioffe, 2017), we study the case where examples in a minibatch are sampled from a small number of classes — specifically, we consider CIFAR-100, and study the extreme case where each minibatch ( $B = 1 2 8$ ) is comprised of examples from only four random categories (sampled with replacement), each of which is represented with 32 examples in the minibatch. We present results for Batch Normalization, Batch Renormalization, our generalization of Batch and Group Normalization from Sec. 3.4 (“Batch Group Norm.”), and the full interaction of Ghost Batch Normalization and Inference Example Weighing in Table 1. In this challenging setting, Inference Example Weighing, Ghost Batch Normalization, and Batch Group Norm all have large effect, in many cases halving the error rate of Batch Normalization. For example, Inference Example Weighing was able to reduce the error rate by $20 \%$ without any retraining, and tuning Ghost Batch Normalization, even without any inference modifications, was just as effective as Batch Renormalization, a technique partially designed for the non-i.i.d. case. Even further, Batch Group Normalization was hardly affected at all by the non-i.i.d. training distribution (76.1 vs 76.2 for i.i.d.). Last, it is interesting to note that Inference Example Weighing had practically no effect on Batch Renormalization (improvement $\leq 0 . 1 \%$ ), confirming Batch Renormalization’s effect in making models more robust to the use of training vs moving average normalization statistics.
176
+
177
+ # 5 CONCLUSION
178
+
179
+ In this work, we have demonstrated four improvements to Batch Normalization that should be known by all who use it. These include: a method for leveraging the statistics of inference examples more effectively in normalization statistics, fixing a discrepancy between training and inference with Batch Normalization; demonstrating the surprisingly powerful effect of Ghost Batch Normalization for improving generalization of models without requiring very large batch sizes; investigating the previously unstudied effect of weight decay on the scaling and shifting parameters $\gamma$ and $\beta$ ; and introducing a new approach for normalization in the small batch setting, generalizing and leveraging the strengths of both Batch and Group Normalization. In each case, we have done our best to not only demonstrate the effect of the method, but also provide guidance and evidence for precisely which cases in which it may be effective, which we hope will aid in their applicability.
180
+
181
+ # REFERENCES
182
+
183
+ Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
184
+
185
+ Minhyung Cho and Jaehyung Lee. Riemannian approach to batch normalization. In Advances in Neural Information Processing Systems, pp. 5225–5235, 2017.
186
+
187
+ Lucas Deecke, Iain Murray, and Hakan Bilen. Mode normalization. In International Conference on Learning Representations, 2019.
188
+
189
+ 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.
190
+
191
+ Alex Graves, Abdel-rahman Mohamed, and Geoffrey Hinton. Speech recognition with deep recurrent neural networks. In 2013 IEEE international conference on acoustics, speech and signal processing, pp. 6645–6649. IEEE, 2013.
192
+
193
+ Yong Guo, Qingyao Wu, Chaorui Deng, Jian Chen, and Mingkui Tan. Double forward propagation for memorized batch normalization. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
194
+
195
+ 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, 2016a.
196
+
197
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European Conference on Computer Vision, pp. 630–645. Springer, 2016b.
198
+
199
+ Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In ´ Proceedings of the IEEE international conference on computer vision, pp. 2961–2969, 2017.
200
+
201
+ Tong He, Zhi Zhang, Hang Zhang, Zhongyue Zhang, Junyuan Xie, and Mu Li. Bag of tricks for image classification with convolutional neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 558–567, 2019.
202
+
203
+ Elad Hoffer, Itay Hubara, and Daniel Soudry. Train longer, generalize better: closing the generalization gap in large batch training of neural networks. In Advances in Neural Information Processing Systems, pp. 1731–1741, 2017.
204
+
205
+ Elad Hoffer, Ron Banner, Itay Golan, and Daniel Soudry. Norm matters: efficient and accurate normalization schemes in deep networks. In Advances in Neural Information Processing Systems, pp. 2164–2174, 2018.
206
+
207
+ Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
208
+
209
+ Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7132–7141, 2018.
210
+
211
+ Lei Huang, Dawei Yang, Bo Lang, and Jia Deng. Decorrelated batch normalization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 791–800, 2018.
212
+
213
+ Lei Huang, Yi Zhou, Fan Zhu, Li Liu, and Ling Shao. Iterative normalization: Beyond standardization towards efficient whitening. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4874–4883, 2019.
214
+
215
+ Sergey Ioffe. Batch renormalization: Towards reducing minibatch dependence in batch-normalized models. In Advances in Neural Information Processing Systems, pp. 1945–1953, 2017.
216
+
217
+ Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In In Proceedings of The 32nd International Conference on Machine Learning, pp. 448–456, 2015.
218
+
219
+ Gunter Klambauer, Thomas Unterthiner, Andreas Mayr, and Sepp Hochreiter. Self-normalizing ¨ neural networks. In Advances in neural information processing systems, pp. 971–980, 2017.
220
+
221
+ Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.
222
+
223
+ Anders Krogh and John A Hertz. A simple weight decay can improve generalization. In Advances in neural information processing systems, pp. 950–957, 1992.
224
+
225
+ 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.
226
+
227
+ Etai Littwin and Lior Wolf. Regularizing by the variance of the activations’ sample-variances. In Advances in Neural Information Processing Systems, pp. 2119–2129, 2018.
228
+
229
+ Ping Luo, Jiamin Ren, and Zhanglin Peng. Differentiable learning-to-normalize via switchable normalization. In International Conference on Learning Representations, 2019.
230
+
231
+ Yair Movshovitz-Attias, Alexander Toshev, Thomas K Leung, Sergey Ioffe, and Saurabh Singh. No fuss distance metric learning using proxies. In Proceedings of the IEEE International Conference on Computer Vision, pp. 360–368, 2017.
232
+
233
+ Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. 2011.
234
+
235
+ M-E. Nilsback and A. Zisserman. Automated flower classification over a large number of classes. In Proceedings of the Indian Conference on Computer Vision, Graphics and Image Processing, Dec 2008.
236
+
237
+ Hyun Oh Song, Yu Xiang, Stefanie Jegelka, and Silvio Savarese. Deep metric learning via lifted structured feature embedding. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4004–4012, 2016.
238
+
239
+ 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.
240
+
241
+ Tim Salimans and Durk 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.
242
+
243
+ Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4510–4520, 2018.
244
+
245
+ Shibani Santurkar, Dimitris Tsipras, Andrew Ilyas, and Aleksander Madry. How does batch normalization help optimization? In Advances in Neural Information Processing Systems, pp. 2488– 2498, 2018.
246
+
247
+ Christopher J Shallue, Jaehoon Lee, Joe Antognini, Jascha Sohl-Dickstein, Roy Frostig, and George E Dahl. Measuring the effects of data parallelism on neural network training. arXiv preprint arXiv:1811.03600, 2018.
248
+
249
+ Abhinav Shrivastava, Abhinav Gupta, and Ross Girshick. Training region-based object detectors with online hard example mining. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 761–769, 2016.
250
+
251
+ N. Silberman and S. Guadarrama. Tensorflow-slim image classification model library. https: //github.com/tensorflow/models/tree/master/research/slim.
252
+
253
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations, 2015.
254
+
255
+ Saurabh Singh and Abhinav Shrivastava. Evalnorm: Estimating batch normalization statistics for evaluation. In Proceedings of the IEEE International Conference on Computer Vision, pp. 3633– 3641, 2019.
256
+
257
+ Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. In Advances in neural information processing systems, pp. 3104–3112, 2014.
258
+
259
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818–2826, 2016.
260
+
261
+ Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, and Alexander A Alemi. Inception-v4, inception-resnet and the impact of residual connections on learning. In Thirty-First AAAI Conference on Artificial Intelligence, 2017.
262
+
263
+ Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Instance normalization: The missing ingredient for fast stylization. arXiv preprint arXiv:1607.08022, 2016.
264
+
265
+ Twan van Laarhoven. L2 regularization versus batch and weight normalization. arXiv preprint arXiv:1706.05350, 2017.
266
+
267
+ 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.
268
+
269
+ Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011.
270
+
271
+ Yuxin Wu and Kaiming He. Group normalization. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 3–19, 2018.
272
+
273
+ 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. In International Conference on Machine Learning, 2018.
274
+
275
+ Hongyi Zhang, Yann N. Dauphin, and Tengyu Ma. Fixup initialization: Residual learning without normalization. In International Conference on Learning Representations, 2019.
276
+
277
+ Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. In International Conference on Learning Representations, 2017.
278
+
279
+ Barret Zoph, Vijay Vasudevan, Jonathon Shlens, and Quoc V Le. Learning transferable architectures for scalable image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 8697–8710, 2018.
280
+
281
+ # A PROOF OF BATCH NORMALIZATION OUTPUT BOUNDS
282
+
283
+ Here we present a proof of Eq. 2. We first prove the bound as an inequality and then show that it is tight. Without loss of generality, we assume that $x _ { 0 }$ is the minimum of $\{ \stackrel { \cdot } { x } _ { i } \} _ { i = 0 } ^ { B - 1 }$ and that $\gamma \geq 0$
284
+
285
+ $$
286
+ \operatorname* { m i n } _ { x _ { 0 } , \ldots , x _ { B - 1 } } \gamma \frac { x _ { 0 } - \mu _ { i } } { \sqrt { \sigma _ { i } ^ { 2 } + \epsilon } } + \beta = - \gamma \sqrt { B - 1 } + \beta
287
+ $$
288
+
289
+ Expanding $\mu _ { i }$ and $\sigma _ { i } ^ { 2 }$ (using the maximum likelihood estimator for $\sigma _ { i } ^ { 2 }$ ), and canceling the scaling and offset terms $\gamma$ and $\beta$ , we want to show
290
+
291
+ $$
292
+ \operatorname* { m i n } _ { x _ { 0 } , \ldots , x _ { B - 1 } } \frac { x _ { 0 } - \frac { 1 } { B } \sum _ { i = 0 } ^ { B - 1 } x _ { i } } { \sqrt { \frac { 1 } { B } \sum _ { i = 0 } ^ { B - 1 } ( x _ { i } - \frac { 1 } { B } \sum _ { j = 0 } ^ { B - 1 } x _ { j } ) ^ { 2 } + \epsilon } } = - \sqrt { B - 1 }
293
+ $$
294
+
295
+ From here we assume without loss of generality that $x _ { 0 } = 0 -$ since the output of Batch Normalization is invariant to an additive constant on all $x _ { i }$ , we can subtract $x _ { 0 }$ from all $x _ { i }$ and maintain the same value. We also assume that all $x _ { i } \geq 0$ , then frame the minimum as a bound
296
+
297
+ $$
298
+ \begin{array} { r } { \frac { - \frac { 1 } { B } \sum _ { i = 0 } ^ { B - 1 } x _ { i } } { \sqrt { \frac { 1 } { B } \sum _ { i = 0 } ^ { B - 1 } ( x _ { i } - \frac { 1 } { B } \sum _ { j = 0 } ^ { B - 1 } x _ { j } ) ^ { 2 } + \epsilon } } \ge - \sqrt { B - 1 } } \end{array}
299
+ $$
300
+
301
+ $$
302
+ - \frac { 1 } { B } \sum _ { i = 0 } ^ { B - 1 } x _ { i } \ge - \sqrt { \frac { B - 1 } { B } \sum _ { i = 0 } ^ { B - 1 } \left( x _ { i } - \frac { 1 } { B } \sum _ { j = 0 } ^ { B - 1 } x _ { j } \right) ^ { 2 } + \epsilon }
303
+ $$
304
+
305
+ $$
306
+ - \frac { 1 } { B } \sum _ { i = 0 } ^ { B - 1 } x _ { i } \ge - \sqrt { \frac { B - 1 } { B } \sum _ { i = 0 } ^ { B - 1 } \left( x _ { i } ^ { 2 } - \frac { 2 x _ { i } } { B } \sum _ { j = 0 } ^ { B - 1 } x _ { j } + \frac { 1 } { B ^ { 2 } } \left( \sum _ { j = 0 } ^ { B - 1 } x _ { j } \right) ^ { 2 } \right) + \epsilon }
307
+ $$
308
+
309
+ $$
310
+ \begin{array} { r l } & { \frac { n } { 2 } \leq \sigma _ { 1 } \leq ( \frac { n - 1 } { 2 } ( \frac { n } { 2 } - 1 ) \sigma _ { 1 } - \frac { n - 1 } { 2 } \geq \sigma _ { 2 } + \frac { n } { \sigma } - \frac { 1 } { \sigma } ( \frac { n - 1 } { 2 } ) ) ^ { 2 } ) - \frac { \sigma _ { 1 } } { 2 } } \\ & { \frac { n - 1 } { 2 } \leq \sigma _ { 1 } \leq ( \frac { n - 1 } { 2 } ( \frac { n - 1 } { 2 } - 1 ) \sigma _ { 1 } - 2 ( 2 - n - 1 ) \sigma _ { 1 } ^ { 2 - 1 } \geq \sigma _ { 2 } + \frac { n - 1 } { \sigma } ( \frac { n - 1 } { 2 } ) ^ { 2 } ) ^ { 2 } - \sigma _ { 1 } ^ { 2 } } \\ & { \frac { n - 1 } { 2 } \leq \sigma _ { 1 } \leq ( \frac { n - 1 } { 2 } ) \frac { n ^ { 2 } - 1 } { 2 } \frac { n ^ { 2 } - 1 } { 2 } \frac { \sigma _ { 1 } ^ { 2 - 1 } - 1 } { 2 } ( \frac { n - 1 } { 2 } ) ^ { 2 } - ( \sigma _ { 1 } - 1 ) ( \frac { n - 1 } { 2 } ) ^ { 2 } ) ^ { 2 } - \sigma _ { 1 } ^ { 2 } } \\ & { - n } \\ & { \frac { n - 1 } { 2 } \leq \sigma _ { 1 } \leq \sqrt { ( 2 - 1 ) \sigma _ { 1 } } \leq \sigma _ { 1 } \leq \sigma _ { 1 } ^ { 2 - 1 } \ ( \frac { n - 1 } { 2 } ) ^ { 2 } \sigma _ { 1 } - ( \sigma _ { 1 } - 1 ) ( \frac { n - 1 } { 2 } ) ^ { 2 } \sigma _ { 1 } ^ { 2 - 1 } } \\ & { \qquad ( \frac { n - 1 } { 2 } ) ^ { 2 } \leq ( \sigma _ { 1 } - 1 ) \sigma _ { 1 } ^ { 2 - 1 } \leq ( \sigma _ { 1 } - 1 ) \sigma _ { 1 } ^ { 2 - 1 } ( \frac { n - 1 } { 2 } ) ^ { 2 } \sigma _ { 1 } ^ { 2 } } \\ & \qquad ( \frac { n - 1 } { 2 } ) ^ { 2 } \leq ( \sigma _ { 1 } - 1 ) \sigma _ { 1 } ^ { 2 - 1 } \leq ( \sigma _ { 1 } - 1 ) \frac { n - 1 } { 2 } \sigma _ \end{array}
311
+ $$
312
+
313
+ Using the fact that $x _ { 0 } = 0$ and $\epsilon > 0$ , it suffices to show
314
+
315
+ $$
316
+ \left( \sum _ { i = 1 } ^ { B - 1 } x _ { i } \right) ^ { 2 } \leq ( B - 1 ) \sum _ { i = 1 } ^ { B - 1 } x _ { i } ^ { 2 }
317
+ $$
318
+
319
+ With a change of variables, we have the more general
320
+
321
+ $$
322
+ \left( \sum _ { i = 0 } ^ { N - 1 } x _ { i } \right) ^ { 2 } \leq N \sum _ { i = 0 } ^ { N - 1 } x _ { i } ^ { 2 }
323
+ $$
324
+
325
+ $$
326
+ \frac { 1 } { N ^ { 2 } } \left( \sum _ { i = 0 } ^ { N - 1 } x _ { i } \right) ^ { 2 } \leq \frac { 1 } { N } \sum _ { i = 0 } ^ { N - 1 } x _ { i } ^ { 2 }
327
+ $$
328
+
329
+ $$
330
+ \mathbb { E } [ x ] ^ { 2 } \leq \mathbb { E } [ x ^ { 2 } ]
331
+ $$
332
+
333
+ $$
334
+ \mathbb { E } [ x ^ { 2 } ] - \mathbb { E } [ x ] ^ { 2 } \ge 0
335
+ $$
336
+
337
+ which is simply an alternate form for the variance of $\mathbf { X }$ , which is always non-negative, completing the bound.
338
+
339
+ To show that the bound is tight, we can set $x _ { 0 } = 0$ and $x _ { i } = a$ for all $i > 0$ , where $a$ is a non-negative constant:
340
+
341
+ $$
342
+ \begin{array} { r } { \frac { - \frac { 1 } { B } \sum _ { i = 0 } ^ { B - 1 } x _ { i } } { \sqrt { \frac { 1 } { B } \sum _ { i = 0 } ^ { B - 1 } ( x _ { i } - \frac { 1 } { B } \sum _ { j = 0 } ^ { B - 1 } x _ { j } ) ^ { 2 } + \epsilon } } } \\ { \frac { - \frac { 1 } { B } \sum _ { i = 1 } ^ { B - 1 } a } { \sqrt { \frac { 1 } { B } \left( \frac { ( B - 1 ) ^ { 2 } } { B ^ { 2 } } a ^ { 2 } + \sum _ { i = 1 } ^ { B - 1 } ( a - \frac { B - 1 } { B } a ) ^ { 2 } \right) + \epsilon } } } \end{array}
343
+ $$
344
+
345
+ $$
346
+ \frac { - \frac { B - 1 } { B } a } { \sqrt { \frac { 1 } { B } \left( \frac { ( B - 1 ) ^ { 2 } } { B ^ { 2 } } a ^ { 2 } + ( B - 1 ) a ^ { 2 } \left( 1 - \frac { 2 ( B - 1 ) } { B } + \frac { ( B - 1 ) ^ { 2 } } { B ^ { 2 } } \right) \right) + \epsilon } }
347
+ $$
348
+
349
+ $$
350
+ \frac { - ( B - 1 ) a } { B \sqrt { \frac { a ^ { 2 } ( B - 1 ) } { B } \left( \frac { B - 1 } { B ^ { 2 } } + 1 - 2 \frac { B - 1 } { B } + \frac { ( B - 1 ) ^ { 2 } } { B ^ { 2 } } \right) + \epsilon } }
351
+ $$
352
+
353
+ $$
354
+ \frac { - ( B - 1 ) a } { \sqrt { a ^ { 2 } ( B - 1 ) \left( { \frac { B - 1 } { B } } + B - 2 B + 2 + { \frac { ( B - 1 ) ^ { 2 } } { B } } \right) + \epsilon } }
355
+ $$
356
+
357
+ $$
358
+ \begin{array} { c } { { \frac { - ( B - 1 ) a } { \sqrt { a ^ { 2 } ( B - 1 ) \left( \frac { B ^ { 2 } - 2 B + 1 + B - 1 - B ^ { 2 } + 2 B } { B } \right) + \epsilon } } } } \\ { { \frac { - ( B - 1 ) a } { \sqrt { a ^ { 2 } ( B - 1 ) + \epsilon } } } } \end{array}
359
+ $$
360
+
361
+ As $a \infty$ (or if $\epsilon = 0$ ), then this approaches
362
+
363
+ $$
364
+ \frac { - ( B - 1 ) a } { a { \sqrt { ( B - 1 ) } } }
365
+ $$
366
+
367
+ which is simply
368
+
369
+ $$
370
+ - \sqrt { ( B - 1 ) }
371
+ $$
372
+
373
+ completing the proof.
374
+
375
+ ![](images/29489c356c8edf50ad7483d7091a3251e41be4dbf67089041a455ece09e0bcf8.jpg)
376
+ Figure 6: Range of output values obtained during inference on the CIFAR-10 test set, compared with the range observed during training and the bound of Eq. 2. See text for details.
377
+
378
+ # B EMPIRICAL EVIDENCE OF BATCH NORMALIZATION OUTPUT BOUNDS
379
+
380
+ In Fig. 6 we show the observed output ranges for the last Batch Normalization layer in our CIFAR10 network (spatial resolution: $4 \times 4$ ), plotting both the range during training and at inference time on the CIFAR-10 test set. Different values of $B$ were obtained by using different Ghost Batch Normalization sizes, keeping in mind that $B$ is determined by the product of the batch size and spatial dimensions.
381
+
382
+ At large values of $B$ , it is unlikely that any network obtains a value even close to the bound of Eq. 2, but as $B$ gets smaller, the output range of the network during training becomes smaller in magnitude, eventually being nearly tight with our bound — for example, for $\log ( B ) = 5$ , the theoretical minimum is $- 5 . 5 7$ , while the network obtained a minimum of $- 5 . 3 0$ . However, the maximum and minimum values obtained during inference on the test set show no clear pattern as $B$ changes, and are not subject to the training time bound, which is particularly noticeable for small values of $B$ , where values fall outside the training-time bounds.
383
+
384
+ C NEGATIVE RESULTS: APPROACHES THAT DIDN’T WORK.
385
+
386
+ Here we detail a handful of approaches which seemed intuitively promising but ultimately failed to produce positive results.
387
+
388
+ BATCH NORMALIZATION MOVING AVERAGES. In an attempt to resolve the other disparities Batch Normalization has between its training and inference behaviors, we experimented with a handful of different approaches for modifying the moving averages used during inference. First, since examples at inference time do not have data augmentation applied to them, we tried computing the moving averages over examples without data augmentation (implemented by training the model for a few extra epochs over non-augmented examples with a learning rate of 0, but while still updating the moving average variables). This decreased accuracy on CIFAR-100 by roughly half a percent, though it did yield mild improvements to the test set cross-entropy loss.
389
+
390
+ Next, we experimented with calculating the moving averages over the test set, not making use of any of the test labels. Perhaps surprisingly, this behaved very similar to when moving averages were calculated over the training examples (within $0 . 1 \%$ in accuracy and within $1 \%$ in cross-entropy), with trends holding regardless of whether data augmentation was applied or not.
391
+
392
+ ADDING BATCH NORMALIZATION-LIKE STOCHASTICITY TO GROUP NORMALIZATION. One of the hypotheses for why Group Normalization generally performs slightly worse than Batch Normalization is the regularization effect of Batch Normalization due to random minibatches producing variability in the normalization statistics. Therefore, we tried introducing stochasticity to Group Normalization in a variety of ways, none of which we could get to work well: 1) Adding gaussian noise to the normalization statistics, where the noise is based on a moving average of the normalization statistics, 2) Using random groupings of channels for calculating normalization statistics (optionally only doing randomization a fraction of the time), and 3) changing the number of groups throughout the training procedure, either as increasing or decreasing functions of training steps.
393
+
394
+ ![](images/ab0c49f48fbb2d1b605c40e2a3941d6ed8b5321a4b137d21772d7cd209835e70.jpg)
395
+ Figure 7: Effect of the example-weighing hyperparameter $\alpha$ on ImageNet; supplemental version of Fig. 1 with a larger range of $\alpha$ .
396
+
397
+ ![](images/ac8d0517baa1a6f86e22fa3573bf542100e96d4b596383d4c40c88b9d4548be8.jpg)
398
+ Figure 8: Effect of the example-weighing hyperparameter $\alpha$ for models trained with Group Normalization on CIFAR-100, SVHN, and Caltech-256; supplemental version of Fig. 2 with a larger range of $\alpha$ .
399
+
400
+ MORE PRINCIPLED GROUP SIZE COMPUTATION. As part of generalizing Batch and Group Normalization, we examined whether it was possible to determine the number of groups in each normalization layer in a more principled way that simply specifying it as a constant throughout the network. For example, one approach we had mild success with was setting the number of elements per group (height $\times$ wi $\operatorname { d t h } \times \operatorname { g }$ roup size) to a constant, making the number of elements contributing to the normalization statistics uniform across layers. However, we were unable to get any of these ideas to work in a way that generalized properly across datasets. We also tried learning group sizes in a differentiable way with Switchable Normalization, but found that this made models overfit too much.
401
+
402
+ # D SUPPLEMENTAL INFERENCE EXAMPLE WEIGHING PLOTS
403
+
404
+ In Figures 7, 8, and 9 we present plots corresponding to Figures 1, 2, and 4 of the main text, with larger ranges of the inference weight $\alpha$ . In the main text, we restricted the range of $\alpha$ to values which showed off the tradeoff of $\alpha$ versus performance at a reasonably local scale, and these figures show a larger scale for completeness in characterizing model behavior. While this behavior can largely be extrapolated from the behavior for a smaller range of $\alpha$ , there are some interesting trends.
405
+
406
+ On ImageNet 7, we see that only a small amount of inference example weighing is necessary to get most of its benefit, and setting $\alpha$ to larger values corresponds to a regime quite different than in training, smoothly decaying model performance as $\alpha$ becomes less and less appropriate. Similarly, when applying inference example weighing to Group Normalization (Fig. 8, while performance intuitively decays as $\alpha$ moves farther and farther away from 1, a surprisingly large range of values for $\alpha$ result in similar performance to Group Normalization, especially on SVHN. Lastly, when comparing the effect of $\alpha$ on models trained with Ghost Batch Normalization (Fig. 9, we clearly see that the optimal value for $\alpha$ is decreasing with respect to the Ghost Batch Normalization size, with the possible unusual exception of optimizing for loss on SVHN.
407
+
408
+ ![](images/6659de742562522511cf091a2528049428692133763538c175898b2e2b14a9b5.jpg)
409
+ Figure 9: The complementary effects of Inference Example Weighing and Ghost Batch Normalization on CIFAR-100, SVHN, and Caltech-256; supplemental version of Fig. 4 with a larger range of $\alpha$ .
md/train/Hkg5lAEtvS/Hkg5lAEtvS.md ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TOWARDS PHYSICS-INFORMED DEEP LEARNING FOR TURBULENT FLOW PREDICTION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ While deep learning has shown tremendous success in a wide range of domains, it remains a grand challenge to incorporate physical principles in a systematic manner to the design, training and inference of such models. In this paper, we aim to predict turbulent flow by learning its highly nonlinear dynamics from spatiotemporal velocity fields of large-scale fluid flow simulations of relevance to turbulence modeling and climate modeling. We adopt a hybrid approach by marrying two well-established turbulent flow simulation techniques with deep learning. Specifically, we introduce trainable spectral filters in a coupled model of Reynoldsaveraged Navier-Stokes (RANS) and Large Eddy Simulation (LES), followed by a specialized U-net for prediction. Our approach, which we call Turbulent-Flow Net (TF-Net), is grounded in a principled physics model, yet offers the flexibility of learned representations. We compare our model, TF-Net, with state-of-theart baselines and observe significant reductions in error for predictions 60 frames ahead. Most importantly, our method predicts physical fields that obey desirable physical characteristics, such as conservation of mass, whilst faithfully emulating the turbulent kinetic energy field and spectrum, which are critical for accurate prediction of turbulent flows.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Modeling the dynamics of physical processes that evolve over space and time and vary over a wide range of spatial and temporal scales is a fundamental task in science. Computational fluid dynamics (CFD) is at the heart of climate modeling and has direct implications for understanding and predicting climate change. However, the current paradigm in atmospheric CFD is purely physicsdriven: known physical laws encoded in systems of coupled partial differential equations (PDEs) are solved over space and time via numerical differentiation and integration schemes. These methods are tremendously computationally-intensive, requiring significant computational resources and expertise. Recently, data-driven methods, including deep learning, have demonstrated great success in the automation, acceleration, and streamlining of highly compute-intensive workflows for science (Reichstein et al., 2019). But existing deep learning methods are mainly statistical with little or no underlying physical knowledge incorporated, and are yet to be proven to be successful in capturing and predicting accurately the properties of complex physical systems.
12
+
13
+ Developing deep learning methods that can incorporate physical laws in a systematic manner is a key element in advancing AI for physical sciences (Steven Brunton, 2019). Towards this goal, we investigate the challenging problem of predicting a turbulent flow, governed by the high-dimensional nonlinear Navier-Stokes equations. Recently, several studies have attempted incorporating knowledge about a physical system into deep learning. For example, Emmanuel de Bezenac (2018) proposed a warping scheme to predict the sea surface temperature, but only considered the linear advectiondiffusion equation. Xie et al. (2018) and Jonathan Tompson (2017) developed deep learning models in the context of fluid flow animation, where physical consistency is less critical. Wu et al. (2019) and Tom Beucler (2019) introduced statistical and physical constraints in the loss function to regularize the predictions of the model. However, their studies only focused on spatial modeling without temporal dynamics, besides regularization being ad-hoc and difficult to tune the hyper-parameters.
14
+
15
+ In this work, we propose a hybrid learning paradigm that unifies turbulence modeling and deep representation learning. We develop a novel deep learning model, Turbulent-Flow Net (TF-Net), that enhances the capability of predicting complex turbulent flows with deep neural networks. TF-Net applies scale separation to model different ranges of scales of the turbulent flow individually. Building upon a promising and popular CFD technique, the RANS-LES coupling approach (E. Labourasse, 2004), our model replaces a priori spectral filters with trainable convolutional layers. We decompose the turbulent flow into three components, each of which is approximated by a specialized U-net to preserve invariance properties. To the best of our knowledge, this is the first hybrid framework of its kind for predicting turbulent flow. We compare our method with state-of-the-art baselines for forecasting velocity fields up to 60 steps ahead given the history. We observe that TF-Net is capable of generating accurate and physically meaningful predictions that preserve critical quantities of relevance. In summary, our contributions are as follows:
16
+
17
+ 1. We study the challenging task of turbulent flow prediction as a test bed to investigate incorporating physics knowledge into deep learning in a principled fashion.
18
+ 2. We propose a novel hybrid learning framework, TF-Net, that unifies a popular CFD technique, RANS-LES coupling, with custom-designed deep neural networks.
19
+ 3. When evaluated on turbulence simulations, TF-Net achieves $1 1 . 1 \%$ reduction in prediction RMSE, $3 0 . 1 \%$ improvement in the energy spectrum, $21 \%$ turbulence kinetic energy RMSEs and $6 4 . 2 \%$ reduction of flow divergence in difference from the target, compared to the best baseline.
20
+
21
+ # 2 BACKGROUND IN TURBULENCE MODELING
22
+
23
+ Most fluid flows in nature are turbulent, but theoretical understanding of solutions to the governing equations, the Navier–Stokes equations, is incomplete. Turbulent fluctuations occur over a wide range of length and time scales with high correlations between these scales. Turbulent flows are characterized by chaotic motions and intermittency, which are difficult to predict.
24
+
25
+ ![](images/7d3386d2bc1b4492371a10e129eb0524d58d151d9be0ce449d32d34be7a992ed.jpg)
26
+ Figure 1: A snapshot of the Rayleigh-Bénard convection flow, the velocity fields along $x$ direction (top) and $y$ direction (bottom) (Chirila, 2018). The spatial resolution is $1 7 9 2 \mathrm { ~ x ~ } 2 5 6$ pixels.
27
+
28
+ The physical system we investigate is two-dimensional Rayleigh-Bénard convection (RBC), a model for turbulent convection, with a horizontal layer of fluid heated from below so that the lower surface is at a higher temperature than the upper surface. Turbulent convection is a major feature of the dynamics of the oceans, the atmosphere, as well as engineering and industrial processes, which has motivated numerous experimental and theoretical studies for many years. The RBC system serves as an idealized model for turbulent convection that exhibits the full range of dynamics of turbulent convection for sufficiently large temperature gradients.
29
+
30
+ Let $\textbf { \em w }$ be the vector velocity field of the flow with two components $( u , v )$ , velocities along $x$ and $y$ directions, the governing equations for this physical system are:
31
+
32
+ Continuity Equation
33
+
34
+ $$
35
+ \begin{array} { r l } & { \nabla \cdot { \pmb w } = 0 } \\ & { \frac { \partial { \pmb w } } { \partial t } + ( { \pmb w } \cdot \nabla ) { \pmb w } = - \frac { 1 } { \rho _ { 0 } } \nabla p + \nu \nabla ^ { 2 } { \pmb w } + f } \\ & { \frac { \partial T } { \partial t } + ( { \pmb w } \cdot \nabla ) T = \kappa \nabla ^ { 2 } T } \end{array}
36
+ $$
37
+
38
+ Momentum Equation
39
+
40
+ Temperature Equation
41
+
42
+ where $p$ and $T$ are pressure and temperature respectively, $\kappa$ is the coefficient of heat conductivity, $\rho _ { 0 }$ is density at temperature at the beginning, $\alpha$ is the coefficient of thermal expansion, $\nu$ is the kinematic viscosity, $f$ the body force that is due to gravity. In this work, we use a particular approach to modeling RBC that uses a Boussinesq approximation, resulting in a divergence-free flow, so $\nabla \cdot \pmb { w }$ should be zero everywhere (Chirila, 2018). Figure 1 shows a snapshot in our RBC flow dataset.
43
+
44
+ CFD allows simulating complex turbulent flows, however, the wide range of scales makes it very challenging to accurately resolve all the scales. More precisely, fully resolving a complex turbulent flow numerically, known as direct numerical simulations – DNS, requires a very fine discretization of space-time, which makes the computation prohibitive even with advanced high-performance computing. Hence most CFD methods, like Reynolds-Averaged Navier-Stokes and Large Eddy Simulations (McDonough, 2007a; Pierre Sagaut, 2006; McDonough, 2007b), resort to resolving the large scales whilst modeling the small scales, using various averaging techniques and/or low-pass filtering of the governing equations (Eqn. 1). However, the unresolved processes and their interactions with the resolved scales are extremely challenging to model. CFD remains computationally expensive despite decades of advancements in turbulence modeling and HPC.
45
+
46
+ Deep learning (DL) is poised to accelerate and improve turbulent flow simulations because welltrained DL models can generate realistic instantaneous flow fields with physically accurate spatiotemporal coherence, without solving the complex nonlinear coupled PDEs that govern the system (Tompson et al., 2017; Maziar Raissi, 2019; 2018). However, DL models are hard to train and are often used as "black boxes" in physical science as they lack knowledge of the underlying physics and are very hard to interpret. While these DL models may achieve low prediction errors they often lack scientific consistency and do not respect the physics of the systems they model. Therefore, it is critical to infusing known physics and design efficient turbulent flow prediction DL models that are not only accurate but also physically meaningful.
47
+
48
+ # 3 TURBULENT-FLOW NET
49
+
50
+ Inspired by techniques used in CFD to separate scales of this multi-scale system, the global idea behind TF-Net is to decompose the flow into three components of different scales with trainable modules for simulating each component. First, we provide a brief introduction of the CFD techniques which are built on this basic idea.
51
+
52
+ ![](images/6ce600b0b08c1dd34bb4b6e98ce118b3c0b54e388a7ffa3b53faa3047d99107f.jpg)
53
+ Figure 2: Turbulent Flow Net: three identical encoders to learn the transformations of the three components of different scales, and one shared decoder that learns the interactions among these three components to generate the predicted 2D velocity field at the next instant. Each encoder-decoder pair can be viewed as a U-net and the aggregation is weighted summation.
54
+
55
+ Reynolds-averaged Navier–Stokes (RANS) decomposes the turbulent flow $\pmb { w }$ into two separable time scales: a time-averaged mean flow $\bar { \pmb { w } }$ and a fluctuating quantity $\mathbf { \Delta } w ^ { \prime }$ . The resulting RANS equations contain a closure term, the Reynolds stresses, that require modeling, the classic closure problem of turbulence modeling. While this approach is a good first approximation to solving a turbulent flow, RANS does not account for broadband unsteadiness and intermittency, characteristic of most turbulent flows. Further, closure models for the unresolved scales are often inadequate, making RANS solutions to be less accurate. $T$ here is the moving average window size.
56
+
57
+ $$
58
+ w ( \mathbf { x } , t ) = \bar { w } ( \mathbf { x } , t ) + w ^ { \prime } ( \mathbf { x } , t ) , \quad \mathrm { w h e r e } \ \bar { w } ( \mathbf { x } , t ) = \frac { 1 } { T } \int _ { t - T } ^ { t } G ( s ) w ( \mathbf { x } , s ) d s
59
+ $$
60
+
61
+ Large Eddy Simulation (LES) is an alternative approach based on low-pass filtering of the Navier-Stokes equations that solves a part of the multi-scale turbulent flow corresponding to the most energetic scales. In LES, the large scales are a spatially filtered variable $\tilde { w }$ , which is usually expressed as a convolution product by the filter kernel $G$ . The kernel $G$ is often taken to be a Gaussian kernel. $\Omega _ { i }$ is a subdomain of the solution and depends on the filter size (Sagaut, 2001).
62
+
63
+ $$
64
+ w ( \boldsymbol { x } , t ) = \tilde { w } ( \boldsymbol { x } , t ) + w ^ { \prime } ( \boldsymbol { x } , t ) , \quad \mathrm { w h e r e } \ \tilde { w } ( \boldsymbol { x } , t ) = \int _ { \Omega _ { i } } G ( \boldsymbol { x } | \boldsymbol { \xi } ) w ( \boldsymbol { \xi } , t ) d \boldsymbol { \xi }
65
+ $$
66
+
67
+ The key difference between RANS and LES is that RANS is based on time averaging, leading to simpler steady equations, whereas LES is based on a spatial filtering process which is more accurate but also computationally more expensive.
68
+
69
+ Hybrid RANS-LES Coupling combines both RANS and LES approaches in order to be able to take advantage of both methods (E. Labourasse, 2004; Chaoua, 2017). It decomposes the flow variables into three parts: mean flow, resolved fluctuations and unresolved (subgrid) fluctuations. RANS-LES coupling applies the spatial filtering operator $G _ { 1 }$ and the temporal average operator $G _ { 2 }$ sequentially. We can define $\bar { \mathbf { \Gamma } } _ { \bar { \mathbf { w } } }$ in discrete form with using $\ b { w } ^ { * }$ as an intermediate term,
70
+
71
+ $$
72
+ \begin{array} { l } { { \displaystyle w ^ { * } ( x , t ) = G _ { 1 } ( w ) = \sum _ { \xi } G _ { 1 } ( x | \xi ) w ( \xi , t ) } } \\ { { \displaystyle } } \\ { { \displaystyle \bar { w } ( x , t ) = G _ { 2 } ( w ^ { * } ) = \frac { 1 } { T } \sum _ { s = t - T } ^ { t } G _ { 2 } ( s ) w ^ { * } ( x , s ) } } \end{array}
73
+ $$
74
+
75
+ ![](images/22fd2005ab7d1a6e9fea30e714f34d338c736ed1c5dab1b73dbc4a4eb96b7a8c.jpg)
76
+ Figure 3: Three level spectral decomposition of velocity $\pmb { w }$ , $E ( k )$ is the energy spectrum and $k$ is wavenumber.
77
+
78
+ then $\tilde { w }$ can be defined as the difference between $\ b { w } ^ { * }$ and $\bar { \pmb w }$ :
79
+
80
+ $$
81
+ \tilde { \pmb { w } } = \pmb { w } ^ { * } - \pmb { \bar { w } } , \qquad \pmb { w } ^ { \prime } = \pmb { w } - \pmb { w } ^ { * }
82
+ $$
83
+
84
+ Finally we can have the three-level decomposition of the velocity field.
85
+
86
+ $$
87
+ \pmb { w } = \pmb { \bar { w } } + \pmb { \tilde { w } } + \pmb { w } ^ { \prime }
88
+ $$
89
+
90
+ Figure 3 shows this three-level decomposition in wavenumber space (E. Labourasse, 2004). $k$ is the wavenumber, the spatial frequency in the Fourier domain. $E ( k )$ is the energy spectrum describing how much kinetic energy is contained in eddies with wavenumber $k$ . Small $k$ corresponds to large eddies that contain most of the energy. The slope of the spectrum is negative and indicates the transfer of energy from large scales of motion to the small scales. This hybrid approach combines the ease and computational efficiency of RANS with the resolving power of LES to provide a technique that is less expensive and more tractable than pure LES.
91
+
92
+ Turbulent Flow Net We describe TF-Net, a hybrid deep learning framework based on the multilevel spectral decomposition of hybrid RANS-LES Coupling method. We decompose the velocity field into three components of different scales using two scale separation operators, the spatial filter $G _ { 1 }$ and the temporal filter $G _ { 2 }$ . In traditional CFD, these filters are usually pre-defined, such as the Gaussian spatial filter. In our model, both filters are trainable neural networks. The spatial filtering process is realized by applying one convolutional layer with a single $5 \times 5$ filter to each input image. The temporal filter is implemented as a convolutional layer with a single $1 \times 1$ filter applied to every $T$ images. The motivation for this design is to explicitly guide the DL model to learn the non-linear dynamics of both large and small eddies as relevant to the task of spatio-temporal prediction.
93
+
94
+ We design three identical encoders to encode the three scale components separately. We use a shared decoder to learn the interactions among these three components and generate the final prediction. Each encoder and the decoder can be viewed as a U-net without duplicate layers and middle layer in the original architecture (Olaf Ronneberger, 2015). The encoder consists of four convolutional layers with double the number of feature channels of the previous layer and stride 2 for down-sampling. The decoder consists of one output layer and four deconvolutional layers with summation of the corresponding feature channels from the three encoders and the output of the previous layer as input. Figure 2 shows the overall architecture of our hybrid model TF-Net. To generate multiple timestep forecasts, we perform one-step ahead prediction and roll out autoregressively. Furthermore, since the turbulent flow under investigation has zero divergence ( $\nabla \cdot \pmb { w }$ should be zero everywhere), we include $| | \nabla \cdot \boldsymbol { w } | | ^ { 2 }$ as a regularizer to constrain the predictions, leading to Con TF-Net.
95
+
96
+ # 4 RELATED WORK
97
+
98
+ Turbulence Modeling Recently, machine learning models, especially DL models have been used to accelerate and improve the simulation of turbulent flows. For example, Ling et al. (2016); Fang et al. (2018) studied tensor invariant neural networks to learn the Reynolds stress tensor while preserving Galilean invariance, but Galilean invariance only applies to flows without external forces. In our case, RBC flow has gravity as an external force. Most recently, Kim & Lee (2019) studied unsupervised generative modeling of turbulent flows but the model is not able to make real time future predictions given the historic data. Raissi et al. (2017) applied a Galerkin finite element method with deep neural networks to solve PDEs automatically, what they call “Physics-informed deep learning”. Though these methods have shown the ability of deep learning in solving PDEs directly and deriving generalizable solutions, the key limitation of these approaches is that they require explicitly inputs of boundary conditions during inference, which are generally not available in realtime. Arvind Mohan (2019) proposed a purely data-driven DL model for turbulence, compressed convolutional LSTM, but the model lacks physical constraints and interpretability. Wu et al. (2019) and Tom Beucler (2019) introduced statistical and physical constraints in the loss function to regularize the predictions of the model. However, their studies only focused on spatial modeling without temporal dynamics, besides regularization being ad-hoc and difficult to tune the hyper-parameters.
99
+
100
+ Fluid Animation In parallel, the computer graphics community has also investigated using deep learning to speed up numerical simulations for generating realistic animations of fluids such as water and smoke. For example, Tompson et al. (2017) used an incompressible Euler’s equation with a customized Convolutional Neural Network (CNN) to predict velocity update within a finite difference method solver. Chu & Thuerey (2017) propose double CNN networks to synthesize high-resolution flow simulation based on reusable space-time regions. Xie et al. (2018) and Jonathan Tompson (2017) developed deep learning models in the context of fluid flow animation, where physical consistency is less critical. Steffen Wiewel (2019) proposed a method for the data-driven inference of temporal evolutions of physical functions with deep learning. However, fluid animation emphases on the realism of the simulation rather than the physical consistency of the predictions or physics metrics and diagnostics of relevance to scientists.
101
+
102
+ Video Prediction Our work is also related to future video prediction. Conditioning on the observed frames, video prediction models are trained to predict future frames, e.g., Mathieu et al. (2015); Finn et al. (2016); Xue et al. (2016); Villegas et al. (2017); Chelsea Finn (2016). Many of these models are trained on natural videos with complex noisy data from unknown physical processes. Therefore, it is difficult to explicitly incorporate physical principles into the model. The turbulent flow problem studied in this work is substantially different from natural video prediction because it does not attempt to predict object or camera motions. Instead, our approach aims to emulate numerical simulations given noiseless observations from known governing equations. Hence, some of these techniques are perhaps under-suited for our application.
103
+
104
+ # 5 EXPERIMENTS
105
+
106
+ # 5.1 DATASET
107
+
108
+ The dataset for our experiments comes from two dimensional turbulent flow simulated using the Lattice Boltzmann Method (Chirila, 2018). We use only the velocity vector fields, where the spatial resolution of each image is $1 7 9 2 \mathrm { ~ x ~ } 2 5 6$ . Each image has two channels, one is the turbulent flow velocity along $x$ direction and the other one is the velocity along $y$ direction. The physics parameters relevant to this numerical simulation are: Prandtl number $= 0 . 7 1$ , Rayleigh number $= 2 . { \bar { 5 } } \times 1 0 ^ { 8 }$ and the maximum Mach number $= 0 . 1$ . We use 1500 images (snapshots in time) for our experiments. The task is to predict the spatiotemporal velocity fields up to 60 steps ahead given 10 initial frames.
109
+
110
+ We divided each 1792 by 256 image into 7 square sub-regions of size $2 5 6 \times 2 5 6$ , then downsample them into $6 4 \times 6 4$ pixels sized images. We use a sliding window approach to generate 9,870 samples of sequences of velocity fields: 6,000 training samples, 1,700 validation samples and 2,170 test samples. The DL model is trained using back-propagation through prediction errors accumulated over multiple steps. We use a validation set for hyper-parameters tuning based on the average error of predictions up to six steps ahead. The hyper-parameters tuning range can be found in Table 2 in the appendix. All results are averaged over three runs.
111
+
112
+ # 5.2 BASELINE
113
+
114
+ We compare our model with a series of state-of-the-art baselines for turbulent flow prediction.
115
+
116
+ • ResNet (Kaiming He, 2015): a 34-layer Residual Network by replacing the final dense layer with a convolutional layer with two output channels. ConvLSTM (Xingjian Shi, 2015): a 3-layer Convolutional LSTM model used for spatiotemporal precipitation nowcasting.
117
+ • U-Net (Olaf Ronneberger, 2015): Convolutional neural networks originally developed for image segmentation, also used for video prediction.
118
+ • GAN: U-net trained with a discriminator like the Generative Neural Networks.
119
+ • SST (Emmanuel de Bezenac, 2018): hybrid deep learning model using warping scheme for linear energy equation to predict sea surface temperature, which is also applicable to the linearized momentum equation that governs the velocity fields. DHPM (Raissi, 2018): Deep Hidden Physics Model is to directly approximate the solution of partial differential equations with fully connected networks using space and time as inputs. The model is trained twice on the training set and the test set with boundary conditions.
120
+
121
+ Here ResNet, ConvLSTM, U-net and GAN are pure data-driven spatiotemporal deep learning models for video predictions. SST and DHPM are hybrid techniques that aim to incorporate prior physical knowledge into deep learning for fluid simulation.
122
+
123
+ # 5.3 EVALUATION METRICS
124
+
125
+ Even though Root Mean Square Error (RMSE) is a widely accepted metric for quantifying the differences between model predictions and the ground truth, it is still insufficient to apply the predicted turbulent flows with good RMSE to scientific fields. We need to check whether the predictions are physically meaningful and preserve desired physical quantities, such as Turbulence Kinetic Energy, Divergence and Energy Spectrum. Therefore, we include a set of additional metrics for evaluation.
126
+
127
+ Root Mean Square Error We calculate the RMSE of all predicted values from the ground truth for each pixel, $\sqrt { \sum _ { i = 1 } ^ { N } ( \hat { w } _ { i } - w _ { i } ) ^ { 2 } / N }$ .
128
+
129
+ Divergence Since we investigate incompressible turbulent flows in this work, which means the divergence, $\nabla \cdot \mathbf { w }$ , at each pixel should be zero, we use the average of absolute divergence over all pixels at each prediction step as an additional evaluation metric.
130
+
131
+ Turbulence Kinetic Energy In fluid dynamics, turbulence kinetic energy is the mean kinetic energy per unit mass associated with eddies in turbulent flow. Physically, the turbulence kinetic energy is characterised by measured root mean square velocity fluctuations, $( \overline { { ( u ^ { ' } ) ^ { 2 } } } + \overline { { ( v ^ { ' } ) ^ { 2 } } } ) / 2$ , where $\overline { { ( u ^ { \prime } ) ^ { 2 } } } =$ $\begin{array} { r } { \frac { 1 } { T } \sum _ { t = 0 } ^ { T } ( u ( t ) - \bar { u } ) ^ { 2 } } \end{array}$ and $t$ is the time step. We calculate the turbulence kinetic energy for each predicted sample of 60 velocity fields.
132
+
133
+ Energy Spectrum The energy spectrum of turbulence, $E ( k )$ , is related to the mean turbulence kinetic energy as $\begin{array} { r } { \int _ { 0 } ^ { \infty } E ( k ) d k = ( \overline { { ( u ^ { ' } ) ^ { 2 } } } + \overline { { ( v ^ { ' } ) ^ { 2 } } } ) / 2 } \end{array}$ . $k$ is the wavenumber, the spatial frequency in 2D Fourier domain. We calculate the Energy Spectrum on the Fourier transformation of the Turbulence Kinetic Energy fields. The large eddies have low wavenumbers and the small eddies correspond to high wavenumbers. The spectrum tells how much kinetic energy is contained in eddies with wavenumber $k$ .
134
+
135
+ # 6 RESULTS
136
+
137
+ Figure 4 shows the growth of RMSE with prediction horizon up to 60 time steps ahead. TF-Net consistently outperforms all baselines, and constraining it with divergence free regularizer can further improve the performance. We also found DHPM is able to overfit the training set but performs poorly when tested outside of the training domain. Neither Dropout nor regularization techniques can improve its performance. Also, the warping scheme of the Emmanuel de Bezenac (2018) relies on the simplified linear assumption, which was too limiting for our non-linear problem.
138
+
139
+ ![](images/745b50dd517594578d14941a42da8f3d2262488151ed0b96fda8b22c370a336b.jpg)
140
+
141
+ ![](images/6004eb3db4284d0117e3e43ad8c661dbec0978ca806171fc9e6aefe55ddbd521.jpg)
142
+
143
+ ![](images/feb536fdafee5795da1342ac80bd2681b7d3c0c4257e1466307ba9bec3964a44.jpg)
144
+ Figure 4: Root mean square errors of different models’ predictions at varying forecasting horizon
145
+ Figure 5: Mean absolute divergence of different models’ predictions at varying forecasting horizon
146
+ Figure 6: Turbulence kinetic energy of all models’ predictions at the leftmost square field in the original rectangular field with respect to the target.
147
+
148
+ Figure 5 shows the averages of absolute divergence over all pixels at each prediction step. TF-Net has lower divergence than other models even without additional divergence free constraint for varying prediction step. It is worth mentioning that there is a subtle trade-off between RMSE and divergence. Even though explicitly constraining model with the divergence-free regularizer can reduce the divergence of the model predictions, it also has the side effect of smoothing out the small scale eddies, which results in a larger RMSE.
149
+
150
+ Figure 6 displays the turbulence kinetic energy fields of all models’ predictions at the leftmost square field in the original rectangular field. Figure 7 shows the energy spectrum of our model and two best baseline at the leftmost square sub-field. We also convert square predicted images back to the big rectangular ones and calculate the Energy Spectrum on the entire domain, which can be found in Figure 10 in the appendix. While the turbulence kinetic energy of TF-Net, U-net and ResNet appear to be similar in Figure 6, however, from the energy spectrum in Figure 7 and Figure 10, we can see that TF-Net predictions are in fact much closer to the target. Extra divergence free constraint does not affect the energy spectrum of predictions. Thus, unlike other models, TF-Net is able to generate predictions that are physically consistent with the ground truth.
151
+
152
+ ![](images/8d293ee45befbc219153b4c5ffeacc575a284b4bf0a541403a879da2db5f5d4f.jpg)
153
+ Figure 7: The Energy Spectrum of TF-Net, U-net and ResNet on the leftmost square sub-region.
154
+
155
+ Figure 8 shows the ground truth and the predicted $u$ velocity fields from all models from time step 0 to 60. We also provide videos of predictions by TF-Net and several best baselines in https://www.youtube.com/watch?v $=$ sLuVGIuEE9A and https://www.youtube. com/watch?v $=$ VMeYHID5LL8, respectively. We see that the predictions by our TF-Net model are the closest to the target based on the shape and the frequency of the motions. GAN is able to generate flows with fine-grained details but physics are not captured in a correct way, which also shows the benefit of developing hybrid models with embedded physics knowledge. U-net is the best performing data-driven video prediction baseline. N. Thuerey (2019) also found the U-net architecture is quite effective in modeling dynamics flows.
156
+
157
+ We also performed an additional ablation study of TF-net to understand each component of TFnet investigate whether the TF-net has actually learned the flow with different scales. The video, https://www.youtube.com/watch?v $=$ ysdrMUfdhe0, includes the predictions of TFnet, and the outputs of each small U-net while the other two encoders are zeroed out. We can see that the outputs of each small u-net are the flow with different scales. During Inference, we applied the trained TF-net to the entire input domain instead of square sub-regions. We observed that the boundaries between square sub-regions in the previous videos have disappeared. We also did the same experiments on an additional dataset (Rayleigh number $= 1 0 ^ { 5 }$ ). TF-Net still consistently outperforms the best two baselines, U-net and ResNet, based on all four evaluation metrics. The results are shown in in Figure 12 in the appendix.
158
+
159
+ ![](images/df23418184c6bc5790b15d2b54059eca64fad3865d468c3f66df23919d6716e7.jpg)
160
+ Figure 8: Ground truth and predicted $u$ velocities by all models. From left to right, constrained TF-Net, TF-Net and all the baselines. From top to bottom, predictions from time $T + 1$ to $T + 6 0$ (suppose $T$ is the time step of the last input frame).
161
+
162
+ # 7 DISCUSSION AND FUTURE WORK
163
+
164
+ We have presented a novel hybrid deep learning model, TF-Net, that unifies representation learning and turbulence simulation techniques. TF-Net exploits the multi-scale behavior of turbulent flows to design trainable scale-separation operators to model different ranges of scales individually. We provide exhaustive comparisons of TF-Net and baselines and observe significant improvement in both the prediction error and desired physical quantifies, including divergence, turbulence kinetic energy and energy spectrum. We argue that different evaluation metrics are necessary to evaluate a DL model’s prediction performance for physical systems that include both accuracy and physical consistency. A key contribution of this work is the skillful combination of state-of-the-art turbulent flow simulation paradigms with deep learning. Future work includes extending these techniques to very high-resolution predictions, 3D turbulent flows and incorporating additional physical variables to improve the accuracy and faithfulness of physically-informed deep learning models.
165
+
166
+ # REFERENCES
167
+
168
+ Michael Chertkov Daniel Livescu Arvind Mohan, Don Daniel. Compressed convolutional lstm: An efficient deep learning framework to model high fidelity 3d turbulence. arXiv:1903.00033, 2019.
169
+
170
+ Bruno Chaoua. The state of the art of hybrid rans/les modeling for the simulation of turbulent flows. 99:279–327, 2017. doi: https://doi.org/10.1007/s10494-017-9828-8.
171
+
172
+ Sergey Levine Chelsea Finn, Ian Goodfellow. Unsupervised learning for physical interaction through video prediction. arXiv:1605.07157v4, 2016.
173
+
174
+ D. B. Chirila. Towards lattice boltzmann models for climate sciences: The gelb programming language with application. 2018.
175
+
176
+ Mengyu Chu and Nils Thuerey. Data-driven synthesis of smoke flows with cnn-based feature descriptors. ACM Transactions on Graphics (TOG), 36(4):69, 2017.
177
+
178
+ P. Sagaut E. Labourasse. Advance in rans-les coupling, a review and an insight on the nlde approach. Archives of Computational Methods in Engineering, 11:199–256, 2004.
179
+
180
+ Patrick Gallinari Emmanuel de Bezenac, Arthur Pajot. Deep learning for physical processes: Incorporating prior scientific knowledge. arXiv:1505.04597, 2018.
181
+
182
+ Rui Fang, David Sondak, Pavlos Protopapas, and Sauro Succi. Deep learning for turbulent channel flow. arXiv preprint arXiv:1812.02241, 2018.
183
+
184
+ Chelsea Finn, Ian Goodfellow, and Sergey Levine. Unsupervised learning for physical interaction through video prediction. In Advances in neural information processing systems, pp. 64–72, 2016.
185
+
186
+ Pablo Sprechmann Ken Perlin Jonathan Tompson, Kristofer Schlachter. Accelerating eulerian fluid simulation with convolutional networks. In ICML’17 Proceedings of the 34th International Conference on Machine Learning, volume 70, pp. 3424–3433, 2017.
187
+
188
+ Shaoqing Ren Jian Sun Kaiming He, Xiangyu Zhang. Deep residual learning for image recognition. arXiv:1505.04597, 2015.
189
+
190
+ Junhyuk Kim and Changhoon Lee. Deep unsupervised learning of turbulence for inflow generation at various reynolds numbers. arXiv:1908.10515, 2019.
191
+
192
+ Julia Ling, Andrew Kurzawski, and Jeremy Templeton. Reynolds averaged turbulence modeling using deep neural networks with embedded invariance. Journal of Fluid Mechanics, 807:155– 166, 2016.
193
+
194
+ Michael Mathieu, Camille Couprie, and Yann LeCun. Deep multi-scale video prediction beyond mean square error. arXiv preprint arXiv:1511.05440, 2015.
195
+
196
+ George E Karniadakis Maziar Raissi, Paris Perdikaris. Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational Physics, 378:686–707, 2019.
197
+
198
+ George Em Karniadakis Maziar Raissi. Hidden physics models: Machine learning of nonlinear partial differential equations. Journal of Computational Physics, 357:125–141, 2018.
199
+
200
+ J. M. McDonough. Introductory Lectures on Turbulence. Mechanical Engineering Textbook Gallery, 2007a. URL https://uknowledge.uky.edu/me_textbooks/2.
201
+
202
+ James M McDonough. Introductory lectures on turbulence: physics, mathematics and modeling. 2007b.
203
+
204
+ L. Prantl Xiangyu Hu N. Thuerey, K. Weibenow. Deep learning methods for reynolds-averaged navier-stokes simulations of airfoil flows. arXiv:1810.08217, 2019.
205
+
206
+ Thomas Brox Olaf Ronneberger, Philipp Fischer. U-net: Convolutional networks for biomedical image segmentation. arXiv:1512.03385, 2015.
207
+
208
+ Marc Terracol Pierre Sagaut, Sebastien Deck. Multiscale and Multiresolution Approaches in Turbulence. Imperial College Press, 2006.
209
+
210
+ Maziar Raissi. Deep hidden physics models: Deep learning of nonlinear partial differential equations. Journal of Machine Learning Research, 2018.
211
+
212
+ Maziar Raissi, Paris Perdikaris, and George Em Karniadakis. Physics informed deep learning (part i): Data-driven solutions of nonlinear partial differential equations. arXiv preprint arXiv:1711.10561, 2017.
213
+
214
+ Markus Reichstein, Gustau Camps-Valls, Bjorn Stevens, Martin Jung, Joachim Denzler, Nuno Carvalhais, and Prabhat. Deep learning and process understanding for data-driven earth system science. Nature, 566(7743):195–204, 2019. doi: 10.1038/s41586-019-0912-1. URL https://doi.org/10.1038/s41586-019-0912-1.
215
+
216
+ Pierre Sagaut. Large Eddy Simulation for Incompressible Flows. Springer-Verlag Berlin Heidelberg, 2001. doi: 10.1007/978-3-662-04416-2.
217
+
218
+ Nils Thuerey Steffen Wiewel, Moritz Becher. Latent-space physics: Towards learning the temporal evolution of fluid flow. Computer Graphics Forum, 38, 2019.
219
+
220
+ Petros Koumoutsakos Steven Brunton, Bernd Noack. Machine learning for fluid mechanics. arXiv:1905.11075, 2019.
221
+
222
+ Stephan Rasp Pierre Gentine Jordan Ott-Pierre Baldi Tom Beucler, Michael Pritchard. Enforcing analytic constraints in neural-networks emulating physical systems. arXiv:1909.00912v2, 2019.
223
+
224
+ Jonathan Tompson, Kristofer Schlachter, Pablo Sprechmann, and Ken Perlin. Accelerating eulerian fluid simulation with convolutional networks. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 3424–3433. JMLR. org, 2017.
225
+
226
+ Ruben Villegas, Jimei Yang, Seunghoon Hong, Xunyu Lin, and Honglak Lee. Decomposing motion and content for natural video sequence prediction. arXiv:1706.08033, 2017.
227
+
228
+ Jin-Long Wu, Karthik Kashinath, Adrian Albert, Dragos Chirila, Prabhat, and Heng Xiao. Enforcing Statistical Constraints in Generative Adversarial Networks for Modeling Chaotic Dynamical Systems. arXiv e-prints, May 2019.
229
+
230
+ You Xie, Erik Franz, Mengyu Chu, and Nils Thuerey. tempogan: A temporally coherent, volumetric gan for super-resolution fluid flow. ACM Transactions on Graphics (TOG), 37(4):95, 2018.
231
+
232
+ Hao Wang Dit-Yan Yeung Wai-kin Wong Wang-chun Woo Xingjian Shi, Zhourong Chen. Convolutional lstm network: A machine learning approach for precipitation nowcasting. arXiv:1506.04214, 2015.
233
+
234
+ Tianfan Xue, Jiajun Wu, Katherine Bouman, and Bill Freeman. Visual dynamics: Probabilistic future frame synthesis via cross convolutional networks. In Advances in neural information processing systems, pp. 91–99, 2016.
235
+
236
+ # A APPENDIX
237
+
238
+ # A.1 ADDITIONAL RESULTS
239
+
240
+ Table 1 displays the number of parameters, the best number of input frames, the best number of accumulated errors for backpropogation and training time for one epoch on 8 v-100 GPUs for each model. We can conclude that our model has significantly smaller number of parameters than most baselines yet achieves the best performance. About 25 historic images are enough for deep learning models to generate reasonable predictions, and ConvLSTM require large memory and training time, especially when the number of historic input frames is large. Additionally, Table 2 displays the hyper-parameters tuning range of models.
241
+
242
+ <table><tr><td rowspan=1 colspan=1>Models</td><td rowspan=1 colspan=1>TF-net</td><td rowspan=1 colspan=1>U_net</td><td rowspan=1 colspan=1>GAN</td><td rowspan=1 colspan=1>ResNet</td><td rowspan=1 colspan=1>ConvLSTM</td><td rowspan=1 colspan=1>SST</td><td rowspan=1 colspan=1>DHPM</td></tr><tr><td rowspan=1 colspan=1>#params(10^6)</td><td rowspan=1 colspan=1>15.9</td><td rowspan=1 colspan=1>25.0</td><td rowspan=1 colspan=1>26.1</td><td rowspan=1 colspan=1>21.2</td><td rowspan=1 colspan=1>11.8</td><td rowspan=1 colspan=1>49.9</td><td rowspan=1 colspan=1>2.12</td></tr><tr><td rowspan=1 colspan=1>input length</td><td rowspan=1 colspan=1>25</td><td rowspan=1 colspan=1>25</td><td rowspan=1 colspan=1>24</td><td rowspan=1 colspan=1>26</td><td rowspan=1 colspan=1>27</td><td rowspan=1 colspan=1>23</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=1 colspan=1>#accumulated errors</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=1 colspan=1>time for one epoch(min)</td><td rowspan=1 colspan=1>0.39</td><td rowspan=1 colspan=1>0.57</td><td rowspan=1 colspan=1>0.73</td><td rowspan=1 colspan=1>1.68</td><td rowspan=1 colspan=1>45.6</td><td rowspan=1 colspan=1>0.95</td><td rowspan=1 colspan=1>4.591</td></tr></table>
243
+
244
+ Table 1: The number of parameters, the best number of input frames, the best number of accumulated errors for backpropogation and training time for one epoch on 8 v-100 GPUs for each model.
245
+
246
+ Table 2: Hyper-parameters tuning ranges
247
+
248
+ <table><tr><td colspan="8">Hyper-parameters Tuning Range</td></tr><tr><td>Learning rate</td><td>Batch Size</td><td>#Accumulated errors for backpropogation</td><td>#Input frames</td><td>Movingaverage window size (TF-net)</td><td>Size of the spatial filter (TF-net)</td><td>#Layers (ConvLSTM)</td><td>Hidden Dimension (ConvLSTM)</td></tr><tr><td>le-1~le-6</td><td>16~128</td><td>1~10</td><td>1~30</td><td>2~10</td><td>3~9</td><td>1~5</td><td>32~512</td></tr></table>
249
+
250
+ Figure 9 shows the ground truth and the predicted $v$ velocity fields over 60 time steps. Similar to the $u$ velocity predictions, we observe that the predictions from $\mathrm { T } \mathrm { E } - \mathrm { N e t }$ are the closest to the target. ${ \mathrm { U } } - { \mathrm { n e t } }$ and GAN generate smooth predictions and miss the details of small scale motion. There is still room for improvement in long-term prediction for all the models.
251
+
252
+ We converted square predicted images back to the big rectangular ones and calculated the Energy Spectrum on the entire domain, as shown in Figure 10. we can see that TF-Net predictions are in fact much closer to the target on small wavenumbers and more stable on large wavenumbers.
253
+
254
+ We visualized the learned filters in Figure 11. We only found two types of spatial and temporal filters from all trained TF-Net models, with and without the divergence regularizer. The meaning of these learned filters are yet to be explored.
255
+
256
+ We also performed the same experiments on an additional dataset (Rayleigh number $= 1 0 ^ { 5 }$ ). TF-Net still consistently outperforms the best two baselines, U-net and ResNet, based on all four evaluation metrics. The results are shown in Figure 12.
257
+
258
+ # A.2 IMPLEMENTATION DETAILS
259
+
260
+ We adapt $S S T$ Emmanuel de Bezenac (2018) to model non-linear turbulent flow. $\mathrm { S } \mathrm { S T }$ successfully infused a deep learning model into the solution of the linear energy equation to predict sea surface temperature. If we make the assumption that the advection term $( { \bf w } \cdot \nabla ) u$ in the momentum equation is a linear term $( { \bf { c } } \cdot \nabla ) u$ , where c is unknown, then we can use two separate models to predict $u$ and $v$ , and the inputs of both parts are the same stacked $u$ and $v$ from previous time steps.
261
+
262
+ For DHPM (Raissi, 2018), we approximate both the velocity field two 6-layer neural networks with 512 neurons per hidden layer and use and a 4-layer neural networks with 512 neurons per hidden layer to represent pressure $p$ and an non-homogeneous term $f$ that encapsulates the influence of temperature and viscosity. During the training, we make sure the outputs of these neural networks satisfy the continuity and momentum equations. It is worth mentioning that the DHPM model is supposed to be trained twice, first on the training set then on the initial and boundary conditions of the test set. This model can be formulated as below.
263
+
264
+ $$
265
+ L o s s = | | \pmb { w } - \pmb { \hat { w } } | | + | | \nabla \cdot \pmb { \hat { w } } | | + \big | | \pmb { \hat { w } } _ { t } + ( \pmb { \hat { w } } \cdot \nabla ) \pmb { \hat { w } } - \nu \nabla ^ { 2 } \pmb { \hat { w } } - f \big | |
266
+ $$
267
+
268
+ ![](images/ad2aeede055f9a462305942ec37e3b80dc7745335389e972c80a267d2c3885fc.jpg)
269
+ Figure 9: Ground truth and predicted $v$ velocities by models, suppose $T$ is the time step of the last input image.
270
+
271
+ ![](images/36d60e00851b30146bd9c64828d69da7c70deee1f0181829a6eaa510a674eded.jpg)
272
+ Figure 10: Energy Spectrums of all models’ predictions on the entire rectangular domain.
273
+
274
+ ![](images/7e6029ad51a082e9fc1435b8078241282fa24ce48bfaeff391be267632a187fe.jpg)
275
+ Figure 11: Learned spatial and temporal filters in TF-Net
276
+
277
+ ![](images/914ffee4588fed8780f7254c653b0b9d91dca00cbb640a560640deac0d14d7b8.jpg)
278
+ Figure 12: The performances of TF-net, U-net and ResNet on an additional dataset $\mathrm { { R a } = 1 0 0 0 0 }$ . (a): Root mean square errors of different models’ predictions at varying forecasting horizon, (b): Mean absolute divergence of models’ predictions at varying forecasting horizon, (c): The Energy Spectrums on the entire domain, (d): Turbulence kinetic energy fields of three models’ predictions.
md/train/HkpYwMZRb/HkpYwMZRb.md ADDED
The diff for this file is too large to render. See raw diff
 
md/train/OU98jZWS3x_/OU98jZWS3x_.md ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Diffusion Models Beat GANs on Image Synthesis
2
+
3
+ Prafulla Dhariwal⇤ OpenAI prafulla@openai.com
4
+
5
+ Alex Nichol⇤
6
+ OpenAI
7
+ alex@openai.com
8
+
9
+ # Abstract
10
+
11
+ We show that diffusion models can achieve image sample quality superior to the current state-of-the-art generative models. We achieve this on unconditional image synthesis by finding a better architecture through a series of ablations. For conditional image synthesis, we further improve sample quality with classifier guidance: a simple, compute-efficient method for trading off diversity for fidelity using gradients from a classifier. We achieve an FID of 2.97 on ImageNet $1 2 8 \times 1 2 8$ , 4.59 on ImageNet $2 5 6 \times 2 5 6$ , and 7.72 on ImageNet $5 1 2 \times 5 1 2$ , and we match BigGAN-deep even with as few as 25 forward passes per sample, all while maintaining better coverage of the distribution. Finally, we find that classifier guidance combines well with upsampling diffusion models, further improving FID to 3.94 on ImageNet $2 5 6 \times 2 5 6$ and 3.85 on ImageNet $5 1 2 \times 5 1 2$ .
12
+
13
+ # 1 Introduction
14
+
15
+ ![](images/88360c3236154304146ad2cec322e05f63a49acb48c6c1b23c464f964e2fe1f0.jpg)
16
+ Figure 1: Selected samples from our best ImageNet $5 1 2 \times 5 1 2$ model (FID 3.85)
17
+
18
+ Over the past few years, generative models have gained the ability to generate human-like natural language $\mathbf { \widehat { \mathbb { Q } } }$ , high-quality synthetic images [8, 34, 57] and highly diverse human speech and music [70, 17]. These models can be used in a variety of ways, such as generating images from text prompts [78, 56] or learning useful feature representations [18, 10]. While these models are already capable of producing realistic images and sound, there is still much room for improvement beyond the current state-of-the-art, and better generative models could have wide-ranging impacts on graphic design, games, music production, and countless other fields.
19
+
20
+ GANs $\lVert 2 5 \rVert$ currently hold the state-of-the-art on most image generation tasks $\textcircled { 1 8 } \textcircled { 7 4 } \textcircled { 3 4 } \textcircled { 1 }$ as measured by sample quality metrics such as FID $\left[ \left[ 2 9 \right] \right]$ , Inception Score $\pmb { \mathbb { \left| 6 1 \right| } }$ and Precision $\pmb { \Vert 3 8 } \Vert$ . However, some of these metrics do not fully capture diversity, and it has been shown that GANs capture less diversity than state-of-the-art likelihood-based models [57, 49, 48]. Furthermore, GANs are often difficult to train, collapsing without carefully selected hyperparameters and regularizers $\mathbb { B } \mathbb { A } \mathbb { Z } \mathbb { Z }$ . While GANs hold the state-of-the-art, their drawbacks make them difficult to scale and apply to new domains. As a result, much work has been done to achieve GAN-like sample quality with likelihood-based models $\mathbb { \left[ \left[ 2 2 \right] \right. }$ 57, 31, 48, 12]. While these models capture more diversity and are typically easier to scale and train than GANs, they still fall short in terms of visual fidelity. Furthermore, except for VAEs, sampling from these models is slower than GANs in terms of wall-clock time.
21
+
22
+ Diffusion models are a class of likelihood-based models which have recently been shown to produce high-quality images $\pmb { \mathbb { B } } 3 \pmb { \mathbb { B } } 6 2 \pmb { \mathbb { B } } \pmb { \mathbb { B } } \pmb { \mathbb { B } }$ while offering desirable properties such as distribution coverage, a stationary training objective, and easy scalability. These models generate samples by gradually removing noise from a signal, and their training objective can be expressed as a reweighted variational lower-bound $\textcircled { \scriptsize { 1 3 1 } }$ . This class of models already holds the state-of-the-art $ { \mathbb { I } } { \mathbb { I } }$ on CIFAR-10 [37], but still lags behind GANs on difficult generation datasets like LSUN and ImageNet. We hypothesize that this gap exists for at least two reasons: first, that the model architectures used by recent GAN literature have been heavily explored and refined; second, that GANs are able to trade off diversity for fidelity, producing high quality samples but not covering the whole distribution. We aim to bring these benefits to diffusion models, first by improving model architecture and then by devising a scheme for trading off diversity for fidelity.
23
+
24
+ The rest of the paper is organized as follows. In Section $^ { 2 , }$ we give a brief background of diffusion models based on Ho et al. [31] and the improvements from Nichol and Dhariwal [49] and Song et al. $\pmb { \mathbb { \lVert 6 4 \rVert } }$ , and we describe our evaluation setup. In Section $\textcircled { 3 }$ we introduce simple architecture improvements that give a substantial boost to FID. In Section $\mathbb { E }$ we describe a method for using gradients from a classifier to guide a diffusion model during sampling. Finally, in Section 5 we show that models with our improved architecture achieve state-of-the-art on unconditional image synthesis tasks, and with classifier guidance achieve state-of-the-art on conditional image synthesis.
25
+
26
+ # 2 Background
27
+
28
+ In this section, we provide a brief overview of diffusion models. For a more detailed mathematical description, we refer the reader to Appendix $\boxplus$ On a high level, diffusion models sample from a distribution by reversing a gradual noising process. In particular, sampling starts with noise $x _ { T }$ and produces gradually less-noisy samples $x _ { T - 1 } , x _ { T - 2 } , . . .$ until reaching a final sample $x _ { 0 }$ . In particular, a diffusion model learns to produce a slightly more “denoised” $x _ { t - 1 }$ from $x _ { t }$ . $\mathbb { H o } \operatorname { e t } { \mathrm { a l } } .$ $\overline { { \| 3 \| } }$ parameterize this model using a function $\epsilon _ { \theta } ( x _ { t } , t )$ which predicts the noise component of a noisy sample $x _ { t }$ . To train this function, each sample in a minibatch is produced by randomly drawing a data sample $x _ { 0 }$ , a timestep $t$ , and noise $\epsilon$ , which together give rise to a noised sample $x _ { t }$ (Equation 3, Appendix $\bigtriangledown$ . The training objective is then $| | \epsilon _ { \theta } ( x _ { t } , t ) - \mathbf { \bar { \epsilon } } \epsilon | | ^ { 2 }$ , i.e. a simple mean-squared error loss between the true noise and the predicted noise (Equation 12, Appendix $\bigtriangledown$ .
29
+
30
+ Ho et al. [31] show that, under reasonable assumptions, we can then model the denoising distribution $\overline { { p _ { \theta } ( x _ { t - 1 } | } } x _ { t } )$ of $x _ { t - 1 }$ given $x _ { t }$ as a diagonal Gaussian $\mathcal { N } ( x _ { t - 1 } ; \mu _ { \theta } ( x _ { t } , t ) , \Sigma _ { \theta } ( x _ { t } , t ) )$ , where the mean $\mu _ { \theta } ( x _ { t } , t )$ can be calculated as a function of $\epsilon _ { \theta } ( x _ { t } , t )$ (Equation $^ { 1 3 , }$ Appendix $\underset { . } { \mathbf { C } } )$ Ho et al. [31] observe that the simple mean-squared error objective, $L _ { \mathrm { s i m p l e } }$ , works better in practice than the actual variational lower bound $L _ { \mathrm { v l b } }$ that can be derived from interpreting the denoising diffusion model as a VAE. They also note that training with this objective and using their corresponding sampling procedure is equivalent to the denoising score matching model from $\boxed { \mathrm { S o n g ~ a n d ~ E r m o n } } \boxed { \overline { { 6 5 } } }$ , who use Langevin dynamics to sample from a denoising model trained with multiple noise levels to produce high quality image samples. We often use “diffusion models” as shorthand to refer to both classes of models.
31
+
32
+ Following the breakthrough work of Song and Ermon [65] and Ho et al. [31], several recent papers have proposed improvements to diffusion models. Nichol and Dhariwal [49] find that fixing the variance $\Sigma _ { \theta } ( x _ { t } , t )$ to a constant as done in Ho et al. $\textcircled { \scriptsize { 1 3 1 } }$ is sub-optimal for sampling with fewer diffusion steps, and propose to parameterize $\overline { { \Sigma _ { \theta } ( x _ { t } , } } t )$ as a neural network whose output $v$ is interpolated as $\Sigma _ { \theta } ( x _ { t } , t ) = \exp ( v \log \beta _ { t } + ( 1 - v ) \log \tilde { \beta } _ { t } )$ . Here, $\beta _ { t }$ and $\tilde { \beta } _ { t }$ (Equation ${ \mathfrak { s } } ,$ Appendix $\boxed { \mathbf { C } }$ are the variances in Ho et al. $\pmb { \mathbb { B } } \pmb { \mathbb { 1 } }$ corresponding to upper and lower bounds for the reverse process variances. Additionally, Nichol and Dhariwal $\textcircled { \lVert { 4 9 } \rVert }$ propose a hybrid objective for training both $\epsilon _ { \theta } ( x _ { t } , t )$ and $\Sigma _ { \theta } ( x _ { t } , t )$ using the weighted sum $\overline { { L } } _ { \mathrm { s i m p l e } } + \lambda L _ { \mathrm { v l b } }$ . Learning the reverse process variances with their hybrid objective allows sampling with fewer steps without much drop in sample quality. We adopt this objective and parameterization, and use it throughout our experiments.
33
+
34
+ Song et al. [64] propose DDIM, which formulates an alternative non-Markovian noising process that has the same forward marginals as DDPM, but allows producing different reverse samplers by changing the variance of the reverse noise. By setting this noise to 0, they provide a way to turn any model $\epsilon _ { \theta } ( x _ { t } , t )$ into a deterministic mapping from latents to images, and find that this provides an alternative way to sample with fewer steps. We adopt this sampling approach when using fewer than 50 sampling steps, since Nichol and Dhariwal [49] found it to be beneficial in this regime.
35
+
36
+ Sample Quality Metrics: For comparing sample quality across models, we perform quantitative evaluations using the following metrics. While these metrics are often used in practice and correspond well with human judgement, they are not a perfect proxy, and finding better metrics for sample quality evaluation is still an open problem.
37
+
38
+ We use FID $\mathbb { \left[ \left[ 2 9 \right] \right] }$ as our default metric for overall sample quality comparisons as it captures both fidelity and diversity and has been the de facto standard metric for state-of-the-art generative models [33, 34, 8, 31]. We use Precision and Recall $[ [ 3 8 ] ]$ as proxies for separately measuring fidelity and diversity, respectively. We include sFID $\lVert \rVert \bigotimes \rVert$ as a metric that better captures spatial relationships than FID, and also include Inception Score (IS) $\mathbb { \left[ 6 1 \right] }$ as another proxy for fidelity. When comparing against other methods, we re-compute these metrics using public samples or models whenever possible. This is for two reasons: first, some papers [33, 34, 31] compare against arbitrary subsets of the training set which are not readily available; and second, subtle implementation differences can affect the resulting FID values $\pmb { \mathbb { B } } \mathbf { \mathbb { 1 } }$ . For consistent comparisons, we use the full training set as the reference batch [29, $\textcircled { 8 } ]$ , and evaluate metrics for all models using the same codebase.
39
+
40
+ # 3 Architecture Improvements
41
+
42
+ Ho et al. [31] adopted the UNet architecture $\pmb { \Vert 5 8 \Vert }$ for diffusion models, which Jolicoeur-Martineau et al. [32] found to substantially improve sample quality over the previous architectures [65, 39] used for denoising score matching. The UNet model uses a stack of residual layers and downsampling convolutions, followed by a stack of residual layers with upsampling convolutions, with skip connections connecting the layers with the same spatial size. In addition, they use a global attention layer at the $1 6 \times 1 6$ resolution with a single head, and add a projection of the timestep embedding into each residual block. $\boxed { \mathrm { S o n g ~ e t ~ a l . } } \boxed { \boxed { 6 7 } }$ found that further changes to the UNet architecture improved performance on the CIFAR-10 [37] and CelebA-64 [40] datasets. We show the same result on ImageNet $1 2 8 \times 1 2 8$ , finding that architecture can indeed give a substantial boost to sample quality on a much larger and more diverse datasets at a higher resolution.
43
+
44
+ We explore the following architectural changes: increasing depth versus width, holding model size relatively constant; increasing the number of attention heads; using attention at $3 2 \times 3 2$ , $1 6 \times 1 6$ , and $8 \times 8$ resolutions rather than only at $1 6 \times 1 6$ ; using the BigGAN $\textcircled { 8 } \textcircled { 1 8 }$ residual block for upsampling and downsampling the activations, following $\pmb { \Vert 6 7 \Vert }$ ; and finally; rescaling residual connections with $\scriptstyle { \frac { 1 } { \sqrt { 2 } } }$ , following [67, 33, 34].
45
+
46
+ We train models with the above architecture changes on ImageNet $1 2 8 \times 1 2 8$ and compare them on FID, evaluated at two different points of training, in Table $^ { 1 . }$ Aside from rescaling residual connections, all of the other modifications improve performance and have a positive compounding effect. On wall-clock (Figure $\boxed { 5 }$ Appendix $\bar { \bigstar . 1 \bigstar }$ we find that increased depth hurts training time most, so we opt not to use this change in further experiments. We also study other attention configurations that better match the Transformer architecture $\lVert \ b { 7 2 } \rVert$ . We try two configurations: constant attention heads, or constant channels per head. Table $2$ shows our results, indicating that more heads or fewer channels per head improves FID. On wall-clock (Figure $\boxed { 5 }$ Appendix $\underline { { \mathsf { R . 1 } } } )$ , we see that 64 channels is best so we opt to use 64 channels per head as our default. We note that this choice also better matches modern transformer architectures, and is on par with our other configurations in terms of final FID.
47
+
48
+ Table 1: Ablation of various architecture changes, evaluated at 700K and 1200K iterations
49
+
50
+ <table><tr><td>Channels</td><td>Depth</td><td>Heads</td><td>Attention resolutions</td><td>BigGAN up/downsample</td><td>Rescale resblock</td><td>FID 700K</td><td>FID 1200K</td></tr><tr><td>160</td><td>2</td><td>1</td><td>16</td><td>X</td><td>X</td><td>15.33</td><td>13.21</td></tr><tr><td>128</td><td>4</td><td></td><td></td><td></td><td></td><td>-0.21</td><td>-0.48</td></tr><tr><td></td><td></td><td>4</td><td></td><td></td><td></td><td>-0.54</td><td>-0.82</td></tr><tr><td></td><td></td><td></td><td>32,16,8</td><td></td><td></td><td>-0.72</td><td>-0.66</td></tr><tr><td></td><td></td><td></td><td></td><td>√</td><td></td><td>-1.20</td><td>-1.21</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>0.16</td><td>0.25</td></tr><tr><td>160</td><td>2</td><td>4</td><td>32,16,8</td><td>√</td><td>×</td><td>-3.14</td><td>-3.00</td></tr></table>
51
+
52
+ Table 2: Ablation of attention heads. More heads or lower channels per heads both improve FID. The base model was a smaller version of the best model from Table 1.
53
+
54
+ <table><tr><td>Number of heads</td><td>Channels per head</td><td>FID</td></tr><tr><td>1</td><td></td><td>14.08</td></tr><tr><td>2</td><td></td><td>-0.50</td></tr><tr><td>4</td><td></td><td>-0.97</td></tr><tr><td>8</td><td></td><td>-1.17</td></tr><tr><td></td><td>32</td><td>-1.36</td></tr><tr><td></td><td>64</td><td>-1.03</td></tr><tr><td></td><td>128</td><td>-1.08</td></tr></table>
55
+
56
+ We also experiment with a layer $\boxed { \boxplus 9 }$ that we refer to as adaptive group normalization (AdaGN), which incorporates the timestep and class embedding into each residual block after a group normalization operation $\mathbb { [ [ \mathsf { Z } \mathsf { S } ] ] }$ , similar to adaptive instance norm $\pmb { \Vert 3 3 \Vert }$ and FiLM [54]. We define this layer as $\mathrm { A d a G N } ( h , y ) = y _ { s }$ $\mathrm { G r o u p N o r m } ( h ) + y _ { b }$ , where $h$ is the intermediate activations of the residual block following the first convolution, and $y = [ y _ { s } , y _ { b } ]$ is obtained from a linear projection of the timestep and class embedding. We had already seen AdaGN improve our earliest diffusion models, and so had included it by default in all our runs. We explicitly ablate this choice (Table $\mathbb { E } ,$ , Appendix $\mathbf { A . } 1 )$ , and find that FID becomes worse by 2.02 when we remove the adaptive group normalization layer.
57
+
58
+ In the rest of the paper, we use this final improved model architecture as our default: variable width with 2 residual blocks per resolution, multiple heads with 64 channels per head, attention at 32, 16 and 8 resolutions, BigGAN residual blocks for up and downsampling, and adaptive group normalization for injecting timestep and class embeddings into residual blocks.
59
+
60
+ # 4 Classifier Guidance
61
+
62
+ In addition to employing well designed architectures, GANs for conditional image synthesis [45, 8] make heavy use of class labels. This often takes the form of class-conditional normalization statistics $\mathbb { \ Z O } \mathbb { \perp } \mathbb { \perp } \mathbb { I }$ as well as discriminators with heads explicitly designed to behave like classifiers $p ( y | x )$ [46]. As further evidence that class information is crucial to the success of these models, Lucic et al. [42] find that it is helpful to generate synthetic labels when working in a label-limited regime. Given this observation for GANs, it makes sense to explore different ways to condition diffusion models on class labels. We already incorporate class information into adaptive group normalization layers (Section $3 )$ . Here, we explore a different approach: exploiting a classifier $p ( y | x )$ to improve a diffusion generator. Sohl-Dickstein et al. $\pmb { \mathbb { \left\| 6 3 \right\| } }$ and $\widetilde { \mathbb { S } \mathrm { o n g } \ e t \ a l . } \Vert \widehat { \mathbb { b } \mathrm { 7 } } \Vert$ show one way to achieve this, wherein a pre-trained diffusion model can be conditioned using the gradients of a classifier. In particular, we can train a classifier $p _ { \phi } ( y | x _ { t } , t )$ on noisy images $x _ { t }$ , and then use gradients $\nabla _ { x _ { t } } \log \overset { \cdot } { p _ { \phi } } ( y | x _ { t } , t )$ to guide the diffusion sampling process towards an arbitrary class label $y$ .
63
+
64
+ For class conditional diffusion sampling, we reproduce the derivation from Sohl-Dickstein et al. [63] in Appendix $\mathbb { D . 2 }$ For DDIM, we perform a score-based derivation in Appendix $\overline { { \mathbf { D } . 3 } }$ inspired by Song et al. $[ \overbrace { 6 7 } ]$ . The resulting sampling algorithms we use for guidance are Algorithms $\mathbf { \overline { { \Pi } } }$ and $\dot { \bigtriangledown }$ respectively. Both algorithms incorporate class information by adding the gradients of a classifier to each sampling step with an appropriate step size. In these algorithms, we choose the notation
65
+
66
+ Algorithm 1 Classifier guided diffusion sampling, given a diffusion model $( \mu _ { \theta } ( x _ { t } ) , \Sigma _ { \theta } ( x _ { t } ) )$ , classifier $p _ { \phi } ( y | x _ { t } )$ , and gradient scale $s$ .
67
+
68
+ Input: class label $y$ , gradient scale $s$
69
+ $x _ { T } \gets$ sample from $\mathcal { N } ( 0 , \bf { I } )$
70
+ for all $t$ from $T$ to 1 do $\mu , \Sigma \mu _ { \theta } ( x _ { t } ) , \Sigma _ { \theta } ( x _ { t } )$ $x _ { t - 1 } \gets$ sample from $\overset { \vartriangle } { \mathcal { N } } ( \mu + s \Sigma \nabla _ { x _ { t } } \log p _ { \phi } ( y | x _ { t } ) , \Sigma )$
71
+ end for
72
+ return $x _ { 0 }$
73
+
74
+ Algorithm 2 Classifier guided DDIM sampling, given a diffusion model $\epsilon _ { \theta } ( x _ { t } )$ , classifier $\overline { { p _ { \phi } ( y | x _ { t } ) } }$ and gradient scale $s$ .
75
+
76
+ Input: class label $y$ , gradient scale $s$
77
+ $x _ { T } \gets$ sample from $\bar { \mathcal { N } } ( 0 , \mathbf { I } )$
78
+ for all $t$ from $T$ to 1 do $\begin{array} { r l } & { \hat { \epsilon } \epsilon _ { \theta } ( x _ { t } ) - \sqrt { 1 - \bar { \alpha } _ { t } } \nabla _ { x _ { t } } \log p _ { \phi } ( y \vert x _ { t } ) } \\ & { x _ { t - 1 } \sqrt { \bar { \alpha } _ { t - 1 } } ( \frac { x _ { t } - \sqrt { 1 - \bar { \alpha } _ { t } } \hat { \epsilon } } { \sqrt { \bar { \alpha } _ { t } } } ) + \sqrt { 1 - \bar { \alpha } _ { t - 1 } } \hat { \epsilon } } \end{array}$
79
+ end for
80
+ return $x _ { 0 }$
81
+
82
+ ![](images/17ede98c7663465d7ae64d6b390139ee6801c95c8a9097d5ed812d3bb08e68d8.jpg)
83
+ Figure 2: Samples from an unconditional diffusion model with classifier guidance to condition on the class "Pembroke Welsh corgi". Using classifier scale 1.0 (left; FID: 33.0) does not produce convincing samples in this class, whereas classifier scale 10.0 (right; FID: 12.0) produces much more class-consistent images.
84
+
85
+ $p _ { \phi } ( y | x _ { t } , t ) = p _ { \phi } ( y | x _ { t } )$ and $\epsilon _ { \theta } ( x _ { t } , t ) = \epsilon _ { \theta } ( x _ { t } )$ for brevity, noting that they refer to separate functions for each timestep $t$ and at training time the models must be conditioned on the input $t$ .
86
+
87
+ To apply classifier guidance to a large scale generative task, we train classification models on ImageNet. Our classifier architecture is simply the downsampling trunk of the UNet model with an attention pool $\begin{array} { r l } { \| \boldsymbol { \bar { 5 } } \boldsymbol { \bar { 5 } } \| } & { { } } \end{array}$ at the $8 \mathrm { x } 8$ layer to produce the final output. We train these classifiers on the same noising distribution as the corresponding diffusion model, and also add random crops to reduce overfitting.
88
+
89
+ In initial experiments with unconditional ImageNet models, we found it necessary to scale the classifier gradients by a constant factor larger than 1. When using a scale of 1, we observed that the classifier assigned reasonable probabilities (around $5 0 \%$ ) to the desired classes for the final samples, but these samples did not match the intended classes upon visual inspection. Scaling up the classifier gradients remedied this problem, and the class probabilities from the classifier increased to nearly $100 \%$ . Figure $\bigtriangledown$ shows an example of this effect. To understand the effect of scaling classifier gradients, note that $\begin{array} { r } { s \cdot \nabla _ { x } \log p ( y | x ) \stackrel { \cdot } { = } \nabla _ { x } \log \frac { 1 } { Z } p ( y | x ) ^ { s } } \end{array}$ , where $Z$ is an arbitrary constant. As a result, the conditioning process is still theoretically grounded in a re-normalized classifier distribution proportional to $p ( y | x ) ^ { s }$ . When $s > 1$ , this distribution becomes sharper than $p ( y | x )$ , since larger values are amplified by the exponent. In other words, using a larger gradient scale focuses more on the modes of the classifier, which is potentially desirable for producing higher quality (but less diverse) samples.
90
+
91
+ In the above derivations, we assumed that the underlying diffusion model was unconditional, modeling $p ( x )$ . It is also possible to train conditional diffusion models, $p ( x | y )$ , and use classifier guidance in the exact same way. Table $\textcircled { 3 }$ shows that the sample quality of both unconditional and conditional models can be greatly improved by classifier guidance. We see that, with a high enough scale, the guided unconditional model can get quite close to the FID of an unguided conditional model, although training directly with the class labels still helps. Guiding a conditional model further improves FID.
92
+
93
+ ![](images/b972c296c95e38207891fcbe7c43985a22a9400506330b2ed868ce523a2947d5.jpg)
94
+ Figure 3: Change in sample quality as we vary scale of the classifier gradients for a class-conditional ImageNet $1 2 8 \times 1 2 8$ model.
95
+
96
+ Table $\perp$ also shows that classifier guidance improves precision at the cost of recall, thus introducing a trade-off in sample fidelity versus diversity. We explicitly evaluate how this trade-off varies with the gradient scale in Figure $3 { \dot { . } }$ We see that scaling the gradients beyond 1.0 smoothly trades off recall (a measure of diversity) for higher precision and IS (measures of fidelity). Since FID and sFID depend on both diversity and fidelity, their best values are obtained at an intermediate point. We also compare our guidance with the truncation trick from BigGAN (Figure $\bigtriangledown$ Appendix A.2). We find that classifier guidance is strictly better than BigGAN-deep when trading off FID for Inception Score. Less clear cut is the precision/recall trade-off, which shows that classifier guidance is only a better choice up until a certain precision threshold, after which point it cannot achieve better precision.
97
+
98
+ # 5 Results
99
+
100
+ To evaluate our improved model architecture on unconditional image generation, we train separate diffusion models on three LSUN $\mathbb { \ m }$ classes: bedroom, horse, and cat. To evaluate classifier guidance, we train conditional diffusion models on the ImageNet $\mathbb { \left[ 5 9 \right] }$ dataset at $1 2 8 \times 1 2 8$ , $2 5 6 \times 2 5 6$ , and $5 1 2 \times 5 1 2$ resolution.
101
+
102
+ Table 4 summarizes our results. ADM refers to our ablated diffusion model, and ADM-G additionally uses classifier guidance. Our diffusion models can obtain the best FID on each task, and the best sFID on all but one task. With the improved architecture, we already obtain state-of-the-art image generation on LSUN and ImageNet $6 4 \times 6 4$ . For higher resolution ImageNet, we observe that classifier guidance allows our models to substantially outperform the best GANs. These models obtain perceptual quality similar to GANs, while maintaining a higher coverage of the distribution as measured by recall, and can even do so using only 25 sampling steps. We also evaluate the computational requirements for training our models (Table $^ { 1 0 , }$ Appendix $\underline { { \overline { { \mathbf { B } } } } } )$ , and find that we can obtain competitive sample quality while using the same or less compute than the corresponding BigGAN-deep or StyleGAN2 model.
103
+
104
+ Figure 4 compares random samples from the best BigGAN-deep model to our guided diffusion model. While the samples are of similar perceptual quality, the diffusion model contains more modes than the GAN, such as zoomed ostrich heads, single flamingos, different orientations of cheeseburgers, and a tinca fish with no human holding it. We also check our generated samples for nearest neighbors in the Inception-V3 feature space in Appendix E, and we show additional samples in Appendices M-O.
105
+
106
+ Table 4: Sample quality comparison with state-of-the-art generative models for each task. LSUN diffusion models are sampled using 1000 steps (see Appendix $\mathbf { L } )$ . ImageNet diffusion models are sampled using 250 steps, except when we use the DDIM sampler with 25 steps. \*No BigGAN-deep model was available at this resolution, so we trained our own. †Values are taken from a previous paper, due to lack of public models or samples. ‡Results use two-resolution stacks. §Results use compute-intensive classifier rejection sampling.
107
+
108
+ <table><tr><td>Model</td><td>FID</td><td>sFID</td><td>Prec</td><td>Rec</td></tr><tr><td colspan="5">LSUN Bedrooms 256×256 DCTransformer+ 48</td></tr><tr><td>DDPM [31]</td><td>6.40 4.89</td><td>6.66 9.07</td><td>0.44 0.60</td><td>0.56 0.45</td></tr><tr><td>IDDPM[49]</td><td>4.24</td><td>8.21</td><td>0.62</td><td>0.46</td></tr><tr><td>StyleGAN [33]</td><td>2.35</td><td>6.62</td><td>0.59</td><td>0.48</td></tr><tr><td>ADM (dropout)</td><td>1.90</td><td>5.59</td><td>0.66</td><td>0.51</td></tr><tr><td colspan="5">LSUN Horses 256×256</td></tr><tr><td>StyleGAN2 34 ADM ADM (dropout)</td><td>3.84 2.95</td><td>6.46 5.94</td><td>0.63 0.69</td><td>0.48 0.55</td></tr><tr><td></td><td>2.57</td><td>6.81</td><td>0.71</td><td>0.55</td></tr><tr><td>LSUN Cats 256×256</td><td></td><td></td><td></td><td></td></tr><tr><td colspan="5">DDPM [31]</td></tr><tr><td>StyleGAN2 [34]</td><td>17.1</td><td>12.4</td><td>0.53</td><td>0.48</td></tr><tr><td></td><td>7.25</td><td>6.33</td><td>0.58</td><td>0.43</td></tr><tr><td>ADM (dropout)</td><td>5.57</td><td>6.69</td><td>0.63</td><td>0.52</td></tr><tr><td>ImageNet 64×64</td><td></td><td></td><td></td><td></td></tr><tr><td colspan="5">BigGAN-deep* 回</td></tr><tr><td></td><td>4.06</td><td>3.96</td><td>0.79</td><td>0.48</td></tr><tr><td>IDDPM[ [49]</td><td>2.92</td><td>3.79</td><td>0.74</td><td>0.62</td></tr><tr><td>ADM</td><td>2.61</td><td>3.77</td><td>0.73</td><td>0.63</td></tr><tr><td>ADM (dropout)</td><td>2.07</td><td>4.29</td><td>0.74</td><td>0.63</td></tr></table>
109
+
110
+ <table><tr><td>Model</td><td>FID</td><td>SFID</td><td>Prec</td><td>Rec</td></tr><tr><td>ImageNet 128×128 BigGAN-deep 8</td><td>6.02</td><td>7.18</td><td>0.86</td><td>0.35</td></tr><tr><td>LOGANt 四</td><td>3.36</td><td></td><td></td><td></td></tr><tr><td>ADM</td><td>5.91</td><td>5.09</td><td>0.70</td><td>0.65</td></tr><tr><td>ADM-G (25 steps)</td><td>5.98</td><td>7.04</td><td>0.78</td><td>0.51</td></tr><tr><td>ADM-G</td><td>2.97</td><td>5.09</td><td>0.78</td><td>0.59</td></tr><tr><td>ImageNet 256×256</td><td></td><td></td><td></td><td></td></tr><tr><td>DCTransformer† 8</td><td>36.51</td><td>8.24</td><td></td><td>0.67</td></tr><tr><td>VQ-VAE-2†‡ 回</td><td></td><td></td><td>0.36</td><td></td></tr><tr><td></td><td>31.11</td><td>17.38</td><td>0.36</td><td>0.57</td></tr><tr><td>VQ-VAE-2 (RS)t‡ $ 四</td><td>~10</td><td></td><td></td><td>0.58</td></tr><tr><td>VQ-GAN* 四</td><td>15.97</td><td>19.05</td><td>0.63</td><td>0.48</td></tr><tr><td>VQ-GAN (RS)t$ 四 IDDPM‡ [ 49</td><td>5.06 12.26</td><td>7.34 5.42</td><td>0.79 0.70</td><td>0.62</td></tr><tr><td>SR3tt 四</td><td>11.30</td><td></td><td></td><td></td></tr><tr><td>BigGAN-deep 回</td><td>6.95</td><td>7.36</td><td>0.87</td><td>0.28</td></tr><tr><td>ADM</td><td>10.94</td><td>6.02</td><td>0.69</td><td>0.63</td></tr><tr><td>ADM-G (25 steps)</td><td>5.44</td><td>5.32</td><td>0.81</td><td>0.49</td></tr><tr><td>ADM-G</td><td>4.59</td><td>5.25</td><td>0.82</td><td>0.52</td></tr><tr><td>ImageNet 512×512</td><td></td><td></td><td></td><td></td></tr><tr><td>BigGAN-deep 图</td><td>8.43</td><td>8.13</td><td></td><td>0.29</td></tr><tr><td>ADM</td><td></td><td></td><td>0.88</td><td></td></tr><tr><td></td><td>23.24</td><td>10.19</td><td>0.73</td><td>0.60</td></tr><tr><td>ADM-G (25 steps)</td><td>8.41</td><td>9.67</td><td>0.83</td><td>0.47</td></tr><tr><td>ADM-G</td><td>7.72</td><td>6.57</td><td>0.87</td><td>0.42</td></tr></table>
111
+
112
+ We also compare guidance to using a two-stage upsampling stack. Nichol and Dhariwal [49] and Saharia et al. $\boxed { 6 0 }$ train two-stage diffusion models by combining a low-resolution diffusion model with a corresponding upsampling diffusion model. In this approach, the upsampling model is trained to upsample images from the training set, and conditions on low-resolution images that are concatenated channel-wise to the model input using a simple interpolation (e.g. bilinear). During sampling, the low-resolution model produces a sample, and then the upsampling model is conditioned on this sample. This greatly improves FID on ImageNet $2 5 6 \times 2 5 6$ , but does not reach the same performance as state-of-the-art models like BigGAN-deep [49, 60], as seen in Table 4.
113
+
114
+ In Table $\boxed { 5 }$ we show that guidance and upsampling improve sample quality along different axes. We use the upsampling stack from Nichol and Dhariwal [49] combined with our architecture improvements, which we refer to as ADM-U. While upsampling improves precision while keeping a high recall, guidance provides a knob to trade off diversity for much higher precision. We achieve the best FIDs by using guidance at a lower resolution before upsampling to a higher resolution, indicating that these approaches complement one another.
115
+
116
+ # 6 Related Work
117
+
118
+ Score based generative models were introduced by Song and Ermon [66] as a way of modeling a data distribution using its gradients, and then sampling using Langevin dynamics [73]. Ho et al. [31] found a connection between this method and diffusion models $[ [ 6 3 ] ]$ , and achieved excellent sample quality by leveraging this connection. After this breakthrough work, many works followed up with more promising results: Kong et al. [36] and Chen et al. [11] demonstrated that diffusion models work well for audio; Jolicoeur-Martineau et al. [32] found that a GAN-like setup could improve samples from these models; Song et al. [67] explored ways to leverage techniques from stochastic differential equations to improve the sample quality obtained by score-based models; Song et al. [64] and Nichol and Dhariwal [49] proposed methods to improve sampling speed; Nichol and Dhariwal [49] and Saharia et al. [60] demonstrated promising results on the difficult ImageNet generation task using upsampling diffusion models. Also related to diffusion models, and following the work of Sohl-Dickstein et al. [63], Goyal et al. [27] described a technique for learning a model with learned iterative generation steps, and found that it could achieve good image samples when trained with a likelihood objective.
119
+
120
+ ![](images/d9704a85040ab49727c123479c513cf7b2c243c18519d8a70391578c96ff2109.jpg)
121
+ Figure 4: Samples from BigGAN-deep with truncation 1.0 (FID 6.95, left) vs samples from our diffusion model with guidance (FID 4.59, middle) and samples from the training set (right).
122
+
123
+ Table 5: Comparing our single, upsampling and classifier guided models. The upsamplers are $6 4 2 5 6$ and $1 2 8 \to 5 1 2$ . When combining guidance with upsampling, we only guide the lower resolution model. All models are sampled using 250 sampling steps.
124
+
125
+ <table><tr><td>Model</td><td>FID</td><td>sFID</td><td>IS</td><td>Prec</td><td>Rec</td><td>Model</td><td>FID</td><td>SFID</td><td>IS</td><td>Prec</td><td>Rec</td></tr><tr><td>ImageNet 256×256</td><td></td><td></td><td></td><td></td><td></td><td>ImageNet 512×512</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ADM</td><td>10.94</td><td>6.02</td><td>100.98</td><td>0.69</td><td>0.63</td><td>ADM</td><td>23.24</td><td>10.19</td><td>58.06</td><td>0.73</td><td>0.60</td></tr><tr><td>ADM, ADM-U</td><td>7.49</td><td>5.13</td><td>127.49</td><td>0.72</td><td>0.63</td><td>ADM, ADM-U</td><td>9.96</td><td>5.62</td><td>121.78</td><td>0.75</td><td>0.64</td></tr><tr><td>ADM-G</td><td>4.59</td><td>5.25</td><td>186.70</td><td>0.82</td><td>0.52</td><td>ADM-G</td><td>7.72</td><td>6.57</td><td>172.71</td><td>0.87</td><td>0.42</td></tr><tr><td>ADM-G,ADM-U</td><td>3.94</td><td>6.14</td><td>215.84</td><td>0.83</td><td>0.53</td><td>ADM-G, ADM-U</td><td>3.85</td><td>5.86</td><td>221.72</td><td>0.84</td><td>0.53</td></tr></table>
126
+
127
+ One missing element from previous work on diffusion models is a way to trade off diversity for fidelity. Other generative techniques provide natural levers for this trade-off. Brock et al. [8] introduced the truncation trick for GANs, wherein the latent vector is sampled from a truncated normal distribution. They found that increasing truncation naturally led to a decrease in diversity but an increase in fidelity. More recently, Razavi et al. [57] proposed to use classifier rejection sampling to filter out bad samples from an autoregressive likelihood-based model, and found that this technique improved FID. DeVries et al. [16] found that filtering out low-density regions of the training set improves GAN training performance. Most likelihood-based models also allow for low-temperature sampling [1], which provides a natural way to emphasize modes of the data distribution (see Appendix I).
128
+
129
+ Other likelihood-based models have been shown to produce high-fidelity image samples. VQ-VAE $\pmb { \mathbb { Z } 1 }$ and VQ-VAE-2 $ { \mathbb { B } } 5 7 { \mathbb { I } }$ are autoregressive models trained on top of quantized latent codes, greatly reducing the computational resources required to train these models on large images. These models produce diverse and high quality images, but still fall short of GANs without expensive rejection sampling and special metrics to compensate for blurriness. DCTransformer $[ \overline { { | 4 8 | } }$ is a related method which relies on a more intelligent compression scheme. VAEs are another promising class of likelihood-based models, and recent methods such as NVAE $\textcircled { 1 6 9 } \textcircled { 1 }$ and VDVAE $\bar { \mathbb { E } 2 } \mathbb { I }$ have successfully been applied to difficult image generation domains. Energy-based models are another class of likelihood-based models with a rich history [1, 13, 30]. Sampling from the EBM distribution is challenging, and Xie et al. $\pmb { \mathbb { Z } } \pmb { 6 } \|$ demonstrate that Langevin dynamics can be used to sample coherent images from these models. Du and Mordatch [19] further improve upon this approach, obtaining high quality images. More recently, Gao et al. [24] incorporate diffusion steps into an energy-based model, and find that doing so improves image samples from these models.
130
+
131
+ Other works have controlled generative models with a pre-trained classifier. For example, an emerging body of work [23, 53, 2] aims to optimize GAN latent spaces for text prompts using pre-trained CLIP $\textcircled { \vert 5 5 \vert }$ models. More similar to our work, Song et al. $\pmb { \mathbb { E } } \pmb { \bigtriangledown }$ uses a classifier to generate class-conditional CIFAR-10 images with a diffusion model. In some cases, classifiers can act as stand-alone generative models. For example, Santurkar et al. [62] demonstrate that a robust image classifier can be used as a stand-alone generative model, and Grathwohl et al. [28] train a model which is jointly a classifier and an energy-based model.
132
+
133
+ # 7 Limitations and Future Work
134
+
135
+ While we believe diffusion models are an extremely promising direction for generative modeling, they are still slower than GANs at sampling time due to the use of multiple denoising steps (and therefore forward passes). Since our diffusion models are also larger than the competing GAN generators, each forward pass takes anywhere from 5-20 times longer too. A promising direction to reduce this latency gap is Luhman and Luhman [43], who explore a way to distill the DDIM sampling process into a single step model. The samples from the single step model are not yet competitive with GANs, but are much better than previous single-step likelihood-based models. Future work in this direction might be able to completely close the sampling speed gap between diffusion models and GANs without sacrificing image quality.
136
+
137
+ Unlike GANs, Flows, and VAEs, diffusion models do not learn an explicit latent representation. While DDIM provides a way to encode images into an implicit latent space, it is unclear how semantically meaningful this latent representation is compared to those of other model classes. This could make it difficult to use diffusion models for representation learning or image editing applications.
138
+
139
+ The effectiveness of classifier guidance demonstrates that we can obtain powerful generative models from the gradients of a classification function. This could be used to condition an image generator with a text caption using a noisy version of CLIP $\lVert \boldsymbol { \bar { 5 5 } } \rVert$ , similar to recent methods that guide GANs using text prompts $[ 1 2 3 , 5 3 , 1 2 ]$ . Our proposed classifier guidance technique is currently limited to labeled datasets. In the future, our method could be extended to unlabeled data by clustering samples to produce synthetic labels $[ | \overline { { 4 2 } } | |$ or by training discriminative models to use for guidance. This also suggests that large unlabeled datasets could be leveraged in the future to pre-train powerful diffusion models that can later be improved by using a classifier with desirable properties.
140
+
141
+ # 8 Societal Impact
142
+
143
+ Our proposed technique makes generative models more accessible in terms of compute costs, especially because new classifiers can be trained and used on top of existing high-quality diffusion models. While we believe this is generally a benefit of these models, it could also have negative societal implications. For example, cheaper generative models could enable bad actors to generate fake news, propaganda images, or doctored photos. Additionally, the wide-spread deployment of these models could displace jobs in art, graphic design, animation, and photography. One could imagine, however, that democratizing generative models could also have positive impacts in the long run, creating new types of jobs such as generative photo editing. Intentionally deceitful generated images are a more direct concern, and detecting and mitigating propaganda and fake news based on generative models is an ongoing area of research [4, 3, 5].
144
+
145
+ # 9 Conclusion
146
+
147
+ We have shown that diffusion models, a class of likelihood-based models with a stationary training objective, can obtain better sample quality than state-of-the-art GANs. Our improved architecture is sufficient to achieve this on unconditional image generation tasks, and our classifier guidance technique allows us to do so on class-conditional tasks. In the latter case, we find that the scale of the classifier gradients can be adjusted to trade off diversity for fidelity. These guided diffusion models can reduce the sampling time gap between GANs and diffusion models, although diffusion models still require multiple forward passes during sampling. Finally, by combining guidance with upsampling, we can further improve sample quality on high-resolution conditional image synthesis.
148
+
149
+ # References
150
+
151
+ [1] David Ackley, Geoffrey Hinton, and Terrence Sejnowski. A learning algorithm for boltzmann machines. Cognitive science, 9(1):147-169, 1985.
152
+ [2] Adverb. The big sleep. https://twitter.com/advadnoun/status/ 1351038053033406468, 2021.
153
+ [3] Shruti Agarwal, Hany Farid, Yuming Gu, Mingming He, Koki Nagano, and Hao Li. Protecting world leaders against deep fakes. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, June 2019.
154
+ [4] Hadeer Ahmed, Issa Traore, and Sherif Saad. Detection of online fake news using n-gram analysis and machine learning techniques. pages 127–138, 10 2017. ISBN 978-3-319-69154-1. doi: 10.1007/978-3-319-69155-8_9.
155
+ [5] Hadeer Ahmed, Issa Traore, and Sherif Saad. Detecting opinion spams and fake news using text classification. Security and Privacy, 1(1):e9, 2018. doi: https://doi.org/10.1002/spy2.9. URL https://onlinelibrary.wiley.com/doi/abs/10.1002/spy2.9.
156
+ [6] Shane Barratt and Rishi Sharma. A note on the inception score. arXiv:1801.01973, 2018.
157
+ [7] Andrew Brock, Theodore Lim, J. M. Ritchie, and Nick Weston. Neural photo editing with introspective adversarial networks. arXiv:1609.07093, 2016.
158
+ [8] Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. arXiv:1809.11096, 2018.
159
+ [9] Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. arXiv:2005.14165, 2020.
160
+ [10] Mark Chen, Alec Radford, Rewon Child, Jeffrey Wu, Heewoo Jun, David Luan, and Ilya Sutskever. Generative pretraining from pixels. In International Conference on Machine Learning, pages 1691–1703. PMLR, 2020.
161
+ [11] Nanxin Chen, Yu Zhang, Heiga Zen, Ron J. Weiss, Mohammad Norouzi, and William Chan. Wavegrad: Estimating gradients for waveform generation. arXiv:2009.00713, 2020.
162
+ [12] Rewon Child. Very deep vaes generalize autoregressive models and can outperform them on images. arXiv:2011.10650, 2021.
163
+ [13] Peter Dayan, Geoffrey E Hinton, Radford M Neal, and Richard S Zemel. The helmholtz machine. Neural computation, 7(5):889–904, 1995.
164
+ [14] Harm de Vries, Florian Strub, Jérémie Mary, Hugo Larochelle, Olivier Pietquin, and Aaron Courville. Modulating early visual processing by language. arXiv:1707.00683, 2017.
165
+ [15] DeepMind. Biggan-deep $1 2 8 \mathrm { x } 1 2 8$ on tensorflow hub. https://tfhub.dev/deepmind/ biggan-deep-128/1, 2018.
166
+ [16] Terrance DeVries, Michal Drozdzal, and Graham W. Taylor. Instance selection for gans. arXiv:2007.15255, 2020.
167
+ [17] Prafulla Dhariwal, Heewoo Jun, Christine Payne, Jong Wook Kim, Alec Radford, and Ilya Sutskever. Jukebox: A generative model for music. arXiv:2005.00341, 2020.
168
+ [18] Jeff Donahue and Karen Simonyan. Large scale adversarial representation learning. arXiv:1907.02544, 2019.
169
+ [19] Yilun Du and Igor Mordatch. Implicit generation and generalization in energy-based models. arXiv:1903.08689, 2019.
170
+ [20] Vincent Dumoulin, Jonathon Shlens, and Manjunath Kudlur. A learned representation for artistic style. arXiv:1610.07629, 2017.
171
+ [21] Patrick Esser, Robin Rombach, and Björn Ommer. Taming transformers for high-resolution image synthesis. arXiv:2012.09841, 2020.
172
+ [22] Jeffrey De Fauw, Sander Dieleman, and Karen Simonyan. Hierarchical autoregressive image models with auxiliary decoders. arXiv:1903.04933, 2019.
173
+ [23] Federico A. Galatolo, Mario G. C. A. Cimino, and Gigliola Vaglini. Generating images from caption and vice versa via clip-guided generative latent space search. arXiv:2102.01645, 2021.
174
+ [24] Ruiqi Gao, Yang Song, Ben Poole, Ying Nian Wu, and Diederik P. Kingma. Learning energybased models by diffusion recovery likelihood. arXiv:2012.08125, 2020.
175
+ [25] Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial networks. arXiv:1406.2661, 2014.
176
+ [26] Google. Cloud tpus. https://cloud.google.com/tpu/, 2018.
177
+ [27] Anirudh Goyal, Nan Rosemary Ke, Surya Ganguli, and Yoshua Bengio. Variational walkback: Learning a transition operator as a stochastic recurrent net. arXiv:1711.02282, 2017.
178
+ [28] Will Grathwohl, Kuan-Chieh Wang, Jörn-Henrik Jacobsen, David Duvenaud, Mohammad Norouzi, and Kevin Swersky. Your classifier is secretly an energy based model and you should treat it like one. arXiv:1912.03263, 2019.
179
+ [29] Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in Neural Information Processing Systems 30 (NIPS 2017), 2017.
180
+ [30] Geoffrey E Hinton. Training products of experts by minimizing contrastive divergence. Neural computation, 14(8):1771–1800, 2002.
181
+ [31] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv:2006.11239, 2020.
182
+ [32] Alexia Jolicoeur-Martineau, Rémi Piché-Taillefer, Rémi Tachet des Combes, and Ioannis Mitliagkas. Adversarial score matching and improved sampling for image generation. arXiv:2009.05475, 2020.
183
+ [33] Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. arXiv:arXiv:1812.04948, 2019.
184
+ [34] Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and improving the image quality of stylegan. arXiv:1912.04958, 2019.
185
+ [35] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv:1412.6980, 2014.
186
+ [36] Zhifeng Kong, Wei Ping, Jiaji Huang, Kexin Zhao, and Bryan Catanzaro. Diffwave: A versatile diffusion model for audio synthesis. arXiv:2009.09761, 2020.
187
+ [37] Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. CIFAR-10 (Canadian Institute for Advanced Research), 2009. URL http://www.cs.toronto.edu/\~kriz/cifar.html.
188
+ [38] Tuomas Kynkäänniemi, Tero Karras, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Improved precision and recall metric for assessing generative models. arXiv:1904.06991, 2019.
189
+ [39] Guosheng Lin, Anton Milan, Chunhua Shen, and Ian Reid. Refinenet: Multi-path refinement networks for high-resolution semantic segmentation. arXiv:1611.06612, 2016.
190
+ [40] Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015.
191
+ [41] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv:1711.05101, 2017.
192
+ [42] Mario Lucic, Michael Tschannen, Marvin Ritter, Xiaohua Zhai, Olivier Bachem, and Sylvain Gelly. High-fidelity image generation with fewer labels. arXiv:1903.02271, 2019.
193
+ [43] Eric Luhman and Troy Luhman. Knowledge distillation in iterative generative models for improved sampling speed. arXiv:2101.02388, 2021.
194
+ [44] Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, and Hao Wu. Mixed precision training. arXiv:1710.03740, 2017.
195
+ [45] Mehdi Mirza and Simon Osindero. Conditional generative adversarial nets. arXiv:1411.1784, 2014.
196
+ [46] Takeru Miyato and Masanori Koyama. cgans with projection discriminator. arXiv:1802.05637, 2018.
197
+ [47] Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. arXiv:1802.05957, 2018.
198
+ [48] Charlie Nash, Jacob Menick, Sander Dieleman, and Peter W. Battaglia. Generating images with sparse representations. arXiv:2103.03841, 2021.
199
+ [49] Alex Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. arXiv:2102.09672, 2021.
200
+ [50] NVIDIA. Stylegan2. https://github.com/NVlabs/stylegan2, 2019.
201
+ [51] Gaurav Parmar, Richard Zhang, and Jun-Yan Zhu. On buggy resizing libraries and surprising subtleties in fid calculation. arXiv:2104.11222, 2021.
202
+ [52] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. arXiv:1912.01703, 2019.
203
+ [53] Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski. Styleclip: Text-driven manipulation of stylegan imagery. arXiv:2103.17249, 2021.
204
+ [54] Ethan Perez, Florian Strub, Harm de Vries, Vincent Dumoulin, and Aaron Courville. Film: Visual reasoning with a general conditioning layer. arXiv:1709.07871, 2017.
205
+ [55] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. arXiv:2103.00020, 2021.
206
+ [56] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. arXiv:2102.12092, 2021.
207
+ [57] Ali Razavi, Aaron van den Oord, and Oriol Vinyals. Generating diverse high-fidelity images with VQ-VAE-2. arXiv:1906.00446, 2019.
208
+ [58] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. arXiv:1505.04597, 2015.
209
+ [59] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. Imagenet large scale visual recognition challenge. arXiv:1409.0575, 2014.
210
+ [60] Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J. Fleet, and Mohammad Norouzi. Image super-resolution via iterative refinement. arXiv:arXiv:2104.07636, 2021.
211
+ [61] Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. arXiv:1606.03498, 2016.
212
+ [62] Shibani Santurkar, Dimitris Tsipras, Brandon Tran, Andrew Ilyas, Logan Engstrom, and Aleksander Madry. Image synthesis with a single (robust) classifier. arXiv:1906.09453, 2019.
213
+ [63] Jascha Sohl-Dickstein, Eric A. Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. arXiv:1503.03585, 2015.
214
+ [64] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv:2010.02502, 2020.
215
+ [65] Yang Song and Stefano Ermon. Improved techniques for training score-based generative models. arXiv:2006.09011, 2020.
216
+ [66] Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. arXiv:arXiv:1907.05600, 2020.
217
+ [67] Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv:2011.13456, 2020.
218
+ [68] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. arXiv:1512.00567, 2015.
219
+ [69] Arash Vahdat and Jan Kautz. Nvae: A deep hierarchical variational autoencoder. arXiv:2007.03898, 2020.
220
+ [70] Aaron van den Oord, Sander Dieleman, Heiga Zen, Karen Simonyan, Oriol Vinyals, Alex Graves, Nal Kalchbrenner, Andrew Senior, and Koray Kavukcuoglu. Wavenet: A generative model for raw audio. arXiv:1609.03499, 2016.
221
+ [71] Aaron van den Oord, Oriol Vinyals, and Koray Kavukcuoglu. Neural discrete representation learning. arXiv:1711.00937, 2017.
222
+ [72] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. arXiv:1706.03762, 2017.
223
+ [73] Max Welling and Yee W Teh. Bayesian learning via stochastic gradient langevin dynamics. In Proceedings of the 28th international conference on machine learning (ICML-11), pages 681–688. Citeseer, 2011.
224
+ [74] Yan Wu, Jeff Donahue, David Balduzzi, Karen Simonyan, and Timothy Lillicrap. Logan: Latent optimisation for generative adversarial networks. arXiv:1912.00953, 2019.
225
+ [75] Yuxin Wu and Kaiming He. Group normalization. arXiv:1803.08494, 2018.
226
+ [76] Jianwen Xie, Yang Lu, Song-Chun Zhu, and Ying Nian Wu. A theory of generative convnet. arXiv:1602.03264, 2016.
227
+
228
+ [77] Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser, and Jianxiong Xiao. Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop. arXiv:1506.03365, 2015.
229
+
230
+ [78] Han Zhang, Tao Xu, Hongsheng Li, Shaoting Zhang, Xiaogang Wang, Xiaolei Huang, and Dimitris Metaxas. Stackgan: Text to photo-realistic image synthesis with stacked generative adversarial networks. arXiv:1612.03242, 2016.
231
+
232
+ # Checklist
233
+
234
+ • Did you include the license to the code and datasets? [No] We were unable to find the official license for either ImageNet or LSUN. We do include a license for our released source code.
235
+
236
+ 1. For all authors...
237
+
238
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
239
+ (b) Did you describe the limitations of your work? [Yes] See Section 7.
240
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 8.
241
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
242
+
243
+ 2. If you are including theoretical results...
244
+
245
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Appendix D.
246
+ (b) Did you include complete proofs of all theoretical results? [Yes] We provide detailed derivations in Appendix D.
247
+
248
+ 3. If you ran experiments...
249
+
250
+ (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] We include the source code and instructions for running it.
251
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix K.
252
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Each experiment requires several hundred GPU days to run, so it is quite costly to compute error bars.
253
+ (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 Appendix B.
254
+
255
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
256
+
257
+ (a) If your work uses existing assets, did you cite the creators? [Yes] Our codebase references the codebase it is forked from [49, 31]. We also cite PyTorch [52], which we use throughout our experiments.
258
+ (b) Did you mention the license of the assets? [Yes] A license file is included with the code release.
259
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] The code is included in the supplemental material.
260
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
261
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
262
+
263
+ 5. If you used crowdsourcing or conducted research with human subjects...
264
+
265
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
266
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
267
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/train/S1c2cvqee/S1c2cvqee.md ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DESIGNING NEURAL NETWORK ARCHITECTURES USING REINFORCEMENT LEARNING
2
+
3
+ Bowen Baker, Otkrist Gupta, Nikhil Naik & Ramesh Raskar
4
+
5
+ Media Laboratory
6
+ Massachusetts Institute of Technology
7
+ Cambridge MA 02139, USA
8
+ {bowen, otkrist, naik, raskar}@mit.edu
9
+
10
+ # ABSTRACT
11
+
12
+ At present, designing convolutional neural network (CNN) architectures requires both human expertise and labor. New architectures are handcrafted by careful experimentation or modified from a handful of existing networks. We introduce MetaQNN, a meta-modeling algorithm based on reinforcement learning to automatically generate high-performing CNN architectures for a given learning task. The learning agent is trained to sequentially choose CNN layers using $Q$ - learning with an $\epsilon$ -greedy exploration strategy and experience replay. The agent explores a large but finite space of possible architectures and iteratively discovers designs with improved performance on the learning task. On image classification benchmarks, the agent-designed networks (consisting of only standard convolution, pooling, and fully-connected layers) beat existing networks designed with the same layer types and are competitive against the state-of-the-art methods that use more complex layer types. We also outperform existing meta-modeling approaches for network design on image classification tasks.
13
+
14
+ # 1 INTRODUCTION
15
+
16
+ Deep convolutional neural networks (CNNs) have seen great success in the past few years on a variety of machine learning problems (LeCun et al., 2015). A typical CNN architecture consists of several convolution, pooling, and fully connected layers. While constructing a CNN, a network designer has to make numerous design choices: the number of layers of each type, the ordering of layers, and the hyperparameters for each type of layer, e.g., the receptive field size, stride, and number of receptive fields for a convolution layer. The number of possible choices makes the design space of CNN architectures extremely large and hence, infeasible for an exhaustive manual search. While there has been some work (Pinto et al., 2009; Bergstra et al., 2013; Domhan et al., 2015) on automated or computer-aided neural network design, new CNN architectures or network design elements are still primarily developed by researchers using new theoretical insights or intuition gained from experimentation.
17
+
18
+ In this paper, we seek to automate the process of CNN architecture selection through a metamodeling procedure based on reinforcement learning. We construct a novel $Q$ -learning agent whose goal is to discover CNN architectures that perform well on a given machine learning task with no human intervention. The learning agent is given the task of sequentially picking layers of a CNN model. By discretizing and limiting the layer parameters to choose from, the agent is left with a finite but large space of model architectures to search from. The agent learns through random exploration and slowly begins to exploit its findings to select higher performing models using the $\epsilon \cdot$ - greedy strategy (Mnih et al., 2015). The agent receives the validation accuracy on the given machine learning task as the reward for selecting an architecture. We expedite the learning process through repeated memory sampling using experience replay (Lin, 1993). We refer to this $Q$ -learning based meta-modeling method as MetaQNN, which is summarized in Figure 1.1
19
+
20
+ We conduct experiments with a space of model architectures consisting of only standard convolution, pooling, and fully connected layers using three standard image classification datasets: CIFAR-10,
21
+
22
+ ![](images/46d5c58f33c694a26ef479826deb91e729210b90ab747d2d227eb608e4fdeb87.jpg)
23
+ Figure 1: Designing CNN Architectures with $Q$ -learning: The agent begins by sampling a Convolutional Neural Network (CNN) topology conditioned on a predefined behavior distribution and the agent’s prior experience (left block). That CNN topology is then trained on a specific task; the topology description and performance, e.g. validation accuracy, are then stored in the agent’s memory (middle block). Finally, the agent uses its memories to learn about the space of CNN topologies through $Q$ -learning (right block).
24
+
25
+ SVHN, and MNIST. The learning agent discovers CNN architectures that beat all existing networks designed only with the same layer types (e.g., Springenberg et al. (2014); Srivastava et al. (2015)). In addition, their performance is competitive against network designs that include complex layer types and training procedures (e.g., Clevert et al. (2015); Lee et al. (2016)). Finally, the MetaQNN selected models comfortably outperform previous automated network design methods (Stanley & Miikkulainen, 2002; Bergstra et al., 2013). The top network designs discovered by the agent on one dataset are also competitive when trained on other datasets, indicating that they are suited for transfer learning tasks. Moreover, we can generate not just one, but several varied, well-performing network designs, which can be ensembled to further boost the prediction performance.
26
+
27
+ # 2 RELATED WORK
28
+
29
+ Designing neural network architectures: Research on automating neural network design goes back to the 1980s when genetic algorithm-based approaches were proposed to find both architectures and weights (Schaffer et al., 1992). However, to the best of our knowledge, networks designed with genetic algorithms, such as those generated with the NEAT algorithm (Stanley & Miikkulainen, 2002), have been unable to match the performance of hand-crafted networks on standard benchmarks (Verbancsics & Harguess, 2013). Other biologically inspired ideas have also been explored; motivated by screening methods in genetics, Pinto et al. (2009) proposed a high-throughput network selection approach where they randomly sample thousands of architectures and choose promising ones for further training. In recent work, Saxena & Verbeek (2016) propose to sidestep the architecture selection process through densely connected networks of layers, which come closer to the performance of hand-crafted networks.
30
+
31
+ Bayesian optimization has also been used (Shahriari et al., 2016) for automatic selection of network architectures (Bergstra et al., 2013; Domhan et al., 2015) and hyperparameters (Snoek et al., 2012; Swersky et al., 2013). Notably, Bergstra et al. (2013) proposed a meta-modeling approach based on Tree of Parzen Estimators (TPE) (Bergstra et al., 2011) to choose both the type of layers and hyperparameters of feed-forward networks; however, they fail to match the performance of handcrafted networks.
32
+
33
+ Reinforcement Learning: Recently there has been much work at the intersection of reinforcement learning and deep learning. For instance, methods using CNNs to approximate the $Q$ -learning utility function (Watkins, 1989) have been successful in game-playing agents (Mnih et al., 2015; Silver et al., 2016) and robotic control (Lillicrap et al., 2015; Levine et al., 2016). These methods rely on phases of exploration, where the agent tries to learn about its environment through sampling, and exploitation, where the agent uses what it learned about the environment to find better paths. In traditional reinforcement learning settings, over-exploration can lead to slow convergence times, yet over-exploitation can lead to convergence to local minima (Kaelbling et al., 1996). However, in the case of large or continuous state spaces, the $\epsilon$ -greedy strategy of learning has been empirically shown to converge (Vermorel & Mohri, 2005). Finally, when the state space is large or exploration is costly, the experience replay technique (Lin, 1993) has proved useful in experimental settings (Adam et al., 2012; Mnih et al., 2015). We incorporate these techniques— $Q$ -learning, the $\epsilon$ -greedy strategy and experience replay—in our algorithm design.
34
+
35
+ # 3 BACKGROUND
36
+
37
+ Our method relies on $Q$ -learning, a type of reinforcement learning. We now summarize the theoretical formulation of $Q$ -learning, as adopted to our problem. Consider the task of teaching an agent to find optimal paths as a Markov Decision Process (MDP) in a finite-horizon environment. Constraining the environment to be finite-horizon ensures that the agent will deterministically terminate in a finite number of time steps. In addition, we restrict the environment to have a discrete and finite state space $s$ as well as action space $\mathcal { U }$ . For any state $s _ { i } \in S$ , there is a finite set of actions, $\mathcal { U } ( s _ { i } ) \subseteq \mathcal { U }$ , that the agent can choose from. In an environment with stochastic transitions, an agent in state $s _ { i }$ taking some action $u \in \mathcal { U } ( s _ { i } )$ will transition to state $s _ { j }$ with probability $p _ { s ^ { \prime } | s , u } ( s _ { j } | s _ { i } , u )$ , which may be unknown to the agent. At each time step $t$ , the agent is given a reward $r _ { t }$ , dependent on the transition from state $s$ to $s ^ { \prime }$ and action $u$ . $r _ { t }$ may also be stochastic according to a distribution $p _ { r | s ^ { \prime } , s , u }$ . The agent’s goal is to maximize the total expected reward over all possible trajectories, i.e., $\operatorname* { m i n } _ { \mathbf { \zeta } } { } _ { T _ { i } \in \mathcal { T } } { \cal R } _ { T _ { i } }$ , where the total expected reward for a trajectory $\mathcal { T } _ { i }$ is
38
+
39
+ $$
40
+ \begin{array} { r } { R _ { \mathcal { T } _ { i } } = \sum _ { ( s , u , s ^ { \prime } ) \in \mathcal { T } _ { i } } \mathbb { E } _ { r | s , u , s ^ { \prime } } [ r | s , u , s ^ { \prime } ] . } \end{array}
41
+ $$
42
+
43
+ Though we limit the agent to a finite state and action space, there are still a combinatorially large number of trajectories, which motivates the use of reinforcement learning. We define the maximization problem recursively in terms of subproblems as follows. For any state $s _ { i } \in S$ and subsequent action $u \in \mathcal { U } ( s _ { i } )$ , we define the maximum total expected reward to be $Q ^ { * } ( s _ { i } , u )$ . $Q ^ { * } ( \cdot )$ is known as the action-value function and individual $Q ^ { * } ( s _ { i } , u )$ are know as $Q$ -values. The recursive maximization equation, which is known as Bellman’s Equation, can be written as
44
+
45
+ $$
46
+ \begin{array} { r } { Q ^ { * } ( s _ { i } , u ) = \mathbb { E } _ { s _ { j } \mid s _ { i } , u } \left[ \mathbb { E } _ { r \mid s _ { i } , u , s _ { j } } [ r \mid s _ { i } , u , s _ { j } ] + \gamma \operatorname* { m a x } _ { u ^ { \prime } \in \mathcal { U } ( s _ { j } ) } Q ^ { * } ( s _ { j } , u ^ { \prime } ) \right] . } \end{array}
47
+ $$
48
+
49
+ In many cases, it is impossible to analytically solve Bellman’s Equation (Bertsekas, 2015), but it can be formulated as an iterative update
50
+
51
+ $$
52
+ \begin{array} { r } { Q _ { t + 1 } ( s _ { i } , u ) = ( 1 - \alpha ) Q _ { t } ( s _ { i } , u ) + \alpha \left[ r _ { t } + \gamma \operatorname* { m a x } _ { u ^ { \prime } \in \mathcal { U } ( s _ { j } ) } Q _ { t } ( s _ { j } , u ^ { \prime } ) \right] . } \end{array}
53
+ $$
54
+
55
+ Equation 3 is the simplest form of $Q$ -learning proposed by Watkins (1989). For well formulated problems, $\begin{array} { r } { \operatorname* { l i m } _ { t \to \infty } \bar { Q _ { t } } ( s , u ) = Q ^ { * } ( s , u ) } \end{array}$ , as long as each transition is sampled infinitely many times (Bertsekas, 2015). The update equation has two parameters: (i) $\alpha$ is a $Q$ -learning rate which determines the weight given to new information over old information, and (ii) $\gamma$ is the discount factor which determines the weight given to short-term rewards over future rewards. The $Q$ -learning algorithm is model-free, in that the learning agent can solve the task without ever explicitly constructing an estimate of environmental dynamics. In addition, $Q$ -learning is off policy, meaning it can learn about optimal policies while exploring via a non-optimal behavioral distribution, i.e. the distribution by which the agent explores its environment.
56
+
57
+ We choose the behavior distribution using an $\epsilon$ -greedy strategy (Mnih et al., 2015). With this strategy, a random action is taken with probability $\epsilon$ and the greedy action, $\begin{array} { r } { \operatorname* { m a x } _ { u \in \mathcal { U } ( s _ { i } ) } Q _ { t } \mathopen { } \mathclose \bgroup \left( s _ { i } , u \aftergroup \egroup \right) } \end{array}$ , is chosen with probability $1 - \epsilon$ . We anneal $\epsilon$ from $1 0$ such that the agent begins in an exploration phase and slowly starts moving towards the exploitation phase. In addition, when the exploration cost is large (which is true for our problem setting), it is beneficial to use the experience replay technique for faster convergence (Lin, 1992). In experience replay, the learning agent is provided with a memory of its past explored paths and rewards. At a given interval, the agent samples from the memory and updates its $Q$ -values via Equation 3.
58
+
59
+ # 4 DESIGNING NEURAL NETWORK ARCHITECTURES WITH $Q$ -LEARNING
60
+
61
+ We consider the task of training a learning agent to sequentially choose neural network layers. Figure 2 shows feasible state and action spaces (a) and a potential trajectory the agent may take along with the CNN architecture defined by this trajectory (b). We model the layer selection process as a Markov Decision Process with the assumption that a well-performing layer in one network should also perform well in another network. We make this assumption based on the hierarchical nature of the feature representations learned by neural networks with many hidden layers (LeCun et al., 2015). The agent sequentially selects layers via the $\epsilon$ -greedy strategy until it reaches a termination state. The CNN architecture defined by the agent’s path is trained on the chosen learning problem, and the agent is given a reward equal to the validation accuracy. The validation accuracy and architecture description are stored in a replay memory, and experiences are sampled periodically from the replay memory to update $Q$ -values via Equation 3. The agent follows an $\epsilon$ schedule which determines its shift from exploration to exploitation.
62
+
63
+ ![](images/dee80030fc5fc1b6ad35a44d75d773edc835d64b20e4221813dc684b9dea8980.jpg)
64
+ Figure 2: Markov Decision Process for CNN Architecture Generation: Figure 2(a) shows the full state and action space. In this illustration, actions are shown to be deterministic for clarity, but they are stochastic in experiments. $C ( n , f , l )$ denotes a convolutional layer with $n$ filters, receptive field size $f$ , and stride l. $P ( f , l )$ denotes a pooling layer with receptive field size $f$ and stride l. $G$ denotes a termination state (Softmax/Global Average Pooling). Figure 2(b) shows a path the agent may choose, highlighted in green, and the corresponding CNN topology.
65
+
66
+ Our method requires three main design choices: (i) reducing CNN layer definitions to simple state tuples, (ii) defining a set of actions the agent may take, i.e., the set of layers the agent may pick next given its current state, and (iii) balancing the size of the state-action space—and correspondingly, the model capacity—with the amount of exploration needed by the agent to converge. We now describe the design choices and the learning process in detail.
67
+
68
+ # 4.1 THE STATE SPACE
69
+
70
+ Each state is defined as a tuple of all relevant layer parameters. We allow five different types of layers: convolution (C), pooling (P), fully connected (FC), global average pooling (GAP), and softmax (SM), though the general method is not limited to this set. Table 1 shows the relevant parameters for each layer type and also the discretization we chose for each parameter. Each layer has a parameter layer depth (shown as Layer $1 , 2 , \ldots$ in Figure 2). Adding layer depth to the state space allows us to constrict the action space such that the state-action graph is directed and acyclic (DAG) and also allows us to specify a maximum number of layers the agent may select before terminating.
71
+
72
+ Each layer type also has a parameter called representation size $R$ -size). Convolutional nets progressively compress the representation of the original signal through pooling and convolution. The presence of these layers in our state space may lead the agent on a trajectory where the intermediate signal representation gets reduced to a size that is too small for further processing. For example, five $2 \times 2$ pooling layers each with stride 2 will reduce an image of initial size $3 2 \times 3 2$ to size $1 \times 1$ . At this stage, further pooling, or convolution with receptive field size greater than 1, would be meaningless and degenerate. To avoid such scenarios, we add the $R$ -size parameter to the state tuple $s$ , which allows us to restrict actions from states with $R$ -size $n$ to those that have a receptive field size less than or equal to $n$ . To further constrict the state space, we chose to bin the representation sizes into three discrete buckets. However, binning adds uncertainty to the state transitions: depending on the true underlying representation size, a pooling layer may or may not change the $R$ -size bin. As a result, the action of pooling can lead to two different states, which we model as stochasticity in state transitions. Please see Figure A1 in appendix for an illustrated example.
73
+
74
+ <table><tr><td rowspan=1 colspan=1>Layer Type</td><td rowspan=1 colspan=1>LayerParameters</td><td rowspan=1 colspan=1>ParameterValues</td></tr><tr><td rowspan=1 colspan=1>Convolution (C)</td><td rowspan=1 colspan=1>i~Layer depthf~Receptive field sizel~Strided ~ # receptive fieldsn ~ Representation size</td><td rowspan=1 colspan=1>&lt;12Square. ∈ {1,3,5}Square.Always equal to 1∈{64,128,256,512}∈{(,8],(8,4],(4,1]}</td></tr><tr><td rowspan=1 colspan=1>Pooling (P)</td><td rowspan=1 colspan=1>i~Layer depth(f,l)~ (Receptive field size, Strides)n ~ Representation size</td><td rowspan=1 colspan=1>&lt;12Square.∈{(5,3),(3,2),(2,2)}∈{(∞,8],(8,4] and (4,1]}</td></tr><tr><td rowspan=1 colspan=1>Fully Connected (FC)</td><td rowspan=1 colspan=1>i~Layerdepthn ~ # consecutive FC layersd ~# neurons</td><td rowspan=1 colspan=1>&lt;12&lt;3∈ {512,256,128}</td></tr><tr><td rowspan=1 colspan=1>Termination State</td><td rowspan=1 colspan=1>S~Previous Statet~Type</td><td rowspan=1 colspan=1>Global Avg.Pooling/Softmax</td></tr></table>
75
+
76
+ Table 1: Experimental State Space. For each layer type, we list the relevant parameters and the values each parameter is allowed to take.
77
+
78
+ # 4.2 THE ACTION SPACE
79
+
80
+ We restrict the agent from taking certain actions to both limit the state-action space and make learning tractable. First, we allow the agent to terminate a path at any point, i.e. it may choose a termination state from any non-termination state. In addition, we only allow transitions for a state with layer depth $i$ to a state with layer depth $i + 1$ , which ensures that there are no loops in the graph. This constraint ensures that the state-action graph is always a DAG. Any state at the maximum layer depth, as prescribed in Table 1, may only transition to a termination layer.
81
+
82
+ Next, we limit the number of fully connected (FC) layers to be at maximum two, because a large number of FC layers can lead to too may learnable parameters. The agent at a state with type FC may transition to another state with type FC if and only if the number of consecutive FC states is less than the maximum allowed. Furthermore, a state $s$ of type FC with number of neurons $d$ may only transition to either a termination state or a state $s ^ { \prime }$ of type FC with number of neurons $d ^ { \prime } \leq d$ .
83
+
84
+ An agent at a state of type convolution (C) may transition to a state with any other layer type. An agent at a state with layer type pooling (P) may transition to a state with any other layer type other than another $\mathrm { \bf P }$ state because consecutive pooling layers are equivalent to a single, larger pooling layer which could lie outside of our chosen state space. Furthermore, only states with representation size in bins (8, 4] and (4, 1] may transition to an FC layer, which ensures that the number of weights does not become unreasonably huge. Note that a majority of these constraints are in place to enable faster convergence on our limited hardware (see Section 5) and not a limitation of the method in itself.
85
+
86
+ # 4.3 $Q$ -LEARNING TRAINING PROCEDURE
87
+
88
+ For the iterative $Q$ -learning updates (Equation 3), we set the $Q$ -learning rate $( \alpha )$ to 0.01. In addition, we set the discount factor $( \gamma )$ to 1 to not over-prioritize short-term rewards. We decrease $\epsilon$ from 1.0 to 0.1 in steps, where the step-size is defined by the number of unique models trained (Table 2). At $\epsilon = 1 . 0$ , the agent samples CNN architecture with a random walk along a uniformly weighted Markov chain. Every topology sampled by the agent is trained using the procedure described in Section 5, and the prediction performance of this network topology on the validation set is recorded. We train a larger number of models at $\epsilon = 1 . 0$ as compared to other values of $\epsilon$ to ensure that the agent has adequate time to explore before it begins to exploit. We stop the agent at $\epsilon = 0 . 1$ (and not at $\epsilon = 0$ ) to obtain a stochastic final policy, which generates perturbations of the global minimum.2 Ideally, we want to identify several well-performing model topologies, which can then be ensembled to improve prediction performance.
89
+
90
+ During the entire training process (starting at $\epsilon = 1 . 0$ ), we maintain a replay dictionary which stores (i) the network topology and (ii) prediction performance on a validation set, for all of the sampled
91
+
92
+ <table><tr><td rowspan=1 colspan=1>E</td><td rowspan=1 colspan=1>1.0</td><td rowspan=1 colspan=1>0.9</td><td rowspan=1 colspan=1>0.8</td><td rowspan=1 colspan=1>0.7</td><td rowspan=1 colspan=1>0.6</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.4</td><td rowspan=1 colspan=1>0.3</td><td rowspan=1 colspan=1>0.2</td><td rowspan=1 colspan=1>0.1</td></tr><tr><td rowspan=1 colspan=1>#ModelsTrained</td><td rowspan=1 colspan=1>1500</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>150</td><td rowspan=1 colspan=1>150</td><td rowspan=1 colspan=1>150</td><td rowspan=1 colspan=1>150</td><td rowspan=1 colspan=1>150</td><td rowspan=1 colspan=1>150</td></tr></table>
93
+
94
+ Table 2:  Schedule. The learning agent trains the specified number of unique models at each .
95
+
96
+ models. If a model that has already been trained is re-sampled, it is not re-trained, but instead the previously found validation accuracy is presented to the agent. After each model is sampled and trained, the agent randomly samples 100 models from the replay dictionary and applies the $Q$ -value update defined in Equation 3 for all transitions in each sampled sequence. The $Q$ -value update is applied to the transitions in temporally reversed order, which has been shown to speed up $Q$ -values convergence (Lin, 1993).
97
+
98
+ # 5 EXPERIMENT DETAILS
99
+
100
+ During the model exploration phase, we trained each network topology with a quick and aggressive training scheme. For each experiment, we created a validation set by randomly taking 5,000 samples from the training set such that the resulting class distributions were unchanged. For every network, a dropout layer was added after every two layers. The $i ^ { t h }$ dropout layer, out of a total $n$ dropout layers, had a dropout probability of $\dot { \frac { \ i } { 2 n } }$ . Each model was trained for a total of 20 epochs with the Adam optimizer (Kingma & Ba, 2014) with $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 9 9$ , $\varepsilon = 1 0 ^ { - 8 }$ . The batch size was set to 128, and the initial learning rate was set to 0.001. If the model failed to perform better than a random predictor after the first epoch, we reduced the learning rate by a factor of 0.4 and restarted training, for a maximum of 5 restarts. For models that started learning (i.e., performed better than a random predictor), we reduced the learning rate by a factor of 0.2 every 5 epochs. All weights were initialized with Xavier initialization (Glorot & Bengio, 2010). Our experiments using Caffe (Jia et al., 2014) took 8-10 days to complete for each dataset with a hardware setup consisting of 10 NVIDIA GPUs.
101
+
102
+ After the agent completed the $\epsilon$ schedule (Table 2), we selected the top ten models that were found over the course of exploration. These models were then finetuned using a much longer training schedule, and only the top five were used for ensembling. We now provide details of the datasets and the finetuning process.
103
+
104
+ The Street View House Numbers (SVHN) dataset has 10 classes with a total of 73,257 samples in the original training set, 26,032 samples in the test set, and 531,131 additional samples in the extended training set. During the exploration phase, we only trained with the original training set, using 5,000 random samples as validation. We finetuned the top ten models with the original plus extended training set, by creating preprocessed training and validation sets as described by Lee et al. (2016). Our final learning rate schedule after tuning on validation set was 0.025 for 5 epochs, 0.0125 for 5 epochs, 0.0001 for 20 epochs, and 0.00001 for 10 epochs.
105
+
106
+ CIFAR-10, the 10 class tiny image dataset, has 50,000 training samples and 10,000 testing samples. During the exploration phase, we took 5,000 random samples from the training set for validation. The maximum layer depth was increased to 18. After the experiment completed, we used the same validation set to tune hyperparameters, resulting in a final training scheme which we ran on the entire training set. In the final training scheme, we set a learning rate of 0.025 for 40 epochs, 0.0125 for 40 epochs, 0.0001 for 160 epochs, and 0.00001 for 60 epochs, with all other parameters unchanged. During this phase, we preprocess using global contrast normalization and use moderate data augmentation, which consists of random mirroring and random translation by up to 5 pixels.
107
+
108
+ MNIST, the 10 class handwritten digits dataset, has 60,000 training samples and 10,000 testing samples. We preprocessed each image with global mean subtraction. In the final training scheme, we trained each model for 40 epochs and decreased learning rate every 5 epochs by a factor of 0.2. For further tuning details please see Appendix C.
109
+
110
+ # 6 RESULTS
111
+
112
+ Model Selection Analysis: From $Q$ -learning principles, we expect the learning agent to improve in its ability to pick network topologies as $\epsilon$ reduces and the agent enters the exploitation phase. In
113
+
114
+ ![](images/32552c045952a2108296dbbf36564ad8f0b5f3075473a34e23667ff0fce72559.jpg)
115
+
116
+ ![](images/818d2c4b19fb2d138b036e932e80d2c5a38257b0bfc2910a1ad197b14962fe53.jpg)
117
+ Figure 3: $Q$ -Learning Performance. In the plots, the blue line shows a rolling mean of model accuracy versus iteration, where in each iteration of the algorithm the agent is sampling a model. Each bar (in light blue) marks the average accuracy over all models that were sampled during the exploration phase with the labeled $\epsilon$ . As $\epsilon$ decreases, the average accuracy goes up, demonstrating that the agent learns to select better-performing CNN architectures.
118
+
119
+ Table 3: Error Rate Comparison with CNNs that only use convolution, pooling, and fully connected layers. We report results for CIFAR-10 and CIFAR-100 with moderate data augmentation and results for MNIST and SVHN without any data augmentation.
120
+
121
+ <table><tr><td>Method</td><td>CIFAR-10</td><td>SVHN</td><td>MNIST</td><td>CIFAR-100</td></tr><tr><td>Maxout (Goodfellow et al., 2013)</td><td>9.38</td><td>2.47</td><td>0.45</td><td>38.57</td></tr><tr><td>NIN (Lin et al., 2013)</td><td>8.81</td><td>2.35</td><td>0.47</td><td>35.68</td></tr><tr><td>FitNet (Romero et al., 2014)</td><td>8.39</td><td>2.42</td><td>0.51</td><td>35.04</td></tr><tr><td>HighWay (Srivastava et al.,2015)</td><td>7.72</td><td>-</td><td></td><td></td></tr><tr><td>VGGnet (Simonyan &amp; Zisserman,2014)</td><td>7.25</td><td>=</td><td>=</td><td>=</td></tr><tr><td>All-CNN (Springenberg et al., 2014)</td><td>7.25</td><td>=</td><td>=</td><td>33.71</td></tr><tr><td>MetaQNN (ensemble)</td><td>7.32</td><td>2.06</td><td>0.32</td><td>-</td></tr><tr><td>MetaQNN (top model)</td><td>6.92</td><td>2.28</td><td>0.44</td><td>27.14*</td></tr></table>
122
+
123
+ Figure 3, we plot the rolling mean of prediction accuracy over 100 models and the mean accuracy of models sampled at different $\epsilon$ values, for the CIFAR-10 and SVHN experiments. The plots show that, while the prediction accuracy remains flat during the exploration phase $\epsilon = 1$ ) as expected, the agent consistently improves in its ability to pick better-performing models as $\epsilon$ reduces from 1 to 0.1. For example, the mean accuracy of models in the SVHN experiment increases from $5 2 . 2 5 \%$ at $\epsilon = 1$ to $8 8 . 0 2 \%$ at $\epsilon = 0 . 1$ . Furthermore, we demonstrate the stability of the $Q$ -learning procedure with 10 independent runs on a subset of the SVHN dataset in Section D.1 of the Appendix. Additional analysis of $Q$ -learning results can be found in Section D.2.
124
+
125
+ The top models selected by the $Q$ -learning agent vary in the number of parameters but all demonstrate high performance (see Appendix Tables 1-3). For example, the number of parameters for the top five CIFAR-10 models range from 11.26 million to 1.10 million, with only a $2 . 3 2 \%$ decrease in test error. We find design motifs common to the top hand-crafted network architectures as well. For example, the agent often chooses a layer of type $C ( N , 1 , 1 )$ as the first layer in the network. These layers generate $N$ learnable linear transformations of the input data, which is similar in spirit to preprocessing of input data from RGB to a different color spaces such as YUV, as found in prior work (Sermanet et al., 2012; 2013).
126
+
127
+ Prediction Performance: We compare the prediction performance of the MetaQNN networks discovered by the $Q$ -learning agent with state-of-the-art methods on three datasets. We report the accuracy of our best model, along with an ensemble of top five models. First, we compare MetaQNN with six existing architectures that are designed with standard convolution, pooling, and fully-connected layers alone, similar to our designs. As seen in Table 3, our top model alone, as well as the committee ensemble of five models, outperforms all similar models. Next, we compare our results with six top networks overall, which contain complex layer types and design ideas, including generalized pooling functions, residual connections, and recurrent modules. Our results are competitive with these methods as well (Table 4). Finally, our method outperforms existing automated network design methods. MetaQNN obtains an error of $6 . 9 2 \%$ as compared to $2 1 . 2 \%$ reported by Bergstra et al. (2011) on CIFAR-10; and it obtains an error of $0 . 3 2 \%$ as compared to $7 . 9 \%$ reported by Verbancsics & Harguess (2013) on MNIST.
128
+
129
+ Table 4: Error Rate Comparison with state-of-the-art methods with complex layer types. We report results for CIFAR-10 and CIFAR-100 with moderate data augmentation and results for MNIST and SVHN without any data augmentation.
130
+
131
+ <table><tr><td>Method</td><td>CIFAR-10</td><td>SVHN</td><td>MNIST</td><td>CIFAR-100</td></tr><tr><td>DropConnect (Wan et al., 2013)</td><td>9.32</td><td>1.94</td><td>0.57</td><td></td></tr><tr><td>DSN (Lee et al., 2015)</td><td>8.22</td><td>1.92</td><td>0.39</td><td>34.57</td></tr><tr><td>R-CNN (Liang&amp; Hu,2015)</td><td>7.72</td><td>1.77</td><td>0.31</td><td>31.75</td></tr><tr><td>MetaQNN (ensemble)</td><td>7.32</td><td>2.06</td><td>0.32</td><td>-</td></tr><tr><td>MetaQNN (top model)</td><td>6.92</td><td>2.28</td><td>0.44</td><td>27.14*</td></tr><tr><td>Resnet(110) (He et al.,2015)</td><td>6.61</td><td>1</td><td></td><td></td></tr><tr><td>Resnet(1001) (He et al.,2016)</td><td>4.62</td><td>=</td><td>=</td><td>22.71</td></tr><tr><td>ELU (Clevert et al., 2015)</td><td>6.55</td><td>=</td><td>=</td><td>24.28</td></tr><tr><td>Tree+Max-Avg (Lee et al.,2016)</td><td>6.05</td><td>1.69</td><td>0.31</td><td>32.37</td></tr></table>
132
+
133
+ Table 5: Prediction Error for the top MetaQNN (CIFAR-10) model trained for other tasks. Finetuning refers to initializing training with the weights found for the optimal CIFAR-10 model.
134
+
135
+ <table><tr><td>Dataset</td><td>CIFAR-100</td><td>SVHN</td><td>MNIST</td></tr><tr><td>Training from scratch</td><td>27.14</td><td>2.48</td><td>0.80</td></tr><tr><td>Finetuning</td><td>34.93</td><td>4.00</td><td>0.81</td></tr><tr><td>State-of-the-art</td><td>24.28 (Clevert et al.,2015)</td><td>1.69 (Lee et al., 2016)</td><td>0.31 (Lee et al.,2016)</td></tr></table>
136
+
137
+ The difference in validation error between the top 10 models for MNIST was very small, so we also created an ensemble with all 10 models. This ensemble achieved a test error of ${ \bf0 . 2 8 \% }$ —which beats the current state-of-the-art on MNIST without data augmentation.
138
+
139
+ The best CIFAR-10 model performs $1 \%$ better than the four next best models, which is why the ensemble accuracy is lower than the best model’s accuracy. We posit that the CIFAR-10 MetaQNN did not have adequate exploration time given the larger state space compared to that of the SVHN experiment, causing it to not find more models with performance similar to the best model. Furthermore, the coarse training scheme could have been not as well suited for CIFAR-10 as it was for SVHN, causing some models to under perform.
140
+
141
+ Transfer Learning Ability: Network designs such as VGGnet (Simonyan & Zisserman, 2014) can be adopted to solve a variety of computer vision problems. To check if the MetaQNN networks provide similar transfer learning ability, we use the best MetaQNN model on the CIFAR-10 dataset for training other computer vision tasks. The model performs well (Table 5) both when training from random initializations, and finetuning from existing weights.
142
+
143
+ # 7 CONCLUDING REMARKS
144
+
145
+ Neural networks are being used in an increasingly wide variety of domains, which calls for scalable solutions to produce problem-specific model architectures. We take a step towards this goal and show that a meta-modeling approach using reinforcement learning is able to generate tailored CNN designs for different image classification tasks. Our MetaQNN networks outperform previous metamodeling methods as well as hand-crafted networks which use the same types of layers.
146
+
147
+ While we report results for image classification problems, our method could be applied to different problem settings, including supervised (e.g., classification, regression) and unsupervised (e.g., autoencoders). The MetaQNN method could also aid constraint-based network design, by optimizing parameters such as size, speed, and accuracy. For instance, one could add a threshold in the state-action space barring the agent from creating models larger than the desired limit. In addition, one could modify the reward function to penalize large models for constraining memory or penalize slow forward passes to incentivize quick inference.
148
+
149
+ There are several future avenues for research in reinforcement learning-driven network design as well. In our current implementation, we use the same set of hyperparameters to train all network topologies during the $Q$ -learning phase and further finetune the hyperparameters for top models selected by the MetaQNN agent. However, our approach could be combined with hyperparameter optimization methods to further automate the network design process. Moreover, we constrict the state-action space using coarse, discrete bins to accelerate convergence. It would be possible to move to larger state-action spaces using methods for $Q$ -function approximation (Bertsekas, 2015; Mnih et al., 2015).
150
+
151
+ # ACKNOWLEDGMENTS
152
+
153
+ We thank Peter Downs for creating the project website and contributing to illustrations. We acknowledge Center for Bits and Atoms at MIT for their help with computing resources. Finally, we thank members of Camera Culture group at MIT Media Lab for their help and support.
154
+
155
+ # REFERENCES
156
+
157
+ Sander Adam, Lucian Busoniu, and Robert Babuska. Experience replay for real-time reinforcement learning control. IEEE Transactions on Systems, Man, and Cybernetics, Part C (Applications and Reviews), 42(2):201–212, 2012.
158
+
159
+ James Bergstra, Daniel Yamins, and David D Cox. Making a science of model search: Hyperparameter optimization in hundreds of dimensions for vision architectures. ICML (1), 28:115–123, 2013.
160
+
161
+ James S Bergstra, Remi Bardenet, Yoshua Bengio, and Bal ´ azs K ´ egl. Algorithms for hyper-parameter ´ optimization. NIPS, pp. 2546–2554, 2011.
162
+
163
+ Dimitri P Bertsekas. Convex optimization algorithms. Athena Scientific Belmont, 2015.
164
+
165
+ Djork-Arne Clevert, Thomas Unterthiner, and Sepp Hochreiter. Fast and accurate deep network ´ learning by exponential linear units (ELUs). arXiv preprint arXiv:1511.07289, 2015.
166
+
167
+ Tobias Domhan, Jost Tobias Springenberg, and Frank Hutter. Speeding up automatic hyperparameter optimization of deep neural networks by extrapolation of learning curves. IJCAI, 2015.
168
+
169
+ Xavier Glorot and Yoshua Bengio. Understanding the difficulty of training deep feedforward neural networks. AISTATS, 9:249–256, 2010.
170
+
171
+ Ian J Goodfellow, David Warde-Farley, Mehdi Mirza, Aaron C Courville, and Yoshua Bengio. Maxout networks. ICML (3), 28:1319–1327, 2013.
172
+
173
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. arXiv preprint arXiv:1512.03385, 2015.
174
+
175
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European Conference on Computer Vision, pp. 630–645. Springer, 2016.
176
+
177
+ Yangqing Jia, Evan Shelhamer, Jeff Donahue, Sergey Karayev, Jonathan Long, Ross Girshick, Sergio Guadarrama, and Trevor Darrell. Caffe: Convolutional architecture for fast feature embedding. arXiv preprint arXiv:1408.5093, 2014.
178
+
179
+ Leslie Pack Kaelbling, Michael L Littman, and Andrew W Moore. Reinforcement learning: A survey. Journal of Artificial Intelligence Research, 4:237–285, 1996.
180
+
181
+ Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
182
+
183
+ Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. Nature, 521(7553):436–444, 2015.
184
+
185
+ Chen-Yu Lee, Saining Xie, Patrick Gallagher, Zhengyou Zhang, and Zhuowen Tu. Deeplysupervised nets. AISTATS, 2(3):6, 2015.
186
+
187
+ Chen-Yu Lee, Patrick W Gallagher, and Zhuowen Tu. Generalizing pooling functions in convolutional neural networks: Mixed, gated, and tree. International Conference on Artificial Intelligence and Statistics, 2016.
188
+
189
+ Sergey Levine, Chelsea Finn, Trevor Darrell, and Pieter Abbeel. End-to-end training of deep visuomotor policies. JMLR, 17(39):1–40, 2016.
190
+
191
+ Ming Liang and Xiaolin Hu. Recurrent convolutional neural network for object recognition. CVPR, pp. 3367–3375, 2015.
192
+
193
+ Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
194
+
195
+ Long-Ji Lin. Self-improving reactive agents based on reinforcement learning, planning and teaching. Machine Learning, 8(3-4):293–321, 1992.
196
+
197
+ Long-Ji Lin. Reinforcement learning for robots using neural networks. Technical report, DTIC Document, 1993.
198
+
199
+ Min Lin, Qiang Chen, and Shuicheng Yan. Network in network. arXiv preprint arXiv:1312.4400, 2013.
200
+
201
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. Nature, 518(7540):529–533, 2015.
202
+
203
+ Nicolas Pinto, David Doukhan, James J DiCarlo, and David D Cox. A high-throughput screening approach to discovering good forms of biologically inspired visual representation. PLoS Computational Biology, 5(11):e1000579, 2009.
204
+
205
+ Adriana Romero, Nicolas Ballas, Samira Ebrahimi Kahou, Antoine Chassang, Carlo Gatta, and Yoshua Bengio. Fitnets: Hints for thin deep nets. arXiv preprint arXiv:1412.6550, 2014.
206
+
207
+ Shreyas Saxena and Jakob Verbeek. Convolutional neural fabrics. In Advances in Neural Information Processing Systems 29, pp. 4053–4061. 2016.
208
+
209
+ J David Schaffer, Darrell Whitley, and Larry J Eshelman. Combinations of genetic algorithms and neural networks: A survey of the state of the art. International Workshop on Combinations of Genetic Algorithms and Neural Networks, pp. 1–37, 1992.
210
+
211
+ Pierre Sermanet, Soumith Chintala, and Yann LeCun. Convolutional neural networks applied to house numbers digit classification. ICPR, pp. 3288–3291, 2012.
212
+
213
+ Pierre Sermanet, Koray Kavukcuoglu, Soumith Chintala, and Yann LeCun. Pedestrian detection with unsupervised multi-stage feature learning. CVPR, pp. 3626–3633, 2013.
214
+
215
+ Bobak Shahriari, Kevin Swersky, Ziyu Wang, Ryan P Adams, and Nando de Freitas. Taking the human out of the loop: A review of bayesian optimization. Proceedings of the IEEE, 104(1): 148–175, 2016.
216
+
217
+ David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. Nature, 529(7587):484–489, 2016.
218
+
219
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
220
+
221
+ Jasper Snoek, Hugo Larochelle, and Ryan P Adams. Practical bayesian optimization of machine learning algorithms. NIPS, pp. 2951–2959, 2012.
222
+
223
+ Jost Tobias Springenberg, Alexey Dosovitskiy, Thomas Brox, and Martin Riedmiller. Striving for simplicity: The all convolutional net. arXiv preprint arXiv:1412.6806, 2014.
224
+ Rupesh Kumar Srivastava, Klaus Greff, and Jurgen Schmidhuber. Highway networks. ¨ arXiv preprint arXiv:1505.00387, 2015.
225
+ Kenneth O Stanley and Risto Miikkulainen. Evolving neural networks through augmenting topologies. Evolutionary Computation, 10(2):99–127, 2002.
226
+ Kevin Swersky, Jasper Snoek, and Ryan P Adams. Multi-task bayesian optimization. NIPS, pp. 2004–2012, 2013.
227
+ Phillip Verbancsics and Josh Harguess. Generative neuroevolution for deep learning. arXiv preprint arXiv:1312.5355, 2013.
228
+ Joannes Vermorel and Mehryar Mohri. Multi-armed bandit algorithms and empirical evaluation. European Conference on Machine Learning, pp. 437–448, 2005.
229
+ Li Wan, Matthew Zeiler, Sixin Zhang, Yann L Cun, and Rob Fergus. Regularization of neural networks using dropconnect. ICML, pp. 1058–1066, 2013.
230
+ Christopher John Cornish Hellaby Watkins. Learning from delayed rewards. PhD thesis, University of Cambridge, England, 1989.
231
+
232
+ # APPENDIX
233
+
234
+ # A ALGORITHM
235
+
236
+ We first describe the main components of the MetaQNN algorithm. Algorithm 1 shows the main loop, where the parameter $M$ would determine how many models to run for a given $\epsilon$ and the parameter $K$ would determine how many times to sample the replay database to update $Q$ -values on each iteration. The function TRAIN refers to training the specified network and returns a validation accuracy. Algorithm 2 details the method for sampling a new network using the $\epsilon$ -greedy strategy, where we assume we have a function TRANSITION that returns the next state given a state and action. Finally, Algorithm 3 implements the $Q$ -value update detailed in Equation 3, with discounting factor set to 1, for an entire state sequence in temporally reversed order.
237
+
238
+ # Algorithm 1 $Q$ -learning For CNN Topologies
239
+
240
+ Initialize: replay memory $ [ ]$ $Q \{ ( s , u ) \forall s \in S , u \in \mathcal { U } ( s ) \ : \ 0 . 5 \}$
241
+ for episode $= 1$ to $M$ do $S$ , U ← SAMPLE NEW NETWORK(, Q) accuracy $ \mathrm { T R A I N } ( S )$ replay memory.append((S, U, accuracy)) for memory $= 1$ to $K$ do $S _ { S A M P L E }$ , $U _ { S A M P L E }$ , accuracySAMP LE Uniform{replay memory} $Q $ UPDATE Q VALUES( $Q$ , $S _ { S A M P L E }$ , $U _ { S A M P L E }$ , accuracySAMP LE) end for
242
+ end for
243
+
244
+ # Algorithm 2 SAMPLE NEW NETWORK(, Q)
245
+
246
+ Initialize: state sequence $S = [ s _ { \mathrm { S T A R T } } ]$ action sequence $U = [ ]$
247
+ while $U [ - 1 ] \neq$ terminate do $\alpha \sim \mathrm { U n i f o r m } [ 0 , 1 )$ if $\alpha > \epsilon$ then u = argmaxu∈U(S[−1]) Q[(S[−1], u)] s0 = TRANSITION(S[−1], u) else u ∼ Uniform{U(S[−1])} s0 = TRANSITION(S[−1], u) end if U.append $( u )$ if $u : =$ terminate then S.append $\left( s ^ { \prime } \right)$ end if
248
+ end while
249
+ return S, U
250
+
251
+ <table><tr><td>Algorithm3UPDATE_Q_VALUES(Q,S,U,accuracy)</td></tr><tr><td>Q[S[-1],U[-1]] = (1- α)Q[S[-1],U[-1] + α·accuracy</td></tr><tr><td>fori= length(S) - 2 to 0 do</td></tr><tr><td>Q[S[i],U[i]] = (1 -α)Q[S[i], U[i]] + α maxu∈u(S[i+1]) Q[S[i +1],u]</td></tr><tr><td>end for return Q</td></tr></table>
252
+
253
+ # B REPRESENTATION SIZE BINNING
254
+
255
+ As mentioned in Section 4.1 of the main text, we introduce a parameter called representation size to prohibit the agent from taking actions that can reduce the intermediate signal representation to a size that is too small for further processing. However, this process leads to uncertainties in state transitions, as illustrated in Figure A1, which is handled by the standard $Q$ -learning formulation.
256
+
257
+ ![](images/bbf152a1215e64fdb34aeb4684b1733d98942af3e1032056d78615c9c7da28af.jpg)
258
+ Figure A1: Representation size binning: In this figure, we show three example state transitions. The true representation size ( $R$ -size) parameter is included in the figure to show the true underlying state. Assuming there are two $R$ -size bins, $R$ -size $\mathrm { B i n _ { 1 } }$ : $[ 8 , \infty )$ and $R$ -size $\mathrm { B i n _ { 2 } }$ : (0, 7], Figure A1a shows the case where the initial state is in $R$ -size $\mathrm { B i n _ { 1 } }$ and true representation size is 18. After the agent chooses to pool with a $2 \times 2$ filter with stride 2, the true representation size reduces to 9 but the $R$ -size bin does not change. In Figure A1b, the same $2 \times 2$ pooling layer with stride 2 reduces the actual representation size of 14 to 7, but the bin changes to $R$ -size $\mathrm { B i n _ { 2 } }$ . Therefore, in figures A1a and A1b, the agent ends up in different final states, despite originating in the same initial state and choosing the same action. Figure A1c shows that in our state-action space, when the agent takes an action that reduces the representation size, it will have uncertainty in which state it will transition to.
259
+
260
+ # C MNIST EXPERIMENT
261
+
262
+ We noticed that the final MNIST models were prone to overfitting, so we increased dropout and did a small grid search for the weight regularization parameter. For both tuning and final training, we warmed the model with the learned weights from after the first epoch of initial training. The final models and solvers can be found on our project website https://bowenbaker.github.io/metaqnn/. Figure A2 shows the $Q$ -Learning performance for the MNIST experiment.
263
+
264
+ # D FURTHER ANALYSIS OF $Q$ -LEARNING
265
+
266
+ Figure 3 of the main text and Figure A2 show that as the agent begins to exploit, it improves in architecture selection. It is also informative to look at the distribution of models chosen at each $\epsilon$ . Figure A4 gives further insight into the performance achieved at each $\epsilon$ for both experiments.
267
+
268
+ # D.1 $Q$ -LEARNING STABILITY
269
+
270
+ Because the $Q$ -learning agent explores via a random or semi-random distribution, it is natural to ask whether the agent can consistently improve architecture performance. While the success of the three independent experiments described in the main text allude to stability, here we present further evidence. We conduct 10 independent runs of the $Q$ -learning procedure on $10 \%$ of the SVHN dataset (which corresponds to $\sim 7 { , } 0 0 0$ training examples). We use a smaller dataset to reduce the computation time of each independent run to 10GPU-days, as opposed to the 100GPU-days it would take on the full dataset. As can be seen in Figure A3, the $Q$ -learning procedure with the exploration schedule detailed in Table 2 is fairly stable. The standard deviation at $\epsilon = 1$ is notably smaller than at other stages, which we attribute to the large difference in number of samples at each stage.
271
+
272
+ ![](images/1040a48db3c9107445d63faf705edb1033b4dc791f36b6e6a2203c2e49609895.jpg)
273
+ Figure A2: MNIST $Q$ -Learning Performance. The blue line shows a rolling mean of model accuracy versus iteration, where in each iteration of the algorithm the agent is sampling a model. Each bar (in light blue) marks the average accuracy over all models that were sampled during the exploration phase with the labeled $\epsilon$ . As $\epsilon$ decreases, the average accuracy goes up, demonstrating that the agent learns to select better-performing CNN architectures.
274
+
275
+ ![](images/a64860a6aa693382887f15593297e5ca583d08775c931f3f68c8338f77f67885.jpg)
276
+ Figure A3: Figure A3a shows the mean model accuracy and standard deviation at each $\epsilon$ over 10 independent runs of the $Q$ -learning procedure on $10 \%$ of the SVHN dataset. Figure A3b shows the mean model accuracy at each $\epsilon$ for each independent experiment. Despite some variance due to a randomized exploration strategy, each independent run successfully improves architecture performance.
277
+
278
+ Furthermore, the best model found during each run had remarkably similar performance with a mean accuracy of $8 8 . 2 5 \%$ and standard deviation of $0 . 5 8 \%$ , which shows that each run successfully found at least one very high performing model. Note that we did not use an extended training schedule to improve performance in this experiment.
279
+
280
+ # D.2 $Q$ -VALUE ANALYSIS
281
+
282
+ We now analyze the actual $Q$ -values generated by the agent during the training process. The learning agent iteratively updates the $Q$ -values of each path during the $\epsilon$ -greedy exploration. Each $Q$ -value is initialized at 0.5. After the $\epsilon$ -schedule is complete, we can analyze the final $Q$ -value associated with each path to gain insights into the layer selection process. In the left column of Figure A5, we plot the average $Q$ -value for each layer type at different layer depths (for both SVHN and CIFAR10) datasets. Roughly speaking, a higher $Q$ -value associated with a layer type indicates a higher probability that the agent will pick that layer type. In Figure A5, we observe that, while the average $Q$ -value is higher for convolution and pooling layers at lower layer depths, the $Q$ -values for fullyconnected and termination layers (softmax and global average pooling) increase as we go deeper into the network. This observation matches with traditional network designs.
283
+
284
+ We can also plot the average $Q$ -values associated with different layer parameters for further analysis. In the right column of Figure A5, we plot the average $Q$ -values for convolution layers with receptive field sizes 1, 3, and 5 at different layer depths. The plots show that layers with receptive field size of 5 have a higher $Q$ -value as compared to sizes 1 and 3 as we go deeper into the networks. This indicates that it might be beneficial to use larger receptive field sizes in deeper networks.
285
+
286
+ In summary, the $Q$ -learning method enables us to perform analysis on the relative benefits of different design parameters of our state space, and possibly gain insights for new CNN designs.
287
+
288
+ # E TOP TOPOLOGIES SELECTED BY ALGORITHM
289
+
290
+ In Tables A1 through A3, we present the top five model architectures selected with Q-learning for each dataset, along with their prediction error reported on the test set, and their total number of parameters. To download the Caffe solver and prototext files, please visit https://bowenbaker.github.io/metaqnn/.
291
+
292
+ Table A1: Top 5 model architectures: CIFAR-10.
293
+
294
+ <table><tr><td rowspan=1 colspan=1>Model Architecture</td><td rowspan=1 colspan=1>Test Error (%)</td><td rowspan=1 colspan=1>#Params (10)</td></tr><tr><td rowspan=1 colspan=1>[C(512,5,1), C(256,3,1), C(256,5,1), C(256,3,1),P(5,3),C(512,3,1),C(512,5,1), P(2,2), SM(10)]</td><td rowspan=1 colspan=1>6.92</td><td rowspan=1 colspan=1>11.18</td></tr><tr><td rowspan=1 colspan=1>[C(128,1,1),C(512,3,1),C(64,1,1), C(128,3,1),P(2,2),C(256,3,1),P(2,2), C(512,3,1),P(3,2),,SM(10)]</td><td rowspan=1 colspan=1>8.78</td><td rowspan=1 colspan=1>2.17</td></tr><tr><td rowspan=1 colspan=1>[C(128,3,1),C(128,1,1),C(512,5,1),P(2,2),C(128,3,1),P(2,2),C(64,3,1),C(64,5,1), S(10)]</td><td rowspan=1 colspan=1>8.88</td><td rowspan=1 colspan=1>2.42</td></tr><tr><td rowspan=1 colspan=1>[C(256,3,1),C(256,3,1),P(5,3),C(256,1,1),C(128,3,1),P(2,2),C(128,3,1), ,SM(10)]</td><td rowspan=1 colspan=1>9.24</td><td rowspan=1 colspan=1>1.10</td></tr><tr><td rowspan=1 colspan=1>[C(128,5,1),C(512,3,1),P(2,2),C(128,1,1),C(128,5,1),P(3,2),C(512,3,1), SM(10)]</td><td rowspan=1 colspan=1>11.63</td><td rowspan=1 colspan=1>1.66</td></tr></table>
295
+
296
+ <table><tr><td rowspan=1 colspan=1>Model Architecture</td><td rowspan=1 colspan=1>Test Error (%)</td><td rowspan=1 colspan=1>#Params (106)</td></tr><tr><td rowspan=1 colspan=1>[C(128,3,1), P(2,2),C(64,5,1),C(512,5,1),C(256,3,1),C(512,3,1),P(2,2), C(512,3,1),C(256,5,1),C(256,3,1),C(128,5,1),C(64,3,1),SM(10)]</td><td rowspan=1 colspan=1>2.24</td><td rowspan=1 colspan=1>9.81</td></tr><tr><td rowspan=1 colspan=1>[C(128,1,1), C(256,5,1),C(128,5,1), P(2,2),C(256,5,1),C(256,1,1),C(256,3,1), C(256,3,1), C(256,5,1), C(512,5,1), C(256,3,1),C(128,3,1), SM(10)]</td><td rowspan=1 colspan=1>2.28</td><td rowspan=1 colspan=1>10.38</td></tr><tr><td rowspan=1 colspan=1>[C(128,5,1), C(128,3,1),C(64,5,1),P(5,3),C(128,3,1),C(512,5,1),C(256,5,1), C(128,5,1), C(128,5,1),,C(128,3,1), SM(10)]</td><td rowspan=1 colspan=1>2.32</td><td rowspan=1 colspan=1>6.83</td></tr><tr><td rowspan=1 colspan=1>[C(128,1,1),C(256,5,1),C(128,5,1),C(256,3,1),C(256,5,1), P(2,2),C(128,1,1),C(512,3,1),C(256,5,1),P(2,2),C(64,5,1),C(64,1,1),SM(10)]</td><td rowspan=1 colspan=1>2.35</td><td rowspan=1 colspan=1>6.99</td></tr><tr><td rowspan=1 colspan=1>[C(128,1,1), C(256,5,1), C(128,5,1), C(256,5,1), C(256,5,1),C(256,1,1), P(3,2), C(128,1,1),C(256,5,1),C(512,5,1),C(256,3,1),C(128,3,1), SM(10)]</td><td rowspan=1 colspan=1>2.36</td><td rowspan=1 colspan=1>10.05</td></tr></table>
297
+
298
+ Table A2: Top 5 model architectures: SVHN. Note that we do not report the best accuracy on test set from the above models in Tables 3 and 4 from the main text. This is because the model that achieved $2 . 2 8 \%$ on the test set performed the best on the validation set.
299
+
300
+ <table><tr><td rowspan=1 colspan=1>Model Architecture</td><td rowspan=1 colspan=1>Test Error (%)</td><td rowspan=1 colspan=1>#Params (10)</td></tr><tr><td rowspan=1 colspan=1>[C(64,1,1),C(256,3,1),P(2,2),C(512,3,1), C(256,1,1), P(5,3),C(256,3,1), C(512,3,1),FC(512), SM(10)]</td><td rowspan=1 colspan=1>0.35</td><td rowspan=1 colspan=1>5.59</td></tr><tr><td rowspan=1 colspan=1>[C(128,3,1), C(64,1,1),C(64,3,1), C(64,5,1), P(2,2), C(128,3,1), P(3,2),C(512,3,1), FC(512),FC(128), S(10)]</td><td rowspan=1 colspan=1>0.38</td><td rowspan=1 colspan=1>7.43</td></tr><tr><td rowspan=1 colspan=1>[C(512,1,1), C(128,3,1), C(128,5,1), C(64,1,1), C(256,5,1), C(64,1,1),P(5,3), C(512,1,1), C(512,3,1), C(256,3,1), C(256,5,1), C(256,5,1),SM(10)]</td><td rowspan=1 colspan=1>0.40</td><td rowspan=1 colspan=1>8.28</td></tr><tr><td rowspan=1 colspan=1>[C(64,3,1), C(128,3,1), C(512,1,1), C(256,1,1), C(256,5,1), C(128,3,1),P(5,3), C(512,1,1), C(512,3,1), C(128,5,1), SM(10)]</td><td rowspan=1 colspan=1>0.41</td><td rowspan=1 colspan=1>6.27</td></tr><tr><td rowspan=1 colspan=1>[C(64,3,1),C(128,1,1),P(2,2), C(256,3,1),C(128,5,1),C(64,1,1),C(512,5,1), C(128,5,1), C(64,1,1), C(512,5,1), C(256,5,1), C(64,5,1),SM(10)]</td><td rowspan=1 colspan=1>0.43</td><td rowspan=1 colspan=1>8.10</td></tr><tr><td rowspan=1 colspan=1>[C(64,1,1),C(256,5,1),,C(256,5,1),C(512,1,1),C(64,3,1),P(5,3),C(256,5,1), C(256,5,1), C(512,5,1), C(64,1,1), C(128,5,1), C(512,5,1),SM(10)]</td><td rowspan=1 colspan=1>0.44</td><td rowspan=1 colspan=1>9.67</td></tr><tr><td rowspan=1 colspan=1>[C(128,3,1), C(512,3,1),P(2,2), C(256,3,1),,C(128,5,1),C(64,1,1),C(64,5,1), C(512,5,1), GAP(10), SM(10)]</td><td rowspan=1 colspan=1>0.44</td><td rowspan=1 colspan=1>3.52</td></tr><tr><td rowspan=1 colspan=1>[C(256,3,1), C(256,5,1), C(512,3,1), C(256,5,1),C(512,1,1),P(5,3),C(256,3,1), C(64,3,1), C(256,5,1), C(512,3,1), C(128,5,1), C(512,5,1),SM(10)]</td><td rowspan=1 colspan=1>0.46</td><td rowspan=1 colspan=1>12.42</td></tr><tr><td rowspan=1 colspan=1>[C(512,5,1), C(128,5,1), C(128,5,1), C(128,3,1), C(256,3,1),C(512,5,1), C(256,3,1), C(128,3,1), S(10)]</td><td rowspan=1 colspan=1>0.55</td><td rowspan=1 colspan=1>7.25</td></tr><tr><td rowspan=1 colspan=1>[C(64,5,1),C(512,5,1),P(3,2),C(256,5,1),C(256,3,1),C(256,3,1),C(128,1,1),C(256,3,1), C(256,5,1), C(64,1,1), C(256,3,1),C(64,3,1),SM(10)]</td><td rowspan=1 colspan=1>0.56</td><td rowspan=1 colspan=1>7.55</td></tr></table>
301
+
302
+ Table A3: Top 10 model architectures: MNIST. We report the top 10 models for MNIST because we included all 10 in our final ensemble. Note that we do not report the best accuracy on test set from the above models in Tables 3 and 4 from the main text. This is because the model that achieved $0 . 4 4 \%$ on the test set performed the best on the validation set.
303
+
304
+ ![](images/fd32a7a7238161bd217f837e7aa678dfc6a19faca503b359140d345a8d6ea0ab.jpg)
305
+ Figure A4: Accuracy Distribution versus $\epsilon$ : Figures A4a, A4c, and A4e show the accuracy distribution for each $\epsilon$ for the SVHN, CIFAR-10, and MNIST experiments, respectively. Figures A4b, A4d, and A4f show the accuracy distributions for the initial $\epsilon = 1$ and the final $\epsilon = 0 . 1$ . One can see that the accuracy distribution becomes much more peaked in the high accuracy ranges at small $\epsilon$ for each experiment.
306
+
307
+ ![](images/7533dcaeb55b1d1b05fd06f4deb470699d4d0219efe173f88397cbc8c105105c.jpg)
308
+ Figure A5: Average $Q$ -Value versus Layer Depth for different layer types are shown in the left column. Average $Q$ -Value versus Layer Depth for different receptive field sizes of the convolution layer are shown in the right column.
md/train/S1lvm305YQ/S1lvm305YQ.md ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TIMBRETRON: A WAVENET(CYCLEGAN(CQT(AUDIO))) PIPELINE FOR MUSICAL TIMBRE TRANSFER
2
+
3
+ Sicong Huang1,2, Qiyang $\mathbf { L i } ^ { 1 , 2 }$ , $\mathbf { C e m \mathbf { A n i l } ^ { 1 , 2 } }$ , Xuchan $\mathbf { B a o } ^ { 1 , 2 }$ , Sageev Oore2,3, Roger B. Grosse1, University of Toronto1, Vector Institute2, Dalhousie University3
4
+
5
+ # ABSTRACT
6
+
7
+ In this work, we address the problem of musical timbre transfer, where the goal is to manipulate the timbre of a sound sample from one instrument to match another instrument while preserving other musical content, such as pitch, rhythm, and loudness. In principle, one could apply image-based style transfer techniques to a time-frequency representation of an audio signal, but this depends on having a representation that allows independent manipulation of timbre as well as highquality waveform generation. We introduce TimbreTron, a method for musical timbre transfer which applies “image” domain style transfer to a time-frequency representation of the audio signal, and then produces a high-quality waveform using a conditional WaveNet synthesizer. We show that the Constant Q Transform (CQT) representation is particularly well-suited to convolutional architectures due to its approximate pitch equivariance. Based on human perceptual evaluations, we confirmed that TimbreTron recognizably transferred the timbre while otherwise preserving the musical content, for both monophonic and polyphonic samples. We made an accompanying demo video 1 which we strongly encourage you to watch before reading the paper.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Timbre is a perceptual characteristic that distinguishes one musical instrument from another playing the same note with the same intensity and duration. Modeling timbre is very hard, and it has been referred to as “the psychoacoustician’s multidimensional waste-basket category for everything that cannot be labeled pitch or loudness”2. The timbre of a single note at a single pitch has a nonlinear dependence on the volume, time and even the particular way the instrument is played by the performer. While there is a substantial body of research in timbre modelling and synthesis (Chowning (1973); Risset and Wessel (1999); Smith (2010; 2011)), state-of-the-art musical sound libraries used by orchestral composers for analog instruments (e.g. the Vienna Symphonic Library (GmbH, 2018)) are still obtained by extremely careful audio sampling of real instrument recordings. Being able to model and manipulate timbre electronically carries importance for musicians who wish to experiment with different sounds, or compose for multiple instruments. (Appendix A discusses the components of music in more detail.)
12
+
13
+ In this paper, we consider the problem of high quality timbre transfer between audio clips obtained with different instruments. More specifically, the goal is to transform the timbre of a musical recording to match a set of reference recordings while preserving other musical content, such as pitch and loudness. We take inspiration from recent successes in style transfer for images using neural networks (Gatys et al., 2015; Johnson et al., 2016; Ulyanov et al., 2016; Chu et al., 2017). An appealing strategy would be to directly apply image-based style transfer techniques to time-frequency representations of images, such as short-time Fourier transform (STFT) spectrograms. However, needing to convert the generated spectrogram into a waveform presents a fundamental obstacle, since accurate reconstruction requires phase information, which is difficult to predict (Engel et al., 2017), and existing techniques for inferring phase (e.g., Griffin and Lim (1984)) can produce characteristic artifacts which are undesirable for high quality audio generation (Shen et al., 2017).
14
+
15
+ Recent years have seen rapid progress on audio generation methods that directly generate high-quality waveforms, such as WaveNet (van den Oord et al., 2016), SampleRNN (Mehri et al., 2016), and Tacotron2 (Shen et al., 2017). WaveNet’s ability to condition on abstract audio representations is particularly relevant, since it enables one to perform manipulations in high-level auditory representations from which reconstruction would have previously been impractical. Tacotron2 performs high-level processing on time-frequency representations of speech, and then uses WaveNet to output high-quality audio conditioned on the generated mel spectrogram.
16
+
17
+ We adapt this general strategy to the music domain. We propose TimbreTron, a pipeline that performs CQT-based timbre transfer with high-quality waveform output. It is trained only on unrelated samples of two instruments. For our time-frequency representation, we choose the constant Q transform (CQT), a perceptually motivated representation of music (Brown, 1991). We show that this representation is particularly well-suited to musical timbre transfer and other manipulations due to its pitch equivariance and the way it simultaneously achieves high frequency resolution at low frequencies and high temporal resolution at high frequencies, a property that STFT lacks.
18
+
19
+ TimbreTron performs timbre transfer by three steps, shown in Figure 1. First, it computes the CQT spectrogram and treats its log-magnitude values as an image (discarding phase information). Second, it performs timbre transfer in the log-CQT domain using a CycleGAN (Zhu et al., 2017). Finally, it converts the generated log-CQT to a waveform using a conditional WaveNet synthesizer (which implicitly must infer the missing phase information). Empirically, our TimbreTron can successfully perform musical timbre transfer on some instrument pairs. The generated audio samples have realistic timbre that matches the target timbre while otherwise expressing the same musical content (e.g., rhythm, loudness, pitch). We empirically verified that the use of a CQT representation is a crucial component in TimbreTron as it consistently yields qualitatively better timbre transfer than its STFT counterpart.
20
+
21
+ ![](images/b1f409115a04244b694817878bd6141c021e063d063f1f26e0d9c9e55d01559e.jpg)
22
+ Figure 1: The TimbreTron pipeline that performs timbre transfer from Violin to Flute.
23
+
24
+ # 2 BACKGROUND
25
+
26
+ # 2.1 TIME-FREQUENCY ANALYSIS
27
+
28
+ Time-frequency analysis refers to techniques that aim to measure how the signal’s frequency domain representation changes over time.
29
+
30
+ Short Time Fourier Transform (STFT) The STFT is one of the most commonly applied techniques for this purpose. The discrete STFT operation can be compactly expressed as follows:
31
+
32
+ $$
33
+ S T F T \{ x [ n ] \} ( m , \omega _ { k } ) = \sum _ { n = - \infty } ^ { \infty } x [ n ] w [ n - m ] e ^ { - j \omega _ { k } n }
34
+ $$
35
+
36
+ The above formula computes the STFT of an input time-domain signal $x [ n ]$ at time step $m$ and frequency $\omega _ { k }$ . $w$ refers to a zero-centered window function (such as Hann Window), which acts as a means of masking out the values that are away from $m$ . Hence, the equation above can be interpreted as the discrete Fourier transform of the masked signal $x [ n ] w [ n - m ]$ . An example spectrogram is shown in Figure 2.
37
+
38
+ Constant Q Transform (CQT). The CQT (Brown, 1991) is another time-frequency analysis technique in which the frequency values are geometrically spaced, with the following particular pattern (Blankertz): $\omega _ { k } = 2 ^ { \frac { k } { b } } \omega _ { 0 }$ . Here, $k \in \{ 1 , 2 , 3 , . . . k _ { m a x } \}$ and $b$ is a constant that determines the geometric separation between the different frequency bands. To make the filter for different frequencies adjacent to each other, the bandwidth of the $k ^ { t h }$ filter is chosen as: $\Delta _ { k } = \omega _ { k + 1 } - \omega _ { k } = \omega _ { k } ( \bar { 2 } ^ { \frac { 1 } { b } } - 1 )$ . This results in a constant frequency to resolution ratio (as known as the “quality (Q) factor”):
39
+
40
+ $$
41
+ Q = \frac { \omega _ { k } } { \Delta _ { k } } = ( 2 ^ { \frac { 1 } { b } } - 1 ) ^ { - 1 }
42
+ $$
43
+
44
+ Huzaifah (2017) showed that CQT consistently outperformed traditional representations such as Mel-frequency cepstral coefficients (MFCCs) in environmental sound classification tasks using CNNs.
45
+
46
+ Rainbowgram. Engel et al. (2017) introduced the rainbowgram, a visualization of the CQT which uses color to encode time derivatives of phase; this highlights subtle timbral features which are invisible in a magnitude CQT. Examples of CQTs and rainbowgrams are shown in Figure 2.
47
+
48
+ ![](images/a57fed0d78aca8db561770bf227181c481148ab08f6c4d404ef43aa4071cf60d.jpg)
49
+ Figure 2: The STFT of a piano clip (left), the CQT of the same piano clip (second left), the rainbowgram of the same piano clip (second right) and the rainbowgram of a flute clip which has the same pitch as the first piano clip (right). Note that the harmonics of different pitches are approximate translations of each other in the CQT representation.
50
+
51
+ # 2.2 WAVEFORM RECONSTRUCTION FROM SPECTROGRAMS
52
+
53
+ Synthesis (waveform reconstruction) from the aforementioned time-frequency analysis techniques can be performed in the presence of both magnitude and phase information (Allen and Rabiner, 1977) (Holighaus et al., 2013). In the absence of phase information, one of the common methods of synthetically generating phase from STFT magnitude is the Griffin-Lim algorithm (Griffin and Lim, 1984). This algorithm works by randomly guessing the phase values, and iteratively refining them by performing STFT and inverse STFT operations until convergence, while keeping the magnitude values constant throughout the process. Developed to minimize the mean squared error between the target spectrogram and predicted spectrogram, this algorithm is shown to reduce the objective function at each iteration, while having no optimality guarantees due to the non-convexity of the optimization problem (Griffin and Lim, 1984; Sturmel and Daudet) Although recent developments in the field have enabled performing the inverse operation of CQT (Velasco et al., 2011; Fitzgerald et al., 2006), these techniques still require both phase and magnitude information.
54
+
55
+ # 2.3 WAVENET
56
+
57
+ WaveNet, proposed by van den Oord et al. (2016), is an auto-regressive generative model for generating raw audio waveform with high quality. The model consists of stacks of dilated causal convolution layers with residual and skip connections. WaveNet can be easily modified to perform conditional waveform generation; for example, it can be trained as a vocoder for synthesizing natural, high-quality human speech in TTS systems from low-level acoustic features (e.g., phoneme, fundamental frequency, and spectrogram) (Arik et al., 2017; Shen et al., 2017). One limitation of WaveNet is that the generation of waveforms can be expensive, which is undesirable for training procedures that require auto-regressive generation (e.g., GAN training, scheduled sampling).
58
+
59
+ # 2.4 GAN AND CYCLEGAN
60
+
61
+ Generative Adversarial Networks (GANs) are a class of implicit generative models introduced by Goodfellow et al. (2014). A GAN consists of a discriminator and a generator, which are trained
62
+
63
+ adversarially via a two-player min-max game, where the discriminator attempts to distinguish real data from samples, and the generator attempts to fool the discriminator. The objective is:
64
+
65
+ $$
66
+ G ^ { * } , D ^ { * } = \underset { G } { \mathrm { a r g } } \underset { D } { \mathrm { m i n } } \underset { - } { \mathrm { m a x } } \mathbb { E } _ { x \sim \mathcal { X } } [ \log D ( x ) ] + \mathbb { E } _ { z \sim \mathcal { Z } } [ \log ( 1 - D ( G ( z ) ) ) ] ,
67
+ $$
68
+
69
+ where $D$ is the discriminator, $G$ is the generator, $z$ is the latent code vector sampled from Gaussian distribution $\mathcal { Z }$ , and $x$ is sampled from data distribution $\mathcal { X }$ . GANs constituted a significant advance over previous generative models in terms of the quality of the generated samples.
70
+
71
+ CycleGAN (Zhu et al., 2017) is an architecture for unsupervised domain transfer: learning a mapping between two domains without any paired data. (Similar architectures were proposed independently by Yi et al. (2017); Liu et al. (2017); Kim et al. (2017).) The CycleGAN learns two generator mappings: $F : \mathcal { X } \mathcal { Y }$ and $G : \mathcal { y } \mathcal { x }$ ; and two discriminators: $D _ { \mathcal { X } } : \mathcal { X } [ 0 , 1 ]$ and $D y : \mathcal { Y } [ 0 , 1 ]$ . The loss function of CycleGAN consists of both adversarial losses (Eqn. 1), combined with a cycle consistency constraint which forces it to preserve the structure of the input:
72
+
73
+ $$
74
+ \mathcal { L } _ { \mathrm { c y c } } ( F , G , \mathcal { X } , \mathcal { Y } ) = \mathbb { E } _ { x \sim \mathcal { X } } [ \| G ( F ( x ) ) - x \| _ { 1 } ] + \mathbb { E } _ { y \sim \mathcal { Y } } [ \| F ( G ( y ) ) - y \| _ { 1 } ]
75
+ $$
76
+
77
+ # 3 MUSIC PROCESSING WITH CONSTANT-Q-TRANSFORM REPRESENTATION
78
+
79
+ This section focuses on the first and last steps of the TimbreTron pipeline: the steps related to the transforming raw waveforms to and from time frequency representations. We explain our reasoning for choosing the CQT representation and introduce our conditional WaveNet synthesizer which converts a (possibly generated) CQT to a high-quality audio waveform.
80
+
81
+ # 3.1 CQT FOR MUSIC REPRESENTATION
82
+
83
+ The CQT representation (Brown, 1991) has desirable characteristics that make it especially suitable for processing musical audio signals. It uses a logarithmic representation of frequency, where the frequencies are generally chosen to exactly cover all the pitches present in the twelve tone, welltempered scale. Unlike the STFT, the CQT has higher frequency resolution towards lower frequencies, which leads to better pitch resolution for lower register instruments (such as cello or trombone), and higher time resolution towards higher frequencies, which is advantageous for recovering the fine timing of rhythms. Since individual notes contain information across many frequencies (due to their pattern of overtones), this combination of resolutions ought to allow simultaneous recovery of pitch and timing information for any particular note. (While this information is preserved in the signal, waveform recovery is a difficult problem in practice; this is discussed in Section 3.2).
84
+
85
+ Another key feature of the CQT representation in the context of TimbreTron is (approximate) pitch equivariance. Thanks to the geometric spacing of frequencies, a pitch shift corresponds (approximately) to a vertical translation of the “spectral signature” (unique pattern of harmonics) of musical instruments. This means that the convolution operation is approximately equivariant under pitch translation, which allows convolutional architectures to share structure between different pitches. A demonstration of this can be seen in Figure 3. Since the harmonics of a musical instrument are approximately integer multiples of the fundamental frequency, scaling the fundamental frequency (hence the pitch) corresponds to a constant shift in all of the harmonics in log scale.
86
+
87
+ We also want to emphasize on some of the reasons why the equivariance is only approximate:
88
+
89
+ • Imperfect multiples: In real audio samples from instruments, the harmonics are only approximately integer multiples of the fundamental frequency, due to the material properties of the instruments producing the sound. Dependence of spectral signature on pitch and beyond: For each pitch, each instrument has a slightly different spectral signature, meaning that a simple translation in the frequency axis cannot completely account for the changes in the frequency spectrum. Furthermore, even at a given pitch it can still change depending on how it’s played.
90
+
91
+ We used 16ms frame hop (256 time steps under 16kHz). More details can be found in Appendix B.
92
+
93
+ ![](images/e442b9be8a1678a84bb23998a313c9a0c0c16bbf0976d414ba21b7f0dc9970a9.jpg)
94
+ Figure 3: The rainbowgram of a C major scale played by piano.
95
+
96
+ 3.2 WAVEFORM RECONSTRUCTION FROM CQT REPRESENTATION USING CONDITIONAL WAVENET
97
+
98
+ Since empirical studies have shown it is difficult to directly predict phase in time-frequency representations (Engel et al., 2017), we discard the phase information and perform the image-based processing directly on a log-amplitude CQT representation. Therefore, in order to recover a waveform consistent with the generated CQT, we need to infer the missing phase information, which is a difficult problem (Velasco et al., 2011).
99
+
100
+ To convert log magnitude CQT spectrograms back to waveforms, we use a 40-layer conditional WaveNet with the dilation rate of $2 ^ { k }$ (mod 10) for the $k ^ { \mathrm { { t h } } }$ layer. The model is trained using pairs of a CQT and a waveform; this requires only a collection of unlabeled waveforms, since the CQT can be computed from the waveform.3 See Appendix C.4 for the details of the WaveNet architecture. WaveNet reconstructed audio samples can be found here4
101
+
102
+ Beam Search Because the conditional WaveNet generates stochastically from its predictive distribution, it sometimes produces low-probability outputs, such as hallucinated notes. Also, because it has difficulty modeling the local loudness, the loudness often drifts significantly over the timescale of seconds. While these issues could potentially be addressed by improving the WaveNet architecture or training method, we instead take the perspective that the WaveNet’s role is to produce a waveform which matches the target CQT. Since the above artifacts are macro-scale errors which happen only stochastically, the WaveNet has a significant probability of producing high-quality outputs over a short segment (e.g. hundreds of milliseconds). Therefore, we perform a beam search using the WaveNet’s generations in order to better match the target CQT. See Appendix C.5 for more details about our beam search procedure.
103
+
104
+ Reverse Generation In early experiments, we observed that percussive attacks (onset characteristics of an instrument in which it reaches a large amplitude quickly) are sometimes hard to model during forward generation, resulting in multiple attacks or missing attacks. We believe this problem occurs because it is difficult to determine the onset of a note from a CQT spectrogram (in which information is blurred in frequency), and it is difficult to predict precise pitch at the note onset due to the broad frequency spectrum at that moment. We found that the problems of missing and doubled attacks could be mostly solved by having the WaveNet generate the waveform samples in reverse order, from end to beginning.
105
+
106
+ # 4 TIMBRE TRANSFER WITH CYCLEGAN ON CQT REPRESENTATION
107
+
108
+ In this section, we describe the middle step of our TimbreTron pipeline, which performs timbre transfer on log-amplitude CQT representations of the waveforms. As training data, we have collections of unrelated recordings of different musical instruments. Hence, our timbre transfer problem on log-amplitude CQT “images” is an instance of unsupervised “image-to-image” translation. To achieve this, we applied the CycleGAN architecture, but adapted it in several ways to make it more effective for time-frequency representations of audio.
109
+
110
+ Removing Checkerboard Artifacts The convnet-resnet-deconvnet based generators from the original CycleGAN led to significant checkerboard artifacts in the generated CQT, which corresponds to severe noise in the generated waveform. To alleviate this problem, we replaced the deconvolution operation with nearest neighbor interpolation followed with regular convolution, as recommended by Odena et al. (2016).
111
+
112
+ Full-Spectrogram Discriminator Due to the local nature of the original CycleGAN’s transformations, Zhu et al. (2017) found it advantageous for the discriminator only to process a local patch of the image. However, when generating spectrograms, it’s crucial that different partials of the same pitch be consistent with each other; a discriminator which is local in frequency cannot enforce this. Therefore, we gave the discriminator the full spectrogram as input.
113
+
114
+ Gradient Penalty(GP) Replacing the patch discriminator with the full-spectrogram one led to unstable training dynamics because the discriminator was too powerful. To compensate for this, we added the Gradient Penalty(GP) (Gulrajani et al., 2017) to enforce a soft Lipschitz constraint:
115
+
116
+ $$
117
+ \mathcal { L } _ { \mathrm { G P } } ( G , D , \mathcal { Z } , \hat { \mathcal { X } } ) = \alpha \cdot \mathbb { E } _ { \hat { x } \sim \hat { x } } [ ( \| \nabla _ { \hat { x } } D ( \hat { x } ) \| _ { 2 } - 1 ) ^ { 2 } ]
118
+ $$
119
+
120
+ Here $\hat { \mathcal X }$ are samples taken along a line between the true data distribution $\mathcal { X }$ and the generator’s data distribution $\mathcal { X } _ { g } = \{ F ( z ) | z \sim \mathcal { Z } \}$ via convex combination of a real data point and a generated data point. Fedus et al. (2018) showed empirically that the GP can stabilize GAN training. Furthermore, Gomez et al. (2018) showed that GP can also stabilize and improve CycleGAN training with word embeddings. We observed the same benefits in our experiments.
121
+
122
+ Identity loss In addition to the adversarial loss and the reconstruction loss that we applied to the generators, we also added identity loss, which was proposed by Zhu et al. (2017) to preserve color composition in the original CycleGAN. Empirically, we found out that the identity loss component helps generators to preserve music content, which yields better audio quality empirically.
123
+
124
+ $$
125
+ \mathcal { L } _ { \mathrm { i d e n t i t y } } ( F , G , \mathcal { X } , \mathcal { Y } ) = \mathbb { E } _ { x \sim \mathcal { X } } [ \| F ( x ) - y \| _ { 1 } ] + \mathbb { E } _ { y \sim \mathcal { Y } } [ \| G ( y ) - x \| _ { 1 } ]
126
+ $$
127
+
128
+ Our weighting of the identity loss followed a linear decay schedule (details in Appendix C.3). In this way, at the start of training, the generator is encouraged to learn a mapping that preserves pitch; as training progresses, the enforcement is reduced, allowing the generator to learn more expressive mappings.
129
+
130
+ See Appendix C.2, C.3, and C.6 for more details of our CycleGAN architecture, and training and generation methods.
131
+
132
+ # 5 RELATED WORK
133
+
134
+ There is a long history of using clever representations of images or audio signals in order to perform manipulations which are not straightforward on the raw signals. In a seminal work, Tenenbaum and Freeman (1999) used a multilinear representation to separate style and content of images. Ulyanov and Lebedev (2016) and Verma and Smith (2018) then applied the optimization technique proposed by Gatys et al. (2015) to the audio domain by applying the image-based architectures to spectrogram representations of the signals. Grinstein et al. (2017) took a similar approach, but used hand-crafted features to extract statistics from the spectrograms. However, a recent review by Dai et al. (2018) pointed out that the disentanglement of timbre and performance control information remains unsolved.
135
+
136
+ Zhu et al. (2017) introduced Cycle GAN approach to learn an “unsupervised image-to-image mapping” between two unpaired datasets using two generator networks and two discriminator networks with generative adversarial training. Given the success of the CycleGAN on image domain style transfer, Kaneko and Kameoka (2017) applied the same architecture to translate between human voices in the Mel-cepstral coefficient (MCEP) domain and Brunner et al. (2018) applied it to musical style transfer with MIDI representations.
137
+
138
+ What the aforementioned audio style transfer approaches have in common is that the reconstruction quality is limited by the existing non-parametric algorithms for audio reconstruction (e.g., the GriffinLim algorithm for STFT domain reconstruction (Griffin and Lim, 1984), or the WORLD vocoder for MCEP domain reconstruction of speech signals (Morise et al., 2016)), or existing MIDI synthesizer.
139
+
140
+ Another strategy is to operate directly on waveforms. van den Oord et al. (2016) demonstrated high-quality audio generation using WaveNet. Following on this, Engel et al. (2017) proposed a WaveNet-style autoencoder model operating on raw waveforms that was capable of creating new, realistic timbres by interpolating between already existing ones. Donahue et al. (2018) proposed a method to synthesize waveforms directly using GANs with improved quality over naive generative models such as SampleRNN (Mehri et al., 2016) and WaveNet. Mor et al. (2018) used an encoderdecoder approach for the Timbre Transfer problem, where they trained a universal encoder to learn a shared representation of raw waveforms of various instruments, as well as instrument-specific decoders to reconstruct waveforms from the shared representation. In a parallel work, Bitton et al. (2018) approached the many-to-many timbre transfer problem with their MoVE model which is based on UNIT (Liu et al., 2017) but with Maximum Mean Discrepancy (MMD) as their objective. While their approach has the advantage of training a single model for many transfer directions, our TimbreTron model has the advantage that it uses a GAN-based training objective, which (in the image domain) typically results in outputs with higher perceptual quality compared to VAEs.
141
+
142
+ # 6 EXPERIMENTS
143
+
144
+ We conducted two sets of experiments to 1) experiment with pitch-shifting and tempo-changing to further validate our choice of CQT representation; 2) test our full TimbreTron pipeline (along with ablation experiments to validate our architectural choices). See Appendix C for the details of our experimental setup. For this section, please listen to audio samples we provided in our website5 as you read along.
145
+
146
+ # 6.1 DATASETS
147
+
148
+ Training TimbreTron requires collections of unrelated recordings of the source and target instruments. We built our own MIDI and real world datasets of classical music for training TimbreTron. Within each type of dataset, we gathered unrelated recordings of Piano, Flute, Violin and Harpsichord and then divided the entire dataset into training set and test set. We ensured that the training and test sets were entirely disjoint in terms of musical content by splitting the datasets by musical piece. The training dataset was divided into 4-second chunks, which were the basic units processed by our CycleGAN and WaveNet. Links to source audio and more details about our dataset are given in Appendix C.1
149
+
150
+ # 6.2 DISENTANGLING PITCH AND TEMPO USING CQT REPRESENTATION
151
+
152
+ Before presenting our timbre transfer results, we first consider the simpler task of disentangling pitch and tempo. Recall that the two properties are entangled in the time domain representation, e.g. subsampling the waveform simultaneously increases the tempo and raises the pitch. Changing the two independently requires more sophisticated analysis of the signal. In the context of our TimbreTron pipeline, due to the CQT’s pitch equivariance property, pitch shifting can be (approximately) performed simply by translating the CQT representation on the log-frequency axis. (Since the STFT uses linearly sampled frequencies, it does not lend itself easily to this type of simple transformation.) Audio time stretching can be done using either the CQT or STFT representations, combined with the WaveNet synthesizer, by changing the number of waveform samples generated per CQT window. Regardless of the number of samples generated, the WaveNet synthesizer is able to produce the correct pitch based on the local frequency content. (See section 6.2 of the OneDrive folder) In conclusion, our method was able to vary the pitch and tempo independently while otherwise preserving the timbre and musical structure.
153
+
154
+ # 6.3 TIMBRE TRANSFER EXPERIMENTS
155
+
156
+ While most of our experiments on timbre transfer are conducted on real world music recordings, we also use synthetic MIDI audio data in our ablation studies because it is possible to produce paired dataset for evaluation purpose. In this section, we show our experimental findings on the full TimbreTron pipeline using real world data, verify the correctness of our reasoning about CQT, and show the generalization capability of TimbreTron.
157
+
158
+ Comparing CQT and STFT Representations One of the key design choices in TimbreTron was whether to use an STFT or CQT representation. If the STFT representation is used, there is an additional choice of whether to reconstruct using the Griffin-Lim algorithm or the conditional WaveNet synthesizer. We found that the STFT-based pipeline had two problems: 1) it sometimes failed to correctly transfer low pitches, likely due to the STFT’s poor frequency resolution at low frequencies, and 2) it sometimes produced a random permutation of pitches. For example, we ran TimbreTron on a Bach piano sample played by a professional musician. The STFT TimbreTron transposed parts of the longer excerpt by different amounts, and for a few notes in particular, seemed to fail to transpose them by the same amount as it did the others. As is shown by audio samples here6, those problems were completely solved using CQT TimbreTron (likely due to the CQT’s pitch equivariance and higher frequency resolution at low frequencies). Both of these artifacts occurred in both WaveNet and Griffin-Lim reconstruction methods (See Table 4), which suggests that the source of the artifacts are likely to be from the CycleGAN stage of the pipeline. (Please listen to corresponding samples in section 6.3 of the OneDrive folder) This empirically demonstrates the effectiveness of the CQT representation compared with STFT.
159
+
160
+ Generalizing from MIDI to Real-World Audio To further explore the generalization capability of TimbreTron, we also tried one domain adaptation experiment where we took a CycleGAN trained on MIDI data, tested it on the real world test dataset, and synthesized audio with Wavenet trained on training real world data. As is shown from the corresponding audio examples in this section7, the quality of generated audio is very good, with pitch preserved and timbre transfered. The ability to generalize from MIDI to real-world is interesting, in that it opens up the possibility of training on paired examples.
161
+
162
+ # 6.4 EVALUATION WITH AMAZON MECHANICAL TURK (AMT)
163
+
164
+ We conducted a human study to investigate whether TimbreTron could transfer the timbre of a reference collection of signals while otherwise preserving the musical content. We also evaluated the effectiveness of the CQT representation by comparing with a variant of TimbreTron with the CQT replaced by the STFT. All results are showns in Tables 2, 3 and 4, with detailed discussion in this section. A list of questions asked in AMT can be found in Table 1.
165
+
166
+ Does TimbreTron transfer timbre while preserving the musical piece? To be effective, the system must transform a given audio input so that the output is (1) recognizable as the same (or appropriately similar) basic musical piece, and (2) recognizable as the target instrument. We address both of these criteria by two types of comparison-based experiments: instrument similarity and musical piece similarity. The questions we asked are listed in Table 1. Table 2 shows results for the instrument similarity comparison and Table 3 shows results for the music piece similarity comparison. The respondents were also asked to provide their subjective judgment about the instrument used for the provided samples. The original questionnaire can be found here8.
167
+
168
+ (1) Preserving the musical piece. A different instrument playing the same notes may not always sound subjectively like the same “piece”. When this is done in musical contexts, the notes themselves are often changed in order to adapt pieces between instruments, and this is generally referred to as a
169
+
170
+ <table><tr><td colspan="2">Listen to two audio clips: (Embedded link for clip A and clip B)</td></tr><tr><td colspan="2">The clip A and B may be similar in some ways,and different in others. Rate their similarities with the following criteria:</td></tr></table>
171
+
172
+ # (i) Instrument similarity:
173
+
174
+ (a) Instrument is very similar (e.g. A and B were generated with two different pianos)
175
+ (b) Instrument is similar (A and B are in the same family: both wind instrument, or both string instrument, etc)
176
+ (c) Instrument is different
177
+ (d) I don’t know
178
+
179
+ # (ii) Musical piece similarity:
180
+
181
+ (a) Musical pieces are nearly identical (e.g. A and B are two different performances of the same piece: perhaps a few notes are different, perhaps timing is slightly different)
182
+ (b) Musical pieces are very similar (e.g. A and B are different versions of the same piece, e.g. two different arrangements)
183
+ (c) Musical pieces are related (e.g. A and B are two different, but related, pieces)
184
+ (d) Entirely different (unrelated) musical piece
185
+ (e) I don’t know
186
+
187
+ Table 1: The exact question format that was used in the AMT studies. For part (i) and (ii), participants were asked to choose one answer among the options. For part (iii) and (iv), a text box was provided for participants to type in their answers.
188
+
189
+ <table><tr><td>(iii) What instrument did clip A primarily sound like to you?</td></tr><tr><td>(iv) What instrument did clip B primarily sound like to you?</td></tr></table>
190
+
191
+ Table 2: AMT results on pair-wise instrument comparisons between our proposed TimbreTron without beam search, ground truth original instrument and ground truth target instrument. This corresponds to question type (i) in Table 1.
192
+
193
+ <table><tr><td rowspan=1 colspan=1>TotalSamples</td><td rowspan=1 colspan=1>AnswerAudio Sample</td><td rowspan=1 colspan=1>VerySimilar</td><td rowspan=1 colspan=1>Similar</td><td rowspan=1 colspan=1>Different</td><td rowspan=1 colspan=1>Do not know</td></tr><tr><td rowspan=1 colspan=1>200</td><td rowspan=1 colspan=1>Target Instrument &amp; TimbreTronGeneration</td><td rowspan=1 colspan=1>31.2%</td><td rowspan=1 colspan=1>40.5%</td><td rowspan=1 colspan=1>28.0%</td><td rowspan=1 colspan=1>0.5%</td></tr><tr><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>Original Instrument &amp;Tim+breTron Generation</td><td rowspan=1 colspan=1>23.0%</td><td rowspan=1 colspan=1>21.0%</td><td rowspan=1 colspan=1>56.0%</td><td rowspan=1 colspan=1>0.0%</td></tr></table>
194
+
195
+ new “arrangement” of an existing piece. Thus, even in the cases where we had a recording available in the target domain, the exact notes or timings were not always identical to those in the original recording from which we transferred. Overall, when we did have such a target domain recording of a real instrument, we found that for the pair of (Real Target Instrument, TimbreTron Generated Target Instrument), $6 7 . 5 \%$ of responses considered the musical pieces to be nearly identical or very similar, while roughly $2 2 . 5 \%$ considered them related and $10 \%$ considered them different. (Details in Table 3.) Thus, it appears that generally the musical piece was indeed preserved.
196
+
197
+ (2) Transferring the timbre. Evaluating this is challenging because, if the transfer is not perfect (which it is not), then judging similarity of not-quite-identical instruments is fraught with perceptual challenges. With this in mind, we included a range of pairwise comparisons and gave a likert scale with various anchors. Overall, we found that for the pair (Ground Truth Target audio, TimbreTron Generated audio), roughly $7 1 . 7 \%$ of responses considered the instrument generating the audio to be very similar (e.g. still piano, but a different piano) or similar (e.g. another string instrument). (More details in Table 2.) We also asked participants to identify the instrument that they heard in some of the audio excerpts, with an open-ended question. Generally we found that participants were indeed able to either identify the correct instrument, or confused with a very similar-sounding instrument. For example, one participant described a generated harpsichord as a banjo, which is in fact very close to harpsichord in terms of timbre. As a reference, participants had similar reasonable confusions about identifying ground truth instruments as well (e.g., one participant described a real harpsichord as being a sitar). Based on perceptual evaluations above, we claim that TimbreTron is able to transfer timbre recognizably while preserving the musical content.
198
+
199
+ Table 3: AMT results on pair-wise musical piece comparisons between our proposed TimbreTron without beam search, ground truth original instrument and ground truth target instrument. This corresponds to question type (ii) in Table 1.
200
+
201
+ <table><tr><td rowspan=1 colspan=1>TotalSamples</td><td rowspan=1 colspan=1>Answer Architecture</td><td rowspan=1 colspan=1>NearlyIdentical</td><td rowspan=1 colspan=1>VerySimilar</td><td rowspan=1 colspan=1>Related</td><td rowspan=1 colspan=1>EntirelyDifferent</td><td rowspan=1 colspan=1>Do notknow</td></tr><tr><td rowspan=1 colspan=1>200</td><td rowspan=1 colspan=1>TargetInstrument&amp;Tim+breTronGeneration</td><td rowspan=1 colspan=1>29.5%</td><td rowspan=1 colspan=1>38.0%</td><td rowspan=1 colspan=1>22.5%</td><td rowspan=1 colspan=1>10.0%</td><td rowspan=1 colspan=1>0.0%</td></tr><tr><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>OriginalInstrument&amp;Tim+breTron Generation</td><td rowspan=1 colspan=1>32.0%</td><td rowspan=1 colspan=1>21.0%</td><td rowspan=1 colspan=1>25.0%</td><td rowspan=1 colspan=1>22.0%</td><td rowspan=1 colspan=1>0.0%</td></tr></table>
202
+
203
+ Table 4: AMT results on timbre quality comparisons between our proposed TimbreTron, TimbreTron but with STFT Wavenet and TimbreTron with STFT Griffin-Lim. Participants are asked: which one of the following two samples sounds more like the instrument provided in the target instrument sample?
204
+
205
+ <table><tr><td>Total Samples</td><td>Answer Audio Sample</td><td>CQT</td><td>same</td><td>STFT</td></tr><tr><td>400</td><td>STFT+WaveNetcounterpart</td><td>54.5%</td><td>23.5%</td><td>22.0%</td></tr><tr><td>400</td><td>STFT+Griffinlimcounterpart</td><td>55.0%</td><td>25.2%</td><td>19.8%</td></tr></table>
206
+
207
+ Comparing CQT vs. STFT To empirically test if our proposed TimbreTron with CQT representation is better than its STFT-Wavenet counterpart, or its STFT-GriffinLim counterpart, we conducted a human study using AMT. The original questionnaire can be found here9 In the questionnaire, we asked Turkers to listen to three audio clips: the original audio from instrument A (the “instrument example”), the TimbreTron generated audio of instrument A, and its STFT conterparts, then asked them: “In your opinion, which one of A and B sounds more like the instrument provided in ‘instrument example”’? , where A and B in the questions are the generated samples (presented in random order). Naturally, sounding closer to the “instrument sample” means the timbre quality is better. We conducted two groups of experiment. In the first group, the STFT counterpart is the Wavenet and CycleGAN trained on STFT representation and the result is in first row of the Table 4: most people think the CQT TimbreTron is better. In the second group, we took the same CycleGAN trained on STFT, but instead simply generated the waveform using Griffin-Lim algorithm. The results are in the second row: Even more people think CQT TimbreTron is better. In conclusion, compared to Griffin-Lim as the baseline, training a Wavenet on STFT improved Timbre quality marginally. Furthermore, samples generated by TimbreTron trained on CQT was proven to have significantly better timbre quality.
208
+
209
+ # 6.5 ABLATION STUDY FOR TIMBRETRON
210
+
211
+ To better understand and justify each modification we made to the original CycleGAN, we conducted an ablation study where we removed one modification at a time for MIDI CQT experiment. (We used MIDI data for ablation because the dataset has paired samples, which provides a convenient ground truth for transfer quality evaluation.) Figure 4 demonstrates the necessity of each modification for the success of TimbreTron.
212
+
213
+ # 7 CONCLUSION
214
+
215
+ We presented the TimbreTron, a pipeline for perfoming high-quality timbre transfer on musical waveforms using CQT-domain style transfer. We perform the timbre transfer in the time-frequency domain, and then reconstruct the inputs using a WaveNet (circumventing the difficulty of phase recovery from an amplitude CQT). The CQT is particularly well suited to convolutional architectures due to its approximate pitch equivariance. The entire pipeline can be trained on unrelated real-world music segments, and intriguingly, the MIDI-trained CycleGAN demonstrated generalization capability to real-world musical signals. Based on an AMT study, we confirmed that TimbreTron recognizably transferred the timbre while otherwise preserving the musical content, for both monophonic and polyphonic samples. We believe this work constitutes a proof-of-concept for CQT-domain manipulation of musical signals with high-quality waveform outputs.
216
+
217
+ ![](images/4d9cdac31dffec220d75296140c7bee749082676986a3aa1f54d2fe1fc008b7c.jpg)
218
+ Figure 4: Rainbowgrams of the 4-second audio samples for the ablation study on MIDI test dataset. The source ground truth and the target ground truth come from a paired samples in the dataset. All other audio samples are the timbre transfer results from the source ground truth with different versions (full and ablated) of our TimbreTron. “Full Model” corresponds to the output of our final TimbreTron, which is perceptually closest to target ground truth and have the best audio quality. “Original discriminator” or “Original generator” corresponds to the TimbreTron pipeline with the discriminator or generator replaced by the original discriminator or generator in the original CycleGAN. “No gradient penalty”, “No identity loss”, and “No data augmentation” refer to the full model without the corresponding modifications. “Baseline” is the original CycleGAN (Zhu et al., 2017)
219
+
220
+ # ACKNOWLEDGMENTS
221
+
222
+ We thank Doug Eck, Jesse Engel, Phillip Isola, Eleni Triantafillou and Sanja Fidler for helpful discussions. We also thank Aidan Gomez and For.ai for early codebase development and coding advice.
223
+
224
+ # REFERENCES
225
+
226
+ Jont B Allen and Lawrence R Rabiner. A unified approach to short-time Fourier analysis and synthesis. Proceedings of the IEEE, 65(11):1558–1564, 1977.
227
+
228
+ Sercan O Arik, Mike Chrzanowski, Adam Coates, Gregory Diamos, Andrew Gibiansky, Yongguo Kang, Xian Li, John Miller, Jonathan Raiman, Shubho Sengupta, et al. Deep voice: Real-time neural text-to-speech. arXiv preprint arXiv:1702.07825, 2017.
229
+
230
+ Adrien Bitton, Philippe Esling, and Axel Chemla-Romeu-Santos. Modulated variational autoencoders for many-to-many musical timbre transfer. arXiv preprint arXiv:1810.00222, 2018.
231
+
232
+ Benjamin Blankertz. The constant Q transform. URL http://doc.ml.tu-berlin.de/ bbci/material/publications/Bla_constQ.pdf.
233
+
234
+ Judith C Brown. Calculation of a constant Q spectral transform. The Journal of the Acoustical Society of America, 89(1):425–434, 1991.
235
+
236
+ Gino Brunner, Yuyi Wang, Roger Wattenhofer, and Sumu Zhao. Symbolic music genre transfer with CycleGAN. arXiv preprint arXiv:1809.07575, 2018.
237
+
238
+ J. M. Chowning. The synthesis of complex audio spectra by means of frequency modulation. Journal of the Audio Engineering Society, 21(7):526–534, 1973.
239
+ Casey Chu, Andrey Zhmoginov, and Mark Sandler. CycleGAN, a master of steganography. CoRR, abs/1712.02950, 2017. URL http://arxiv.org/abs/1712.02950.
240
+ Shuqi Dai, Zheng Zhang, and Gus Xia. Music style transfer issues: A position paper. CoRR, abs/1803.06841, 2018. URL http://arxiv.org/abs/1803.06841.
241
+ Chris Donahue, Julian McAuley, and Miller Puckette. Synthesizing audio with generative adversarial networks. CoRR, abs/1802.04208, 2018. URL http://arxiv.org/abs/1802.04208.
242
+ Jesse Engel, Cinjon Resnick, Adam Roberts, Sander Dieleman, Douglas Eck, Karen Simonyan, and Mohammad Norouzi. Neural audio synthesis of musical notes with wavenet autoencoders. CoRR, abs/1704.01279, 2017. URL http://arxiv.org/abs/1704.01279.
243
+ William Fedus, Mihaela Rosca, Balaji Lakshminarayanan, Andrew M Dai, Shakir Mohamed, and Ian Goodfellow. Many paths to equilibrium: GANs do not need to decrease a divergence at every step. 2018.
244
+ Derry Fitzgerald, Matt Cranitch, and Marcin T Cychowski. Towards an inverse constant Q transform. In Conference papers, page 12, 2006.
245
+ Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge. A neural algorithm of artistic style. CoRR, abs/1508.06576, 2015. URL http://arxiv.org/abs/1508.06576.
246
+ Vienna Symphonic Library GmbH, 2018. URL https://www.vsl.co.at/en/Products.
247
+ Aidan N Gomez, Sicong Huang, Ivan Zhang, Bryan M Li, Muhammad Osama, and Lukasz Kaiser. Unsupervised cipher cracking using discrete GANs. arXiv preprint arXiv:1801.04883, 2018.
248
+ 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, pages 2672–2680, 2014.
249
+ Daniel Griffin and Jae Lim. Signal estimation from modified short-time Fourier transform. IEEE Transactions on Acoustics, Speech, and Signal Processing, 32(2):236–243, 1984.
250
+ Eric Grinstein, Ngoc Q. K. Duong, Alexey Ozerov, and Patrick Pérez. Audio style transfer. CoRR, abs/1710.11385, 2017. URL http://arxiv.org/abs/1710.11385.
251
+ Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron Courville. Improved training of wasserstein GANs. arXiv preprint arXiv:1704.00028, 2017.
252
+ Jeffrey Hass. Chapter one: An acoustics primer, 2018. URL http://www.indiana.edu/ \~emusic/etext/acoustics/chapter1_loudness.shtml.
253
+ Nicki Holighaus, Monika Dörfler, Gino Angelo Velasco, and Thomas Grill. A framework for invertible, real-time constant-Q transforms. IEEE Transactions on Audio, Speech, and Language Processing, 21(4):775–785, 2013.
254
+ Muhammad Huzaifah. Comparison of time-frequency representations for environmental sound classification using convolutional neural networks. arXiv preprint arXiv:1706.07156, 2017.
255
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In European Conference on Computer Vision, pages 694–711. Springer, 2016.
256
+ Takuhiro Kaneko and Hirokazu Kameoka. Parallel-data-free voice conversion using cycle-consistent adversarial networks. arXiv preprint arXiv:1711.11293, 2017.
257
+ Taeksoo Kim, Moonsu Cha, Hyunsoo Kim, Jungkwon Lee, and Jiwon Kim. Learning to discover cross-domain relations with generative adversarial networks. arXiv preprint arXiv:1703.05192, 2017.
258
+
259
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
260
+
261
+ librosa. librosa. https://librosa.github.io.
262
+
263
+ Ming-Yu Liu, Thomas Breuel, and Jan Kautz. Unsupervised image-to-image translation networks. arXiv preprint arXiv:1703.00848, 2017.
264
+
265
+ Stephen McAdams and Albert Bregman. Hearing musical streams. Computer Music Journal, 3(4): $2 6 { - } 4 3 { + } 6 0$ , December 1979.
266
+
267
+ Soroush Mehri, Kundan Kumar, Ishaan Gulrajani, Rithesh Kumar, Shubham Jain, Jose Sotelo, Aaron C. Courville, and Yoshua Bengio. Samplernn: An unconditional end-to-end neural audio generation model. CoRR, abs/1612.07837, 2016. URL http://arxiv.org/abs/1612. 07837.
268
+
269
+ Noam Mor, Lior Wolf, Adam Polyak, and Yaniv Taigman. A universal music translation network. arXiv preprint arXiv:1805.07848, 2018.
270
+
271
+ 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.
272
+
273
+ Augustus Odena, Vincent Dumoulin, and Chris Olah. Deconvolution and checkerboard artifacts. Distill, 2016. doi: 10.23915/distill.00003. URL http://distill.pub/2016/ deconv-checkerboard.
274
+
275
+ Jean-Claude Risset and David Wessel. Exploration of timbre by analysis and synthesis. In Diana Deutch, editor, The Psychology of Music, pages 113–169. Elsevier, 2 edition, 1999.
276
+
277
+ Juan G Roederer. The physics and psychophysics of music: an introduction. Springer Science & Business Media, 2008.
278
+
279
+ Jonathan Shen, Ruoming Pang, Ron J Weiss, Mike Schuster, Navdeep Jaitly, Zongheng Yang, Zhifeng Chen, Yu Zhang, Yuxuan Wang, RJ Skerry-Ryan, et al. Natural TTS synthesis by conditioning wavenet on mel spectrogram predictions. arXiv preprint arXiv:1712.05884, 2017.
280
+
281
+ Julius O. III Smith. Physical Audio Signal Processing: for Virtual Musical Instruments and Audio Effects. W3K Publishing, 2010.
282
+
283
+ Julius O. III Smith. Spectral Audio Signal Processing. W3K Publishing, 2011.
284
+
285
+ Nicolas Sturmel and Laurent Daudet. Signal reconstruction from STFT magnitude: A state of the art.
286
+
287
+ Joshua B Tenenbaum and William T Freeman. Separating style and content with bilinear models. 1999.
288
+
289
+ Dmitry Ulyanov and Vadim Lebedev. Audio texture synthesis and style transfer. 2016. URL https://dmitryulyanov.github.io/ audio-texture-synthesis-and-style-transfer/.
290
+
291
+ Dmitry Ulyanov, Vadim Lebedev, Andrea Vedaldi, and Victor S. Lempitsky. Texture networks: Feed-forward synthesis of textures and stylized images. CoRR, abs/1603.03417, 2016. URL http://arxiv.org/abs/1603.03417.
292
+
293
+ Aäron van den Oord, Sander Dieleman, Heiga Zen, Karen Simonyan, Oriol Vinyals, Alex Graves, Nal Kalchbrenner, Andrew W. Senior, and Koray Kavukcuoglu. Wavenet: A generative model for raw audio. CoRR, abs/1609.03499, 2016. URL http://arxiv.org/abs/1609.03499.
294
+
295
+ Gino Angelo Velasco, Nicki Holighaus, Monika Dörfler, and Thomas Grill. Constructing an invertible constant-Q transform with non-stationary gabor frames. Proceedings of DAFX11, Paris, pages 93–99, 2011.
296
+
297
+ Prateek Verma and Julius O Smith. Neural style transfer for audio spectograms. arXiv preprint arXiv:1801.01589, 2018.
298
+
299
+ Zili Yi, Hao Zhang, Ping Tan Gong, et al. DualGAN: Unsupervised dual learning for image-to-image translation. arXiv preprint arXiv:1704.02510, 2017.
300
+
301
+ Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A. Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. CoRR, abs/1703.10593, 2017. URL http:// arxiv.org/abs/1703.10593.
302
+
303
+ # A COMPONENTS OF A MUSICAL TONE
304
+
305
+ In this section, we will briefly describe the main components of a musical tone: pitch, loudness and timbre (Roederer, 2008).
306
+
307
+ Pitch is described subjectively as the “height” of a musical tone, and is closely tied to the fundamental mode of oscillation of the instrument that is producing the tone. This oscillation mode is often called the fundamental frequency, and can often be observed as the lowest band in spectrogram visualizations (Figure 3).
308
+
309
+ Loudness is linked to the perception of sound pressure, and is often subjectively described as the “intensity” of the tone. It roughly correlates with the amplitude of the waveform of the perceived tone, and has a weak dependence to pitch (Hass, 2018).
310
+
311
+ Timbre is the perceptual quality of a musical tone that enables us to distinguish between different instruments and sound sources with the same pitch and loudness (Roederer, 2008). The physical characteristics that define the timbre of a tone are its energy spectrum (the magnitude of the corresponding spectrogram) and its envelope.
312
+
313
+ Since sounds generated by physical instruments mostly rely on oscillations of physical material, the energy spectra of instruments consist of bands, which correspond to (approximately) the integer multiples of the fundamental frequency. These multiples are called harmonics, or overtones, and can be observed in Figure 3. The timbre of an instrument is tightly related to the relative strengths of the harmonics. The spectral signature of an instrument not only depends on the pitch of the tone played, but also changes over time. To see this clearly, consider that a single piano note of duration 500 milliseconds is played in reverse - the resultant sound will not be recognizable as a piano, although it will have the same spectral energy. The envelope of a tone corresponds to how the instantaneous amplitude changes over time, and is mainly affected by the instrument’s attack time (the transient “noise” created by the instrument when it is first played), decay/sustain (how the amplitude decreases over time, or can be sustained by the player of the instrument) and release (the very end of the tone, following the time the player “releases” the note). All these factors add to the complexity and richness of an instrument’s sound, while also making it difficult to model it explicitly.
314
+
315
+ # B SPECTROGRAM PROCESSING DETAILS
316
+
317
+ Waveform to CQT Spectrogram Using constant-Q transform as described in Section 2.1, CQT spectrogram can be easily computed from time-domain waveforms. In this work, we use a 16 ms frame hop (256 time steps under $1 6 \mathrm { k H z }$ ), $\omega _ { 0 } = 3 2 . 7 0 \ \mathrm { H z }$ (the frequency of $\mathrm { C 1 ~ } ^ { 1 0 }$ ), $b = 4 8$ , $k _ { m a x } = 3 3 6$ for the CQT transform. Standard implementations of CQT (e.g., librosa (librosa)) also allow scaling the Q values by a constant $\gamma > 0$ to have finer control over time resolution - choosing $\gamma \in ( 0 , 1 )$ results in increased time resolution. In our experiments, we choose $\gamma = 0 . 8$ . After the transformation, we take the log magnitude of the CQT spectrogram as the spectrogram representation.
318
+
319
+ Waveform to STFT Spectrogram All the STFT spectrograms are generated using STFT with $k _ { m a x } = 3 3 7$ . The window function is picked to be Hann Window with a window length of 672. A $1 6 \mathrm { m s }$ frame hop is also used (256 time steps under 16kHz). Similar to CQT spectrogram, we also take the log magnitude of the STFT spectrogram as the spectrogram representation after the STFT.
320
+
321
+ # C DETAILED EXPERIMENTAL SETTINGS
322
+
323
+ # C.1 DATASETS
324
+
325
+ MIDI Dataset Our MIDI dataset consists of two parts: MIDI-BACH 11 and MIDI-Chopin 12. MIDI-BACH dataset is synthesized from a collection of bach MIDI files which have a total duration of around 10 hours 13. Each dataset contains 6 instruments: acoustic grand, violin, electric guitar, flute, and harpsichord. We generated the audio with the same melody but different timbre, which makes it possible to obtain paired data during evaluation.
326
+
327
+ Real World Dataset Our Real World Dataset comprises of data collected from YouTube videos of people performing solo on different instruments including piano, harpsichord, violin and flute. Each instrument contains around 3 to 10 hours of recording. Here is a complete list of YouTube links from which we collected our Real World Dataset. Note that we’ve also randomly taken out some segments for the validation set.
328
+
329
+ • Piano https://www.youtube.com/watch?v $=$ cOrKeFUZSJ0 https://www.youtube.com/watch?v=GujB0ahKFrY https://www.youtube.com/watch?v $=$ 0sDleZkIK-w&t=629s
330
+ • Harpsichord https://www.youtube.com/watch?v $=$ oeY4a4C-Xuk&t $=$ 1555s https://www.youtube.com/watch?v $=$ Seu9ju7g9u8
331
+ • Violin https://www.youtube.com/watch?v $=$ wtbIT8ALNEA&t $= .$ 21s https://www.youtube.com/watch?v $=$ XkZvyA69wCo
332
+ • Flute https://www.youtube.com/watch?v $=$ 6GwfuWhOOdY https://www.youtube.com/watch?v $=$ s6CUi8Gthzc https://www.youtube.com/watch?v $=$ uE9SjAqPGsc&t $=$ 1001s
333
+
334
+ # C.2 DOMAIN SPECIFIC GLOBAL NORMALIZATION
335
+
336
+ As is shown in Figure 5 in Appendix C.7, the distribution of spectrogram pixel magnitude is roughly centered at -2, which is not good for learning because of the tanh activation function works better when the activation is in the range of $[ - 1 , 1 ]$ . Thus, we globally normalized the spectrogram data to be mostly in the range of $[ - 1 , 1 ]$ for each instrument domain. We scaled and shifted the spectrograms based on the mean and standard deviation of each instrument domain to achieve Domain Specific Global Normalization in the input pipeline, and reverse this operation on the output of CycleGAN to minimize possible distribution shift before feeding the output for wavenet generation.
337
+
338
+ # C.3 CYCLEGAN TRAINING DETAILS
339
+
340
+ In CycleGAN training, because we made several architectural changes, we retuned the hyperparameters. The weighting for our cycle consistency loss is 10 and the weighting of the identity loss is 5. In the original CycleGAN the weighting of identity loss is constant throughout training but in our experiment, it stays constant for the first 100000 steps, then it starts linearly decay to 0. We set the weighing for Gradient Penalty to be 10, as was suggested in Gulrajani et al. (2017). Our learning rate is exponentially warmed up to 0.0001 over 2500 steps, stays constant, then at step 100000 starts to linearly decay to zero. The total training step is 1.5 million steps, trained with Adam optimizer (Kingma and Ba, 2014) with $\beta _ { 1 } = 0$ and $\beta _ { 2 } = 0 . 9$ , with a batch size of 1.
341
+
342
+ # C.4 CONDITIONAL WAVENET TRAINING
343
+
344
+ For the conditional wavenet , we used kernel size of 3 for all the dilated convolution layers and the initial causal convolution. The residual connections and the skip connections all have width of 256 for all the residual blocks. The initial causal convolution maps from a channel size of 1 to 256. The dilated convolutions map from a channel size of 256 to 512 before going through the gated activation unit. The conditional wavenet is trained with a learning rate of 0.0001 using Adam optimizer (Kingma and Ba, 2014), batch size of 4, sample length of 8196 $\approx 0 . 5 s$ for audio with $1 6 0 0 0 \mathrm { H z }$ sampling rate). To improve the generation quality we maintain an exponential moving average of the weights of the network with a decaying factor of 0.999. The averaged weights are then used to perform the autoregressive generation. To make the model more robust, we augmented the training dataset by randomly rescaling the original waveform based on its peak value based on a uniform distribution uniform(0.1, 1.0). In addition, we also added a constant shift to the spectrogram before feeding it into the WaveNet as the local conditioning signal; this shift of $+ 2$ was chosen to achieve a mean of approximately zero.
345
+
346
+ # C.5 BEAM SEARCH
347
+
348
+ During autoregressive generation, we perform a modified beam search where the global objective is to minimize the discrepancy between the target CQT spectrogram and the CQT spectrogram of the synthesized audio waveform. Our beam search alternates between two steps: 1) run the autoregressive WaveNet on each existing candidate waveforms for $n$ steps $n = 2 0 4 8 )$ ) to extend the candidate waveforms, 2) prune the waveforms that have large squared error between the waveforms’ CQT spectrogram and the target CQT spectrogram (beam search heuristic). We maintain a constant number of candidates (beam width $= 8$ ) by replicating the remaining candidate waveforms after each pruning process. To make sure the local beam search heuristic is approximately aligned with the global objective, we take $n$ extra prediction steps forward and use the extra $n$ samples along with the candidate waveforms to obtain a better prediction of the spectrogram for the candidate waveforms. The algorithm is provided in details as follows given the target spectrogram $C _ { t a r g e t }$ :
349
+
350
+ 1. $k 0$
351
+ 2. Perform $2 n$ autoregressive synthesis step on WaveNet on $\{ x _ { 1 } , \cdots , x _ { k } \}$ with $m$ parallel probes $\mathbf { \chi } _ { m }$ is the beam width) to produce $m$ subsequent waveforms: $\bar { \{ x _ { k + 1 } ^ { ( 1 ) } , \cdot \cdot \cdot , x _ { k + 2 n } ^ { ( 1 ) } \} } , \{ x _ { k + 1 } ^ { ( 2 ) } , \cdot \cdot \cdot , x _ { k + 2 n } ^ { ( 2 ) } \} , \cdot \cdot \cdot , \{ x _ { k + 1 } ^ { ( \hat { m } ) } , \cdot \cdot \cdot , x _ { k + 2 n } ^ { ( m ) } \}$
352
+ 3. Compute the CQT spectrogram 0 $C _ { i }$ of 0 $\{ x _ { k + 1 } ^ { ( i ) } , \cdot \cdot \cdot , x _ { k + 2 n } ^ { ( i ) } \}$ for each $i \in \{ 1 , 2 , \cdots , m \}$ , and find the waveform $\{ x _ { k + 1 } ^ { ( i ^ { \prime } ) } , \cdot \cdot \cdot , x _ { k + 2 n } ^ { ( i ^ { \prime } ) } \}$ with the lowest square difference between $C _ { i }$ and the target CQT spectrogram $C _ { t }$ arget
353
+ 4. Update the waveform $x _ { j } = x _ { j } ^ { i ^ { \prime } } , \forall j \in \{ k + 1 , k + 2 , \cdots , k + n \}$
354
+ 5. $k \gets k + n$
355
+
356
+ # C.6 ONE-SHOT GENERATION OF LONGER SEGMENTS
357
+
358
+ In our earlier attempts, we tried generating 4 seconds segments and then merge them back. However, this resulted in volume inconsistencies between the 4 second generations. We suspect the CycleGAN learned a random volume permutation, because essentially there’s no explicit gradient signal against it from the discriminator, after we enabled volume augmentation during train time. To resolve this issue, we removed the size constraint in our generator during test time so that it can generate based on input of arbitrary length. At test time, the dataset is no longer 4 second chunks, instead, we preserved the original length of the musical piece(except when the piece is too long we cut it down to 2 minutes due to GPU memory constraint). During test time generation, the entire piece is fed into the CycleGAN generator in one shot.
359
+
360
+ # C.7 SPECTROGRAM RAW PIXEL INTENSITY HISTOGRAM
361
+
362
+ Figure 5 shows that the rough distribution of spectrograms are centered at $^ { - 2 }$ . As is discussed in Section 3.1, we globally normalized our input data based oh the distribution of spectrograms for each domain of instruments.
363
+
364
+ ![](images/baf5cae67422b2418efbf16466cad51c13df39e45c1778ff1515c43061fb772e.jpg)
365
+ Figure 5: Spectrogram raw pixel intensity histogram
md/train/S1vuO-bCW/S1vuO-bCW.md ADDED
@@ -0,0 +1,450 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LEAVE NO TRACE: LEARNING TO RESET FOR SAFE AND AUTONOMOUS REINFORCEMENT LEARNING
2
+
3
+ Benjamin Eysenbach∗ †, Shixiang $\mathbf { G u } ^ { \dagger \dagger } \mathbf { \Psi } ^ { \dagger }$ ††, Julian Ibarz†, Sergey Levine† ‡‡
4
+
5
+ †Google Brain
6
+ ‡University of Cambridge
7
+ ††Max Planck Institute for Intelligent Systems
8
+ ‡‡UC Berkeley
9
+ {eysenbach,shanegu,julianibarz,slevine}@google.com
10
+
11
+ # ABSTRACT
12
+
13
+ Deep reinforcement learning algorithms can learn complex behavioral skills, but real-world application of these methods requires a large amount of experience to be collected by the agent. In practical settings, such as robotics, this involves repeatedly attempting a task, resetting the environment between each attempt. However, not all tasks are easily or automatically reversible. In practice, this learning process requires extensive human intervention. In this work, we propose an autonomous method for safe and efficient reinforcement learning that simultaneously learns a forward and reset policy, with the reset policy resetting the environment for a subsequent attempt. By learning a value function for the reset policy, we can automatically determine when the forward policy is about to enter a non-reversible state, providing for uncertainty-aware safety aborts. Our experiments illustrate that proper use of the reset policy can greatly reduce the number of manual resets required to learn a task, can reduce the number of unsafe actions that lead to non-reversible states, and can automatically induce a curriculum.1
14
+
15
+ # 1 INTRODUCTION
16
+
17
+ Deep reinforcement learning (RL) algorithms have the potential to automate acquisition of complex behaviors in a variety of real-world settings. Recent results have shown success on games (Mnih et al. (2013)), locomotion (Schulman et al. (2015)), and a variety of robotic manipulation skills (Pinto & Gupta (2017); Schulman et al. (2016); Gu et al. (2017)). However, the complexity of tasks achieved with deep RL in simulation still exceeds the complexity of the tasks learned in the real world. Why have real-world results lagged behind the simulated accomplishments of deep RL algorithms?
18
+
19
+ One challenge with real-world application of deep RL is the scaffolding required for learning: a bad policy can easily put the system into an unrecoverable state from which no further learning is possible. For example, an autonomous car might collide at high speed, and a robot learning to clean glasses might break them. Even in cases where failures are not catastrophic, some degree of human intervention is often required to reset the environment between attempts (e.g., Chebotar et al. (2017)).
20
+
21
+ Most RL algorithms require sampling from the initial state distribution at the start of each episode. On real-world tasks, this operation often corresponds to a manual reset of the environment after every episode, an expensive solution for complex environments. Even when tasks are designed so that these resets are easy (e.g., Levine et al. (2016) and Gu et al. (2017)), manual resets are necessary when the robot or environment breaks (e.g., Gandhi et al. (2017)). The bottleneck for learning many real-world tasks is not that the agent collects data too slowly, but rather that data collection stops entirely when the agent is waiting for a manual reset. To avoid manual resets caused by the environment breaking, task designers often add negative rewards to dangerous states and intervene to prevent agents from taking dangerous actions. While this works well for simple tasks, scaling to more complex environments requires writing large numbers of rules for types of actions the robot should avoid. For example, a robot should avoid hitting itself, except when clapping. One interpretation of our method is as automatically learning these safety rules. Decreasing the number of manual resets required to learn to a task is important for scaling up RL experiments outside simulation, allowing researchers to run longer experiments on more agents for more hours.
22
+
23
+ We propose to address these challenges by forcing our agent to “leave no trace.” The goal is to learn not only how to do the task at hand, but also how to undo it. The intuition is that the sequences of actions that are reversible are safe; it is always possible to undo them to get back to the original state. This property is also desirable for continual learning of agents, as it removes the requirements for manual resets. In this work, we learn two policies that alternate between attempting the task and resetting the environment. By learning how to reset the environment at the end of each episode, the agent we learn requires significantly fewer manual resets. Critically, our value-based reset policy restricts the agent to only visit states from which it can return, intervening to prevent the forward policy from taking potentially irreversible actions. Using the reset policy to regularize the forward policy encodes the assumption that whether our learned reset policy can reset is a good proxy for whether any reset policy can reset. The algorithm we propose can be applied to both deterministic and stochastic MDPs. For stochastic MDPs we say that an action is reversible if the probability that an oracle reset policy can successfully reset from the next state is greater than some safety threshold. The set of states from which the agent knows how to return grows over time, allowing the agent to explore more parts of the environment as soon as it is safe to do so.
24
+
25
+ The main contribution of our work is a framework for continually and jointly learning a reset policy in concert with a forward task policy. We show that this reset policy not only automates resetting the environment between episodes, but also helps ensure safety by reducing how frequently the forward policy enters unrecoverable states. Incorporating uncertainty into the value functions of both the forward and reset policy further allows us to make this process risk-aware, balancing exploration against safety. Our experiments illustrate that this approach reduces the number of “hard” manual resets required during learning of a variety of simulated robotic skills.
26
+
27
+ # 2 RELATED WORK
28
+
29
+ Our method builds off previous work in areas of safe exploration, multiple policies, and automatic curriculum generation. Previous work has examined safe exploration in small MDPs. Moldovan & Abbeel (2012a) examine risk-sensitive objectives for MDPs, and propose a new objective of which minmax and expectation optimization are both special cases. Moldovan & Abbeel (2012b) consider safety using ergodicity, where an action is safe if it is still possible to reach every other state after having taken that action. These methods are limited to small, discrete MDPs where exact planning is straightforward. Our work includes a similar notion of safety, but can be applied to solve complex, high-dimensional tasks. Thomas et al. (2015a;b) prove high confidence bounds for off policy evaluation and policy improvement. While these works look at safety as guaranteeing some reward, our work defines safety as guaranteeing that an agent can reset.
30
+
31
+ Previous work has also used multiple policies for safety and for learning complex tasks. Han et al. (2015) learn a sequence of forward and reset policies to complete a complex manipulation task. Similar to Han et al. (2015), our work learns a reset policy to undo the actions of the forward policy. While Han et al. (2015) engage the reset policy when the forward policy fails, we preemptively predict whether the forward policy will fail, and engage the reset policy before allowing the forward policy to fail. Similar to our approach, Richter & Roy (2017) also propose to use a safety policy that can trigger an “abort” to prevent a dangerous situation. However, in contrast to our approach, Richter & Roy (2017) use a heuristic, hand-engineered reset policy, while our reset policy is learned simultaneously with the forward policy. Kahn et al. (2017) uses uncertainty estimation via bootstrap to provide for safety. Our approach also uses bootstrap for uncertainty estimation, but unlike our method, Kahn et al. (2017) does not learn a reset or safety policy.
32
+
33
+ Learning a reset policy is related to curriculum generation: the reset controller is engaged in increasingly distant states, naturally providing a curriculum for the reset policy. Prior methods have studied curriculum generation by maintaining a separate goal setting policy or network (Sukhbaatar et al., 2017; Matiisen et al., 2017; Held et al., 2017). In contrast to these methods, we do not set explicit goals, but only allow the reset policy to abort an episode. When learning the forward and reset policies jointly, the training dynamics of our reset policy resemble those of reverse curriculum generation (Florensa et al., 2017), but in reverse. In particular, reverse curriculum learning can be viewed as a special case of our method: our reset policy is analogous to the learner in the reverse curriculum, while the forward policy plays a role similar to the initial state selector. However, reverse curriculum generation requires that the agent can be reset to any state (e.g., in a simulator), while our method is specifically aimed at streamlining real-world learning, through the use of uncertainty estimation and early aborts.
34
+
35
+ # 3 PRELIMINARIES
36
+
37
+ In this section, we discuss the episodic RL problem setup, which motivates our proposed joint learning of forward and reset policies. RL considers decision-making problems that consist of a state space $s$ , action space $\mathcal { A }$ , transition dynamics $P ( s ^ { \prime } \mid s , a )$ , an initial state distribution $p _ { 0 } ( s )$ , and a scalar reward function $r ( s , a )$ . In episodic, finite horizon tasks, the objective is to find the optimal policy $\pi ^ { * } ( a \mid s )$ that maximizes the expected sum of $\gamma$ -discounted returns, $\begin{array} { r } { \mathbb { E } _ { \boldsymbol { \pi } } \left[ \sum _ { t = 0 } ^ { T } \gamma ^ { t } r ( s _ { t } , a _ { t } ) \right] } \end{array}$ , where $s _ { 0 } \sim p _ { 0 }$ , $a _ { t } \sim \pi ( a _ { t } \mid s _ { t } )$ , and $s _ { t + 1 } \sim P ( s _ { t + 1 } \mid s _ { t } , a _ { t } )$ .
38
+
39
+ Typical RL training routines involve iteratively sampling new episodes; at the end of each episode, a new starting state $s _ { 0 }$ is sampled from a given initial state distribution $p _ { 0 }$ . In practical applications, such as robotics, this procedure involves a hard-coded reset policy or a human intervention to manually reset the agent. Our work is aimed at avoiding these manual resets by learning an additional reset policy that satisfies the following property: when the reset policy is executed from any state reached by the forward policy, the distribution over final states is close to the initial state distribution $p _ { 0 }$ . If we learn such a reset policy, then the agent never requires querying the black-box distribution $p _ { 0 }$ and can continually learn on its own.
40
+
41
+ # 4 CONTINUAL LEARNING WITH JOINT FORWARD-RESET POLICIES
42
+
43
+ Our method for continual learning relies on jointly learning a forward policy and reset policy, using early aborts to avoid manual resets. The forward policy aims to maximize the task reward, while the reset policy takes actions to reset the environment. Both have the same state and action spaces, but are given different reward objectives. The forward policy reward $r _ { f } ( s , a )$ is the usual task reward given by the environment. The reset policy reward $r _ { r } ( s )$ is designed to approximate the initial state distribution. In practice, we found that a very simple design worked well for our experiments. We used the negative distance to some start state, plus any reward shaping included in the forward reward.
44
+
45
+ To make this set-up applicable for solving the task, we make two assumptions on the task environment. First, we make the weak assumption that there exists a policy that can reset from at least one of the reachable states with maximum reward in the environment. This assumption ensures that it is possible to solve the task without any manual resets. Many manipulation and locomotion tasks in robotics satisfy this assumption. As a counterexample, the Atari game Ms. Pacman violates this assumption because transitioning from one level to the next level is not reversible; the agent cannot transition from level 3 back to level 1. Second, we assume that the initial state distribution is unimodal and has narrow support. This assumption ensures that the distribution over the reset policy’s final state is close to the initial state distribution $p _ { 0 }$ . If the initial state distribution were multi-modal, the reset policy might only learn to return to one of these modes. Detecting whether an environment violates this second assumption is straightforward. A mismatch between $p _ { 0 }$ and the reset policy’s final state distribution will cause the forward policy to earn a small reward when the initial state is sampled from $p _ { 0 }$ and a larger reward when the initial state is the final state of the reset policy.
46
+
47
+ We choose off-policy actor-critic as the base RL algorithm (Silver et al., 2014; Lillicrap et al., 2015), since its off-policy learning allows sharing of the experience between the forward and reset policies. Additionally, the Q-functions can be used to signal early aborts. Our method can also be used directly with any other Q-learning method (Watkins & Dayan, 1992; Mnih et al., 2013; Gu et al., 2017; Amos et al., 2016; Metz et al., 2017).
48
+
49
+ # 4.1 EARLY ABORTS
50
+
51
+ The reset policy learns how to transition from the forward policy’s final state back to an initial state. In challenging domains where the reset policy is unable to reset from some states or would take prohibitively long to reset, a costly manual reset is required. The reset policy offers a natural mechanism for reducing these manual resets. We observe that, for states from which we cannot quickly reset, the value function of the reset policy will be low. We can therefore use this value function (or, specifically, its Q-function) as a metric to determine when to terminate the forward policy, performing an early abort.
52
+
53
+ Before an action proposed by the forward policy is executed in the environment, it must be “approved” by the reset policy. In particular, if the reset policy’s Q-value for the proposed action is too small, then an early abort is performed: the proposed action is not taken and the reset policy takes control. Formally, early aborts restrict exploration to a ‘safe’ subspace of the MDP. Let ${ \mathcal { E } } \subseteq S \times A$ be the set of (possibly stochastic) transitions, and let $Q _ { r e s e t } ( s , a )$ be the $\mathrm { Q }$ -value of our reset policy at state $s$ taking action $a$ . The subset of transitions $\mathcal { E } ^ { \ast } \in \mathcal { E }$ allowed by our algorithm is
54
+
55
+ $$
56
+ \mathcal { E } ^ { * } \triangleq \{ ( s , a ) \in \mathcal { E } \mid Q _ { r e s e t } ( s , a ) > Q _ { m i n } \}
57
+ $$
58
+
59
+ Noting that $V ( s ) \triangleq \operatorname* { m a x } _ { a \in \mathcal { A } } Q ( s , a )$ , we see that given access to the true Q-values, Leave No Trace only visits safe states:
60
+
61
+ $$
62
+ \begin{array} { c } { { S ^ { \ast } \triangleq \{ s \mid ( s , a ) \in \mathcal { E } ^ { \ast } \mathrm { ~ f o r ~ a t ~ l e a s t ~ o n e ~ } a \in \mathcal { A } \} } } \\ { { = \{ s \mid V _ { r e s e t } ( s ) > Q _ { m i n } \} } } \end{array}
63
+ $$
64
+
65
+ In Appendix A, we prove that if we learn the true $\mathbf { Q }$ -values for the reset policy, then early aborts restrict the forward policy to visiting states that are safe in expectation at convergence.
66
+
67
+ Early aborts can be interpreted as a learned, dynamic, safety constraint, and a viable alternative for the manual constraints that are typically used for real-world RL experiments. Early aborts promote safety by preventing the agent from taking actions from which it cannot recover. These aborts are dynamic because the states at which they occur change throughout training as more states are considered safe. Early aborts can make learning the forward policy easier by preventing the agent from entering unsafe states. We experimentally analyze early aborts in Section 6.3, and discuss how our approach handles over/under-estimates of Q-values in Appendix B.
68
+
69
+ # 4.2 HARD RESETS
70
+
71
+ A hard reset is an action that resamples that state from the initial state distribution. Hard resets are available to an external agent (e.g., a human) but not the learned agent. Early aborts decrease the requirement for “hard” resets, but do not eliminate them, since an imperfect reset policy might still miss a dangerous state early in the training process.
72
+
73
+ It is challenging to identify whether any policy can reset from the current state. Formally, we define a set of states $\boldsymbol { S _ { r e s e t } }$ that give a reward greater than $r _ { m i n }$ to the reset policy:
74
+
75
+ $$
76
+ S _ { r e s e t } \triangleq \{ s \mid r _ { r } ( s ) > r _ { m i n } \}
77
+ $$
78
+
79
+ We say that we are in an irreversible state if we have not visited a state in $\boldsymbol { S _ { r e s e t } }$ within the past $N$ episodes, where $N$ is a hyperparameter. This is a necessary but not sufficient condition, as the reset policy may have not yet learned to reset from a safe state. Increasing $N$ decreases the number of hard resets. However, when we are in an irreversible state, increasing $N$ means that we remain in that state (learning nothing) for more episodes. Section 6.4 empirically examines this trade-off. In practice, the setting of this parameter should depend on the cost of hard resets.
80
+
81
+ # 4.3 ALGORITHM SUMMARY
82
+
83
+ Our full algorithm (Algorithm 1) consists of alternately running a forward policy and reset policy. When running the forward policy, we perform an early abort if the Q-value for the reset policy is less than $Q _ { m i n }$ . Only if the reset policy fails to reset after $N$ episodes do we do a manual reset.
84
+
85
+ # 4.4 VALUE FUNCTION ENSEMBLES
86
+
87
+ The accuracy of the Q-value estimates directly affects task reward and indirectly affects safety (through early aborts). Our Q-values may not be good estimates of the true value function for
88
+
89
+ # Algorithm 1 Joint Training
90
+
91
+ <table><tr><td colspan="2">1: repeat</td></tr><tr><td>2:</td><td>for max_steps-per_episode do</td></tr><tr><td>3:</td><td>α ←FORWARD_AGENT.CHOOSE_ACTION(S)</td></tr><tr><td>4:</td><td>if RESET_AGENT.Q(s,a) &lt; Qmin then</td></tr><tr><td>5:</td><td>Switch to reset policy.</td></tr><tr><td>6:</td><td>(s,r)← ENVIRONMENT.STEP(α)</td></tr><tr><td>7:</td><td>Update the forward policy.</td></tr><tr><td>8:</td><td>for max_steps-per_episode do</td></tr><tr><td>9:</td><td>α ←RESET_AGENT.CHOOSE_ACTION(s)</td></tr><tr><td>10:</td><td>(s,r)←ENVIRONMENT.STEP(a)</td></tr><tr><td>11:</td><td>Update the reset policy.</td></tr><tr><td>12: Let SN ifs</td><td>be the final states from the last N reset episodes. reset</td></tr><tr><td>13:</td><td>∩Sreset=O then Detect Failed Reset (Eq. 4) reset</td></tr><tr><td>14:</td><td>S←ENVIRONMENT.RESET() Hard Reset</td></tr></table>
92
+
93
+ previously-unseen states. To address this, we train Q-functions for both the forward and reset policies that provide uncertainty estimates. Several prior works have explored how uncertainty estimates can be obtained in such settings (Gal & Ghahramani, 2016; Osband et al., 2016). In our method, we train an ensemble of Q-functions, each with a different random initialization. This technique has been established in the literature as a principled way to provides a distribution over Q-values at each state given the observed data Osband et al. (2016); Chen et al. (2017).
94
+
95
+ Given this distribution over Q-values, we can propose three strategies for early aborts:
96
+
97
+ Optimistic Aborts: Perform an early abort only if all the Q-values are less than $Q _ { m i n }$ Equivalently, do an early abort if maxθ $Q _ { r e s e t } ^ { \theta } ( \dot { s } , a ) < Q _ { m i n }$ .
98
+
99
+ Realist Aborts: Perform an early abort if the mean Q-value is less than $Q _ { m i n }$ .
100
+
101
+ Pessimistic Aborts: Perform an early abort if any of the $\mathbf { Q }$ -values are less than $Q _ { m i n }$ Equivalently, do an early abort if $\mathrm { m i n } \stackrel { \cdot } { \theta } Q _ { r e s e t } ^ { \theta } ( s , a ) \stackrel { \cdot } { < } Q _ { m i n }$ .
102
+
103
+ We expect that optimistic aborts will provide better exploration at the cost of more hard resets, while pessimistic aborts should decrease hard resets, but may be unable to effectively explore. We empirically test this hypothesis in Appendix C.
104
+
105
+ # 5 SMALL-SCALE DIDACTIC EXAMPLE
106
+
107
+ We first present a small didactic example to illustrate how our forward and reset policies interact and how cautious exploration reduces the number of hard resets. We first discuss the gridworld in Figure 1. The states with red borders are absorbing, meaning that the agent cannot leave them and must use a hard reset. The agent receives a reward of 1 for reaching the goal state, and 0 otherwise. States are colored based on the number of early aborts triggered in each state. Note that most aborts occur next to the initial state, when the forward policy attempts to enter the absorbing state South-East of the start state, but is blocked by the reset policy. In Figure 2, we present a harder start environment, where the task can be successfully completed by reaching one of the two goals, exactly one of which is reversible. The forward policy has no preference for which goal is better, but the reset policy successfully prevents the forward policy from entering the absorbing goal state, as indicated by the much larger early abort count in the blue-colored state next to the absorbing goal.
108
+
109
+ ![](images/59a3c8b22831c7c8d32c8ea11a76216402c80d2c3055e356e85b8dfda9fdd3d9.jpg)
110
+ Figure 1: Early aborts in gridworld.
111
+
112
+ Figure 3 shows how changing the early abort threshold to explore more cautiously reduces the number of failures. Increasing $Q _ { m i n }$ from 0 to 0.4 reduced the number of hard resets by
113
+
114
+ ![](images/a7d04878165ae6b78846fef9a42d23658df329233f08bbdfb48835ada0eba49a.jpg)
115
+ Figure 2: Early aborts with an absorbing goal.
116
+
117
+ ![](images/c3b2d8997167f76f95f22d307499d3278cb7a8d60012c05dbab1b69a3d6f263e.jpg)
118
+ Figure 3: Early abort threshold: In our didactic example, increasing the early abort threshold causes more cautious exploration (left) without severely increasing the number of steps to solve (right).
119
+
120
+ $78 \%$ without increasing the number of steps to solve the task. In a real-world setting, this might produce a substantial gain in efficiency, as time spend waiting for a hard reset could be better spent collecting more experience. Thus, for some real-world experiments, increasing $Q _ { m i n }$ can decrease training time even if it requires more steps to learn.
121
+
122
+ # 6 CONTINUOUS ENVIRONMENT EXPERIMENTS
123
+
124
+ ![](images/709a75e78140f4923d9951307217b10d96100dd5f4fbe05c14928e9ce1bfb86a.jpg)
125
+
126
+ In this section, we use the five complex, continuous control environments shown above to answer questions about our approach. While ball in cup and peg insertion are completely reversible, the other environments are not: the pusher can knock the puck outside its workspace and the cheetah and walker can jump off a cliff. Crucially, reaching the goal states or these irreversible states does not terminate the episode, so the agent remains in the irreversible state until it calls for a hard reset. To ensure fair evaluation of all approaches, we use a different procedure for evaluation than for training. We evaluate the performance of a policy by creating a copy of the policy in a separate thread, running the forward policy for a fixed number of steps, and computing the average per-step reward. All approaches observe the same amount of data during training. We visualize the training dynamics and provide additional plots and experimental details are in the Appendix.
127
+
128
+ # 6.1 WHY LEARN A RESET CONTROLLER?
129
+
130
+ One proposal for learning without resets is to run the forward policy until the task is learned. This “forwardonly” approach corresponds to the standard, fully online, non-episodic lifelong RL setting, commonly studied in the context of temporal difference learning (Sutton & Barto (1998)). We show that this approach fails, even on reversible environments where safety is not a concern. We benchmarked the forward-only approach and our method on ball in cup, using no hard resets for either. Figure 5 shows that our approach solves the task while the “forward-only” approach fails to learn how to catch the ball when initialized below the cup. Note that the x axis includes steps taken by the reset policy. Once the forward-only approach catches the ball, it gets maximum reward by keeping the ball in the cup. In contrast, our method learns to solve this task by automatically resetting the environment after each attempt, so the forward policy can practice catching the ball without hard resets. As an upper bound,
131
+
132
+ ![](images/63ed8be6b72d353b198093402c0790cc436e5f8f8b4a58512a0781eb564232fe.jpg)
133
+ Figure 5: We compare our method to a nonepisodic (“forward-only”) approach on ball in cup. Although neither uses hard resets, only our method learns to catch the ball. As an upper bound, we also show the “status quo” approach that performs a hard reset after episode, which is often impractical outside simulation.
134
+
135
+ we show policy reward for the “status quo” approach, which performs a hard reset after every attempt.
136
+ Note that the dependence on hard resets makes this third method impractical outside simulation.
137
+
138
+ # 6.2 DOES OUR METHOD REDUCE MANUAL RESETS?
139
+
140
+ ![](images/c6ff16bd1f90ea4386d15c8054b03634f34628bb019c994a85f9f0c0ce06c0d2.jpg)
141
+ Figure 6: Our method achieves equal or better rewards than the status quo with fewer manual resets.
142
+
143
+ Our first goal is to reduce the number of hard resets during learning. In this section, we compare our algorithm to the standard, episodic learning setup (“status quo”), which only learns a forward policy. As shown in Figure 6 (left), the conventional approach learns the pusher task somewhat faster than ours, but our approach eventually achieves the same reward with half the number of hard resets. In the cliff cheetah task (Figure 6 (right)), not only does our approach use an order of magnitude fewer hard resets, but the final reward of our method is substantially higher. This suggests that, besides reducing the number of resets, the early aborts can actually aid learning by preventing the forward policy from wasting exploration time waiting for resets in irreversible states.
144
+
145
+ # 6.3 DO EARLY ABORTS AVOID HARD RESETS?
146
+
147
+ ![](images/2914d32b90eb4dfea52d1c05f820879fb85320d57331f6429b3676bff05b4796.jpg)
148
+ Figure 7: Early abort threshold: Increasing the early abort threshold to act more cautiously avoids many hard resets, indicating that early aborts help avoid irreversible states.
149
+
150
+ To test whether early aborts prevent hard resets, we can see if the number of hard resets increases when we lower the early abort threshold. Figure 7 shows the effect of three values for $Q _ { m i n }$ while learning the pusher and cliff cheetah. In both environments, decreasing the early abort threshold increased the number of hard resets, supporting our hypothesis that early aborts prevent hard resets. On pusher, increasing $Q _ { m i n }$ to 80 allowed the agent to learn a policy that achieved nearly the same reward using $33 \%$ fewer hard resets. The cliff cheetah task has lower rewards than pusher, even an early abort threshold of 10 is enough to prevent $69 \%$ of the total early aborts that the status quo would have performed.
151
+
152
+ # 6.4 MULTIPLE RESET ATTEMPTS
153
+
154
+ While early aborts help avoid hard resets, our algorithm includes a mechanism for requesting a manual reset if the agent reaches an unresettable state. As described in Section 4.2, we only perform a hard reset if the reset agent fails to reset in $N$ consecutive episodes. Figure 8 shows how the number of reset attempts, $N$ , affects hard resets and reward. On the pusher task, when our algorithm was given a single reset attempt, it used $64 \%$ fewer hard resets than the status quo approach would have. Increasing the number of reset attempts to 4 resulted in another $2 . 5 \mathrm { x }$ reduction in hard resets, while decreasing the reward by less than $2 5 \%$ . On the cliff cheetah task, increasing the number of reset attempts brought the number of resets down to nearly zero, without changing the reward. Surprisingly, these results indicate that for some tasks, it is possible to learn an equally good policy with significantly fewer hard resets.
155
+
156
+ ![](images/3100859df4e0fcec7df8b24826dbf004926dba311d14eb48891fc85fb8fdcd8d.jpg)
157
+ Figure 8: Reset attempts: Increasing the number of reset attempts reduces hard resets. Allowing too many reset attempts reduces reward for the pusher environment.
158
+
159
+ # 6.5 ENSEMBLES ARE SAFER
160
+
161
+ Our approach uses an ensemble of value functions to trigger early aborts. Our hypothesis was that our algorithm would be sensitive to bias in the value function if we used a single Q network. To test this hypothesis, we varied the ensemble size from 1 to 50. Figure 9 shows the effect on learning the pushing task. An ensemble with one network failed to learn, but still required many hard resets. Increasing the ensemble size slightly decreased the number of hard resets without affecting the reward.
162
+
163
+ # 6.6 AUTOMATIC CURRICULUM LEARNING
164
+
165
+ Our method can automatically produce a curriculum in settings where the desired skill is performed by the reset policy, rather than the forward policy. As an example, we evaluate our method on a peg insertion task, where the reset policy inserts the peg and the forward policy removes it. The reward for a successful peg insertion is provided only when the peg is in the hole, making this task challenging to learn with random exploration. Hard resets provide illustrations of what a successful outcome looks like, but do not show how to achieve it. Our algorithm starts with the peg in the hole and runs the forward (peg removal) policy until an early abort occurs. As the reset (peg insertion) policy improves, early aborts occur further and further from the hole. Thus, the initial state distribution for the reset (peg insertion) policy moves further and further from the hole, increasing the difficulty of the task as the policy improves. We compare our approach to an “insert-only” baseline that only learns the peg insertion policy – we manually remove the peg from the hole after every episode. For evaluation, both approaches start outside the hole. Figure 10 shows that only our method solves the task. The number of resets required by our method plateaus after one million steps, indicating that it has solved the task and no longer requires hard resets at the end of the episode. In contrast, the “insert-only” baseline fails to solve the task, never improving its reward. Thus, even if reducing manual resets is not important, the curriculum automatically created by Leave No Trace can enable agents to learn policies they otherwise would be unable to solve.
166
+
167
+ ![](images/14dadd5f25bc254695023b0ea49859d20f36601710ff05204675d5efc991101d.jpg)
168
+ Figure 9: Increasing ensemble size boosts policy reward while decreasing rate of hard resets.
169
+
170
+ ![](images/4442cd412f0a221dbb15880339f18d25fde8fb44f692568fbf79f24abfa1dae3.jpg)
171
+ Figure 10: Our method automatically induces a curriculum, allowing the agent to solve peg insertion with sparse rewards.
172
+
173
+ # 7 CONCLUSION
174
+
175
+ In this paper, we presented a framework for automating reinforcement learning based on two principles: automated resets between trials, and early aborts to avoid unrecoverable states. Our method simultaneously learns a forward and reset policy, with the value functions of the two policies used to balance exploration against recoverability. Experiments in this paper demonstrate that our algorithm not only reduces the number of manual resets required to learn a task, but also learns to avoid unsafe states and automatically induces a curriculum.
176
+
177
+ Our algorithm can be applied to a wide range of tasks, only requiring a few manual resets to learn some tasks. During the early stages of learning we cannot accurately predict the consequences of our actions. We cannot learn to avoid a dangerous state until we have visited that state (or a similar state) and experienced a manual reset. Nonetheless, reducing the number of manual resets during learning will enable researchers to run experiments for longer on more agents. A second limitation of our work is that we treat all manual resets as equally bad. In practice, some manual resets are more costly than others. For example, it is more costly for a grasping robot to break a wine glass than to push a block out of its workspace. An approach not studied in this paper for handling these cases would be to specify costs associated with each type of manual reset, and incorporate these reset costs into the learning algorithm.
178
+
179
+ While the experiments for this paper were done in simulation, where manual resets are inexpensive, the next step is to apply our algorithm to real robots, where manual resets are costly. A challenge introduced when switching to the real world is automatically identifying when the agent has reset. In simulation we can access the state of the environment directly to compute the distance between the current state and initial state. In the real world, we must infer states from noisy sensor observations to deduce if they are the same. If we cannot distinguish between the state where the forward policy started and the state where the reset policy ended, then we have succeeded in Leaving No Trace!
180
+
181
+ Acknowledgements: We thank Sergio Guadarrama, Oscar Ramirez, and Anoop Korattikara for implementing DDPG and thank Peter Pastor for insightful discussions.
182
+
183
+ # REFERENCES
184
+
185
+ Brandon Amos, Lei Xu, and J Zico Kolter. Input convex neural networks. arXiv preprint arXiv:1609.07152, 2016.
186
+ Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym. arXiv preprint arXiv:1606.01540, 2016.
187
+ Yevgen Chebotar, Mrinal Kalakrishnan, Ali Yahya, Adrian Li, Stefan Schaal, and Sergey Levine. Path integral guided policy search. 2017 IEEE International Conference on Robotics and Automation (ICRA), pp. 3381– 3388, 2017.
188
+ Richard Y Chen, John Schulman, Pieter Abbeel, and Szymon Sidor. Ucb and infogain exploration via $\ b { Q }$ - ensembles. arXiv preprint arXiv:1706.01502, 2017.
189
+ C. Finn, M. Zhang, J. Fu, X. Tan, Z. McCarthy, E. Scharff, and S. Levine. Guided policy search code implementation, 2016. URL http://rll.berkeley.edu/gps. Software available from rll.berkeley.edu/gps.
190
+
191
+ Carlos Florensa, David Held, Markus Wulfmeier, and Pieter Abbeel. Reverse curriculum generation for reinforcement learning. arXiv preprint arXiv:1707.05300, 2017.
192
+
193
+ Yarin Gal and Zoubin Ghahramani. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conference on machine learning, pp. 1050–1059, 2016.
194
+
195
+ Dhiraj Gandhi, Lerrel Pinto, and Abhinav Gupta. Learning to fly by crashing. arXiv preprint arXiv:1704.05588, 2017.
196
+
197
+ Shixiang Gu, Ethan Holly, Timothy Lillicrap, and Sergey Levine. Deep reinforcement learning for robotic manipulation with asynchronous off-policy updates. In Robotics and Automation (ICRA), 2017 IEEE International Conference on, pp. 3389–3396. IEEE, 2017.
198
+
199
+ Weiqiao Han, Sergey Levine, and Pieter Abbeel. Learning compound multi-step controllers under unknown dynamics. In Intelligent Robots and Systems (IROS), 2015 IEEE/RSJ International Conference on, pp. 6435–6442. IEEE, 2015.
200
+
201
+ David Held, Xinyang Geng, Carlos Florensa, and Pieter Abbeel. Automatic goal generation for reinforcement learning agents. arXiv preprint arXiv:1705.06366, 2017.
202
+
203
+ Gregory Kahn, Adam Villaflor, Vitchyr Pong, Pieter Abbeel, and Sergey Levine. Uncertainty-aware reinforcement learning for collision avoidance. arXiv preprint arXiv:1702.01182, 2017.
204
+
205
+ Sergey Levine, Peter Pastor, Alex Krizhevsky, Julian Ibarz, and Deirdre Quillen. Learning hand-eye coordination for robotic grasping with deep learning and large-scale data collection. The International Journal of Robotics Research, pp. 0278364917710318, 2016.
206
+
207
+ Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
208
+
209
+ Tambet Matiisen, Avital Oliver, Taco Cohen, and John Schulman. Teacher-student curriculum learning. arXiv preprint arXiv:1707.00183, 2017.
210
+
211
+ Luke Metz, Julian Ibarz, Navdeep Jaitly, and James Davidson. Discrete sequential prediction of continuous actions for deep rl. arXiv preprint arXiv:1705.05035, 2017.
212
+
213
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013.
214
+
215
+ Teodor M Moldovan and Pieter Abbeel. Risk aversion in markov decision processes via near optimal chernoff bounds. In Advances in neural information processing systems, pp. 3131–3139, 2012a.
216
+
217
+ Teodor Mihai Moldovan and Pieter Abbeel. Safe exploration in markov decision processes. arXiv preprint arXiv:1205.4810, 2012b.
218
+
219
+ Ian Osband, Charles Blundell, Alexander Pritzel, and Benjamin Van Roy. Deep exploration via bootstrapped dqn. In Advances in Neural Information Processing Systems, pp. 4026–4034, 2016.
220
+
221
+ Lerrel Pinto and Abhinav Gupta. Learning to push by grasping: Using multiple tasks for effective learning. In Robotics and Automation (ICRA), 2017 IEEE International Conference on, pp. 2161–2168. IEEE, 2017.
222
+
223
+ Charles Richter and Nicholas Roy. Safe visual navigation via deep learning and novelty detection. In Proc. of the Robotics: Science and Systems Conference, 2017.
224
+
225
+ John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel. High-dimensional continuous control using generalized advantage estimation. arXiv preprint arXiv:1506.02438, 2015.
226
+
227
+ John Schulman, Jonathan Ho, Cameron Lee, and Pieter Abbeel. Learning from demonstrations through the use of non-rigid registration. In Robotics Research, pp. 339–354. Springer, 2016.
228
+
229
+ David Silver, Guy Lever, Nicolas Heess, Thomas Degris, Daan Wierstra, and Martin Riedmiller. Deterministic policy gradient algorithms. In Proceedings of the 31st International Conference on Machine Learning (ICML-14), pp. 387–395, 2014.
230
+
231
+ Sainbayar Sukhbaatar, Ilya Kostrikov, Arthur Szlam, and Rob Fergus. Intrinsic motivation and automatic curricula via asymmetric self-play. arXiv preprint arXiv:1703.05407, 2017.
232
+
233
+ Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction, volume 1. MIT press Cambridge, 1998.
234
+
235
+ Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdolmaleki, Josh Merel, Andrew Lefrancq, Timothy Lillicrap, and Martin Riedmiller. Deepmind control suite, 2018.
236
+
237
+ Philip Thomas, Georgios Theocharous, and Mohammad Ghavamzadeh. High confidence policy improvement. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pp. 2380–2388, 2015a.
238
+
239
+ Philip S Thomas, Georgios Theocharous, and Mohammad Ghavamzadeh. High-confidence off-policy evaluation. In AAAI, pp. 3000–3006, 2015b.
240
+
241
+ Christopher JCH Watkins and Peter Dayan. Q-learning. Machine learning, 8(3-4):279–292, 1992.
242
+
243
+ # A SAFETY INVARIANT PROOF
244
+
245
+ In this section, we prove that if we indeed learn the true Q-values for the reset policy, then the abort condition stipulated by our method will keep the forward policy safe (able to reset) for deterministic infinite-horizon discounted reward MDPs. For stochastic MDPs, the abort condition will keep the forward policy safe in expectation. Thus, the abort condition is effective at convergence. Before convergence, the reliability of this abort condition depends on the accuracy of the learned Q-values. In practice, we partially mitigate issues with imperfect Q functions by means of the Q-function ensemble (Section 4.4).
246
+
247
+ # A.1 ASSUMPTIONS
248
+
249
+ In the proofs that follow, we make the following assumptions:
250
+
251
+ 1. The reward function for the reset policy depends only on the current state. We use $r _ { r } ( s )$ as the reset reward received for arriving at state $s$ throughout this proof.
252
+
253
+ 2. From every state $s _ { t }$ , there exists an action $a _ { t }$ such that the expected reset reward at the next state is at least as large as the reset reward at the current state:
254
+
255
+ $$
256
+ \mathbb { E } _ { s _ { t + 1 } \sim p ( s _ { t + 1 } \mid s _ { t } , a _ { t } ) } [ r _ { r } ( s _ { t + 1 } ) ] \geq r _ { r } ( s _ { t } )
257
+ $$
258
+
259
+ For example, if the reset reward is uniform over $\boldsymbol { S } _ { r e s e t }$ and zero everywhere else, then this assumption requires that for every state $\boldsymbol { S _ { r e s e t } }$ , there exists an action that deterministically transitions to another state in $\boldsymbol { S _ { r e s e t } }$ . As a counterexample, a modified cliff cheetah environment where the cheetah is initialized a meter above the ground does not satisfy this assumption. If the cheetah in $\boldsymbol { S _ { r e s e t } }$ (above the ground), there are no actions it can take to stop itself from falling to the ground and leaving $\boldsymbol { S _ { r e s e t } }$ .
260
+
261
+ # A.2 PROOFS
262
+
263
+ In the proofs below, we assume a stochastic MDP. For a deterministic MDP, we can remove the expectations over $s _ { t + 1 }$ (Lemma 4). To begin, we use the two assumptions to establish a lower bound for the value of any state for the reset policy.
264
+
265
+ Lemma 1. For every state $s \in S$ , the expected cumulative discounted reward for the reset agent is greater than a term that depends on the discount $\gamma$ and the reward of the current state $r _ { r } ( s )$ :
266
+
267
+ $$
268
+ V _ { r e s e t } ( s ) \geq \frac { 1 } { 1 - \gamma } r _ { r } ( s ) \qquad \forall s \in \mathcal { S }
269
+ $$
270
+
271
+ Proof. As a consequence of the assumptions, a reset policy at state $s$ that acts optimally is guaranteed to receive an expected reset reward of at least $r _ { r } ( s )$ in every future time step. Thus, its expected cumulative discounted reward is at least $\textstyle { \frac { 1 } { 1 - \gamma } } r _ { r } ( s )$ . □
272
+
273
+ Next, we show that the reset policy can choose actions so that the Q-values do not decrease in expectation.
274
+
275
+ Theorem 1. For any state $s _ { t } \in S$ and action $a _ { t } \in \mathcal A$ , there exists another action $a _ { t + 1 } ^ { * } \in \mathcal { A }$ such that
276
+
277
+ $$
278
+ \begin{array} { r } { \mathbb { E } _ { s _ { t + 1 } \sim p ( s _ { t + 1 } | s _ { t } , a _ { t } ) } \left[ Q _ { r e s e t } ( s _ { t + 1 } , a _ { t + 1 } ^ { * } ) \right] \geq Q _ { r e s e t } ( s _ { t } , a _ { t } ) } \end{array}
279
+ $$
280
+
281
+ In the proof that follows, note that the next state $s _ { t + 1 }$ is an unknown random variable. Functions of $s _ { t + 1 }$ are also random variables.
282
+
283
+ Proof. Let state $s _ { t }$ and action $a _ { t }$ be given and let $s _ { t + 1 }$ be a random variable indicating the next state following a possibly stochastic transition. Let $a _ { t + 1 } ^ { * }$ to be the action with largest Q-value at the next state:
284
+
285
+ $$
286
+ a _ { t + 1 } ^ { * } = \arg \operatorname* { m a x } _ { a _ { t + 1 } } Q ( s _ { t + 1 } , a _ { t + 1 } )
287
+ $$
288
+
289
+ We want to bound the expected difference between $Q _ { r e s e t } ( s _ { t } , a _ { t } )$ and $Q _ { r e s e t } ( s _ { t + 1 } , a _ { t + 1 } ^ { * } )$ , where the expectation is with respect to the unknown next state $s _ { t + 1 }$ . We begin by unrolling the first term of the Q-value. Because $a _ { t + 1 } ^ { * }$ is defined to be the action with largest Q-value, we can replace the first Q-value expression with the value function. We then apply the bound from Lemma 1. For brevity, we omit the subscript reset and omit that the expectation is over $s _ { t + 1 }$ .
290
+
291
+ $$
292
+ \begin{array} { r l } & { \mathbb { E } [ Q ( s _ { t + 1 } , a _ { t + 1 } ^ { * } ) - Q ( s _ { t } , a _ { t } ) ] = \mathbb { E } \left[ Q ( s _ { t + 1 } , a _ { t + 1 } ^ { * } ) - ( r _ { r } ( s _ { t + 1 } ) + \gamma V ( s _ { t + 1 } ) ) \right] } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad = \mathbb { E } \left[ V ( s _ { t + 1 } ) - r _ { r } ( s _ { t + 1 } ) - \gamma V ( s _ { t + 1 } ) ) \right] } \\ & { \quad \quad \quad \quad \quad = \mathbb { E } \left[ ( 1 - \gamma ) V ( s _ { t + 1 } ) - r _ { r } ( s _ { t + 1 } ) ) \right] } \\ & { \quad \quad \quad \quad \quad \quad \quad \geq \mathbb { E } \left[ ( 1 - \gamma ) \frac { 1 } { 1 - \gamma } r _ { r } ( s _ { t + 1 } ) - r _ { r } ( s _ { t + 1 } ) \right] } \\ & { \quad \quad \quad \quad = \mathbb { E } \left[ r _ { r } ( s _ { t + 1 } ) - r _ { r } ( s _ { t + 1 } ) \right] } \\ & { \quad \quad \quad = 0 } \end{array}
293
+ $$
294
+
295
+ Next, we want to show that if one state is safe, the next state will also be safe in expectation. As a reminder, we say transitions $( s , a )$ in $\mathcal { E } ^ { * }$ are safe and states $s$ in ${ \boldsymbol { S } } ^ { * }$ are safe (Eq. 1 and 3):
296
+
297
+ $$
298
+ \begin{array} { r l } & { \mathcal { E } ^ { * } \triangleq \{ ( s , a ) \in \mathcal { E } \mid Q _ { r e s e t } ( s , a ) > Q _ { m i n } \} } \\ & { \mathcal { S } ^ { * } \triangleq \{ s \mid ( s , a ) \in \mathcal { E } ^ { * } \mathrm { ~ f o r ~ a t ~ l e a s t ~ o n e ~ } a \in \mathcal { A } \} } \end{array}
299
+ $$
300
+
301
+ Lemma 2. Let safe state $s _ { t } \in S ^ { * }$ be given and choose an action $a _ { t }$ such that $( s _ { t } , a _ { t } ) \in \mathcal { E } ^ { * }$ . Then the following state $s _ { t + 1 }$ is also safe in expectation:
302
+
303
+ $$
304
+ \begin{array} { r } { \mathbb { E } _ { s _ { t + 1 } \sim p ( s _ { t + 1 } \mid s _ { t } , a _ { t } ) } \left[ Q _ { r e s e t } ( s _ { t + 1 } , a _ { t + 1 } ^ { * } ) \right] \ge Q _ { m i n } } \end{array}
305
+ $$
306
+
307
+ Proof. By our assumption that $( s _ { t } , a _ { t } ) \in \mathcal { E } ^ { * }$ , we know $Q _ { r e s e t } ( s _ { t } , a _ { t } ) > Q _ { m i n }$ . Combining with Theorem 1, we get
308
+
309
+ $$
310
+ \begin{array} { r } { \mathbb { E } _ { s _ { t + 1 } \sim p ( s _ { t + 1 } \mid s _ { t } , a _ { t } ) } \left[ Q _ { r e s e t } ( s _ { t + 1 } , a _ { t + 1 } ^ { * } ) \right] \ge Q _ { m i n } } \end{array}
311
+ $$
312
+
313
+ Thus, state $s _ { t + 1 }$ is safe in expectation.
314
+
315
+ Finally, we want to show that Leave No Trace only visits safe states in expectation.
316
+
317
+ Lemma 3. If the initial state $s _ { 0 }$ is safe, then Leave No Trace only visits states that are also safe in expectation.
318
+
319
+ Proof. Proof by induction. We assumed that the initial state $s _ { 0 }$ is safe. Lemma 2 shows that safety is a preserved invariant. Thus, each future state $s _ { t }$ is also safe in expectation. □
320
+
321
+ Leave No Trace being safe in expectation means that if we look an arbitrary number of steps into the future, the expected Q-value for that state is at least $Q _ { m i n }$ . Equivalently, the probability that the state we arrive at is safe is greater than $50 \%$ .
322
+
323
+ Deterministic MDPs are a special case for which we can prove that Leave No Trace only visits safe states (not in expectation).
324
+
325
+ Lemma 4. For deterministic MDPs, if the initial state $s _ { 0 }$ is safe, then Leave No Trace only visits states that are also safe (not in expectation.)
326
+
327
+ Proof. When the next state $s _ { t + 1 }$ is a deterministic function of the current state $s _ { t }$ and action $a _ { t }$ , we can remove the expectation over $s _ { t + 1 }$ from Theorem 1 and Lemma 2. Thus, if the initial state $s _ { 0 }$ is safe, we are guaranteed that every future state is also safe. □
328
+
329
+ # A.3 LEAVE NO TRACE IN PRACTICE
330
+
331
+ In practice, Leave No Trace does visit unsafe states (though significantly less frequently than existing approaches). First, the proofs above only show that each state is safe in expectation. We do not prove that every state is safe with high probability. Second, we do not have access to the true Q-values. Our learned Q-function may overestimate the Q-value of some action, leading us to take an unsafe action. Empirically, we found that using an ensemble of Q-functions helped mitigate this problem, decreasing the number of unsafe actions taken as compared to using a single Q-function (Section 6.5).
332
+
333
+ # B Q-VALUE ESTIMATION ERRORS
334
+
335
+ We introduced early aborts in Section 4.1 and analyzed them in Appendix A under the assumption that we had access to the true Q-values. In practice, our learned $\mathbf { Q }$ -values may over/under-estimate the Q-value for the reset policy. First, consider the case that the Q-function overestimates the reset Q-value for state $s _ { u }$ , so the agent mistakenly thinks that unsafe state $s _ { u }$ is safe. The agent will visit state $s _ { u }$ and discover that it cannot reset. When the reset Q-function is updated with this experience, it will decrease its predicted reset $\mathrm { Q }$ -value for state $s _ { u }$ . Second, consider the case that the Q-function underestimates the reset Q-value for state $s _ { s }$ , so the agent mistakenly thinks that safe state $s _ { s }$ is unsafe. For continuous tasks, once the agent learns to reset from a nearby safe state, generalization of the Q-function across states will lead the reset policy to assume that it can also reset from the state $s _ { s }$ For discrete state tasks where the Q-function does not generalize across states, we act optimistically in the face of uncertainty by acting based on the largest predicted Q-value from our ensemble, helping to avoid this second case (see Appendix C).
336
+
337
+ # C COMBINING AN ENSEMBLE OF VALUE FUNCTIONS
338
+
339
+ We benchmarked three methods for combining our ensemble of values functions (optimistic, realistic, and pessimistic, as discussed in Section 4.4). Figure 11 compares the three methods on gridworld on the gridworld environment from Section 5. Only the optimistic agent efficiently explored. As expected, the realistic and pessimistic agents, which are more conservative in letting the forward policy continue, fail to explore when $Q _ { m i n }$ is too large.
340
+
341
+ ![](images/b04e317781eb2b0304a70215791faaf1685c50cf6e40658dbb7905450e22f6b6.jpg)
342
+ Figure 11: Combining value functions: We compare three methods for ensembling value functions on gridworld. Missing points for the red and green lines indicate that pessimistic and realistic method fail to solve the task for larger values of $Q _ { m i n }$ .
343
+
344
+ Interestingly, for the continuous control environments, the ensembling method makes relatively little difference for the number of resets or final performance, as shown in Figure 12. This suggests that much of the benefit of ensemble comes from its ability to produce less biased abort predictions in novel states, rather than the particular risk-sensitive rule that is used. This result also indicates that no Q-function in the ensemble significantly overestimates or underestimates the value function – such a Q-function would result in bogus Q-value estimates when the ensemble was combined by taking the max or min (respectively).
345
+
346
+ # D TRAINING DYNAMICS
347
+
348
+ In this section, we provide some intuition for the training dynamics of our algorithm. In particular, we visualize the number of steps taken by the forward policy before an early abort occurs. Figure 13 shows this quantity (the episode length for the forward policy) as a function of training iteration. Note that we stop the forward policy after a fixed number of steps (500 steps for cliff cheetah and cliff walker, 100 steps for pusher) if an early abort has not already occurred. For all tasks, initially the reset policy is unable to reset from any state, so early aborts happen almost immediately. As the reset policy improves, early aborts occur further and further from the initial state distribution, corresponding to longer forward episode lengths. In all tasks, increasing the safety threshold $Q _ { m i n }$ caused early aborts to occur sooner, especially early in training. For the cliff cheetah, another curious pattern emerges when $Q _ { m i n }$ is 10 and 20. After 200 thousand steps, the agent had learned rudimentary policies for running forwards and backwards. As the agent learns to run forwards faster, it reaches the cliff sooner and does an early abort, so the forward episode length actually decreases. For cliff walker, we do not see the same pattern because the forward task is more difficult, so the agent only reaches the cliff near the end of training. Both the cliff walker and pusher environments highlight the sensitivity of our method to $Q _ { m i n }$ . If $Q _ { m i n }$ is too small, early aborts will never occur. Automatically tuning the safety threshhold based on the real-world cost of hard resets is an exciting direction for future research.
349
+
350
+ ![](images/3c84746db609dddbdc895cce9257bef3def44b136106d00574ac3de187f1fa54.jpg)
351
+ Figure 12: Combining value functions: For continuous environments, the method for combing value functions has little effect.
352
+
353
+ ![](images/0992f990660519ca75ca5085ddbe360248206b8455055dd41af50067cd06a8b9.jpg)
354
+ Figure 13: Training dynamics: We show the number of steps taken before an early abort for cliff cheetah (top row), cliff walker (middle row), and pusher (bottom row). Increasing the safety threshold causes early aborts to occur earlier, causing the agent to explore more cautiously. These plots are the average across 5 random seeds.
355
+
356
+ # E ADDITIONAL FIGURES
357
+
358
+ For each experiment in the main paper, we chose one or two demonstrative environments. Below, we show all experiments run on cliff cheetah, cliff walker, and pusher.
359
+
360
+ # E.1 DOES OUR METHOD REDUCE MANUAL RESETS? – MORE PLOTS
361
+
362
+ This experiment, described in Section 6.2, compared our method to the status quo approach (resetting after every episode). Figure 14 shows plots for all environments.
363
+
364
+ ![](images/6b8b9531a4bb0ee4ed2d297ac5393f4981b5cd3a0da1280bf9cb070c0019d982.jpg)
365
+ Figure 14: Experiment from $\ S 6 . 2$
366
+
367
+ # E.2 DO EARLY ABORTS AVOID HARD RESETS PLOTS? – MORE PLOTS
368
+
369
+ This experiment, described in Section 6.3, shows the effect of varying the early abort threshold.
370
+ Figure 15 shows plots for all environments.
371
+
372
+ ![](images/3549972b5d517e0b09e45f3d417597498a7e520366ff45585d078f72907c23d7.jpg)
373
+ Figure 15: Experiment from $\ S 6 . 3$
374
+
375
+ # E.3 MULTIPLE RESET ATTEMPTS – MORE PLOTS
376
+
377
+ This experiment, described in Section 6.4, shows the effect of increasing the number of reset attempts.
378
+ Figure 16 shows plots for all environments.
379
+
380
+ ![](images/e275e788b605ad1d0e634d85949e51c4df3bebd7f55c330a49d7094ab7a6f0d8.jpg)
381
+ Figure 16: Experiment from § 6.4
382
+
383
+ # E.4 ENSEMBLES ARE SAFER – MORE PLOTS
384
+
385
+ This experiment, described in Section 6.5, shows the effect of increasing the number of reset attempts.
386
+ Figure 17 shows plots for all environments.
387
+
388
+ ![](images/f8c344d8680011b29b75307de0ee3d6a4022eabcd02af1a7de44bb0468888637.jpg)
389
+ Figure 17: Experiment from $\ S 6 . 5$
390
+
391
+ # F EXPERIMENTAL DETAILS
392
+
393
+ # F.1 GRIDWORLD EXPERIMENTS
394
+
395
+ To generate Figures 1 and 2, we averaged early abort counts across 10 random seeds. For Figure 3 we took the median result across 10 random seeds. Both gridworld experiments used 5 models in the ensemble.
396
+
397
+ # F.2 CONTINUOUS CONTROL ENVIRONMENTS
398
+
399
+ In this section, we provide additional information on the continuous control environments in our experiments. We use the ball in cup environment implemented in Tassa et al. (2018). The cliff cheetah and cliff walker environments are modified versions of the cheetah and walker environments in Tassa et al. (2018). The pusher environment is a modified version of Pusher-v0 environment in Brockman et al. (2016). Finally, the peg insertion environment is based on Finn et al. (2016).
400
+
401
+ Below, we provide a high level description of each task, the forward reward, the reset reward, and any reward shaping used. Note that the reset reward is always the Euclidean distance between certain dimensions of the current observation and a reference start observation.
402
+
403
+ Ball in Cup:
404
+
405
+ Description: The agent swings a ball attached by a string up into a cup.
406
+ Forward reward: $+ 1$ if the ball is in the cup and 0 otherwise.
407
+ Reset reward: Negative Euclidean distance between current observation and start observation (ball hanging stationary below the cup).
408
+ Reward shaping: Control penalty (negative Euclidean norm of action)
409
+
410
+ Cliff Cheetah:
411
+
412
+ Description: The agent learns how to run on a $1 4 \mathrm { m }$ cliff.
413
+ Forward reward: Scaled linear velocity (see Tassa et al. (2018)).
414
+ Reset reward: Negative distance from origin along the X axis (i.e., $- | x | )$ .
415
+ Reward shaping: Indicator of whether agent is standing and a control penalty (see Tassa et al. (2018)).
416
+
417
+ Cliff Walker:
418
+
419
+ Description: The agent learns how to walker on a 6m cliff.
420
+ Forward reward: Scaled linear velocity (see Tassa et al. (2018)).
421
+ Reset reward: Negative distance from origin along the X axis (i.e., $- | x | )$ .
422
+ Reward shaping: Indicator of whether agent is standing and a control penalty (see Tassa et al. (2018)).
423
+
424
+ Pusher:
425
+
426
+ Description: The agent pushes a puck to a goal location.
427
+ Forward reward: Negative Euclidean distance from puck to goal.
428
+ Reset reward: Negative Euclidean distance from puck to start.
429
+ Reward shaping: Negative Euclidean distance from end of arm to puck and a control penalty (negative Euclidean norm of action).
430
+
431
+ Peg Insertion:
432
+
433
+ Description: The agent inserts a peg into a small hole.
434
+ Forward reward: $+ 1$ if the peg is in the hole and 0 otherwise.
435
+ Reset reward: (Positive) Euclidean distance from peg to hole.
436
+ Reward shaping: Control penalty (negative Euclidean norm of action).
437
+
438
+ F.3 CONTINUOUS CONTROL EXPERIMENTS
439
+
440
+ We did not do hyperparameter optimization for our experiments, but did run with 5 random seeds. To aggregate results, we took the median number across all random seeds that solved the task. For most experiments, all random seeds solved the task.
441
+
442
+ For the three continuous control environments, we normalized the rewards to be in $[ 0 , 1 ]$ so we could use the same hyperparameters for each. The initial state distribution $p _ { 0 }$ for each task is a uniform distribution centered at some “start pose.” Using a discount factor of $\gamma = 0 . 9 9$ , the cumulative discounted reward was in [0, 100). We defined $\boldsymbol { S _ { r e s e t } }$ as states with reset reward was greater than 0.7.
443
+
444
+ We used the same DDPG hyperparameters for all continuous control environments:
445
+
446
+ Actor Network: Two fully connected layers of sizes 400 and 300, with tanh nonlinearities throughout.
447
+
448
+ Critic Network: We apply a 400-dimensional fully connected layer to states, then concatenate the actions and apply another 300-dimensional fully connected layer. Again, we use tanh nonlinearities.
449
+
450
+ Unless otherwise noted, experiments used an ensemble of size 20, $Q _ { m i n } = 1 0$ , 1 reset attempt, and early aborts using $\operatorname* { m i n } ( q )$ . The experiments in Section 6.2, our model used 2 reset attempts to better illustrate the potential for our approach to reduce hard resets.
md/train/SJeeL04KvH/SJeeL04KvH.md ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ROBUST FEDERATED LEARNING THROUGH REPRESENTATION MATCHING AND ADAPTIVE HYPERPARAMETERS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Federated learning is a distributed, privacy-aware learning scenario which trains a single model on data belonging to several clients. Each client trains a local model on its data and the local models are then aggregated by a central party. Current federated learning methods struggle in cases with heterogeneous client-side data distributions which can quickly lead to divergent local models and a collapse in performance. Careful hyper-parameter tuning is particularly important in these cases but traditional automated hyper-parameter tuning methods would require several training trials which is often impractical in a federated learning setting. We describe a two-pronged solution to the issues of robustness and hyper-parameter tuning in federated learning settings. We propose a novel representation matching scheme that reduces the divergence of local models by ensuring the feature representations in the global (aggregate) model can be derived from the locally learned representations. We also propose an online hyper-parameter tuning scheme which uses an online version of the REINFORCE algorithm to find a hyper-parameter distribution that maximizes the expected improvements in training loss. We show on several benchmarks that our two-part scheme of local representation matching and global adaptive hyper-parameters significantly improves performance and training robustness.1
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ The size of the data used to train machine learning models is steadily increasing, and the privacy concerns associated with storing and managing this data are becoming more pressing. Offloading model training to the data owners is an attractive solution to address both scalability and privacy concerns. This gives rise to the Federated Learning (FL) setting (McMahan et al., 2016) where several clients collaboratively train a model without disclosing their data. In synchronous FL, training proceeds in rounds where at the beginning of each round, a central party sends the latest version of the model to the clients. The clients (or a subset of them) train the received model on their local datasets and then communicate the resulting models to the central party at the end of the round. The central party aggregates the client models (typically by averaging them) to obtain the new version of the model which it then communicates to the clients in the next round.
12
+
13
+ The FL setting poses a unique set of challenges compared to standard stochastic gradient descent (SGD) learning on a monolithic dataset. In real-world settings, data from each client may be drawn from different distributions, and this heterogeneity can lead the local learning processes to diverge from each other, harming the convergence rate and final performance of the aggregate model. We address this challenge in two ways: (1) adaptive on-line tuning of hyper-parameters; and (2) adding a regularization term that punishes divergent representation learning across clients.
14
+
15
+ Traditional hyper-parameter tuning schemes, such as random search (Bergstra & Bengio, 2012) or Bayesian methods (Bergstra et al., 2011; Snoek et al., 2012), require several training runs to evaluate the fitness of different hyper-parameters. This is impractical in the FL setting, which strives to minimize unnecessary communication. To address this issue, we formulate the hyper-parameter selection problem as an online reinforcement learning (RL) problem: in each round, the learners perform an action by selecting particular hyper-parameter values, and at the end of the round get a reward which is the relative reduction in training loss. We then update the hyper-parameter selection policy online to maximize the rewards.
16
+
17
+ Unlike centralized SGD, where there is a single trajectory of parameter updates, the FL setting has many local parameter trajectories, one per each active client. Even though they share the same initial point, these trajectories could significantly diverge. Averaging the endpoints of these divergent trajectories at the end of a training round would then result in a poor model (Zhao et al., 2018). Clients with heterogeneous data distributions exacerbate this effect as each client could quickly learn representations specific to its local dataset. We introduce a scheme that mitigates the problem of divergent representations: each client uses the representations it learns to reconstruct the representations in the initial model it receives. A client is thus discouraged from learning representations that are too specific and that discard information about the globally learned representations. We show that this representation matching scheme significantly improves robustness and accuracy in the presence of heterogeneous client-side data distributions.
18
+
19
+ We evaluate the performance of our two-part scheme, representation matching and online hyperparameter adjustments, on image classification tasks: MNIST, CIFAR10; and on a keyword spotting (KWS) task. We show that for homogeneous client-side data distributions, our scheme consistently improves accuracy. For heterogeneous clients, in addition to improving accuracy, our scheme improves training robustness and stops catastrophic training failures without having to manually tune hyper-parameters for each task.
20
+
21
+ # 2 RELATED WORK
22
+
23
+ The simplest automated hyper-parameter tuning methods execute random searches in hyperparameter space to find the best-performing hyper-parameters (Bergstra & Bengio, 2012). Random search is outperformed by Bayesian methods (Bergstra et al., 2011; Snoek et al., 2012) that use the performance of previously selected hyper-parameters to inform the choice of new hyper-parameter to try. In these methods, the fitness of a hyper-parameter choice is the post-training validation accuracy. Running the training process to completion in order to evaluate the hyper-parameter fitness is computationally intensive. This motivates running partial training runs instead (Klein et al., 2016; Li et al., 2016). However, in FL settings with tight communication budgets, running several (partial) training runs to select the right hyper-parameters could still be impractical.
24
+
25
+ Hyper-parameters can be optimized using gradient descent to minimize the final validation loss. To avoid storing the entire training trajectory in order to evaluate the hyper-gradients, Maclaurin et al. (2015) uses reversible learning dynamics to allow the entire training trajectory to be reconstructed from the final model. Alternatively, the hyper-gradients can be calculated in a forward manner, albeit at an increased memory overhead (Franceschi et al., 2017). Using the hyper-gradient to optimize hyper-parameters is an iterative process that requires several standard training runs (hyper-iterations), again making this approach impractical in a communication-constrained FL setting. Hyper-parameters can be optimized using SGD in tandem with model parameters through the use of hyper-networks (Ha et al., 2016; Lorraine & Duvenaud, 2018) which map hyper-parameters to optimal model parameters. It is unclear how hyper-networks can be learned in a FL setting as we are interested in choosing hyper-parameters that result in the best post-aggregation model and not the hyper-parameters chosen by any particular client to optimize its own model on its own dataset.
26
+
27
+ The hyper-parameter tuning approaches most related to ours are those based on RL methods. Daniel et al. (2016); Jomaa et al. (2019) learn policies and/or state-action values that are then used to select good hyper-parameters. However, several training runs are needed to learn the policies and the action values. Perhaps the closest approach to ours is the method in Xu et al. (2017) which trains an actor-critic network in tandem with the main model and uses it to select actions (hyper-parameter choices) that maximize the expected reduction in training loss. It is unclear how this approach can be applied in a FL setting as the training process on each client has no access to the loss of interest which is the loss of the post-aggregation model.
28
+
29
+ FL typically struggles when the client-side data distributions are significantly different (McMahan et al., 2016; Zhao et al., 2018) as this causes the parameter trajectories to significantly diverge across different clients. This severely degrades the performance of the averaged model (Zhao et al., 2018). One straightforward solution is to reduce the SGD steps each client takes between the synchronization (model averaging) points. More frequent model synchronization, however, increases communication volume. Various compression methods (Sattler et al., 2019; Konecnˇ y et al., 2016) \` are able to compress the model updates, which makes it possible to synchronize more frequently and mitigate the effect of heterogeneous data distributions. Sattler et al. (2019) takes the extreme case of synchronizing after every SGD step, which reduces the FL setting to standard SGD. An alternative solution is to mix the datasets of the different clients to obtain more homogeneous client-side data distributions (Zhao et al., 2018). This, however, compromises the privacy of the clients’ data.
30
+
31
+ ![](images/f394b0d830561608f4ea8db20dda87845d0c8ef02ebe2c20927c5e757ea9d396.jpg)
32
+ Figure 1: The three steps in a federated learning round. (a) The server communicates the latest model parameters $\mathbf { w } _ { t }$ and the training hyper-parameters $\mathbf { h } _ { t }$ to each client. (b) client $i$ trains the model parameters $\mathbf { w } _ { t } ^ { i }$ and the representation matching parameters $\theta _ { t } ^ { i }$ to minimize the classification loss and the matching loss. (c) Each client sends back the updated model parameters to the server. The server aggregates the received parameters, evaluates the loss of the aggregate model, and updates the parameters of the hyper-parameter distribution, $\psi$ , based on the history of the aggregate losses.
33
+
34
+ # 3 METHODS
35
+
36
+ We build upon the federated averaging (FedAvg) algorithm (McMahan et al., 2016) and introduce two novel aspects to it: global adaptive hyper-parameters and local (per-client) representation matching. We first give an informal description of the complete algorithm. We consider a synchronous FedAvg setting with $K$ clients, where $\mathbf { D } _ { k }$ is the dataset local to client $k$ . Training proceeds in rounds. Figure 1 illustrates the steps involved in training round $t$ . The server maintains a distribution $P ( \bar { \mathcal { H } } | \psi )$ over the space of hyper-parameters $\mathcal { H }$ . At the beginning of round $t$ (Fig. 1a), the selected clients receive the most recent model parameters from the server, $\mathbf { w } _ { t }$ , together with training hyper-parameters $\mathbf { h } _ { t }$ sampled from $P ( \mathcal { H } | \bar { \psi _ { t } } )$ . Client $i$ uses two copies of $\mathbf { w } _ { t }$ to initialize two models: a fixed model $\mathcal { M } ^ { F }$ and a trainable model $\mathcal { M } _ { t } ^ { i }$ . The parameters $\mathbf { \bar { w } } _ { t } ^ { i }$ of $\mathcal { M } _ { t } ^ { i }$ are trained using SGD (Fig. 1b). Client $i$ maintains a set of local parameters $\bar { { \boldsymbol { \theta } } } _ { t } ^ { i }$ that it uses to map the activations in $\mathcal { M } _ { t } ^ { i }$ to the activations in $\mathcal { M } ^ { F }$ . $\theta _ { t } ^ { i }$ and $\mathbf { w } _ { t } ^ { i }$ are simultaneously trained to minimize a two-component loss: the first component is the standard training loss of $\mathcal { M } _ { t } ^ { i }$ on $\mathbf { D } _ { i }$ (for example, the cross-entropy loss); the second component is the mean squared difference between the activations in $\mathcal { M } ^ { F }$ and the activations reconstructed from $\mathcal { M } _ { t } ^ { i }$ using $\theta _ { t } ^ { i }$ . We denote this second component as the representation matching loss. In the final step in the round (Fig. 1c), each participating client sends its final model parameters, $\mathbf { w } _ { t } ^ { i }$ , to the central server. The server aggregates the model parameters, and uses the loss of the resulting model to update the parameters $\psi$ of the hyper-parameter distribution, $P ( \mathcal { H } | \psi )$ .
37
+
38
+ # 3.1 REPRESENTATION MATCHING
39
+
40
+ We now describe the representation matching scheme. For an example model, Fig. 2 illustrates how the local parameters $\theta ^ { i }$ in client $i$ are used to map the activations of the model being trained, $\mathcal { M } ^ { i }$ ,to the activations of the fixed model $\mathcal { M } ^ { F }$ . $\mathcal { M } ^ { i }$ is parameterized by $\mathbf { w } ^ { i }$ while $\mathcal { M } ^ { F }$ is parameterized by w which was received from the server at the beginning of training. To simplify notation, we dropped the index of the round, $t$ . Given a data point $\mathbf { x } \sim \mathbf { D } _ { i }$ , $\mathbf { x }$ is fed to $\mathcal { M } ^ { i }$ and $\boldsymbol { \mathcal { M } ^ { F } }$ to obtain the layer activations $[ \mathbf { a } _ { 1 } ( x ; \mathbf { w } ^ { i } ) , \dots \mathbf { a } _ { M } ( x ; \mathbf { w } ^ { i } ) ]$ and $[ \mathbf { a } _ { 1 } ( x ; \mathbf { w } ) , \hdots , \mathbf { a } _ { M } ( x ; \mathbf { w } ) ]$ , respectively. These are not all the model activations, but only the $M$ activations we are interested in matching. The activations in the two models are matched by a set of matching layers parameterized by $\theta ^ { i }$ $\theta ^ { i } \equiv$ $[ \theta _ { 1 } ^ { i } , \theta _ { 2 } ^ { i } , \theta _ { 3 } ^ { i } ]$ in Fig. 2). Instead of deriving the activations of one layer in $\bar { \mathcal { M } } ^ { F }$ from the activations of the corresponding layer in $\mathcal { M } ^ { i }$ , we found performance significantly improves if the activations of one layer are instead derived from the activations of the next layer of interest above it. As shown in the representative example in Fig. 2, the activations/layers of interest are the input layer, the point-wise non-linearity layers and the top layer. We use convolutional matching layers if the input has spatial information (such as within a convolutional stack), and fully-connected matching layers otherwise. To reverse a pooling operation, we follow the scheme in Zhao et al. (2015) and unpool pooled activations using the pooling positions used during the pooling operation as shown in Fig. 2.
41
+
42
+ ![](images/eee053431cfb89efd2e90e9fa1c695c48f40cbfe0b96099c3965ce3f17ee7d2d.jpg)
43
+ Figure 2: Illustration of representation matching using a model with one convolutional layer and two fully connected layers. Layers whose activations are used in the matching loss are shown in red. The matching layers map the activations in $\mathcal { M } ^ { i }$ to the activations in $\mathcal { M } ^ { F }$ .
44
+
45
+ Given a training point and label $( \mathbf { x } , y ) \sim \mathbf { D } _ { i }$ , we define the matching loss at client $i$ as:
46
+
47
+ $$
48
+ \mathcal { L } _ { M } ^ { i } ( \mathbf { x } ; \mathbf { w } ^ { i } , \mathbf { w } , \boldsymbol { \theta } ^ { i } ) = \sum _ { j = 1 } ^ { j = M - 1 } | | f _ { j } ( \mathbf { a } _ { j + 1 } ( x ; \mathbf { w } ^ { i } ) ; \boldsymbol { \theta } _ { j } ^ { i } ) - \mathbf { a } _ { j } ( x ; \mathbf { w } ) | | _ { 2 } ^ { 2 }
49
+ $$
50
+
51
+ where $f _ { j }$ denotes the $j ^ { t h }$ matching layer. The per-point training loss at client $i$ is:
52
+
53
+ $$
54
+ \begin{array} { r } { \mathcal { L } ^ { i } ( \mathbf { x } , y ; \mathbf { w } ^ { i } , \mathbf { w } , \theta ^ { i } ) = \mathcal { L } _ { C } ( \mathbf { a } _ { M } ( \mathbf { x } ; \mathbf { w } ^ { i } ) ; y ) + \mathcal { L } _ { M } ^ { i } ( \mathbf { x } ; \mathbf { w } ^ { i } , \mathbf { w } , \theta ^ { i } ) } \end{array}
55
+ $$
56
+
57
+ where $\mathcal { L } _ { C }$ is the cross-entropy loss and $\mathbf { a } _ { M } ( \mathbf { x } ; \mathbf { w } ^ { i } )$ is the top layer activation in the trainable model.
58
+
59
+ Our representation matching architecture is similar in some respects to auto-encoding architectures, particularly ladder networks (Rasmus et al., 2015). Unlike ladder networks, however, we do not reconstruct the activations of a non-noisy model from a noisy model but rather, reconstruct the activations of the most recent aggregate model from the activations of the model while it is being trained on a local dataset. This has a regularizing influence as it stops the clients from learning representations that are too specific to their local datasets. This should also ameliorate the effect of model divergence in the clients as all client models have to learn representations that are mappable to a common set of representations defined by the common aggregate model. Additional regularization comes about because a layer’s activations are used to reconstruct the activations of a layer below it. A similar technique was used in what-where autoencoders (Zhao et al., 2015), and was shown to significantly improve accuracy. Our approach is fundamentally distinct, however, as we use the activations in one one model, $\dot { \mathcal { M } } ^ { i }$ , to reconstruct the activations in a different model, $\mathcal { M } ^ { F }$ .
60
+
61
+ Our representation matching scheme is similar in spirit to the techniques used to learn invariant feature representations for domain adaptation where the goal is to minimize the discrepancy between the distributions of features extracted from different domains. However, current techniques for learning domain-invariant features(Ganin et al., 2016; Shen et al., 2017) are incompatible with the FL setting as they require the learner to have access to data from different domains (clients in our case) in order to match the feature distributions across these domains.
62
+
63
+ # 3.2 ADAPTIVE HYPER-PARAMETERS
64
+
65
+ At each round, the server provides the clients with training hyper-parameters. The hyper-parameters $\mathbf { h } _ { t }$ provided in round $t$ are a sample from $P ( \mathcal { H } | \psi _ { t } )$ . Let $L _ { t }$ be the loss of the aggregate model at the beginning of round $t$ on a representative set of data points (we describe in the next subsection practical schemes for evaluating $L _ { t }$ ). We define the reward received for choosing hyper-parameter $\mathbf { h } _ { t }$ as $r _ { t } = ( L _ { t } - L _ { t + 1 } ) / L _ { t }$ . The use of relative loss reduction is motivated by the desire to have the scale of rewards unchanged throughout training. At round $t$ , the goal is to maximize:
66
+
67
+ $$
68
+ J _ { t } = \mathbb { E } _ { P ( \mathbf { h } _ { t } \mid \psi _ { t } ) } [ r _ { t } ]
69
+ $$
70
+
71
+ Taking the derivative of $J _ { t }$ and approximating it with a one-sample Monte Carlo estimate, we obtain
72
+
73
+ $$
74
+ \begin{array} { r } { \nabla _ { \psi _ { t } } J _ { t } = \mathbb { E } _ { P ( \mathbf { h } _ { t } \mid \psi _ { t } ) } [ r _ { t } \nabla _ { \psi _ { t } } l o g ( P ( \mathbf { h } _ { t } \mid \psi _ { t } ) ) ] \qquad } \\ { \approx r _ { t } \nabla _ { \psi _ { t } } l o g ( P ( \mathbf { h } _ { t } \mid \psi _ { t } ) ) \quad w h e r e \quad \mathbf { h } _ { t } \sim P ( \mathbf { h } _ { t } \mid \psi _ { t } ) } \end{array}
75
+ $$
76
+
77
+ The score-function or REINFORCE gradient estimator (Williams, 1992) in Eq. 5 can be readily evaluated and can be used to update $\psi _ { t }$ . However, the variance of this gradient estimator can be quite high (Rezende et al., 2014), especially since we are using a single-sample estimate. To reduce variance, we introduce a reward baseline (Greensmith et al., 2004) which is the weighted average reward in an interval $[ t - Z , t + Z ]$ centered around $t$ . The update equation for $\psi _ { t }$ is:
78
+
79
+ $$
80
+ \psi _ { t + 1 } \psi _ { t } - \eta _ { H } ( r _ { t } - \bar { r } _ { t } ) \nabla _ { \psi _ { t } } l o g ( P ( \mathbf { h } _ { t } | \psi _ { t } ) ) \quad w h e r e \quad \bar { r } _ { t } = \gamma _ { Z } \sum _ { \tau = t - Z } ^ { \tau = t + Z } ( Z + 1 - | \tau - t | ) r _ { \tau }
81
+ $$
82
+
83
+ where $\eta _ { H }$ is the hyper learning rate and $\gamma _ { Z }$ a normalizing constant. We weigh nearby rewards more heavily than distant rewards when calculating the baseline in round $t$ . A causal version of Eq. 6 that only depends on past rewards is:
84
+
85
+ $$
86
+ \psi _ { t + 1 } \psi _ { t } - \eta _ { H } \sum _ { \tau = t - Z } ^ { \tau = t } ( r _ { \tau } - \hat { r } _ { t } ) \nabla _ { \psi _ { \tau } } l o g ( P ( \mathbf { h } _ { \tau } | \psi _ { \tau } ) ) \quad w h e r e \quad \hat { r } _ { t } = \frac { 1 } { Z + 1 } \sum _ { \tau = t - Z } ^ { \tau = t } r _ { \tau }
87
+ $$
88
+
89
+ which is the update equation for $\psi$ that we use. Even though we are using RL terminology, there are several fundamental differences between our problem and traditional RL problems. First, the setting is non-stationary as the same action in different rounds could lead to a different reward distribution. For example, large learning rates are appropriate towards the beginning of training but would increase the loss towards the end of training. In our scheme, this is reflected in the design of the baseline which weighs nearby rewards more heavily as these provide a more accurate baseline of the rewards at the current state of the learning problem. This non-stationary behavior can be modeled as a partially-observable Markov decision process (Jaakkola et al., 1995). While several techniques can be used to learn policies in non-stationary settings (Padakandla et al., 2019; Abdallah & Kaisers, 2016), these methods are not online and require several trajectories (training runs in our case) to optimize the policy. The second difference from traditional RL methods is that we do not seek to maximize the (discounted) sum of rewards, but rather, at each round $t$ , we seek to maximize the rewards in a small interval $[ t - Z , t ]$ which is what allows us to formulate an online algorithm.
90
+
91
+ # 3.3 FULL ALGORITHM AND PRACTICAL CONSIDERATIONS
92
+
93
+ Algorithm 1 describes the FedAvg algorithm with our two contributions: representation matching and adaptive hyper-parameters. There are a couple of practical considerations that we address here:
94
+
95
+ Evaluating the loss of the aggregate model: After each round, the server needs to evaluate the loss of the aggregate model in order to obtain the reward signal (Line 15 in algorithm 1). This could be done in two ways:1) The server maintains a small validation set on which it evaluates the loss. This validation set has to be representative of the clients’ data. Unlike the scheme in Zhao et al. (2015), this validation set is not shared with the clients and can be collected from them in a secure way to avoid revealing the origin of each data point. 2) At the start of a round, the clients themselves evaluate the loss of the aggregate model on a small part of their training data and then send the scalar loss to the server. The server averages these losses to obtain an estimate of the loss. This estimate is good if the fraction of participating clients in the round is high, which would make the evaluated loss more representative of the loss across all clients. In our experiments, we use the first approach.
96
+
97
+ Algorithm 1 Federated averaging with representation matching and online hyper-parameter tuning. Setting with $T$ training rounds, $K$ clients, $n _ { k }$ datapoints per client, $N$ total datapoints, and a fraction $C$ of clients participating in each round
98
+
99
+ <table><tr><td>1: initialize w1 and 01,...,0K and γ1</td></tr><tr><td>2: L1←Loss(W1)</td></tr><tr><td>3: for t=1 to T do</td></tr><tr><td>4: ht ~P(o|t) &gt; Sample a set of hyper-parameters</td></tr><tr><td>5: St ←(random selection of CK clients)</td></tr><tr><td>6: fori∈ St do Run in parallel in each client in St</td></tr><tr><td>7: w←Wt &gt;Receive model parameters from server</td></tr><tr><td>8: for n=1 to n_iterations(ht) do &gt;Number of SGD iterations as defined in ht</td></tr><tr><td></td></tr><tr><td>9: (X,Y) ← sample(Di) Sample a training mini-batch</td></tr><tr><td>10: [w²,0]←[w²,0]-n(ht)V[wi,θi]Li(X,Y;w²,Wt,0i)&gt;Li as defined in Eq.2</td></tr><tr><td>11: end for +1← 12:</td></tr><tr><td>13: end for</td></tr><tr><td>14: Wt+1←Wt+∑ (w-Wt)</td></tr><tr><td>iESt</td></tr><tr><td>15: Lt+1←Loss(Wt+1)</td></tr><tr><td>16: rt←(Lt-Lt+1)/Lt Z&#x27;←min(Z,t-1)</td></tr><tr><td>17: T=t T=t</td></tr><tr><td>(rr -rt)Vp,log(P(h,lψ+)) where rt= z/+1 18: t+1←t-nH M 1 £ rT T=t-z&#x27;</td></tr></table>
100
+
101
+ 19: end for
102
+
103
+ Choosing the form of $\begin{array} { r l } { P ( \mathcal { H } | \boldsymbol { \psi } ) } & { { } : \operatorname { F o r } D } \end{array}$ hyper-parameters, we use a discrete D-dimensional hyperparameter space. For the $p ^ { t h }$ hyper-parameter, we have a finite set of allowable values $\mathcal { H } _ { p }$ . $\mathcal { H }$ is a D-dimensional grid containing all possible combinations of the allowed values of the $D$ hyperparameter. $\begin{array} { r } { | \mathcal { H } | \overset { \mathbf { \bar { \mathbf { \Lambda } } } } { = } \prod _ { p = 1 } ^ { D } | \mathcal { H } _ { p } | } \end{array}$ . For $P ( \mathcal { H } | \psi )$ we use a D-dimensional discrete Gaussian. Let $\mathcal { N } ( \bullet | \boldsymbol { \mu } , \mathbf { A } )$ be a standard(continuous) D-dimensional Gaussian with mean $\mu$ and precision A. Let $\mathbf { h } _ { j } \overset { \cdot } { = } ( h _ { j } ^ { 1 } , \ldots , h _ { j } ^ { D } )$ be a point on the grid $\mathcal { H }$ . $\begin{array} { r } { P ( \mathbf { h } _ { j } | \psi ) = \frac { 1 } { \mathbf { Z } } \mathcal { N } ( \mathbf { h } _ { j } | \mu , \mathbf { A } ) } \end{array}$ where $\mathbf { \bar { \boldsymbol { \psi } } } = \{ \mu , \mathbf { A } \}$ and $\begin{array} { r } { \mathbf { Z } = \sum _ { \mathbf { h } \in \mathcal { H } } \mathcal { N } ( \mathbf { h } | \mu , \mathbf { A } ) } \end{array}$ . Since different hyper-parameters can have different scales, we shift and normalize the allowed values for each hyper-parameter so that they have zero mean and are in the range $[ - 0 . 5 , 0 . 5 ]$ before constructing the grid. The grid of hyper-parameters $\mathcal { H }$ thus has zero-mean and the same scale in all dimensions. This increase the stability of the hyper-parameter tuning algorithm as the optimization space is uniform in all directions.
104
+
105
+ We choose a discrete hyper-parameter space $\mathcal { H }$ to force different hyper-parameter choices to be significantly different, which would provide more distinct reward signals to the online REINFORCE algorithm. The choice of a uni-modal distribution, such as the discrete Gaussian, encourages hyperparameter exploration to focus on areas around the mode. This embodies the inductive bias that the optimal hyper-parameter in one round is close to the optimal hyper-parameter in the previous round.
106
+
107
+ # 4 EXPERIMENTAL RESULTS
108
+
109
+ We evaluate the performance of our two-part scheme on the MNIST and CIFAR10 image classification datasets, and on a KWS task using the speech commands dataset (Warden, 2018). We restrict the KWS task to only ten keywords. In all experiments, we use ten clients and use one of two data distributions: iid where the dataset is split randomly across the ten clients, and non-iid where each client only has data points belonging to one of the ten classes. We use our online hyper-parameter tuning scheme to tune the learning rate and the number of SGD iterations (see algorithm 1). In all experiments, we use the same hyper-hyper-parameters controlling the hyper-parameter tuning process which are the hyper-learning rate $\eta _ { H }$ , the hyper-parameter grid $\mathcal { H }$ , and the REINFORCE baseline interval $Z$ . One exception is the KWS task where we modify the grid $\mathcal { H }$ to reduce the number of allowed SGD iterations per round to reflect the smaller size of the dataset. A batch size of 64 is used throughout. In all experiments, we add an entropy regularization (ER) term (Pereyra et al., 2017) to the client losses during training. For client $i$ in round $t$ with input $\mathbf { x }$ , the ER loss term has the form:
110
+
111
+ $$
112
+ \mathscr { L } _ { E R } ( \mathbf { x } , \mathbf { w } _ { t } ^ { i } ) = m a x \left( 0 , H _ { m i n } - H ( s o f t m a x ( \mathbf { a } _ { M } ( \mathbf { x } ; \mathbf { w } _ { t } ^ { i } ) ) ) \right)
113
+ $$
114
+
115
+ where $H ( \bullet )$ is the entropy operator and $\mathbf { a } _ { M }$ the top layer activity. $\mathcal { L } _ { E R }$ penalizes highly confident (low entropy) output distributions when their entropy falls below $H _ { m i n }$ . This loss term significantly improves the performance of the FedAvg algorithm in the presence of non-iid client data.
116
+
117
+ As a comparison baseline, we run experiments with a fixed decay schedule for both the learning rate and the number of SGD iterations per round. As a baseline for our representation matching scheme, we run experiments where each client’s training loss is augmented with a term that penalizes weight divergence between the client model parameters and the initial parameters received from the server. For client $i$ in round $t$ , this weight divergence (WD) loss term has the form $| | \mathbf { w } _ { t } - \mathbf { w } _ { t } ^ { i } | | _ { 2 } ^ { 2 }$ . This penalty function was introduced into the FL setting by the FedProx algorithm (Li et al., 2018) to mitigate the effect of model divergence.
118
+
119
+ We report results for the standard FedAvg algorithm (FA), FedAvg with a weight divergence loss term in the clients $\mathrm { ( F A + W D ) }$ ), and FedAvg augmented with adaptive hyper-parameters(AH) and/or representation matching (RM). We consider two values for $C$ (the fraction of clients participating in each round): $C = 0 . 5$ and $C = 1 . 0$ . For the baselines, FA and $\mathrm { F A + W D }$ , we manually tuned the hyper-parameters decay schedule to obtain best accuracy. This tuning was done separately for the iid and non-iid cases . All experiments were repeated 3 times.
120
+
121
+ MNIST : We use a fully-connected network with two hidden layers with 100 neurons each. As shown in table 1, the best performing algorithm is $\mathrm { F A + A H }$ . The use of representation matching causes a slight degradation in performance $\mathbf { \Gamma } \mathbf { F } \mathbf { A } { + } \mathbf { R } \mathbf { M } { + } \mathbf { A } \mathbf { H }$ and $\mathrm { F A + R M }$ ). It is interesting to look at the trajectory of the mean $\mu$ of the discrete Gaussian hyper-parameter distribution $P ( \mathcal { H } | \bar { \mu } , \mathbf { A } )$ . This is shown in the first column of Fig. 3 for the iid and non-iid cases. In the non-iid case, the online REINFORCE algorithm pushes the mean learning rate down as it detects that a smaller learning rate yields greater loss reductions, while in the iid case, the mean learning rate is pushed up instead. This aligns with what a practitioner would do to ensure convergence in the more challenging non-iid case. The REINFORCE algorithm chooses to keep the mean number of SGD iterations per round relatively high for most of the training run. As shown in table 1, these choices yield slightly better accuracy $\mathrm { ( F A + A H ) }$ ) than the fixed training schedule used in the standard FA algorithm.
122
+
123
+ Table 1: MNIST accuracy figures
124
+
125
+ <table><tr><td></td><td>Data Distribution</td><td>FA</td><td>FA+WD</td><td>FA+RM+AH</td><td>FA+RM</td><td>FA+AH</td></tr><tr><td rowspan="2">C=1.0</td><td>iid</td><td>97.9±0.1</td><td>97.9± 0.005</td><td>97.9± 0.06</td><td>97.8± 0.06</td><td>98.0± 0.04</td></tr><tr><td>non-iid</td><td>94.7 ± 0.07</td><td>94.8 ± 0.2</td><td>94.7 ± 0.08</td><td>94.5 ± 0.3</td><td>95.5 ± 0.04</td></tr><tr><td rowspan="2">C=0.5</td><td>iid</td><td>97.4 ± 0.06</td><td>97.3± 0.03</td><td>98.1±0.06</td><td>97.4± 0.05</td><td>98.2 ± 0.01</td></tr><tr><td>non-iid</td><td>92.1± 0.8</td><td>92.0 ± 0.4</td><td>92.5 ± 0.1</td><td>91.6 ± 0.3</td><td>93.2 ± 0.8</td></tr></table>
126
+
127
+ CIFAR10 : We use a network with two convolutional layers (with 32 and 64 feature maps and 5x5 kernels) followed by two fully connected layers (with 1024 and 10 neurons). 2x2 max pooling was used after each convolutional layer. As shown in table 2, the use of representation matching yields a significant improvement in accuracy for the non-iid case while slightly improving performance in the iid case. The benefit of adaptive hyper-parameters over a fixed hyper-parameter schedule are more equivocal. The evolution of adaptive hyper-parameters is shown in the second column of Fig. 3. Unlike the MNIST case, the REINFORCE algorithm chooses to push down the learning rate for the iid case as well which actually leads to better performance in the iid case compared to the fixed schedule (FA vs. $\mathrm { F A + A H }$ and $\mathrm { F A + R M + A H }$ vs. $\mathrm { F A + R M }$ in table 2). In the non-iid case, the fixed schedule performs better, though.
128
+
129
+ Keyword spotting task : We calculate the mel spectrogram for each speech command to obtain a $3 2 \mathrm { x } 3 2 $ input to our network. The network we use has four convolutional layers with $3 { \tt X } 3$ kernels and 64 feature maps each (with $2 \mathbf { x } 2$ max pooling after each pair), followed by two fully connected layers of 1024 and 10 neurons. In this deeper network, representation matching is essential in the non-iid case as shown in table 3 since training consistently fails in its absence. It might be possible that with fine tuning of hyper-parameters, training would be possible in the non-iid case. However, representation matching obviates the need for such fine tuning. $\mathrm { F A + R M + A H }$ consistently outperforms all other methods indicating the hyper-parameters schedule found by the REINFORCE algorithm (third column in Fig. 3) is better than the fixed schedule.
130
+
131
+ Table 2: CIFAR10 accuracy figures
132
+
133
+ <table><tr><td></td><td>Data Distribution</td><td>FA</td><td>FA+WD</td><td>FA+RM+AH</td><td>FA+RM</td><td>FA+AH</td></tr><tr><td rowspan="2">C=1.0</td><td>iid</td><td>81.9 ± 0.3</td><td>81.4± 0.2</td><td>84.3± 0.1</td><td>83.5 ± 0.1</td><td>83.4± 1.2</td></tr><tr><td>non-iid</td><td>44.2 ± 0.9</td><td>44.3 ± 0.8</td><td>52.4± 2.2</td><td>52.9 ± 0.05</td><td>44.8± 5.8</td></tr><tr><td rowspan="2">C=0.5</td><td>iid</td><td>76.8 ± 0.3</td><td>76.6± 0.2</td><td>79.2 ± 1.9</td><td>76.0±0.2</td><td>82.0 ± 1.04</td></tr><tr><td>non-iid</td><td>33.4 ± 1.0</td><td>34.4 ± 0.9</td><td>39.8 ± 3.8</td><td>43.3± 0.8</td><td>19.8 ± 7.0</td></tr></table>
134
+
135
+ ![](images/ada8294d76d0fdd950157581591b7c3276c51c515f73a96add93f7eee66ee6eb.jpg)
136
+ Figure 3: Evolution of the mean of the hyper-parameter distribution $P ( \mathcal { H } | \psi )$ for the iid and non-iid cases. Results taken from the $\mathrm { F A + R M + A H }$ algorithm when $C = 1 . 0$ . The evolution of the means are shown separately for the learning rate (first row) and for the number of SGD steps per round (second row), with one column each for the MNIST, CIFAR10, and keyword spotting (KWS) tasks. During training, the means are forced to stay within the ranges defined by the hyper-parameter grid.
137
+
138
+ Table 3: Keyword spotting task accuracy figures
139
+
140
+ <table><tr><td></td><td>Data Distribution</td><td>FA</td><td>FA+WD</td><td>FA+RM+AH</td><td>FA+RM</td><td>FA+AH</td></tr><tr><td rowspan="2">C=1.0</td><td>iid</td><td>93.0±0.2</td><td>93.5 ± 0.2</td><td>94.4± 0.2</td><td>92.9± 0.3</td><td>94.0± 0.4</td></tr><tr><td>non-iid</td><td>28.4± 7.2</td><td>29.9 ± 7.3</td><td>81.1 ± 0.5</td><td>79.2 ± 0.6</td><td>9.8± 0.2</td></tr><tr><td rowspan="2">C=0.5</td><td>iid</td><td>91.4±0.3</td><td>93.0±0.4</td><td>94.3± 0.1</td><td>91.0± 0.2</td><td>93.2± 0.4</td></tr><tr><td>non-iid</td><td>11.45 ± 1.7</td><td>11.8 ± 2.7</td><td>74.9 ± 2.5</td><td>60.7 ± 3.3</td><td>10.0± 0.3</td></tr></table>
141
+
142
+ Communication and computational overhead : Our representation matching scheme does not introduce any communication overhead between the clients and the central server. The adaptive hyper-parameters scheme introduces a negligible communication overhead for sending two scalar hyper-parameters to the clients each round. As for computational overhead, we quantify the wallclock run-time1 for training a client for $3 0 ~ \mathrm { S G D }$ iterations or mini-batches (mini-batch size of 64). Where adaptive hyper-parameters are used, we also include the time needed to execute the adaptive hyper-parameter tuning procedure. The results are shown in table 4. We note that the overhead of our hyper-parameter tuning procedure is negligible (FA vs. $\mathrm { F A + A H } ,$ ) and is typically less than $2 \%$ . This negligible computational overhead is primarily the cost of a single inference pass to evaluate the loss $L _ { t }$ on a very small subset of the training set. The representation matching scheme is more demanding as as it requires optimizing a more complicated loss during each SGD iteration at the client.
143
+
144
+ Table 4: Wall-clock run-time in seconds. Mean and std. from 200 trials.
145
+
146
+ <table><tr><td>Task</td><td>FA</td><td>FA+WD</td><td>FA+RM+AH</td><td>FA+RM</td><td>FA+AH</td></tr><tr><td>MNIST</td><td>0.39±0.007</td><td>0.41±0.008</td><td>0.43±0.007</td><td>0.42±0.007</td><td>0.39±0.007</td></tr><tr><td>CIFAR10</td><td>0.50± 0.02</td><td>0.54± 0.01</td><td>0.67 ± 0.02</td><td>0.66 ± 0.02</td><td>0.51 ± 0.02</td></tr><tr><td>KWS</td><td>1.83 ± 0.05</td><td>1.96 ± 0.05</td><td>2.03 ± 0.04</td><td>2.01 ± 0.04</td><td>1.85 ± 0.05</td></tr></table>
147
+
148
+ # 5 DISCUSSION
149
+
150
+ We described two additions to the FedAvg algorithm: representation matching and adaptive hyperparameters. We compared representation matching $( \mathrm { F A + R M } )$ against a scheme based on penalizing weight divergence $\mathrm { ( F A + W D ) }$ and $\mathrm { F A + R M }$ came out on top by a significant margin in the more difficult tasks we tried: CIFAR10 and KWS. We compared our adaptive hyper-parameter scheme against a fixed hyper-parameter schedule chosen based on experience. In most cases, adaptive hyper-parameters outperform the fixed-schedule scheme. The combination of our two new additions $( \mathrm { F A + R M + A H } )$ ) slightly improves performance compared to standard FA in the small MNIST network and significantly improves performance on the deeper networks used in CIFAR10 and KWS.
151
+
152
+ The hyper-parameter schedule chosen by our REINFORCE algorithm exhibits some easily interpretable behavior such as reducing the learning rate in the more difficult non-iid cases. However, we see some behavior that does not have an immediately obvious interpretation. For example, in order to maximize rewards in the non-iid case, reducing the learning rate is more important than reducing the number of SGD iterations per round as can be seen in Fig. 3. It is important to note that at each round, our online REINFORCE algorithm only seeks to maximize the loss improvement in the last few rounds. Moreover, our algorithm continuously samples hyper-parameters around the mean to determine the direction of highest reward. These noisy hyper-parameter choices could prove problematic in settings that depend on highly tuned schedules and which have no room for online exploration of hyper-parameters. We thus expect our scheme would be outperformed by traditional automated hyper-parameter tuning methods that tune hyper-parameters to maximize the final validation loss. However, our scheme is significantly more efficient as it does not require repeated training and introduces only a small computational overhead in each round.
153
+
154
+ # REFERENCES
155
+
156
+ Sherief Abdallah and Michael Kaisers. Addressing environment non-stationarity by repeating qlearning updates. The Journal of Machine Learning Research, 17(1):1582–1612, 2016.
157
+ James Bergstra and Yoshua Bengio. Random search for hyper-parameter optimization. Journal of Machine Learning Research, 13(Feb):281–305, 2012.
158
+ J.S. Bergstra, Remi Bardenet, Yoshua Bengio, and Bal ´ azs K ´ egl. Algorithms for hyper-parameter ´ optimization. In Advances in neural information processing systems, pp. 2546–2554, 2011.
159
+ Christian Daniel, Jonathan Taylor, and Sebastian Nowozin. Learning step size controllers for robust neural network training. In Thirtieth AAAI Conference on Artificial Intelligence, 2016.
160
+ Luca Franceschi, Michele Donini, Paolo Frasconi, and Massimiliano Pontil. Forward and reverse gradient-based hyperparameter optimization. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 1165–1173. JMLR. org, 2017.
161
+
162
+ Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, Franc¸ois Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. The Journal of Machine Learning Research, 17(1):2096–2030, 2016.
163
+
164
+ Evan Greensmith, P.L. Bartlett, and Jonathan Baxter. Variance reduction techniques for gradient estimates in reinforcement learning. Journal of Machine Learning Research, 5(Nov):1471–1530, 2004.
165
+
166
+ David Ha, Andrew Dai, and Q.V. Le. Hypernetworks. arXiv preprint arXiv:1609.09106, 2016.
167
+
168
+ Tommi Jaakkola, S.P. Singh, and M.I. Jordan. Reinforcement learning algorithm for partially observable markov decision problems. In Advances in neural information processing systems, pp. 345–352, 1995.
169
+
170
+ H.S. Jomaa, Josif Grabocka, and Lars Schmidt-Thieme. Hyp-rl: Hyperparameter optimization by reinforcement learning. arXiv preprint arXiv:1906.11527, 2019.
171
+
172
+ Aaron Klein, Stefan Falkner, Simon Bartels, Philipp Hennig, and Frank Hutter. Fast bayesian optimization of machine learning hyperparameters on large datasets. arXiv preprint arXiv:1605.07079, 2016.
173
+
174
+ Jakub Konecnˇ y, H.B. McMahan, F.X. Yu, Peter Richt \` arik, A.T. Suresh, and Dave Bacon. Federated ´ learning: Strategies for improving communication efficiency. arXiv preprint arXiv:1610.05492, 2016.
175
+
176
+ Lisha Li, Kevin Jamieson, Giulia DeSalvo, Afshin Rostamizadeh, and Ameet Talwalkar. Hyperband: A novel bandit-based approach to hyperparameter optimization. arXiv preprint arXiv:1603.06560, 2016.
177
+
178
+ Tian Li, A.K. Sahu, Manzil Zaheer, Maziar Sanjabi, Ameet Talwalkar, and Virginia Smith. Federated optimization in heterogeneous networks. arXiv preprint arXiv:1812.06127, 2018.
179
+
180
+ Jonathan Lorraine and David Duvenaud. Stochastic hyperparameter optimization through hypernetworks. arXiv preprint arXiv:1802.09419, 2018.
181
+
182
+ Dougal Maclaurin, David Duvenaud, and Ryan Adams. Gradient-based hyperparameter optimization through reversible learning. In International Conference on Machine Learning, pp. 2113– 2122, 2015.
183
+
184
+ H.B. McMahan, Eider Moore, Daniel Ramage, Seth Hampson, et al. Communication-efficient learning of deep networks from decentralized data. arXiv preprint arXiv:1602.05629, 2016.
185
+
186
+ Sindhu Padakandla, Shalabh Bhatnagar, et al. Reinforcement learning in non-stationary environments. arXiv preprint arXiv:1905.03970, 2019.
187
+
188
+ Gabriel Pereyra, George Tucker, Jan Chorowski, Łukasz Kaiser, and Geoffrey Hinton. Regularizing neural networks by penalizing confident output distributions. arXiv preprint arXiv:1701.06548, 2017.
189
+
190
+ Antti Rasmus, Mathias Berglund, Mikko Honkala, Harri Valpola, and Tapani Raiko. Semisupervised learning with ladder networks. In Advances in Neural Information Processing Systems, pp. 3546–3554, 2015.
191
+
192
+ D.J. Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In ICML, pp. 1278–1286, 2014.
193
+
194
+ Felix Sattler, Simon Wiedemann, Klaus-Robert Muller, and Wojciech Samek. Robust and ¨ communication-efficient federated learning from non-iid data. arXiv preprint arXiv:1903.02891, 2019.
195
+
196
+ Jian Shen, Yanru Qu, Weinan Zhang, and Yong Yu. Wasserstein distance guided representation learning for domain adaptation. arXiv preprint arXiv:1707.01217, 2017.
197
+
198
+ Jasper Snoek, Hugo Larochelle, and R.P. Adams. Practical bayesian optimization of machine learning algorithms. In Advances in neural information processing systems, pp. 2951–2959, 2012.
199
+
200
+ Pete Warden. Speech commands: A dataset for limited-vocabulary speech recognition. arXiv preprint arXiv:1804.03209, 2018.
201
+ R.J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3-4):229–256, 1992.
202
+ Chang Xu, Tao Qin, Gang Wang, and Tie-Yan Liu. Reinforcement learning for learning rate control. arXiv preprint arXiv:1705.11159, 2017.
203
+ J.J. Zhao, Michael Mathieu, Ross Goroshin, and Yann LeCun. Stacked what-where auto-encoders. arXiv preprint arXiv:1506.02351, 2015.
204
+ Yue Zhao, Meng Li, Liangzhen Lai, Naveen Suda, Damon Civin, and Vikas Chandra. Federated learning with non-iid data. arXiv preprint arXiv:1806.00582, 2018.
md/train/SJlhPMWAW/SJlhPMWAW.md ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GRAPHVAE: TOWARDS GENERATION OF SMALLGRAPHS USING VARIATIONAL AUTOENCODERS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Deep learning on graphs has become a popular research topic with many applications. However, past work has concentrated on learning graph embedding tasks only, which is in contrast with advances in generative models for images and text. Is it possible to transfer this progress to the domain of graphs? We propose to sidestep hurdles associated with linearization of such discrete structures by having a decoder output a probabilistic fully-connected graph of a predefined maximum size directly at once. Our method is formulated as a variational autoencoder. We evaluate on the challenging task of conditional molecule generation.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Deep learning on graphs has very recently become a popular research topic, with useful applications across fields such as chemistry (Gilmer et al., 2017), medicine (Ktena et al.), or computer vision (Simonovsky & Komodakis, 2017). Past work has concentrated on learning graph embedding tasks so far, i.e. encoding an input graph into a vector representation. This is in stark contrast with fastpaced advances in generative models for images and text, which have seen massive rise in quality of generated samples. Hence, it is an intriguing question how one can transfer this progress to the domain of graphs, i.e. their decoding from a vector representation. Moreover, the desire for such a method has been mentioned in the past by Gomez-Bombarelli et al. (2016). ´
12
+
13
+ However, learning to generate graphs is a difficult problem for methods based on gradient optimization, as graphs are discrete structures. Incremental construction involves discrete decisions, which are not differentiable. Unlike sequence (text) generation, graphs can have arbitrary connectivity and there is no clear best way how to linearize their construction in a sequence of steps.
14
+
15
+ In this work, we propose to sidestep these hurdles by having the decoder output a probabilistic fully-connected graph of a predefined maximum size directly at once. In a probabilistic graph, the existence of nodes and edges, as well as their attributes, are modeled as independent random variables. The method is formulated in the framework of variational autoencoders (VAE) by Kingma & Welling (2013).
16
+
17
+ We demonstrate our method, coined GraphVAE, in cheminformatics on the task of molecule generation. Molecular datasets are a challenging but convenient testbed for our generative model, as they easily allow for both qualitative and quantitative tests of decoded samples. While our method is applicable for generating smaller graphs only and its performance leaves space for improvement, we believe our work is an important initial step towards powerful and efficient graph decoders.
18
+
19
+ # 2 RELATED WORK
20
+
21
+ Graph Decoders. Graph generation has been largely unexplored in deep learning. The closest work to ours is by Johnson (2017), who incrementally constructs a probabilistic (multi)graph as a world representation according to a sequence of input sentences to answer a query. While our model also outputs a probabilistic graph, we do not assume having a prescribed order of construction transformations available and we formulate the learning problem as an autoencoder.
22
+
23
+ $\mathrm { X u }$ et al. (2017) learns to produce a scene graph from an input image. They construct a graph from a set of object proposals, provide initial embeddings to each node and edge, and use message passing to obtain a consistent prediction. In contrast, our method is a generative model which produces a probabilistic graph from a single opaque vector, without specifying the number of nodes or the structure explicitly.
24
+
25
+ ![](images/bd2e26609369b1d21ef49469a2b2a5f5cab0a4cffa4eac6081c1771bbc4a90cd.jpg)
26
+ Figure 1: Illustration of the proposed variational graph autoencoder in its conditional form. Starting from a discrete attributed graph $G = ( A , E , F )$ on $n$ nodes (e.g. a representation of propylene oxide), stochastic graph encoder $q _ { \phi } ( \mathbf { z } | G )$ embeds the graph into continuous representation $\mathbf { z }$ . Given a point in the latent space, our novel graph decoder $p _ { \boldsymbol { \theta } } ( G | \mathbf { z } )$ outputs a probabilistic fully-connected graph $\widetilde { G } = ( \widetilde { A } , \widetilde { E } , \widetilde { F } )$ on predefined $k \geq n$ nodes, from which discrete samples may be drawn. The process can be conditioned on label $\mathbf { y }$ for controlled sampling at test time. Reconstruction ability of the autoencoder is facilitated by approximate graph matching for aligning $G$ with $\widetilde { G }$ .
27
+
28
+ Related work pre-dating deep learning includes random graphs (Erdos & Renyi, 1960; Barab ´ asi & ´ Albert, 1999), stochastic blockmodels (Snijders & Nowicki, 1997), or state transition matrix learning (Gong & Xiang, 2003).
29
+
30
+ Discrete Data Decoders. Text is the most common discrete representation. Generative models there are usually trained by teacher forcing (Williams & Zipser, 1989), which avoids the need to backpropagate through output discretization by feeding the ground truth instead of the past sample at each step. Recently, efforts have been made to overcome this problem. Notably, computing a differentiable approximation using Gumbel distribution (Kusner & Hernandez-Lobato, 2016) or ´ bypassing the problem by learning a stochastic policy in reinforcement learning (Yu et al., 2017). Our work also circumvents the non-differentiability problem, namely by formulating the loss on a probabilistic graph.
31
+
32
+ Molecule Decoders. Generative models may become promising for de novo design of molecules fulfilling certain criteria by being able to search for them over a continuous embedding space (Olivecrona et al., 2017). With that in mind, we propose a conditional version of our model. While molecules have an intuitive representation as graphs, the field has had to resort to textual representations with fixed syntax, e.g. so-called SMILES strings, to exploit recent progress made in text generation with RNNs (Olivecrona et al., 2017; Segler et al., 2017; Gomez-Bombarelli et al., 2016). ´ As their syntax is brittle, many invalid strings tend to be generated, which has been recently addressed by Kusner et al. (2017) by incorporating grammar rules into decoding. While encouraging, their approach does not guarantee semantic (chemical) validity, similarly as our method.
33
+
34
+ # 3 METHOD
35
+
36
+ We approach the task of graph generation by devising a neural network able to translate vectors in a continuous code space to graphs. Our main idea is to output a probabilistic fully-connected graph and use a standard graph matching algorithm to align it to the ground truth. The proposed method is formulated in the framework of variational autoencoders (VAE) by Kingma & Welling (2013), although other forms of regularized autoencoders would be equally suitable (Makhzani et al., 2015;
37
+
38
+ Li et al., 2015a). We briefly recapitulate VAE below and continue with introducing our novel graph decoder together with an appropriate loss function.
39
+
40
+ # 3.1 VARIATIONAL AUTOENCODER
41
+
42
+ Let $G = ( A , E , F )$ be a graph specified with its adjacency matrix $A$ , edge attribute tensor $E$ , and node attribute matrix $F$ . We wish to learn an encoder and a decoder to map between the space of graphs $G$ and their continuous embedding $\mathbf { z } \in \mathbb { R } ^ { c }$ , see Figure 1. In the probabilistic setting of a VAE, the encoder is defined by a variational posterior $q _ { \phi } ( \mathbf { z } | G )$ and the decoder by a generative distribution $p _ { \boldsymbol { \theta } } ( G | \mathbf { z } )$ , where $\phi$ and $\theta$ are learned parameters. Furthermore, there is a prior distribution $p ( \mathbf { z } )$ imposed on the latent code representation as a regularization; we use a simplistic isotropic Gaussian prior $p ( \mathbf { z } ) = N ( 0 , I )$ . The whole model is trained by minimizing the upper bound on negative log-likelihood $- \log p _ { \theta } ( G )$ (Kingma & Welling, 2013):
43
+
44
+ $$
45
+ \mathcal { L } ( \phi , \theta ; G ) = \mathbb { E } _ { q _ { \phi } ( \mathbf { z } | G ) } [ - \log p _ { \theta } ( G | \mathbf { z } ) ] + \mathrm { K L } [ q _ { \phi } ( \mathbf { z } | G ) | | p ( \mathbf { z } ) ]
46
+ $$
47
+
48
+ The first term of $\mathcal { L }$ , the reconstruction loss, enforces high similarity of sampled generated graphs to the input graph $G$ . The second term, KL-divergence, regularizes the code space to allow for sampling of $\mathbf { z }$ directly from $p ( \mathbf { z } )$ instead from $q _ { \phi } ( \bar { \bf z } | G )$ later. The dimensionality of $\mathbf { z }$ is usually fairly small so that the autoencoder is encouraged to learn a high-level compression of the input instead of learning to simply copy any given input. While the regularization is independent on the input space, the reconstruction loss must be specifically designed for each input modality. In the following, we introduce our graph decoder together with an appropriate reconstruction loss.
49
+
50
+ # 3.2 PROBABILISTIC GRAPH DECODER
51
+
52
+ Graphs are discrete objects, ultimately. While this does not pose a challenge for encoding, demonstrated by the recent developments in graph convolution networks (Gilmer et al., 2017), graph generation has been an open problem so far. In a related task of text sequence generation, the currently dominant approach is character-wise or word-wise prediction (Bowman et al., 2016). However, graphs can have arbitrary connectivity and there is no clear way how to linearize their construction in a sequence of steps1. On the other hand, iterative construction of discrete structures during training without step-wise supervision involves discrete decisions, which are not differentiable and therefore problematic for back-propagation.
53
+
54
+ Fortunately, the task can become much simpler if we restrict the domain to the set of all graphs on maximum $k$ nodes, where $k$ is fairly small (in practice up to the order of tens). Under this assumption, handling dense graph representations is still computationally tractable. We propose to make the decoder output a probabilistic fully-connected graph $\widetilde { G } = ( \widetilde { A } , \widetilde { E } , \widetilde { F } )$ on $k$ nodes at once. This effectively sidesteps both problems mentioned above.
55
+
56
+ In probabilistic graphs, the existence of nodes and edges is modeled as Bernoulli variables, whereas node and edge attributes are multinomial variables. While not discussed in this work, continuous attributes could be easily modeled as Gaussian variables represented by their mean and variance. We assume all variables to be independent.
57
+
58
+ Each tensor of the representation of $\widetilde { G }$ has thus a probabilistic interpretation. Specifically, the predicted adjacency matrix $\widetilde { A } \in [ 0 , 1 ] ^ { k \times k }$ contains both node probabilities $\widetilde { A } _ { a , a }$ and edge probabilities $\widetilde { A } _ { a , b }$ for nodes $a \neq b$ . The edge attribute tensor $\widetilde { E } \in \mathbb { R } ^ { k \times k \times d _ { e } }$ indicates class probabilities for edges and, similarly, the node attribute matrix $\widetilde { F } \in \mathbb { R } ^ { k \times d _ { n } }$ contains class probabilities for nodes.
59
+
60
+ The decoder itself is deterministic. Its architecture is a simple multi-layer perceptron (MLP) with three outputs in its last layer. Sigmoid activation function is used to compute $\widetilde { A }$ , whereas edge- and node-wise softmax is applied to obtain $\widetilde { E }$ and $\widetilde { F }$ , respectively. At test time, we are often interested in a (discrete) point estimate of $\widetilde { G }$ , which can be obtained by taking edge- and node-wise argmax in $\widetilde { A } , \widetilde { E }$ , and $\widetilde { F }$ . Note that this can result in a discrete graph on less than $k$ nodes.
61
+
62
+ # 3.3 RECONSTRUCTION LOSS
63
+
64
+ Given a particular of a discrete input graph $G$ on $n \leq k$ nodes and its probabilistic reconstruction $\widetilde { G }$ on $k$ nodes, evaluation of Equation 1 requires computation of likelihood $p _ { \theta } ( G | \mathbf { z } ) = P ( G | \widetilde { G } )$ .
65
+
66
+ Since no particular ordering of nodes is imposed in either $\widetilde { G }$ or $G$ and matrix representation of graphs is not invariant to permutations of nodes, comparison of two graphs is hard. However, approximate graph matching described further in Subsection 3.4 can obtain a binary assignment matrix $X \in$ $\{ 0 , 1 \} ^ { k \times n }$ , where $X _ { a , i } = 1$ only if node $a \in { \widetilde { G } }$ is assigned to $i \in G$ and $X _ { a , i } = 0$ otherwise.
67
+
68
+ Knowledge of $X$ allows to map information between both graphs. Specifically, input adjacency matrix is mapped to the predicted graph as $A ^ { \prime } = X A X ^ { T }$ , whereas the predicted node attribute matrix and slices of edge attribute matrix are transferred to the input graph as $\widetilde { F } ^ { \prime } = X ^ { T } \widetilde { F }$ and $\widetilde { E } _ { \cdot , \cdot , l } ^ { \prime } = X ^ { T } \widetilde { E } _ { \cdot , \cdot , l } X$ . The maximum likelihood estimates, i.e. cross-entropy, of respective variables are as follows:
69
+
70
+ $$
71
+ \begin{array} { r l } & { \log p ( { \cal A } ^ { \prime } | { \bf z } ) = 1 / k \displaystyle \sum _ { a } { \cal A } _ { a , a } ^ { \prime } \log \widetilde { { \cal A } } _ { a , a } + ( 1 - { \cal A } _ { a , a } ^ { \prime } ) \log ( 1 - \widetilde { { \cal A } } _ { a , a } ) + } \\ & { \quad \quad \quad \quad + 1 / k ( k - 1 ) \displaystyle \sum _ { a \neq b } { \cal A } _ { a , b } ^ { \prime } \log \widetilde { { \cal A } } _ { a , b } + ( 1 - { \cal A } _ { a , b } ^ { \prime } ) \log ( 1 - \widetilde { { \cal A } } _ { a , b } ) } \\ & { \log p ( { \cal F } | { \bf z } ) = 1 / n \displaystyle \sum _ { i } \log { \cal F } _ { i , \cdot } ^ { T } \widetilde { { \cal F } } _ { i , \cdot } ^ { \prime } } \\ & { \log p ( { \cal E } | { \bf z } ) = 1 / ( \| { \cal A } \| _ { 1 } - n ) \displaystyle \sum _ { i \neq j } \log { \cal E } _ { i , j , \cdot } ^ { T } \widetilde { { \cal E } } _ { i , j , \cdot } ^ { \prime } . } \end{array}
72
+ $$
73
+
74
+ where we assumed that $F$ and $E$ are encoded in one-hot notation. The formulation considers existence of both matched and unmatched nodes and edges but attributes of only the matched ones. Furthermore, averaging over nodes and edges separately has shown beneficial in training as otherwise the edges dominate the likelihood. The overall reconstruction loss is a weighed sum of the previous terms:
75
+
76
+ $$
77
+ - \log p ( G | \mathbf { z } ) = - \lambda _ { A } \log p ( A ^ { \prime } | \mathbf { z } ) - \lambda _ { F } \log p ( F | \mathbf { z } ) - \lambda _ { E } \log p ( E | \mathbf { z } )
78
+ $$
79
+
80
+ # 3.4 GRAPH MATCHING
81
+
82
+ The goal of (second-order) graph matching is to find correspondences $X \in \{ 0 , 1 \} ^ { k \times n }$ between nodes of graphs $G$ and $\widetilde { G }$ based on the similarities of their node pairs $S : ( i , j ) \times ( a , b ) \mathbb { R } ^ { + }$ for $i , j \in G$ and $a , b \in { \widetilde { G } }$ . It can be expressed as integer quadratic programming problem of similarity maximization over $X$ and is typically approximated by relaxation of $X$ into continuous domain: $X ^ { \ast } \in [ 0 , 1 ] ^ { k \times n }$ (Cho et al., 2014). For our use case, the similarity function is defined as follows:
83
+
84
+ $$
85
+ \begin{array} { r l } & { S ( ( i , j ) , ( a , b ) ) = ( E _ { i , j , . } ^ { T } \widetilde { E } _ { a , b , . } ) A _ { i , j } \widetilde { A } _ { a , b } \widetilde { A } _ { a , a } \widetilde { A } _ { b , b } [ i \neq j \wedge a \neq b ] + } \\ & { \quad \quad \quad + ( F _ { i , \cdot } ^ { T } \widetilde { F } _ { a , \cdot } ) \widetilde { A } _ { a , a } [ i = j \wedge a = b ] } \end{array}
86
+ $$
87
+
88
+ The first term evaluates similarity between edge pairs and the second term between node pairs, $[ \cdot ]$ being the Iverson bracket. Note that the scores consider both feature compatibility ( $\widetilde F$ and $\widetilde { E }$ ) and existential compatibility $( \widetilde { A } )$ , which has empirically led to more stable assignments during training. To summarize the motivation behind both Equations 3 and 4, our method aims to find the best graph matching and then further improve on it by gradient descent on the loss. Given the stochastic way of training deep network, we argue that solving the matching step only approximately is sufficient. This is conceptually similar to the approach for learning to output unordered sets by (Vinyals et al., 2015), where the closest ordering of the training data is searched for.
89
+
90
+ In practice, we are looking for a graph matching algorithm robust to noisy correspondences which can be easily implemented on GPU in batch mode. Max-pooling matching (MPM) by Cho et al.
91
+
92
+ (2014) is a simple but effective algorithm following the iterative scheme of power methods, see Appendix A for details. It can be used in batch mode if similarity tensors are zero-padded, i.e. $\mathsf { \bar { S } } ( ( i , j ) , ( a , b ) ) = 0$ for $n < i , j \le k$ , and the amount of iterations is fixed.
93
+
94
+ Max-pooling matching outputs continuous assignment matrix $X ^ { * }$ . Unfortunately, attempts to directly use $X ^ { \ast }$ instead of $X$ in Equation 3 performed badly, as did experiments with direct maximization of $X ^ { * }$ or soft discretization with softmax or straight-through Gumbel softmax (Jang et al., 2016). We therefore discretize $X ^ { * }$ to $X$ using Hungarian algorithm to obtain a strict one-on-one mapping2. While this operation is non-differentiable, gradient can still flow to the decoder directly through the loss function and training convergence proceeds without problems. Note that this approach is often taken in works on object detection, e.g. (Stewart et al., 2016), where a set of detections need to be matched to a set of ground truth bounding boxes and treated as fixed before computing a differentiable loss.
95
+
96
+ # 3.5 FURTHER DETAILS
97
+
98
+ Encoder. A feed forward network with edge-conditioned graph convolutions (ECC) (Simonovsky & Komodakis, 2017) is used as encoder, although any other graph embedding method is applicable. As our edge attributes are categorical, a single linear layer for the filter generating network in ECC is sufficient. Due to smaller graph sizes no pooling is used in encoder except for global pooling, for which we employ soft attention pooling of Li et al. (2015b). As usual in VAE, we formulate encoder as probabilistic and enforce Gaussian distribution of $q _ { \phi } ( \mathbf { z } | G )$ by having the last encoder layer outputs $2 c$ features interpreted as mean and variance, allowing to sample $\mathbf { z } _ { l } \sim N ( \mu _ { l } ( G ) , \sigma _ { l } ( G ) )$ for $l \in { 1 , . . , c }$ using the re-parameterization trick (Kingma & Welling, 2013).
99
+
100
+ Disentangled Embedding. In practice, rather than random drawing of graphs, one often desires more control over the properties of generated graphs. In such case, we follow Sohn et al. (2015) and condition both encoder and decoder on label vector $\mathbf { y }$ associated with each input graph $G$ . Decoder $p _ { \theta } ( G | \mathbf { z } , \mathbf { y } )$ is fed a concatenation of $\mathbf { z }$ and $\mathbf { y }$ , while in encoder $q _ { \phi } ( \mathbf { z } | G , \mathbf { y } )$ , y is concatenated to every node’s features just before the graph pooling layer. If the size of latent space $c$ is small, the decoder is encouraged to exploit information in the label.
101
+
102
+ Limitations. The proposed model is expected to be useful only for generating small graphs. This is due to growth of GPU memory requirements and number of parameters $( O ( k ^ { \bar { 2 } } ) )$ as well matching complexity $( O ( k ^ { 4 } ) )$ with small decrease in quality for high values of $k$ . In Section 4 we demonstrate results for up to $k = 3 8$ . Nevertheless, for many applications even generation of small graphs is still very useful.
103
+
104
+ # 4 EVALUATION
105
+
106
+ We demonstrate our method for the task of molecule generation by evaluating on two large public datasets of organic molecules, QM9 and ZINC.
107
+
108
+ # 4.1 APPLICATION IN CHEMINFORMATICS
109
+
110
+ Quantitative evaluation of generative models of images and texts has been troublesome (Theis et al., 2015), as it very difficult to measure realness of generated samples in an automated and objective way. Thus, researchers frequently resort there to qualitative evaluation and embedding plots. However, qualitative evaluation of graphs can be very unintuitive for humans to judge unless the graphs are planar and fairly simple.
111
+
112
+ Fortunately, we found graph representation of molecules, as undirected graphs with atoms as nodes and bonds as edges, to be a convenient testbed for generative models. On one hand, generated graphs can be easily visualized in standardized structural diagrams. On the other hand, chemical validity of graphs, as well as many further properties a molecule can fulfill, can be checked using software packages (SanitizeMol in RDKit) or simulations. This makes both qualitative and quantitative tests possible.
113
+
114
+ Chemical constraints on compatible types of bonds and atom valences make the space of valid graphs complicated and molecule generation challenging. In fact, a single addition or removal of edge or change in atom or bond type can make a molecule chemically invalid. Comparably, flipping a single pixel in MNIST-like number generation problem is of no issue.
115
+
116
+ To help the network in this application, we introduce three remedies. First, we make the decoder output symmetric $\widetilde { A }$ and $\widetilde { E }$ by predicting their (upper) triangular parts only, as undirected graphs are sufficient representation for molecules. Second, we use prior knowledge that molecules are connected and, at test time only, construct maximum spanning tree on the set of probable nodes $\{ a : \widetilde { A } _ { a , a } \geq 0 . 5 \}$ in order to include its edges $( a , b )$ in the discrete pointwise estimate of the graph even if $\widetilde { A } _ { a , b } < 0 . 5$ originally. Third, we do not generate Hydrogen explicitly and let it be added as ”padding” during chemical validity check.
117
+
118
+ # 4.2 QM9 DATASET
119
+
120
+ QM9 dataset (Ramakrishnan et al., 2014) contains about $1 3 4 \mathrm { k }$ organic molecules of up to 9 heavy (non Hydrogen) atoms with 4 distinct atomic numbers and 4 bond types, we set $k = 9$ , $d _ { e } = 4$ and $d _ { n } = 4$ . We set aside $1 0 \mathrm { k }$ samples for testing and $1 0 \mathrm { k }$ for validation (model selection).
121
+
122
+ We compare our unconditional model to the character-based generator of Gomez-Bombarelli et al. ´ (2016) (CVAE) and the grammar-based generator of Kusner et al. (2017) (GVAE). We used the code and architecture in Kusner et al. (2017) for both baselines, adapting the maximum input length to the smallest possible. In addition, we demonstrate a conditional generative model for an artificial task of generating molecules given a histogram of heavy atoms as 4-dimensional label y, the success of which can be easily validated.
123
+
124
+ Setup. The encoder has two graph convolutional layers (32 and 64 channels) with identity connection, batchnorm, and ReLU; followed by soft attention pooling (Li et al., 2015b) with 128 channels and a fully-connected layer (FCL) to output $( \mu , \sigma )$ . The decoder has 3 FCLs (128, 256, and 512 channels) with batchnorm and ReLU; followed by parallel triplet of FCLs to output graph tensors. We set $c = 4 0$ , $\lambda _ { A } = \lambda _ { F } = \lambda _ { E } = 1$ , batch size 32, 75 MPM iterations and train for 25 epochs with Adam with learning rate 1e-3 and $\beta _ { 1 } { = } 0 . 5$ .
125
+
126
+ Embedding Visualization. To visually judge the quality and smoothness of the learned embedding $\mathbf { z }$ of our model, we may traverse it in two ways: along a slice and along a line. For the former, we randomly choose two $c$ -dimensional orthonormal vectors and sample $\mathbf { z }$ in regular grid pattern over the induced 2D plane. For the latter, we randomly choose two molecules $G ^ { ( 1 ) } , G ^ { ( 2 ) }$ of the same label from test set and interpolate between their embeddings $\mu ( G ^ { ( 1 ) } ) , \mu ( G ^ { ( 2 ) } )$ . This also evaluates the encoder, and therefore benefits from low reconstruction error.
127
+
128
+ We plot two planes in Figure 2, for a frequent label (left) and a less frequent label in QM9 (right). Both images show a varied and fairly smooth mix of molecules. The left image has many valid samples broadly distributed across the plane, as presumably the autoencoder had to fit a large portion of database into this space. The right exhibits stronger effect of regularization, as valid molecules tend to be only around center.
129
+
130
+ An example of several interpolations is shown in Figure 3. We can find both meaningful (1st, 2nd and 4th row) and less meaningful transitions, though many samples on the lines do not form chemically valid compounds.
131
+
132
+ Decoder Quality Metrics. The quality of a conditional decoder can be evaluated by the validity and variety of generated graphs. For a given label $\mathbf { y } ^ { ( l ) }$ , we draw $n _ { s } = 1 0 ^ { 4 }$ samples $\bar { \mathbf { z } } ^ { ( l , s ) } \sim p ( \mathbf { z } )$ and compute the discrete point estimate of their decodings $\hat { G } ^ { ( l , s ) } = \arg \operatorname* { m a x } p _ { \boldsymbol { \theta } } \big ( G | \mathbf { z } ^ { ( l , s ) } , \mathbf { y } ^ { ( l ) } \big )$ .
133
+
134
+ Let $V ^ { ( l ) }$ be the list of chemically valid molecules from $\hat { G } ^ { ( l , s ) }$ and $C ^ { ( l ) }$ be the list of chemically valid molecules with atom histograms equal to $\mathbf { y } ^ { ( l ) }$ . We are interested in ratios $\mathrm { V a l i d } ^ { ( l ) } = | V ^ { ( l ) } | / n _ { s }$ and Accurate $^ { ( l ) } = | C ^ { ( l ) } | / n _ { s }$ . Furthermore, let $\mathrm { U n i q u e } ^ { ( l ) } = | \mathrm { s e t } ( { \cal C } ^ { ( l ) } ) | / | { \cal C } ^ { ( l ) } |$ be the fraction of unique correct graphs and $\mathrm { N o v e l } ^ { ( l ) } = 1 - | \mathrm { s e t } ( C ^ { ( l ) } ) \cap \mathrm { Q M } 9 | / | \mathrm { s e t } ( C ^ { ( l ) } ) |$ the fraction of novel out-of-dataset graphs; we define $\mathrm { U n i q u e } ^ { ( l ) } = 0$ and $\mathrm { N o v e l } ^ { ( l ) } = 0$ if $| C ^ { ( l ) } | = 0$ . Finally, the introduced metrics are aggregated by frequencies of labels in QM9, e.g. $\begin{array} { r } { \mathrm { V a l i d } = \sum _ { l } \mathrm { V a l i d } ^ { ( l ) } \mathrm { f r e q } ( \mathbf { y } ^ { ( l ) } ) } \end{array}$ . Unconditional decoders are evaluated by assuming there is just a single label, therefore Valid $=$ Accurate.
135
+
136
+ ![](images/96f5127b3c5447296d83b5f8ea28fe7690ee2904169d092e93b12b4baf14d311.jpg)
137
+ Figure 2: Decodings of latent space points sampled over a random 2D plane in z-space of $c = 4 0$ (within 5 units from center of coordinates). Left: Samples conditioned on $7 \mathbf { x }$ Carbon, $1 \mathbf { x }$ Nitrogen, 1x Oxygen ( $12 \%$ QM9). Right: Samples conditioned on $5 \mathbf { x }$ Carbon, 1x Nitrogen, $3 \mathbf { x }$ Oxygen $2 . 6 \%$ QM9). Color legend as in Figure 3.
138
+
139
+ ![](images/71807bde150e0d214ffd3dad47fac6f2df24b76c5dc70e5da8b23c84a335fab7.jpg)
140
+ Figure 3: Linear interpolation between row-wise pairs of randomly chosen molecules in $\mathbf { z } \mathrm { . }$ -space of $c = 4 0$ . Color legend: encoder inputs (green), chemically invalid graphs (red), valid graphs with wrong label (blue), valid and correct (white).
141
+
142
+ In Table 1, we can see that on average $50 \%$ of generated molecules are chemically valid and, in the case of conditional models, about $40 \%$ have the correct label which the decoder was conditioned on. Larger embedding sizes $c$ are less regularized, demonstrated by a higher number of Unique samples and by lower accuracy of the conditional model, as the decoder is forced less to rely on actual labels. The ratio of Valid samples shows less clear behavior, likely because the discrete performance is not directly optimized for. For all models, it is remarkable that about $60 \%$ of generated molecules are out of the dataset, i.e. the network has never seen them during training. In Appendix B we additionally trade uniqueness for validity.
143
+
144
+ Table 1: Performance on conditional and unconditional QM9 models evaluated by mean testtime reconstruction log-likelihood $( \log p _ { \theta } ( G | \mathbf { z } ) )$ , mean test-time evidence lower bound (ELBO), and decoding quality metrics (Section 4.2). Baselines CVAE (Gomez-Bombarelli et al., 2016) and ´ GVAE(Kusner et al., 2017) are listed only for the embedding size with the highest Valid.
145
+
146
+ <table><tr><td></td><td></td><td>log pe(G|z)</td><td>ELBO</td><td>Valid</td><td>Accurate</td><td>Unique</td><td>Novel</td></tr><tr><td rowspan="5">&#x27;puoo</td><td>Ours c = 20</td><td>-0.578</td><td>-0.722</td><td>0.565</td><td>0.467</td><td>0.314</td><td>0.598</td></tr><tr><td>Ours c = 40</td><td>-0.504</td><td>-0.617</td><td>0.511</td><td>0.416</td><td>0.484</td><td>0.635</td></tr><tr><td>Ours c = 60</td><td>-0.492</td><td>-0.585</td><td>0.520</td><td>0.406</td><td>0.583</td><td>0.613</td></tr><tr><td>Ours c = 80</td><td>-0.475</td><td>-0.557</td><td>0.458</td><td>0.353</td><td>0.666</td><td>0.661</td></tr><tr><td>Ours c = 20</td><td>-0.660</td><td>-0.916</td><td>0.485</td><td>0.485</td><td>0.457</td><td>0.575</td></tr><tr><td rowspan="8">marrniruirrn</td><td>Ours c = 40</td><td>-0.537</td><td>-0.744</td><td>0.542</td><td>0.542</td><td>0.618</td><td>0.617</td></tr><tr><td>Ours c = 60</td><td>-0.486</td><td></td><td>0.517</td><td>0.517</td><td>0.695</td><td>0.570</td></tr><tr><td>Ours c = 80</td><td>-0.482</td><td>-0.656 -0.628</td><td>0.557</td><td>0.557</td><td>0.760</td><td>0.616</td></tr><tr><td>NoGM c = 80</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>CVAE c = 60</td><td>-2.388</td><td>-2.553</td><td>0.810 0.103</td><td>0.810</td><td>0.241</td><td>0.610</td></tr><tr><td>GVAE c = 20</td><td>二</td><td>1</td><td>0.602</td><td>0.103</td><td>0.675</td><td>0.900</td></tr><tr><td></td><td>1</td><td>1</td><td></td><td>0.602</td><td>0.093</td><td>0.809</td></tr></table>
147
+
148
+ Looking at the baselines, CVAE can output only very few valid samples as expected, while GVAE generates the highest number of valid samples $( 6 0 \% )$ but of very low variance (less than $10 \%$ ). Additionally, we investigate the importance of graph matching by using identity assignment $X$ instead and thus learning to reproduce particular node permutations in the training set, which correspond to the canonical ordering of SMILES strings from rdkit. This ablated model (denoted as NoGM in Table 1) produces many valid samples of lower variety and, surprisingly, outperforms GVAE in this regard. In comparison, our model can achieve good performance in both metrics at the same time.
149
+
150
+ Likelihood. Besides the application-specific metric introduced above, we also report evidence lower bound (ELBO) commonly used in VAE literature, which corresponds to $- { \mathcal { L } } ( { \bar { \phi } } , \theta ; G )$ in our notation. In Table 1, we state mean bounds over train and test set, using a single $\mathbf { z }$ sample per graph. We observe both reconstruction loss and KL-divergence decrease due to larger $c$ providing more freedom. However, there seems to be no strong correlation between ELBO and Valid, which makes model selection somewhat difficult.
151
+
152
+ # 4.3 ZINC DATASET
153
+
154
+ ZINC dataset (Irwin et al., 2012) contains about 250k drug-like organic molecules of up to 38 heavy atoms with 9 distinct atomic numbers and 4 bond types, we set $k = 3 8$ , $d _ { e } = 4$ and $d _ { n } = 9$ and use the same split strategy as with QM9. We investigate the degree of scalability of an unconditional generative model.
155
+
156
+ Setup. The setup is equivalent as for QM9 but with a wider encoder (64, 128, 256 channels).
157
+
158
+ Decoder Quality Metrics. Our best model with $c = 4 0$ has archived $\mathrm { V a l i d } = 0 . 1 3 5$ , which is clearly worse than for QM9. For comparison, CVAE failed to generated any valid sample, while GVAE achieved $\mathrm { V a l i d } = 0 . 3 5 7$ (models provided by Kusner et al. (2017), $c = 5 6$ ).
159
+
160
+ We attribute such a low performance to a generally much higher chance of producing a chemicallyrelevant inconsistency (number of possible edges growing quadratically). To confirm the relationship between performance and graph size $k$ , we kept only graphs not larger than $k = 2 0$ nodes, corresponding to $21 \%$ of ZINC, and obtained $\mathrm { V a l i d } = 0 . 3 4 1$ (and $\mathrm { V a l i d } = 0 . 1 8 5$ for $k = 3 0$ nodes, $92 \%$ of ZINC). To verify that the problem is likely not caused by our proposed graph matching loss, we synthetically evaluate it in the following.
161
+
162
+ <table><tr><td>Noise</td><td>k =15</td><td>k =20</td><td>k =25</td><td>k =30</td><td>k =35</td><td>k = 40</td></tr><tr><td>∈A,E,F =0</td><td>99.55</td><td>99.52</td><td>99.45</td><td>99.4</td><td>99.47</td><td>99.46</td></tr><tr><td>∈A = 0.4</td><td>90.95</td><td>89.55</td><td>86.64</td><td>87.25</td><td>87.07</td><td>86.78</td></tr><tr><td>∈A= 0.8</td><td>82.14</td><td>81.01</td><td>79.62</td><td>79.67</td><td>79.07</td><td>78.69</td></tr><tr><td>€E=0.4</td><td>97.11</td><td>96.42</td><td>95.65</td><td>95.90</td><td>95.69</td><td>95.69</td></tr><tr><td>€E=0.8</td><td>92.03</td><td>90.76</td><td>89.76</td><td>89.70</td><td>88.34</td><td>89.40</td></tr><tr><td>€F=0.4</td><td>98.32</td><td>98.23</td><td>97.64</td><td>98.28</td><td>98.24</td><td>97.90</td></tr><tr><td>∈F=0.8</td><td>97.26</td><td>97.00</td><td>96.60</td><td>96.91</td><td>96.56</td><td>97.17</td></tr></table>
163
+
164
+ Table 2: Mean accuracy of matching ZINC graphs to their noisy counterparts in a synthetic benchmark as a function of maximum graph size $k$ .
165
+
166
+ Matching Robustness. Robust behavior of graph matching using our similarity function $S$ is important for good performance of GraphVAE. Here we study graph matching in isolation to investigate its scalability. To that end, we add Gaussian noise $N ( 0 , \epsilon _ { A } ) , N ( 0 , \epsilon _ { E } ) , N ( 0 , \epsilon _ { F } )$ to each tensor of input graph $G$ , truncating and renormalizing to keep their probabilistic interpretation, to create its noisy version $G _ { N }$ . We are interested in the quality of matching between self, $P [ G , G ]$ , using noisy assignment matrix $X$ between $G$ and $G _ { N }$ . The advantage to naive checking $X$ for identity is the invariance to permutation of equivalent nodes.
167
+
168
+ In Table 2 we vary $k$ and $\epsilon$ for each tensor separately and report mean accuracies (computed in the same fashion as losses in Equation 3) over 100 random samples from ZINC with size up to $k$ nodes. While we observe an expected fall of accuracy with stronger noise, the behavior is fairly robust with respect to increasing $k$ at a fixed noise level, the most sensitive being the adjacency matrix. Note that accuracies are not comparable across tables due to different dimensionalities of random variables. We may conclude that the quality of the matching process is not a major hurdle to scalability.
169
+
170
+ # 5 CONCLUSION
171
+
172
+ In this work we addressed the problem of generating graphs from a continuous embedding in the context of variational autoencoders. We evaluated our method on two molecular datasets of different maximum graph size. While we achieved to learn embedding of reasonable quality on small molecules, our decoder had a hard time capturing complex chemical interactions for larger molecules. Nevertheless, we believe our method is an important initial step towards more powerful decoders and will spark interesting in the community.
173
+
174
+ There are many avenues to follow for future work. Besides the obvious desire to improve the current method (for example, by incorporating a more powerful prior distribution or adding a recurrent mechanism for correcting mistakes), we would like to extend it beyond a proof of concept by applying it to real problems in chemistry, such as optimization of certain properties or predicting chemical reactions. An advantage of a graph-based decoder compared to SMILES-based decoder is the possibility to predict detailed attributes of atoms and bonds in addition to the base structure, which might be useful in these tasks. Our autoencoder can also be used to pre-train graph encoders for fine-tuning on small datasets (Goh et al., 2017).
175
+
176
+ # REFERENCES
177
+
178
+ Albert-Laszl ´ o Barab ´ asi and R ´ eka Albert. Emergence of scaling in random networks. ´ Science, 286 (5439):509–512, 1999.
179
+
180
+ Samuel R. Bowman, Luke Vilnis, Oriol Vinyals, Andrew M. Dai, Rafal Jozefowicz, and Samy ´ Bengio. Generating sentences from a continuous space. In Proceedings of the 20th SIGNLL Conference on Computational Natural Language Learning, CoNLL 2016, Berlin, Germany, August 11-12, 2016, pp. 10–21, 2016.
181
+
182
+ Minsu Cho, Jian Sun, Olivier Duchenne, and Jean Ponce. Finding matches in a haystack: A maxpooling strategy for graph matching in the presence of outliers. In CVPR, pp. 2091–2098, 2014.
183
+
184
+ Ketan Date and Rakesh Nagi. Gpu-accelerated hungarian algorithms for the linear assignment problem. Parallel Computing, 57:52–72, 2016.
185
+
186
+ Paul Erdos and Alfred R ´ enyi. On the evolution of random graphs. ´ Publ. Math. Inst. Hung. Acad. Sci, 5(1):17–60, 1960.
187
+
188
+ Justin Gilmer, Samuel S. Schoenholz, Patrick F. Riley, Oriol Vinyals, and George E. Dahl. Neural message passing for quantum chemistry. In Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, 6-11 August 2017, pp. 1263–1272, 2017.
189
+
190
+ Garrett B. Goh, Charles Siegel, Abhinav Vishnu, and Nathan O. Hodas. Chemnet: A transferable and generalizable deep neural network for small-molecule property prediction. arXiv preprint arXiv:1712.02734, 2017.
191
+
192
+ 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.
193
+
194
+ Shaogang Gong and Tao Xiang. Recognition of group activities using dynamic probabilistic networks. In ICCV, pp. 742–749, 2003.
195
+
196
+ John J. Irwin, Teague Sterling, Michael M. Mysinger, Erin S. Bolstad, and Ryan G. Coleman. ZINC: A free tool to discover chemistry for biology. Journal of Chemical Information and Modeling, 52 (7):1757–1768, 2012.
197
+
198
+ Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. CoRR, abs/1611.01144, 2016.
199
+
200
+ Daniel D Johnson. Learning graphical state transitions. In ICLR, 2017.
201
+
202
+ Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. CoRR, abs/1312.6114, 2013. URL http://arxiv.org/abs/1312.6114.
203
+
204
+ Sofia Ira Ktena, Sarah Parisot, Enzo Ferrante, Martin Rajchl, Matthew C. H. Lee, Ben Glocker, and Daniel Rueckert. Distance metric learning using graph convolutional networks: Application to functional brain networks. In MICCAI.
205
+
206
+ Matt J. Kusner and Jose Miguel Hern ´ andez-Lobato. GANS for sequences of discrete elements with ´ the gumbel-softmax distribution. CoRR, abs/1611.04051, 2016.
207
+
208
+ Matt J. Kusner, Brooks Paige, and Jose Miguel Hern ´ andez-Lobato. Grammar variational autoen- ´ coder. In ICML, pp. 1945–1954, 2017.
209
+
210
+ Greg Landrum. RDKit: Open-source cheminformatics. URL http://www.rdkit.org.
211
+
212
+ Yujia Li, Kevin Swersky, and Richard S. Zemel. Generative moment matching networks. In Proceedings of the 32nd International Conference on Machine Learning, ICML 2015, Lille, France, 6-11 July 2015, pp. 1718–1727, 2015a.
213
+
214
+ Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard S. Zemel. Gated graph sequence neural networks. CoRR, abs/1511.05493, 2015b.
215
+
216
+ Alireza Makhzani, Jonathon Shlens, Navdeep Jaitly, and Ian J. Goodfellow. Adversarial autoencoders. CoRR, abs/1511.05644, 2015.
217
+
218
+ Brendan D. McKay and Adolfo Piperno. Practical graph isomorphism, $\{ \Pi \}$ . Journal of Symbolic Computation, 60(0):94 – 112, 2014. ISSN 0747-7171. doi: http://dx.doi.org/10.1016/j. jsc.2013.09.003. URL http://www.sciencedirect.com/science/article/pii/ S0747717113001193.
219
+
220
+ Marcus Olivecrona, Thomas Blaschke, Ola Engkvist, and Hongming Chen. Molecular de novo design through deep reinforcement learning. CoRR, abs/1704.07555, 2017.
221
+
222
+ Raghunathan Ramakrishnan, Pavlo O Dral, Matthias Rupp, and O Anatole von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. Scientific Data, 1, 2014.
223
+
224
+ Marwin H. S. Segler, Thierry Kogej, Christian Tyrchan, and Mark P. Waller. Generating focussed molecule libraries for drug discovery with recurrent neural networks. CoRR, abs/1701.01329, 2017.
225
+
226
+ Martin Simonovsky and Nikos Komodakis. Dynamic edge-conditioned filters in convolutional neural networks on graphs. In CVPR, 2017. URL https://arxiv.org/abs/1704.02901.
227
+
228
+ Tom A.B. Snijders and Krzysztof Nowicki. Estimation and prediction for stochastic blockmodels for graphs with latent block structure. Journal of Classification, 14(1):75–100, Jan 1997.
229
+
230
+ Kihyuk Sohn, Honglak Lee, and Xinchen Yan. Learning structured output representation using deep conditional generative models. In NIPS, pp. 3483–3491, 2015.
231
+
232
+ Russell Stewart, Mykhaylo Andriluka, and Andrew Y Ng. End-to-end people detection in crowded scenes. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2325–2333, 2016.
233
+
234
+ Lucas Theis, Aaron van den Oord, and Matthias Bethge. A note on the evaluation of generative ¨ models. CoRR, abs/1511.01844, 2015.
235
+
236
+ Oriol Vinyals, Samy Bengio, and Manjunath Kudlur. Order matters: Sequence to sequence for sets. arXiv preprint arXiv:1511.06391, 2015.
237
+
238
+ Ronald J. Williams and David Zipser. A learning algorithm for continually running fully recurrent neural networks. Neural Computation, 1(2):270–280, 1989.
239
+
240
+ Danfei Xu, Yuke Zhu, Christopher Bongsoo Choy, and Li Fei-Fei. Scene graph generation by iterative message passing. In CVPR, 2017.
241
+
242
+ Lantao Yu, Weinan Zhang, Jun Wang, and Yong Yu. Seqgan: Sequence generative adversarial nets with policy gradient. In AAAI, 2017.
243
+
244
+ # APPENDIX
245
+
246
+ # A MAX-POOLING MATCHING
247
+
248
+ In this section we briefly review max-pooling matching algorithm of Cho et al. (2014). In its relaxed form, a continuous correspondence matrix $X ^ { * } \in [ 0 , 1 ] ^ { k \times n }$ between nodes of graphs $G$ and $\widetilde { G }$ is determined based on similarities of node pairs $i , j \in G$ and $a , b \in { \widetilde { G } }$ represented as matrix elements $S _ { i a ; j b } \in \mathbb { R } ^ { + }$ .
249
+
250
+ Let $\mathbf { x } ^ { * }$ denote the column-wise replica of $X ^ { * }$ . The relaxed graph matching problem is expressed as quadratic programming task $\mathbf { x } ^ { * } = \arg \operatorname* { m a x } _ { \mathbf { x } } \mathbf { x } ^ { T } S \mathbf { x }$ such that $\textstyle \sum _ { i = 1 } ^ { n } \mathbf { x } _ { i a } \ \leq \ 1$ , $\textstyle \sum _ { a = 1 } ^ { k } \mathbf { x } _ { i a } \ \leq \ 1$ and $\mathbf { x } \in [ 0 , 1 ] ^ { k n }$ . The optimization strategy of choice is derived to be equivalent to the power method with iterative update rule $\mathbf { x } ^ { ( t + 1 ) } = S \mathbf { x } ^ { ( t ) } / | | S \mathbf { x } ^ { ( t ) } | | _ { 2 }$ . The starting correspondences $\mathbf { x } ^ { ( 0 ) }$ are initialized as uniform and the rule is iterated until convergence; in our use case we run for a fixed amount of iterations.
251
+
252
+ In the context of graph matching, the matrix-vector product $S \mathbf { x }$ can be interpreted as sum-pooling over match candidates: $\begin{array} { r } { \mathbf { x } _ { i a } \gets \bar { \mathbf { x } } _ { i a } S _ { i a ; i a } + \sum _ { j \in N _ { i } } \bar { \sum _ { b \in N _ { a } } } \mathbf { x } _ { j b } S _ { i a ; j b } } \end{array}$ , where $N _ { i }$ and $N _ { a }$ denote the set of neighbors of node $i$ and $a$ . The authors argue that this formulation is strongly influenced by uninformative or irrelevant elements and propose a more robust max-pooling version, which considers only the best pairwise similarity from each neighbor: $\begin{array} { r } { \mathbf { x } _ { i a } \gets \mathbf { x } _ { i a } S _ { i a ; i a } + \sum _ { j \in N _ { i } } \operatorname* { m a x } _ { b \in N _ { a } } \mathbf { x } _ { j b } S _ { i a ; j b } } \end{array}$ .
253
+
254
+ Table 3: Performance on conditional and unconditional QM9 models with implicit node probabilities. Improvement with respect to Table 1 is emphasized in italics.
255
+
256
+ <table><tr><td></td><td></td><td>log pe(G|z)</td><td>ELBO</td><td>Valid</td><td>Accurate</td><td>Unique</td><td>Novel</td></tr><tr><td rowspan="4">&#x27;puoo</td><td>Ours/imp c = 20</td><td>-0.784</td><td>-0.919</td><td>0.572</td><td>0.482</td><td>0.238</td><td>0.718</td></tr><tr><td>Ours/imp c = 40</td><td>-0.671</td><td>-0.776</td><td>0.611</td><td>0.518</td><td>0.307</td><td>0.665</td></tr><tr><td>Ours/imp c = 60</td><td>-0.618</td><td>-0.714</td><td>0.566</td><td>0.448</td><td>0.416</td><td>0.710</td></tr><tr><td>Ours/imp c = 80</td><td>-0.627</td><td>-0.713</td><td>0.583</td><td>0.451</td><td>0.475</td><td>0.681</td></tr><tr><td rowspan="4">&#x27;puooun</td><td>Ours/imp c = 20</td><td>-0.857</td><td>-1.091</td><td>0.533</td><td>0.533</td><td>0.228</td><td>0.610</td></tr><tr><td>Ours/imp c = 40</td><td>-0.737</td><td>-0.932</td><td>0.562</td><td>0.562</td><td>0.420</td><td>0.758</td></tr><tr><td>Ours/imp c = 60</td><td>-0.634</td><td>-0.797</td><td>0.587</td><td>0.587</td><td>0.459</td><td>0.730</td></tr><tr><td>Ours/imp c = 80</td><td>-0.642</td><td>-0.777</td><td>0.571</td><td>0.571</td><td>0.520</td><td>0.719</td></tr></table>
257
+
258
+ # B IMPLICIT NODE PROBABILITIES
259
+
260
+ Our decoder assumes independence of node and edge probabilities, which allows for isolated nodes or edges. Making further use of the fact that molecules are connected graphs, we investigate the effect of making node probabilities a function of edge probabilities in this section. Specifically, we define the probability for node $a$ as that of its most probable edge: $\widetilde { A } _ { a , a } = \operatorname* { m a x } _ { b } \widetilde { A } _ { a , b }$ .
261
+
262
+ The evaluation on QM9 in Table 3 shows a clear improvement in Valid, Accurate, and Novel metrics in both the conditional and unconditional setting. However, this is paid for by lower variability and higher reconstruction loss. This indicates that while the new constraint is useful, the model cannot fully cope with it. Moreover, we have seen no improvement on ZINC dataset.
263
+
264
+ # C UNREGULARIZED AUTOENCODER
265
+
266
+ The regularization in VAE works against achieving perfect reconstruction of training data, especially for small embedding sizes. To understand the reconstruction ability of our architecture, we train it as unregularized in this section, i.e. with a deterministic encoder and without KL-divergence term in Equation 1.
267
+
268
+ Unconditional models for QM9 achieve mean test log-likelihood $\log p _ { \theta } ( G | \mathbf { z } )$ of roughly $- 0 . 3 7$ (about $- 0 . 5 0$ for the implicit model in Appendix B) for all $c \in \{ 2 0 , 4 0 , 6 0 , 8 0 \}$ . While these loglikelihoods are significantly higher than in Tables 1 and 3, our architecture can not achieve perfect reconstruction of inputs. We were successful to increase training log-likelihood to zero only on fixed small training sets of hundreds of examples, where the network could overfit. This indicates that the network has problems finding generally valid rules for assembly of output tensors.
md/train/SJxstlHFPH/SJxstlHFPH.md ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DIFFERENTIABLE REASONING OVER A VIRTUAL KNOWLEDGE BASE
2
+
3
+ Bhuwan Dhingra1∗, Manzil Zaheer2, Vidhisha Balachandran1, Graham Neubig1, Ruslan Salakhutdinov1, William W. Cohen2
4
+
5
+ 1 School of Computer Science, Carnegie Mellon University 2 Google Research {bdhingra, vbalacha, gneubig, rsalakhu}@cs.cmu.edu {manzilzaheer, wcohen}@google.com
6
+
7
+ # ABSTRACT
8
+
9
+ We consider the task of answering complex multi-hop questions using a corpus as a virtual knowledge base $( K B )$ . In particular, we describe a neural module, DrKIT, that traverses textual data like a KB, softly following paths of relations between mentions of entities in the corpus. At each step the module uses a combination of sparse-matrix TFIDF indices and a maximum inner product search (MIPS) on a special index of contextual representations of the mentions. This module is differentiable, so the full system can be trained end-to-end using gradient based methods, starting from natural language inputs. We also describe a pretraining scheme for the contextual representation encoder by generating hard negative examples using existing knowledge bases. We show that DrKIT improves accuracy by 9 points on 3-hop questions in the MetaQA dataset, cutting the gap between text-based and KB-based state-of-the-art by $7 0 \%$ . On HotpotQA, DrKIT leads to a $1 0 \%$ improvement over a BERT-based re-ranking approach to retrieving the relevant passages required to answer a question. DrKIT is also very efficient, processing 10-100x more queries per second than existing multi-hop systems.1
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Large knowledge bases (KBs), such as Freebase and WikiData, organize information around entities, which makes it easy to reason over their contents. For example, given a query like “When was the Grateful Dead’s lead singer born?”, one can identify the entity Grateful Dead and the path of relations LeadSinger, BirthDate to efficiently extract the answer—provided that this information is present in the KB. Unfortunately, KBs are often incomplete (Min et al., 2013). While relation extraction methods can be used to populate KBs, this process is inherently error-prone, expensive and slow.
14
+
15
+ Advances in open-domain QA (Moldovan et al., 2002; Yang et al., 2019) suggest an alternative— instead of performing relation extraction, one could treat a large corpus as a virtual KB by answering queries with spans from the corpus. This ensures facts are not lost in the relation extraction process, but also poses challenges. One challenge is that it is relatively expensive to answer questions using QA models which encode each document in a query-dependent fashion (Chen et al., 2017; Devlin et al., 2019)—even with modern hardware (Strubell et al., 2019; Schwartz et al., 2019). The cost of QA is especially problematic for certain complex questions, such as the example question above. If the passages stating that “Jerry Garcia was the lead singer of the Grateful Dead” and “Jerry Garcia was born in 1942” are far apart in the corpus, it is difficult for systems that retrieve and read a single passage to find an answer—even though in this example, it might be easy to answer the question after the relations were explicitly extracted into a KB. More generally, complex questions involving sets of entities or paths of relations may require aggregating information from multiple documents, which is expensive.
16
+
17
+ One step towards efficient QA is the recent work of Seo et al. (2018; 2019) on phrase-indexed question answering (PIQA), in which spans in the text corpus are associated with question-independent contextual representations and then indexed for fast retrieval. Natural language questions are then answered by converting them into vectors that are used to perform maximum inner product search (MIPS) against the index. This can be done efficiently using approximate algorithms (Shrivastava & Li, 2014). However, this approach cannot be directly used to answer complex queries, since by construction, the information stored in the index is about the local context around a span—it can only be used for questions where the answer can be derived by reading a single passage.
18
+
19
+ This paper addresses this limitation of phrase-indexed question answering. We introduce an efficient, end-to-end differentiable framework for doing complex QA over a large text corpus that has been encoded in a query-independent manner. Specifically, we consider “multi-hop” complex queries which can be answered by repeatedly executing a “soft” version of the operation below, defined over a set of entities $X$ and a relation $R$ :
20
+
21
+ $$
22
+ Y = X . { \mathrm { f o l l o w } } ( R ) = \{ x ^ { \prime } : \exists x \in X { \mathrm { ~ s . t . ~ } } R ( x , x ^ { \prime } ) { \mathrm { ~ h o l d s } } \}
23
+ $$
24
+
25
+ In past work soft, differentiable versions of this operation were used to answer multi-hop questions against an explicit KB (Cohen et al., 2019). Here we propose a more powerful neural module which approximates this operation against an indexed corpus (a virtual KB). In our module, the input $X$ is a sparse-vector representing a weighted set of entities, and the relation $R$ is a dense feature vector, e.g. a vector derived from a neural network over a natural language query. $X$ and $R$ are used to construct a MIPS query used for retrieving the top- $K$ spans from the index. The output $Y$ is another sparse-vector representing the weighted set of entities, aggregated over entity mentions in the top- $K$ spans. We discuss pretraining schemes for the index in $\bar { \ S } \bar { 2 . 3 }$ .
26
+
27
+ For multi-hop queries, the output entities $Y$ can be recursively passed as input to the next iteration of the same module. The weights of the entities in $Y$ are differentiable w.r.t the MIPS queries, which allows end-to-end learning without any intermediate supervision. We discuss an implementation based on sparse-matrix-vector products, whose runtime and memory depend only on the number of spans $K$ retrieved from the index. This is crucial for scaling up to large corpora, providing up to $1 5 \mathrm { x }$ faster inference than existing state-of-the-art multi-hop and open-domain QA systems. The system we introduce is called DrKIT (for Differentiable Reasoning over a Knowledge base of Indexed Text). We test DrKIT on the MetaQA benchmark for complex question answering, and show that it improves on prior text-based systems by 5 points on 2-hop and 9 points on 3-hop questions, reducing the gap between text-based and KB-based systems by $3 0 \%$ and $7 0 \%$ , respectively. We also test DrKIT on a new dataset of multi-hop slot-filling over Wikipedia articles, and show that it outperforms DrQA (Chen et al., 2017) and PIQA (Seo et al., 2019) adapted to this task. Finally, we apply DrKIT to multi-hop information retrieval on the HotpotQA dataset (Yang et al., 2018), and show that it significantly improves over a BERT-based reranking approach, while being $1 0 \mathrm { x }$ faster.
28
+
29
+ # 2 DIFFERENTIABLE REASONING OVER A KB OF INDEXED TEXT
30
+
31
+ We want to answer a question $q$ using a text corpus as if it were a KB. We start with the set of entities $z$ in the question $q$ , and would ideally want to follow relevant outgoing relation edges in the KB to arrive at the answer. To simulate this behaviour on text, we first expand $z$ to set of cooccurring mentions $m$ (say using TFIDF). Not all of these co-occurring mentions are relevant for the question $q$ , so we train a neural network which filters the mentions based on a relevance score of $q$ to $m$ . Then we can aggregate the resulting set of mentions $m$ to the entities they refer to, ending up with an ordered set $z ^ { \prime }$ of entities which are answer candidates, very similar to traversing the KB. Furthermore, if the question requires more than one hop to answer, we can repeat the above procedure starting with $z ^ { \prime }$ . This is depicted pictorially in Figure 1.
32
+
33
+ We begin by first formalizing this idea in a probabilistic framework in $\ S 2 . 1$ . In $\ S 2 . 2$ , we describe how the expansion of entities to mentions and the filtering of mentions can be performed efficiently, using sparse-matrix products and MIPS algorithms (Johnson et al., 2017). Lastly we discuss a pretraining scheme for constructing the mention representations in $\ S 2 . 3$ .
34
+
35
+ Notation: We denote the given corpus as $\mathcal { D } = \{ d _ { 1 } , d _ { 2 } , . . . \}$ , where each $d _ { k } = ( d _ { k } ^ { 1 } , \dots , d _ { k } ^ { L _ { k } } )$ is a sequence of tokens. We start by running an entity linker over the corpus to identify mentions of a fixed set of entities $\mathcal { E }$ . Each mention $m$ is a tuple $( e _ { m } , k _ { m } , i _ { m } , j _ { m } )$ denoting that the text span $d _ { k _ { m } } ^ { i _ { m } } , \ldots , d _ { k _ { m } } ^ { j _ { m } }$ in doc ent $k _ { m }$ mentions the $e _ { m } \in \mathcal { E }$ , and the collection of all mentions in the corpus is denoted as $\mathcal { M }$ . Note that typically $| { \mathcal { M } } | \gg | { \mathcal { E } } |$ .
36
+
37
+ ![](images/374a456e6fc1cc77a02aef3190f3252081d7c8bc178ae0bbe71a04ea91b08de3.jpg)
38
+ Figure 1: DrKIT answers multi-hop questions by iteratively mapping an input set of entities $X$ (The Grateful Dead, Bob Dylan) to an output set of entities $Y$ (Dylan & the Dead, American beauty, ...) which are related to any input entity by some relation $R$ (album by).
39
+
40
+ # 2.1 DIFFERENTIABLE MULTI-HOP REASONING
41
+
42
+ We assume a weakly supervised setting where during training we only know the final answer entities $a \in { \mathcal { E } }$ for a $T$ -hop question. We denote the latent sequence of entities which answer each of the intermediate hops as $z _ { 0 } , z _ { 1 } , \dotsc , z _ { T } \in \mathcal { E }$ , where $z _ { 0 }$ is mentioned in the question, and $z _ { T } = a$ . We can recursively write the probability of an intermediate answer as:
43
+
44
+ $$
45
+ \operatorname* { P r } ( z _ { t } | q ) = \sum _ { z _ { t - 1 } \in \mathcal E } \operatorname* { P r } ( z _ { t } | q , z _ { t - 1 } ) \operatorname* { P r } ( z _ { t - 1 } | q )
46
+ $$
47
+
48
+ Here $\operatorname* { P r } ( z _ { 0 } | q )$ is the output of an entity linking system over the question, and $\operatorname* { P r } \bigl ( z _ { t } | q , z _ { t - 1 } \bigr )$ corresponds to a single-hop model which answers the $t$ -th hop, given the entity from the previous hop $z _ { t - 1 }$ , by following the appropriate relation. Eq. 1 models reasoning over a chain of latent entities, but when answering questions over a text corpus, we must reason over entity mentions, rather than entities themselves. Hence $\operatorname* { P r } \bigl ( z _ { t } | q , z _ { t - 1 } \bigr )$ needs to be aggregated over all mentions of $z _ { t }$ , which yields
49
+
50
+ $$
51
+ \operatorname* { P r } ( z _ { t } | q ) = \sum _ { m \in \mathcal { M } } \sum _ { z _ { t - 1 } \in \mathcal { E } } \operatorname* { P r } ( z _ { t } | m ) \operatorname* { P r } ( m | q , z _ { t - 1 } ) \operatorname* { P r } ( z _ { t - 1 } | q )
52
+ $$
53
+
54
+ The interesting term to model in the above equation is $P r ( m | q , z _ { t - 1 } )$ , which represents the relevance of mention $m$ given the question and entity $z _ { t - 1 }$ . Following the analogy of a KB, we first expand the entity $z _ { t - 1 }$ to co-occuring mentions $m$ and use a learned scoring function to find the relevance of these mentions. Formally, let $F ( m )$ denote a TFIDF vector for the document containing $m$ , $G ( z _ { t - 1 } )$ be the TFIDF vector of the surface form of the entity from the previous hop, and $s _ { t } ( m , z , q )$ be a learnt scoring function (different for each hop). Thus, we model $\mathrm { P r } ( m | q , z _ { t - 1 } )$ as
55
+
56
+ $$
57
+ \operatorname* { P r } ( m | q , z _ { t - 1 } ) \propto \underbrace { \mathbb { 1 } \left\{ G ( z _ { t - 1 } ) \cdot F ( m ) > \epsilon \right\} } _ { \mathrm { e x p a n s i o n ~ t o ~ c o c c u r r i n g ~ m e n t i o n s } } \times \underbrace { s _ { t } ( m , z _ { t - 1 } , q ) } _ { \mathrm { r e l e v a n c e ~ f l t e r i n g } }
58
+ $$
59
+
60
+ Another equivalent way to look at our model in Eq. 3 is that the second term retrieves mentions of the correct type requested by the question in the $t$ -th hop, and the first term filters these based on co-occurrence with $z _ { t - 1 }$ . When dealing with a large set of mentions $m$ , we will typically retain only the top- $K$ relevant mentions. We will show that this joint modelling of co-occurrence and relevance is important for good performance, as was also observed by Seo et al. (2019).
61
+
62
+ The other term left in Eq. 2 is $\Pr ( z | m )$ , which is 1 if mention $m$ refers to the entity $z$ else 0, based on the entity linking system. In general, to compute Eq. 2 the mention scoring of Eq. 3 needs to be evaluated for all latent entity and mention pairs, which is prohibitively expensive. However, by restricting $s _ { t }$ to be an inner product we can implement this efficiently (§2.2).
63
+
64
+ To highlight the differentiability of the proposed overall scheme, we can represent the computation in Eq. 2 as matrix operations. We pre-compute the TFIDF term for all entities and mentions into a sparse matrix, which we denote as $A _ { E \to \bar { M } } [ e , m ] = \mathbb { 1 } \left( G ( e ) \cdot F ( m ) > \epsilon \right)$ . Then entity expansion to co-occuring mentions can be done using a sparse-matrix by sparse-vector multiplication between $A _ { E M }$ and $z _ { t - 1 }$ . For the relevance scores, let $\mathbb { T } _ { K } \big ( s _ { t } ( m , z _ { t - 1 } , q ) \big )$ denote the top- $K$ relevant mentions encoded as a sparse vector in $\mathbb { R } ^ { | \mathcal { M } | }$ . Finally, the aggregation of mentions to entities can be formulated as multiplication with another sparse-matrix $B _ { M E }$ , which encodes coreference, i.e. mentions corresponding to the same entity. Putting all these together, using $\odot$ to denote elementwise product, and defining $Z _ { t } = [ \operatorname* { P r } ( z _ { t } = { \mathsf { \bar { e } } } _ { 1 } | q ) ; \ldots ; \operatorname* { P r } ( z _ { t } = { \mathsf { e } } _ { | \xi | } ^ { - } | q ) ]$ , we can observe that for large $K$ (i.e., as $K | { \mathcal { M } } | )$ , Eq. 2 becomes equivalent to:
65
+
66
+ $$
67
+ Z _ { t } = \mathrm { s o f t m a x } ( [ Z _ { t - 1 } ^ { T } A _ { E M } \odot \mathbb { T } _ { K } ( s _ { t } ( m , z _ { t - 1 } , q ) ) ] B _ { M E } ) .
68
+ $$
69
+
70
+ Note that every operation in above equation is differentiable and between sparse matrices and vectors: we will discuss efficient implementations in $\ S 2 . 2$ . Further, the number of non-zero entries in $Z _ { t }$ is bounded by $K$ , since we filtered (the element-wise product in Eq. 4) to top- $K$ relevant mentions among TFIDF based expansion and since each mention can only point to a single entity in $B _ { M E }$ . This is important, as it prevents the number of entries in $Z _ { t }$ from exploding across hops (which might happen if, for instance, we added the relevance and TFIDF scores instead).
71
+
72
+ We can view $Z _ { t - 1 } , Z _ { t }$ as weighted multisets of entities, and $s _ { t } ( m , z , q )$ as implicitly selecting mentions which correspond to a relation $R$ . Then Eq. 4 becomes a differentiable implementation of $Z _ { t } = Z _ { t - 1 }$ .follow $( R )$ , i.e. mimicking the graph traversal in a traditional KB. We thus call Eq. 4 a textual follow operation.
73
+
74
+ Training and Inference. The model is trained end-to-end by optimizing the cross-entropy loss between $Z _ { T }$ , the weighted set of entities after $T$ hops, and the ground truth answer set $A$ . We use a temperature coefficient $\lambda$ when computing the softmax in Eq, 4 since the inner product scores of the top- $K$ retrieved mentions are typically high values, which would otherwise result in very peaked distributions of $Z _ { t }$ . We also found that taking a maximum over the mention set of an entity $M _ { z _ { t } }$ in Eq. 2 works better than taking a sum. This corresponds to optimizing only over the most confident mention of each entity, which works for corpora like Wikipedia that do not have much redundancy. A similar observation was made by Min et al. (2019) in weakly supervised settings.
75
+
76
+ # 2.2 EFFICIENT IMPLEMENTATION
77
+
78
+ Sparse TFIDF Mention Encoding. To compute the sparse-matrix $A _ { E M }$ for entity-mention expansion in Eq. 4, the TFIDF vectors $F ( m )$ and $G ( z _ { t - 1 } )$ are constructed over unigrams and bigrams, hashed to a vocabulary of $1 6 M$ buckets. While $F$ computes the vector from the whole passage around $m$ , $G$ only uses the surface form of $z _ { t - 1 }$ . This corresponds to retrieving all mentions in a document using $z _ { t - 1 }$ as the query. We limit the number of retrieved mentions per entity to a maximum of $\mu$ , which leads to a $| { \mathcal { E } } | \times | { \mathcal { M } } |$ sparse-matrix.
79
+
80
+ Efficient Entity-Mention expansion. The expansion from a set of entities to mentions occurring around them can be computed using the sparse-matrix by sparse-vector product $Z _ { t - 1 } ^ { T ^ { \prime } } A _ { E \to M }$ . A simple lower bound for multiplying a sparse $| \mathcal { E } | \times | \mathcal { M } |$ matrix, with maximum $\mu$ nonzeros in each row, by a sparse $| \mathcal { E } | \times 1$ vector with $K$ non-zeros is $\Omega ( K \mu )$ . Note that this lower bound is independent of the size of matrix $A _ { E M }$ , or in other words independent of the number of entities or mentions. To attain the lower bound, the multiplication algorithm must be vector driven, because any matrix-driven algorithms need to at least iterate over all the rows. Instead we slice out the relevant rows from $A _ { E M }$ . To enable this our solution is to represent the sparse-matrix $A _ { E M }$ as two row-wise lists of variable-sized lists of the indices and values of the non-zero elements, respectively. This results in a “ragged” representation of the matrix (tf.RaggedTensors, 2018) which can be easily sliced corresponding to the non-zero entries in the vector in $O ( \log | \mathcal { E } | )$ time. We are now left with $K$ sparse-vectors with at most $\mu$ non-zero elements in each. We can add these $K$ sparse-vectors weighted by corresponding values from the vector $Z _ { t - 1 } ^ { T }$ in $O ( K \operatorname* { m a x } \{ K , \mu \} )$ time. Moreover, such an implementation is feasible with deep learning frameworks such as TensorFlow. We tested the scalability of our approach by varying the number of entities for a fixed density of mentions $\mu$ (from Wikipedia). Figure 2 compares our approach to the default sparse-matrix times dense-vector product available in TensorFlow.
81
+
82
+ ![](images/6dcd3f357abcbe05879deb8da50dfb09d6d7f3ee5b37f9f990c10e51134b1892.jpg)
83
+ Figure 2: Runtime on a single K80 GPU when using ragged representations for implementing sparse-matrix vector product, vs the default sparse-matrix times dense vector product available in TensorFlow. $\vert \mathcal { E } \vert > 1 0 ^ { 5 }$ leads to OOM for the latter.
84
+
85
+ Efficient top- $K$ mention relevance filtering: To make computation of Eq. 4 feasible, we need an efficient way to get top- $K$ relevant mentions related to an entity in $z _ { t - 1 }$ for a given question $q$ , without enumerating all possibilities. A key insight is that by restricting the scoring function $s _ { t } ( m , z _ { t - 1 } , q )$ to an inner product, we can easily approximate a parallel version of this computation, across all mentions $m$ . To do this, let $f ( m )$ be a dense encoding of $m$ , and $g _ { t } \big ( q , z _ { t - 1 } \big )$ be a dense encoding of the question $q$ for the $t$ -th hop, both in $\mathbb { R } ^ { p }$ (the details of the dense encoding is provided in next paragraph), then the scoring function $s _ { t } ( m , z _ { t - 1 } , q )$ becomes
86
+
87
+ $$
88
+ s _ { t } ( m , z _ { t - 1 } , q ) \propto \exp \left\{ f ( m ) \cdot g _ { t } ( q , z _ { t - 1 } ) \right\} ,
89
+ $$
90
+
91
+ which can be computed in parallel by multiplying a matrix $f ( { \cal M } ) = [ f ( m _ { 1 } ) ; f ( m _ { 2 } ) ; . . . ]$ with $g _ { t } \big ( q , z _ { t - 1 } \big )$ . Although this matrix will be very large for a realistic corpus, since eventually we are only interested in the top- $K$ values, we can use an approximate algorithm for Maximum Inner Product Search (MIPS) (Andoni et al., 2015; Shrivastava $\&$ Li, 2014) to find the $K$ top-scoring elements. The complexity of this filtering step using MIPS is roughly $O ( K p \mathrm { p o l y l o g } | \mathcal { M } | )$ .
92
+
93
+ Mention and Question Encoders. Mentions are encoded by passing the passages they are contained in through a BERT-large (Devlin et al., 2019) model (trained as described in $\ S 2 . 3 )$ . Suppose mention $m$ appears in passage $d$ , starting at position $i$ and ending at position $j$ . Then $\dot { \boldsymbol { f } } ( \boldsymbol { m } ) = \boldsymbol { W } ^ { T } [ \boldsymbol { H } _ { i } ^ { d } ; \dot { \boldsymbol { H } } _ { j } ^ { d } ]$ , where $H ^ { d }$ is the sequence of embeddings output from BERT, and $W$ is a linear projection to size $p$ . The queries are encoded with a smaller BERT-like model: specifically, they are tokenized with WordPieces (Schuster & Nakajima, 2012), appended to a special [CLS] token, and then passed through a 4-layer Transformer network (Vaswani et al., 2017) with the same architecture as BERT, producing an output sequence $H ^ { q }$ . The $g _ { t }$ functions are defined similarly to the BERT model used for SQuAD-style QA. For each hop $t = 1 , \dots , T$ , we add two additional Transformer layers on top of $H ^ { q }$ , which will be trained to produce MIPS queries from the [CLS] encoding; the first added layer produces a MIPS query $H _ { s t } ^ { \bar { q } }$ to retrieve a start token, and the second added layer a MIPS query $H _ { e n } ^ { q }$ to retrieve an end token. We concatenate the two and define $\tilde { g } _ { t } ( q ) = V ^ { T } [ H _ { s t } ^ { q } ; H _ { e n } ^ { q } ]$ . Finally, to condition on current progress we add the embeddings of $z _ { t - 1 }$ . Specifically, we use entity embeddings $\boldsymbol { E } \in \mathbb { R } ^ { | \mathcal { E } | \times p }$ , to construct an average embedding of the set $Z _ { t - 1 }$ , as $\dot { Z } _ { t - 1 } ^ { T } E$ , and define $g _ { t } ( q , z _ { t - 1 } ) \equiv \tilde { g } _ { t } ( q ) + Z _ { t - 1 } ^ { T } E$ . To avoid a large number of parameters in the model, we compute the entity embeddings as an average over the word embeddings of the tokens in the entity’s surface form. The computational cost of the question encoder $g _ { t } ( q )$ is $O ( p ^ { 2 } )$ .
94
+
95
+ Thus our total computational complexity to answer a query is $\tilde { O } ( K \operatorname* { m a x } \{ K , \mu \} + K p + p ^ { 2 } )$ (almost independent to number of entities or mentions!), with $O ( \mu | \mathcal { E } | + p | \mathcal { M } | )$ memory to store the precomputed matrices and mention index.2
96
+
97
+ # 2.3 PRETRAINING THE INDEX
98
+
99
+ Ideally, we would like to train the mention encoder $f ( m )$ end-to-end using labeled QA data only. However, this poses a challenge when combined with approximate nearest neighbor search—since after every update to the parameters of $f$ , one would need to recompute the embeddings of all mentions in $\mathcal { M }$ . We thus adopt a staged training approach: we first pre-train a mention encoder $f ( m )$ , then compute and index embeddings for all mentions once, keeping these embeddings fixed when training the downstream QA task. Empirically, we observed that using BERT representations “out of the box” do not capture the kind of information our task requires (Appendix C), and thus, pretraining the encoder to capture better mention understanding is a crucial step.
100
+
101
+ One option adopted by previous researchers (Seo et al., 2018) is to fine-tune BERT on SQuAD (Rajpurkar et al., 2016). However, SQuAD is limited to only 536 articles from Wikipedia, leading to
102
+
103
+ Table 1: (Left) MetaQA and (Right) WikiData Hits $@ 1$ for 1-3 hop sub-tasks. ots: off-the-shelf without retraining. $\dagger$ : obtained from Sun et al. (2019). cascade: adapted to multi-hop setting by repeatedly applying Eq. 2. pre: pre-trained on slot-filling. e2e: end-to-end trained on single-hop and multi-hop queries.
104
+
105
+ <table><tr><td colspan="4">MetaQA</td></tr><tr><td>Model</td><td>1hop</td><td>2hop</td><td>3hop</td></tr><tr><td>DrQA (ots)</td><td>0.553</td><td>0.325</td><td>0.197</td></tr><tr><td>KVMemt</td><td>0.762</td><td>0.070</td><td>0.195</td></tr><tr><td>GraftNett</td><td>0.825</td><td>0.362</td><td>0.402</td></tr><tr><td>PullNett</td><td>0.844</td><td>0.810</td><td>0.782</td></tr><tr><td>DrKIT (e2e)</td><td>0.844</td><td>0.860</td><td>0.876</td></tr><tr><td>DrKIT (strong sup.)</td><td>0.845</td><td>0.871</td><td>0.871</td></tr></table>
106
+
107
+ <table><tr><td colspan="4">WikiData</td></tr><tr><td>Model</td><td>1hop</td><td>2hop</td><td>3hop</td></tr><tr><td>DrQA (ots, cascade)</td><td>0.287</td><td>0.141</td><td>0.070</td></tr><tr><td>PIQA (ots, cascade)</td><td>0.240</td><td>0.118</td><td>0.064</td></tr><tr><td>PIQA (pre, cascade)</td><td>0.670</td><td>0.369</td><td>0.182</td></tr><tr><td>DrKIT( T(pre,cascade)</td><td>0.816</td><td>0.404</td><td>0.198</td></tr><tr><td>DrKIT (e2e)</td><td>0.834</td><td>0.469</td><td>0.244</td></tr><tr><td>-BERT index</td><td>0.643</td><td>0.294</td><td>0.165</td></tr></table>
108
+
109
+ a very specific distribution of questions, and is not focused on entity- and relation-centric questions.
110
+ Here we instead train the mention encoder using distant supervision from a KB.
111
+
112
+ Specifically, assume we are given an open-domain KB consisting of facts $( e _ { 1 } , R , e _ { 2 } )$ specifying that the relation $R$ holds between the subject $e _ { 1 }$ and the object $e _ { 2 }$ . Then for a corpus of entity-linked text passages $\{ d _ { k } \}$ , we automatically identify tuples $( d , ( e _ { 1 } , R , e _ { 2 } ) )$ such that $d$ mentions both $e _ { 1 }$ and $e _ { 2 }$ . Using this data, we learn to answer slot-filling queries in a reading comprehension setup, where the query $q$ is constructed from the surface form of the subject entity $e _ { 1 }$ and a natural language description of $R$ (e.g. “Jerry Garcia, birth place, ?”), and the answer $e _ { 2 }$ needs to be extracted from the passage $d$ . Using string representations in $q$ ensures our pre-training setup is similar to the downstream task. In pretraining, we use the same scoring function as in previous section, but over all spans $m$ in the passage:
113
+
114
+ $$
115
+ s ( m , e _ { 1 } , q ) \propto \exp \left\{ f ( s ) \cdot g ( q , e _ { 1 } ) \right\} .
116
+ $$
117
+
118
+ Following Seo et al. (2016), we normalize start and end probabilities of the span separately.
119
+
120
+ For effective transfer to the full corpus setting, we must also provide negative instances during pretraining, i.e. query and passage pairs where the answer is not contained in the passage. We consider three types of hard negatives: (1) shared-entity negatives, which pair a query $( e _ { 1 } , R , ? )$ with a passage which mentions $e _ { 1 }$ but not the correct tail answer; (2) shared-relation negative, which pair a query $( e _ { 1 } , R , ? )$ with a passage mentioning two other entities $e _ { 1 } ^ { \prime }$ and $e _ { 2 } ^ { \prime }$ in the same relation $R$ ; and (3) random negatives, which pair queries with random passages from the corpus.
121
+
122
+ For the multi-hop slot-filling experiments below, we used WikiData (Vrandeciˇ c & Kr´ otzsch, 2014)¨ as our KB, Wikipedia as the corpus, and SLING (Ringgaard et al., 2017) to identify entity mentions. We restrict $d$ be from the Wikipedia article of the subject entity to reduce noise. Overall we collected $9 5 0 K$ pairs over $5 5 0 K$ articles. For the experiments with MetaQA, we supplemented this data with the corpus and KB provided with MetaQA, and string matching for entity linking.
123
+
124
+ # 3 EXPERIMENTS
125
+
126
+ # 3.1 METAQA: MULTI-HOP QUESTION ANSWERING WITH TEXT
127
+
128
+ Dataset. We first evaluate DrKIT on the MetaQA benchmark for multi-hop question answering (Zhang et al., 2018). MetaQA consists of around $4 0 0 K$ questions ranging from 1 to 3 hops constructed by sampling relation paths from a movies KB (Miller et al., 2016) and converting them to natural language using templates. The questions cover 8 relations and their inverses, around $4 3 K$ entities, and are paired with a corpus consisting of $1 8 K$ Wikipedia passages about those entities. The questions are all designed to be answerable using either the KB or the corpus, which makes it possible to compare the performance of our “virtual KB” QA system to a plausible upper bound system that has access to a complete KB. We used the same version of the data as Sun et al. (2019). Details of the implementation are in Appendix A.
129
+
130
+ Results. Table 1 shows the accuracy of the top-most retrieved entity $\left( \mathrm { H i t s } @ 1 \right)$ for the sub-tasks ranging from 1-3 hops, and compares to the state-of-the-art systems for the text-only setting on these tasks. DrKIT outperforms the prior state-of-the-art by a large margin in the 2-hop and 3-hop cases. The strongest prior method, PullNet (Sun et al., 2019; 2018), uses a graph neural network model with learned iterative retrieval from the corpus to answer multi-hop questions. It uses the MetaQA KB during training to identify shortest paths between the question entity and answer entity, which are used to supervise the text retrieval and reading modules. DrKIT, on the other hand, has strong performance without such supervision, demonstrating its capability for end-to-end learning. (Adding the same intermediate supervision to DrKIT does not even consistently improve performance—it gives DrKIT a small lift on 1- and 2-hop questions but does not help for 3-hop questions.)
131
+
132
+ ![](images/d75add69af3c9dd8716a7d92fdb4349616323f9c06444e99de22e8556adfc883.jpg)
133
+ Figure 3: Hits $@ 1$ vs Queries/sec during inference on (Left) MetaQA and (Middle) WikiData tasks, measured on a single CPU server with 6 cores. MSR: Multi-step Retriever model from Das et al. (2019a) (we only show Q/sec). (Right) Effect of varying number of nearest neighbors $K$ during MIPS.
134
+
135
+ DrKIT’s architecture is driven, in part, by efficiency considerations: unlike PullNet, it is designed to answer questions with minimal processing at query time. Figure 3 compares the tradeoffs between accuracy and inference time of DrKIT with PullNet as we vary $K$ , the number of dense nearest neighbors retrieved. The runtime gains of DrKIT over PullNet range between 5x-15x.
136
+
137
+ Analysis. We perform ablations on DrKIT for the MetaQA data. First, we empirically confirm that taking a sum instead of max over the mentions of an entity hurts performance. So does removing the softmax temperature (by setting $\lambda = 1$ ). Removing the TFIDF component from Eq. 3, leads a large decrease in performance for 2-hop and 3-hop questions. This is because the TFIDF component constrains the end-to-end learning to be along reasonable paths of co-occurring mentions, preventing the search space from exploding. The results also highlight the importance of the pretraining method of $\ S 2 . 3$ , as DrKIT over an index of BERT representations without pretraining is 23 points worse in the 3-hop case. We also check the performance when the KB used for pre-training is incomplete. Even with only $5 0 \%$ edges retained, we see good performance—better than PullNet and the state-of-the-art for a KB-only method (in italics).
138
+
139
+ <table><tr><td>Ablations</td><td>1hop</td><td>2hop</td><td>3hop</td></tr><tr><td>DrKIT</td><td>0.844</td><td>0.860</td><td>0.876</td></tr><tr><td>-Sum over Mzt</td><td>0.837</td><td>0.823</td><td>0.797</td></tr><tr><td>-入=1</td><td>0.836</td><td>0.752</td><td>0.799</td></tr><tr><td>-w/o TFIDF</td><td>0.845</td><td>0.548</td><td>0.488</td></tr><tr><td>-BERTindex</td><td>0.634</td><td>0.610</td><td>0.555</td></tr><tr><td colspan="4"> Incomplete KB for pretraining</td></tr><tr><td>25% KB</td><td>0.839</td><td>0.804</td><td>0.830</td></tr><tr><td>50% KB</td><td>0.843</td><td>0.834</td><td>0.834</td></tr><tr><td>(50% KB-only)</td><td>0.680</td><td>0.521</td><td>0.597</td></tr></table>
140
+
141
+ We analyzed 100 2-hop questions correctly answered by DrKIT and found that for 83, the intermediate answers were also correct. The other 17 cases were all where the second hop asked about genre, e.g. “What are the genres of the films directed by Justin Simien?”. We found that in these cases the intermediate answer was the same as the correct final answer—essentially the model learned to answer the question in 1 hop and copy it over for the second hop. Among incorrectly answered questions, the intermediate accuracy was only $4 7 \%$ , so the mistakes were evenly distributed across the two hops.
142
+
143
+ # 3.2 WIKIDATA: MULTI-HOP SLOT-FILLING
144
+
145
+ The MetaQA dataset has been fairly well-studied, but has limitations since it is constructed over a small KB. In this section we consider a new task, in a larger scale setting with many more relations, entities and text passages. The new dataset also lets us evaluate performance in a setting where the test set contains documents and entities not seen at training time, an important issue when devising a QA system that will be used in a real-world setting, where the corpus and entities in the discourse change over time, and lets us perform analyses not possible with MetaQA, such as extrapolating from single-hop to multi-hop settings without retraining.
146
+
147
+ Dataset. We sample two subsets of Wikipedia articles, one for pre-training (§2.3) and end-to-end training, and one for testing. For each subset we consider the set of WikiData entities mentioned in the articles, and sample paths of 1-3 hop relations among them, ensuring that any intermediate entity has an in-degree of no more than 100. Then we construct a semi-structured query by concatenating the surface forms of the head entity with the path of relations (e.g. “Helene Gayle, employer, founded by, ?”). The answer is the tail entity at the end of the path, and the task is to extract it from the Wikipedia articles. Existing slot-filling tasks (Levy et al., 2017; Surdeanu, 2013) focus on a singlehop, static corpus setting, whereas our task considers a dynamic setting which requires the system to traverse the corpus. For each setting, we create a dataset with $1 0 K$ articles, $1 2 0 K$ passages, $> 2 0 0 K$ entities and $1 . 5 M$ mentions, resulting in an index of size about $2 \mathrm { g b }$ . We include example queries in Appendix B.
148
+
149
+ Baselines. We adapt two publicly available open-domain QA systems for this task – $- \mathrm { D r } \mathbf { Q } \mathbf { A } ^ { 3 }$ (Chen et al., 2017) and $\mathrm { P I Q } \mathrm { \dot { A } } ^ { 4 }$ (Seo et al., 2019). While DrQA is relatively mature and widely used, PIQA is recent, and similar to our setup since it also answers questions with minimal computation at query time. It is broadly similar to a single textual follow operation in DrKIT, but is not constructed to allow retrieved answers to be converted to entities and then used in subsequent processing, so it is not directly applicable to multi-hop queries. We thus also consider a cascaded architecture which repeatedly applies Eq. 2, using either of PIQA or $\mathrm { D r Q A }$ to compute $\operatorname* { P r } \bigl ( z _ { t } | q , z _ { t - 1 } \bigr )$ against the corpus, retaining at most $k$ intermediate answers in each step. We tune $k$ in the range of 1-10, since larger values make the runtime infeasible. Further, since these models were trained on natural language questions, we use the templates released by Levy et al. (2017) to convert intermediate questions into natural text.5 We test off-the-shelf versions of these systems, as well as a version of PIQA re-trained on our our slot-filling data.6 We compare to a version of DrKIT trained only on single-hop queries (§2.3) and similarly cascaded, and one version trained end-to-end on the multi-hop queries.
150
+
151
+ Results. Table 1 (right) lists the Hits $@ 1$ performance on this task. Off-the-shelf open-domain QA systems perform poorly, showing the challenging nature of the task. Re-training PIQA on the slotfilling data improves performance considerably, but DrKIT trained on the same data improves on it. A large improvement over these cascaded architectures is seen with end-to-end training, which is made possible by the differentiable operation introduced in this paper. We also list the performance of DrKIT when trained against an index of fixed BERT-large mention representations. While this is comparable to the re-trained version of PIQA, it lags behind DrKIT pre-trained using the KB, once again highlighting the importance of the scheme outlined in $\ S 2 . 3$ . We also plot the Hits $@ 1$ against Queries/sec for cascaded versions of PIQA and DrKIT in Figure 3 (middle). We observe runtime gains of $2 \mathrm { x } \mathrm { - } 3 \mathrm { x }$ to DrKIT due to the efficient implementation of entity-mention expansion of $\ S 2 . 2$ .
152
+
153
+ Analysis. In order to understand where the accuracy gains for DrKIT come from, we conduct experiments on the dataset of slot-filling queries released by Levy et al. (2017). We construct an open version of the task by collecting Wikipedia articles of all subject entities in the data. A detailed discussion is in Appendix C, and here we note the main findings. PIQA trained on SQuAD only gets $3 0 \%$ macro-avg accuracy on this data, but this improves to $4 6 \%$ when re-trained on our slot-filling data. Interestingly, a version of DrKIT which selects from all spans in the corpus performs similarly to PIQA $( 5 0 \% )$ , but when using entity linking it significantly improves to $6 6 \%$ . It also has $5 5 \%$ accuracy in answering queries about rare relations, i.e. those observed $< 5$ times in its training data. We also conduct probing experiments comparing the representations learned using slot-filling to those by vanilla BERT. We found that while the two are comparable in detecting fine-grained entity types, the slot-filling version is significantly better at encoding entity co-occurrence information.
154
+
155
+ 3.3 HOTPOTQA: MULTI-HOP INFORMATION RETRIEVAL
156
+
157
+ Dataset. HotpotQA (Yang et al., 2018) is a recent dataset of over 100K crowd-sourced multi-hop questions and answers over introductory Wikipedia passages. We focus on the open-domain fullwiki setting where the two gold passages required to answer the question are not known in advance. The answers are free-form spans of text in the passages, not necessarily entities, and hence our model which selects entities is not directly applicable here. Instead, inspired by recent works (Das et al., 2019b; Qi et al., 2019), we look at the challenging sub-task of retrieving the passages required to answer the questions from a pool of 5.23M. This is a multi-hop IR task, since for many questions at least one passage may be 1-2 hops away from the entities in the question. Further, each passage is about an entity (the title entity of that Wikipedia page), and hence retrieving passages is the same as identifying the title entities of those passages. We apply DrKIT to this task of identifying the two entities for each question, whose passages contain the information needed to answer that question. Then we pass the top 10 passages identified this way to a standard reading comprehension architecture from Yang et al. (2018) to select the answer span.
158
+
159
+ <table><tr><td>Model</td><td>EM</td><td>F1</td></tr><tr><td>Baselinet</td><td>0.288</td><td>0.381</td></tr><tr><td>+EC IR</td><td>0.354</td><td>0.462</td></tr><tr><td>+Golden Ret</td><td>0.379</td><td>0.486</td></tr><tr><td>+DrKIT†</td><td>0.357</td><td>0.466</td></tr></table>
160
+
161
+ Table 2: (Left) Retrieval performance on the HotpotQA benchmark dev set. $\mathrm { Q } / \mathrm { s }$ denotes the number of queries per second during inference on a single 16-core CPU. Accuracy $@ k$ is the fraction where both the correct passages are retrieved in the top $k$ . †: Baselines obtained from Das et al. (2019b). For DrKIT, we report the performance when the index is pretrained using the WikiData KB alone, the HotpotQA training questions alone, or using both. ∗: Measured on different machines with similar specs. (Right) Overall performance on the HotpotQA task, when passing 10 retrieved passages to a downstream reading comprehension model (Yang et al., 2018). $^ \ddag$ : From Das et al. (2019b). : From Qi et al. (2019). $^ \dagger$ : Results on the dev set.
162
+
163
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Q/s</td><td colspan="4">Accuracy</td></tr><tr><td>@2</td><td>@5</td><td>@10</td><td>@20</td></tr><tr><td>BM25†</td><td>1</td><td>0.093</td><td>0.191</td><td>0.259</td><td>0.324</td></tr><tr><td>PRF-Task†</td><td>1</td><td>0.097</td><td>0.198</td><td>0.267</td><td>0.330</td></tr><tr><td>BERT re-ranker†</td><td>1</td><td>0.146</td><td>0.271</td><td>0.347</td><td>0.409</td></tr><tr><td>Entity Centric IR+</td><td>0.32*</td><td>0.230</td><td>0.482</td><td>0.612</td><td>0.674</td></tr><tr><td>DrKIT (WikiData)</td><td></td><td>0.355</td><td>0.588</td><td>0.671</td><td>0.710</td></tr><tr><td>DrKIT (Hotpot)</td><td>4.26*</td><td>0.385</td><td>0.595</td><td>0.663</td><td>0.703</td></tr><tr><td>DrKIT (Combined)</td><td></td><td>0.383</td><td>0.603</td><td>0.672</td><td>0.710</td></tr></table>
164
+
165
+ Setup. We use the Wikipedia abstracts released by Yang et al. (2018) as the text corpus.7 The total number of entities is the same as the number of abstracts, 5.23M, and we consider hyperlinks in the text as mentions of the entities to whose pages they point to, leading to 22.8M total mentions in an index of size 34GB. For pretraining the mention representations, we compare using the WikiData KB as described in $\ S 2 . 3$ to directly using the HotpotQA training questions, with TFIDF based retrieved passages as negative examples. We set $A _ { E M } [ e , m ] = 1$ if either the entity $e$ is mentioned on the page of the entity denoted by $m$ , or vice versa. For entity linking over the questions, we retrieve the top 20 entities based on the match between a bigram based TFIDF vector of the question with a similar vector derived from the surface form of the entity (same as the title of the Wiki article). We found that the gold entities that need to be retrieved are within 2 hops of the entities linked in this manner for $8 7 \%$ of the dev examples.
166
+
167
+ Unlike the MetaQA and WikiData datasets, however, for HotpotQA we do not know the number of hops required for each question in advance. Instead, we run DrKIT for 2 hops for each question, and then take a weighted average of the distribution over entities after each hop $Z ^ { * } = \pi _ { 0 } Z _ { 0 } + \pi _ { 1 } Z _ { 1 } +$ $\pi _ { 2 } Z _ { 2 }$ . $Z _ { 0 }$ consists of the entities linked to the question itself, rescored based on an encoding of the question, since in some cases one or both the entities to be retrieved are in this set.8 $Z _ { 1 }$ and $Z _ { 2 }$ are given by Eq. 4. The mixing weights $\pi _ { i }$ are the softmax outputs of a classifier on top of another encoding of the question, learnt end-to-end on the retrieval task. This process can be viewed as soft mixing of different templates ranging from 0 to 2 hops for answering a question, similar to NQL (Cohen et al., 2019).
168
+
169
+ Results. We compare our retrieval results to those presented in Das et al. (2019b) in Table 2 (Left). We measure the accuracy $@ k$ retrievals, which is the fraction of questions for which both the required passages are in the top $k$ retrieved ones. We see an improvement in accuracy across the board, with much higher gains $@ 2$ and $@ 5 .$ The main baseline is the entity-centric IR approach which runs a BERT-based re-ranker on 200 pairs of passages for each question. Importantly, DrKIT also improves by over $1 0 \mathrm { x }$ in terms of queries per second during inference. Note that the inference time is measured using a batch size of 1 for both models for fair comparison. DrKIT can be easily run with batch sizes up to 40, but the entity centric IR baseline cannot due to the large number of runs of BERT for each query. When comparing different datasets for pretraining the index, there is not much difference between using the WikiData KB, or the HotpotQA questions. The latter has a better accuracy $@ 2$ , but overall the best performance is when using a combination of both.
170
+
171
+ Table 3: Official leaderboard evaluation on the test set of HotpotQA. #Bert refers to the number of calls to BERT (Devlin et al., 2019) in the model. $\mathrm { s } / \mathrm { Q }$ denotes seconds per query (using batch size 1) for inference on a single 16-core CPU. Answer, Sup Fact and Joint are the official evaluation metrics for HotpotQA. ∗: This is the minimum number of BERT calls based on model and hyperparameter descriptions in the respective papers. †: Computed using code released by authors, using a batch size of 1. ‡: Estimated based on the number of BERT calls, using 0.8s as the time for one call (without considering overhead due to other computation in the model). : One call to a 5-layer Transformer, and one call to BERT.
172
+
173
+ <table><tr><td rowspan="2">System</td><td colspan="2">Runtime</td><td colspan="2">Answer</td><td colspan="2">Sup Fact</td><td colspan="2">Joint</td></tr><tr><td>#Bert</td><td>s/Q</td><td>EM</td><td>F1</td><td>EM</td><td>F1</td><td>EM</td><td>F1</td></tr><tr><td>Baseline (Yang et al., 2018)</td><td>1</td><td>1</td><td>25.23</td><td>34.40</td><td>5.07</td><td>40.69</td><td>2.63</td><td>17.85</td></tr><tr><td>Golden Ret (Qi et al.,2019)</td><td>1</td><td>1.4†</td><td>37.92</td><td>48.58</td><td>30.69</td><td>64.24</td><td>18.04</td><td>39.13</td></tr><tr><td>Semantic Ret (Nie et al., 2019)</td><td>50*</td><td>40.0</td><td>45.32</td><td>57.34</td><td>38.67</td><td>70.83</td><td>25.14</td><td>47.60</td></tr><tr><td>HGN (Fang et al., 2019)</td><td>50*</td><td>40.0t</td><td>56.71</td><td>69.16</td><td>49.97</td><td>76.39</td><td>35.63</td><td>59.86</td></tr><tr><td>Rec Ret (Asai et al., 2020)</td><td>500*</td><td>133.2†</td><td>60.04</td><td>72.96</td><td>49.08</td><td>76.41</td><td>35.35</td><td>61.18</td></tr><tr><td>DrKIT +BERT</td><td>1.20</td><td>1.3</td><td>42.13</td><td>51.72</td><td>37.05</td><td>59.84</td><td>24.69</td><td>42.88</td></tr></table>
174
+
175
+ In Table 2 (Right), we check the performance of the baseline reading comprehension model from Yang et al. (2018), when given the passages retrieved by DrKIT. While there is a significant improvement over the baseline which uses a TFIDF based retrieval, we see only a small improvement over the passages retrieved by the entity-centric IR baseline, despite the significantly improved accuracy $@ 1 0$ of DrKIT. Among the $3 3 \%$ questions where the top 10 passages do not contain both the correct passages, for around $2 0 \%$ the passage containing the answer is also missing. We conjecture this percentage is lower for the entity-centric IR baseline, and the downstream model is able to answer some of these questions without the other supporting passage.
176
+
177
+ Lastly, we feed the top 5 passages retrieved by DrKIT to an improved answer span extraction model based on BERT. This model implements a standard architecture for extracting answers from text, and is trained to predict both the answers and the supporting facts. Details are included in Appendix D. Table 3 shows the performance of this system on the HotpotQA test set, compared with other recently published models on the leaderboard.9 In terms of accuracy, DrKIT $^ +$ BERT reaches a modest score of 42.88 joint F1, but is considerably faster (up to 100x) than the models which outperform it.
178
+
179
+ # 4 RELATED WORK
180
+
181
+ Neural Query Language (NQL) (Cohen et al., 2019) defines differentiable templates for multi-step access to a symbolic KB, in which relations between entities are explicitly enumerated. Here, we focus on the case where the relations are implicit in mention representations derived from text. Knowledge Graph embeddings (Bordes et al., 2013; Yang et al., 2014; Dettmers et al., 2018) attach continuous representations to discrete symbols which allow them to be incorporated in deep networks (Yang & Mitchell, 2017). Embeddings often allow generalization to unseen facts using relation patterns, but text corpora are more complete in the information they contain.
182
+
183
+ Talmor & Berant (2018) also examined answering compositional questions by treating a text corpus (in their case the entire web) as a KB. However their approach consists of parsing the query into a computation tree, and running a black-box QA model on its leaves separately, which cannot be trained end-to-end. Recent papers have also looked at complex QA using graph neural networks (Sun et al., 2018; Cao et al., 2019; Xiao et al., 2019) or by identifying paths of entities in text (Jiang et al., 2019; Kundu et al., 2019; Dhingra et al., 2018). These approaches rely on identifying a small relevant pool of evidence documents containing the information required for multi-step QA. Hence, Sun et al. (2019) and Ding et al. (2019), incorporate a dynamic retrieval process to add text about entities identified as relevant in the previous layer of the model. Since the evidence text is processed in a query-dependent manner, the inference speed is slower than when it is pre-processed into an indexed representation (see Figure 3). The same limitation is shared by methods which perform multi-step retrieval interleaved with a reading comprehension model (Das et al., 2019a; Feldman & El-Yaniv, 2019; Lee et al., 2019).
184
+
185
+ # 5 CONCLUSION
186
+
187
+ We present DrKIT, a differentiable module that is capable of answering multi-hop questions directly using a large entity-linked text corpus. DrKIT is designed to imitate traversal in KB over the text corpus, providing ability to follow relations in the “virtual” KB over text. We achieve state-of-the-art results on the MetaQA dataset for answering natural language questions, with a 9 point increase in the 3-hop case. We also developed an efficient implementation using sparse operations and inner product search, which led to a 10-100x increase in Queries/sec over baseline approaches.
188
+
189
+ # ACKNOWLEDGMENTS
190
+
191
+ Bhuwan Dhingra was supported by a Siemens fellowship during this project. This work was supported in part by ONR Grant N000141812861, Google, Apple, and grants from NVIDIA.
192
+
193
+ # REFERENCES
194
+
195
+ Alexandr Andoni, Piotr Indyk, Thijs Laarhoven, Ilya Razenshteyn, and Ludwig Schmidt. Practical and optimal lsh for angular distance. In Advances in Neural Information Processing Systems, pp. 1225–1233, 2015.
196
+
197
+ Akari Asai, Kazuma Hashimoto, Hannaneh Hajishirzi, Richard Socher, and Caiming Xiong. Learning to retrieve reasoning paths over wikipedia graph for question answering. In International Conference on Learning Representations, 2020.
198
+
199
+ Antoine Bordes, Nicolas Usunier, Alberto Garcia-Duran, Jason Weston, and Oksana Yakhnenko. Translating embeddings for modeling multi-relational data. In Advances in neural information processing systems, pp. 2787–2795, 2013.
200
+
201
+ Yu Cao, Meng Fang, and Dacheng Tao. Bag: Bi-directional attention entity graph convolutional network for multi-hop reasoning question answering. In North American Association for Computational Linguistics (NAACL), 2019.
202
+
203
+ Danqi Chen, Adam Fisch, Jason Weston, and Antoine Bordes. Reading Wikipedia to answer opendomain questions. In Association for Computational Linguistics (ACL), 2017.
204
+
205
+ William W Cohen, Matthew Siegler, and Alex Hofer. Neural query language: A knowledge base query language for tensorflow. arXiv preprint arXiv:1905.06209, 2019.
206
+
207
+ Rajarshi Das, Shehzaad Dhuliawala, Manzil Zaheer, and Andrew McCallum. Multi-step retrieverreader interaction for scalable open-domain question answering. In International Conference on Learning Representations (ICLR), 2019a.
208
+
209
+ Rajarshi Das, Ameya Godbole, Dilip Kavarthapu, Zhiyu Gong, Abhishek Singhal, Mo Yu, Xiaoxiao Guo, Tian Gao, Hamed Zamani, Manzil Zaheer, and Andrew McCallum. Multi-step entity-centric information retrieval for multi-hop question answering. In Proceedings of the 2nd Workshop on Machine Reading for Question Answering, pp. 113–118, Hong Kong, China, November 2019b. Association for Computational Linguistics. doi: 10.18653/v1/D19-5816. URL https://www. aclweb.org/anthology/D19-5816.
210
+
211
+ Tim Dettmers, Pasquale Minervini, Pontus Stenetorp, and Sebastian Riedel. Convolutional 2d knowledge graph embeddings. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
212
+
213
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. NAACL, 2019.
214
+
215
+ Bhuwan Dhingra, Qiao Jin, Zhilin Yang, William W Cohen, and Ruslan Salakhutdinov. Neural models for reasoning over multiple mentions using coreference. In North American Association for Computational Linguistics (NAACL), 2018.
216
+
217
+ Ming Ding, Chang Zhou, Qibin Chen, Hongxia Yang, and Jie Tang. Cognitive graph for multi-hop reading comprehension at scale. In Association for Computational Linguistics (ACL), 2019.
218
+
219
+ Yuwei Fang, Siqi Sun, Zhe Gan, Rohit Pillai, Shuohang Wang, and Jingjing Liu. Hierarchical graph network for multi-hop question answering. arXiv preprint arXiv:1911.03631, 2019.
220
+
221
+ Yair Feldman and Ran El-Yaniv. Multi-hop paragraph retrieval for open-domain question answering. In Association for Computational Linguistics (ACL), 2019.
222
+
223
+ Yichen Jiang, Nitish Joshi, Yen-Chun Chen, and Mohit Bansal. Explore, propose, and assemble: An interpretable model for multi-hop reading comprehension. In Association for Computational Linguistics (ACL), 2019.
224
+
225
+ Jeff Johnson, Matthijs Douze, and Herve J ´ egou. Billion-scale similarity search with gpus. ´ arXiv preprint arXiv:1702.08734, 2017.
226
+
227
+ Souvik Kundu, Tushar Khot, and Ashish Sabharwal. Exploiting explicit paths for multi-hop reading comprehension. In Association for Computational Linguistics (ACL), 2019.
228
+
229
+ Kenton Lee, Ming-Wei Chang, and Kristina Toutanova. Latent retrieval for weakly supervised open domain question answering. In Association for Computational Linguistics (ACL), 2019.
230
+
231
+ Omer Levy, Minjoon Seo, Eunsol Choi, and Luke Zettlemoyer. Zero-shot relation extraction via reading comprehension. In Proceedings of the 21st Conference on Computational Natural Language Learning (CoNLL 2017), pp. 333–342, 2017.
232
+
233
+ Alexander Miller, Adam Fisch, Jesse Dodge, Amir-Hossein Karimi, Antoine Bordes, and Jason Weston. Key-value memory networks for directly reading documents. arXiv preprint arXiv:1606.03126, 2016.
234
+
235
+ Bonan Min, Ralph Grishman, Li Wan, Chang Wang, and David Gondek. Distant supervision for relation extraction with an incomplete knowledge base. In Proceedings of the 2013 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 777–782, 2013.
236
+
237
+ Sewon Min, Danqi Chen, Hannaneh Hajishirzi, and Luke Zettlemoyer. A discrete hard em approach for weakly supervised question answering. In EMNLP, 2019.
238
+
239
+ Dan Moldovan, Marius Pasca, Sanda Harabagiu, and Mihai Surdeanu. Performance issues and error analysis in an open-domain question answering system. In Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics, pp. 33–40, Philadelphia, Pennsylvania, USA, July 2002. Association for Computational Linguistics. doi: 10.3115/1073083.1073091. URL https://www.aclweb.org/anthology/P02-1005.
240
+
241
+ Yixin Nie, Songhe Wang, and Mohit Bansal. Revealing the importance of semantic retrieval for machine reading at scale. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 2553–2566, 2019.
242
+
243
+ Peng Qi, Xiaowen Lin, Leo Mehr, Zijian Wang, and Christopher D. Manning. Answering complex open-domain questions through iterative query generation. In 2019 Conference on Empirical Methods in Natural Language Processing and 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), 2019. URL https://nlp.stanford.edu/pubs/ qi2019answering.pdf.
244
+
245
+ Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. Squad: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. arXiv preprint arXiv:1606.05250, 2016.
246
+
247
+ Michael Ringgaard, Rahul Gupta, and Fernando CN Pereira. Sling: A framework for frame semantic parsing. arXiv preprint arXiv:1710.07032, 2017.
248
+
249
+ Mike Schuster and Kaisuke Nakajima. Japanese and korean voice search. In 2012 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 5149–5152. IEEE, 2012.
250
+
251
+ Roy Schwartz, Jesse Dodge, Noah A Smith, and Oren Etzioni. Green ai. arXiv preprint arXiv:1907.10597, 2019.
252
+
253
+ Minjoon Seo, Aniruddha Kembhavi, Ali Farhadi, and Hannaneh Hajishirzi. Bidirectional attention flow for machine comprehension. arXiv preprint arXiv:1611.01603, 2016.
254
+
255
+ Minjoon Seo, Tom Kwiatkowski, Ankur P Parikh, Ali Farhadi, and Hannaneh Hajishirzi. Phraseindexed question answering: A new challenge for scalable document comprehension. In EMNLP, 2018.
256
+
257
+ Minjoon Seo, Jinhyuk Lee, Tom Kwiatkowski, Ankur P Parikh, Ali Farhadi, and Hannaneh Hajishirzi. Real-time open-domain question answering on wikipedia with dense-sparse phrase index. In Association for Computational Linguistics (ACL), 2019.
258
+
259
+ Anshumali Shrivastava and Ping Li. Asymmetric lsh (alsh) for sublinear time maximum inner product search (mips). In Advances in Neural Information Processing Systems, pp. 2321–2329, 2014.
260
+
261
+ Emma Strubell, Ananya Ganesh, and Andrew McCallum. Energy and policy considerations for deep learning in nlp. arXiv preprint arXiv:1906.02243, 2019.
262
+
263
+ Haitian Sun, Bhuwan Dhingra, Manzil Zaheer, Kathryn Mazaitis, Ruslan Salakhutdinov, and William W Cohen. Open domain question answering using early fusion of knowledge bases and text. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP), 2018.
264
+
265
+ Haitian Sun, Tania Bedrax-Weiss, and William W Cohen. Pullnet: Open domain question answering with iterative retrieval on knowledge bases and text. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP), 2019.
266
+
267
+ Mihai Surdeanu. Overview of the tac2013 knowledge base population evaluation: English slot filling and temporal slot filling. In TAC, 2013.
268
+
269
+ A. Talmor and J. Berant. The web as a knowledge-base for answering complex questions. In North American Association for Computational Linguistics (NAACL), 2018.
270
+
271
+ Ian Tenney, Patrick Xia, Berlin Chen, Alex Wang, Adam Poliak, R Thomas McCoy, Najoung Kim, Benjamin Van Durme, Sam Bowman, Dipanjan Das, and Ellie Pavlick. What do you learn from context? probing for sentence structure in contextualized word representations. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum? id=SJzSgnRcKX.
272
+
273
+ tf.RaggedTensors. TensorFlow Ragged Tensors, 2018. URL https://www.tensorflow. org/guide/ragged_tensors.
274
+
275
+ 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.
276
+
277
+ Denny Vrandeciˇ c and Markus Kr ´ otzsch. Wikidata: a free collaborative knowledge base. 2014. ¨
278
+
279
+ Yunxuan Xiao, Yanru Qu, Lin Qiu, Hao Zhou, Lei Li, Weinan Zhang, and Yong Yu. Dynamically fused graph network for multi-hop reasoning. In Association for Computational Linguistics (ACL), 2019.
280
+
281
+ Bishan Yang and Tom Mitchell. Leveraging knowledge bases in lstms for improving machine reading. 2017.
282
+
283
+ Bishan Yang, Wen-tau Yih, Xiaodong He, Jianfeng Gao, and Li Deng. Embedding entities and relations for learning and inference in knowledge bases. arXiv preprint arXiv:1412.6575, 2014.
284
+
285
+ Wei Yang, Yuqing Xie, Aileen Lin, Xingyu Li, Luchen Tan, Kun Xiong, Ming Li, and Jimmy Lin. End-to-end open-domain question answering with bertserini. arXiv preprint arXiv:1902.01718, 2019.
286
+
287
+ 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 Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP), 2018.
288
+
289
+ Yuyu Zhang, Hanjun Dai, Zornitsa Kozareva, Alexander J Smola, and Le Song. Variational reasoning for question answering with knowledge graph. In AAAI, 2018.
290
+
291
+ # A METAQA: IMPLEMENTATION DETAILS
292
+
293
+ We use $p = 4 0 0$ dimensional embeddings for the mentions and queries, and 200-dimensional embeddings each for the start and end positions. This results in an index of size 750MB. When computing $A _ { E M }$ , the entity to mention co-occurrence matrix, we only retain mentions in the top 50 paragraphs matched with an entity, to ensure sparsity. Further we initialize the first 4 layers of the question encoder with the Transformer network from pre-training. For the first hop, we assign $Z _ { 0 }$ as a 1-hot vector for the least frequent entity detected in the question using an exact match. The number of nearest neighbors $K$ and the softmax temperature $\lambda$ were tuned on the dev set of each task, and we found $\bar { K \mathrm { ~ = ~ } } 1 0 0 0 0$ and $\lambda = 4$ to work best. We pretrain the index on a combination of the MetaQA corpus, using the KB provided with MetaQA for distance data, and the WikiData corpus.
294
+
295
+ # B WIKIDATA DATASET STATISTICS
296
+
297
+ Table 4: WikiData dataset
298
+
299
+ <table><tr><td>Task</td><td>#train</td><td>#dev</td><td>#test</td><td>Etest|</td><td>|Mtestl</td><td>|Dtest|</td><td>Example</td></tr><tr><td>1hop</td><td>16901</td><td>2467</td><td>10000</td><td>216K</td><td>1.2M</td><td>120K</td><td>Q. Mendix, industry? A.Enterprise Software</td></tr><tr><td>2hop</td><td>163607</td><td>398</td><td>9897</td><td>342K</td><td>1.9M</td><td>120K</td><td>Q.2000 Hel van het Mergelland, winner, place of birth? A.Bert Grabsch → Lutherstadt Wittenberg</td></tr><tr><td>3hop</td><td>36061</td><td>453</td><td>9899</td><td>261K</td><td>1.8M</td><td>120K</td><td>Q. Magnificent!, record label,founded by, date of death? A.Prestige →Bob Weinstock → 14 Jan 2006</td></tr></table>
300
+
301
+ Details of the collected WikiData dataset are shown in Table 4.
302
+
303
+ # C INDEX ANALYSIS
304
+
305
+ Single-hop questions and relation extraction. Levy et al. (2017) released a dataset of $1 M$ slotfilling queries of the form $( e _ { 1 } , R , ? )$ paired with Wikipedia sentences mentioning $e _ { 1 }$ , which was used for training systems that answered single-step slot-filling questions based on a small set of candidate passages. Here we consider an open version of the same task, where answers to the queries must be extracted from a corpus rather than provided candidates. We construct the corpus by collecting and entity-linking all paragraphs in the Wikipedia articles of all $8 K$ subject entities in the dev and test sets, leading to a total of $1 0 9 K$ passages. After constructing the TFIDF $A _ { E M }$ and coreference $B _ { M E }$ matrices for this corpus, we directly use our pre-trained index to answer the test set queries.
306
+
307
+ Figure 4 (Right) shows the $\mathrm { H i t s } @ 1$ performance of the Levy et al. (2017) slot-filling dataset. We report results on 2 subsets of relations in addition to all relations. The Rare subset comprises of relations with frequencies $< 5$ in the training data while the ’Frequent’ subset contains the rest. DrKIT on entity-mentions consistently outperforms the other phrase-based models showing the benefit of indexing only entity-mentions in single-hop questions over all spans. Note that DrKit-entities has a high Hits $@ 1$ performance on the Rare relations subset, showing that there is generalization to less frequent data due to the natural language representations of entities and relations.
308
+
309
+ ![](images/fbb07c2868d546ce61ff70eded30b346c15925fb54cd790fd3cf2edf449776d4.jpg)
310
+
311
+ Figure 4: Left: F1 scores on Shared Entity and Shared Relation negatives. The negative examples are for the Query $:$ (Neil Herron, occupation, ?). Right: Macro-avg accuracy on the Levy et al. (2017) relation extraction dataset. We split the results based on frequency of the relations in our WikiData training data. DrKIT-all spans refers to a variant of our model which selects from all spans in the corpus, instead of only entity-linked mentions.
312
+
313
+ <table><tr><td>Probing Task</td><td>Negative Example</td><td>BERT</td><td>DrKIT</td></tr><tr><td>Shared Entity</td><td>Neil Herron played for West of Scotland.</td><td>0.850</td><td>0.876</td></tr><tr><td>Shared Relation</td><td>William Paston was a British politician.</td><td>0.715</td><td>0.846</td></tr></table>
314
+
315
+ Probing Experiments Finally, to compare the representations learned by the BERT model finetuned on the WikiData slot-filling task, we design two probing experiments. In each experiment, we keep the parameters of the BERT model (mention encoders) being probed fixed and only train the query encoders. Similar to Tenney et al. (2019), we use a weighted average of the layers of BERT here rather than only the top-most layer, where the weights are learned on the probing task.
316
+
317
+ In the first experiment, we train and test on shared-entity negatives. Good performance here means the BERT model being probed encodes fine-grained entity-type information reliably10. As shown in Table 4, BERT performs well on this task, suggesting it encodes fine-grained types well.
318
+
319
+ In the second experiment, we train and test only on shared-relation negatives. Good performance here means that the BERT model encodes entity co-occurrence information reliably. In this probe task, we see a large performance drop for BERT, suggesting it does not encode entity co-occurrence information well. The good performance of the DrKIT model on both experiments suggests that fine-tuning on the slot-filling task primarily helps the contextual representations to also encode entity co-occurrence information, in addition to entity type information.
320
+
321
+ # D HOTPOTQA ANSWER EXTRACTION
322
+
323
+ On HotpotQA, we use DrKIT to identify the top passages which are likely to contain the answer to a question. We then train a separate model to extract the answer from a concatenation of these passages. This model is a standard BERT-based architecture used for SQuAD (see Devlin et al. (2019) for details), with a few modifications. First, to handle boolean questions, we train a 3-way classifier on top of the [CLS] representation from BERT to decide whether the question has a “span”, “yes” or “no” answer, respectively. During inference, if this classifier has the highest probability on “span” we extract a start and end position similar to Devlin et al. (2019), else we directly answer as “yes” or “no”.
324
+
325
+ Second, to handle supporting fact prediction, we prepend each sentence in the concatenated passages passed to BERT with a special symbol [unused0], and train a binary classifier on top of the representation of each of these symbols output from BERT. The binary classifier is trained to predict 1 for sentences which are supporting facts and 0 for sentences which are not. During inference, we take all sentences for which the output probability of this classifier is $> 0 . 5$ as supporting facts.
326
+
327
+ The training loss is an average of the loss for the 3-way classifier $( \mathcal { L } _ { c l s } )$ , the sum of the losses for the supporting fact classifiers $( \mathcal { L } _ { s p } )$ , and the losses for the start and end positions of span answers $( \mathcal { L } _ { s t } , \mathcal { L } _ { e n } )$ :
328
+
329
+ $$
330
+ \mathcal { L } = ( \mathcal { L } _ { c l s } + \mathcal { L } _ { s p } + \mathcal { L } _ { s t } + \mathcal { L } _ { e n } ) / 4
331
+ $$
332
+
333
+ We train the system on 5 passages per question, provided in the distractor setting of HotpotQA— 2 gold ones and 3 negatives from a TFIDF retriever. We keep the gold passages at the beginning for $6 0 \%$ of the examples, and randomly shuffle all passages for the rest, since during inference the correct passages are likely to be retrieved at the top by DrKIT. Other hyperparameters include— batch size 32, learning rate $5 \times 1 0 ^ { - 5 }$ , number of training epochs 5, and a maximum combined passage length 512.
md/train/Sk-oDY9ge/Sk-oDY9ge.md ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DIET NETWORKS: THIN PARAMETERS FOR FAT GENOMICS
2
+
3
+ Adriana Romero∗, Pierre Luc Carrier∗, Akram Erraqabi, Tristan Sylvain, Alex Auvolat, Etienne Dejoie
4
+
5
+ Montreal Institute for Learning Algorithms Montreal, Quebec, Canada firstName.lastName@umontreal.ca, except adriana.romero.soriano@umontreal.ca and pierre-luc.carrier@umontreal.ca
6
+
7
+ # Marc-Andre Legault ´ 1, Marie-Pierre Dube´1,2,3
8
+
9
+ 1University of Montreal, Faculty of Medicine
10
+ 2Montreal Heart Institute,
11
+ 3Beaulieu-Saucier Pharmacogenomics Centre
12
+ Montreal, Quebec, Canada
13
+ marc-andre.legault.1@umontreal.ca
14
+ marie-pierre.dube@umontreal.ca
15
+
16
+ # Julie G. Hussin
17
+
18
+ Wellcome Trust Centre for Human Genetics
19
+ University of Oxford
20
+ Oxford, UK
21
+ julieh@well.ox.ac.uk
22
+
23
+ # Yoshua Bengio
24
+
25
+ Montreal Institute for Learning Algorithms Montreal, Quebec, Canada yoshua.umontreal@gmail.com
26
+
27
+ # ABSTRACT
28
+
29
+ Learning tasks such as those involving genomic data often poses a serious challenge: the number of input features can be orders of magnitude larger than the number of training examples, making it difficult to avoid overfitting, even when using the known regularization techniques. We focus here on tasks in which the input is a description of the genetic variation specific to a patient, the single nucleotide polymorphisms (SNPs), yielding millions of ternary inputs. Improving the ability of deep learning to handle such datasets could have an important impact in medical research, more specifically in precision medicine, where highdimensional data regarding a particular patient is used to make predictions of interest. Even though the amount of data for such tasks is increasing, this mismatch between the number of examples and the number of inputs remains a concern. Naive implementations of classifier neural networks involve a huge number of free parameters in their first layer (number of input features times number of hidden units): each input feature is associated with as many parameters as there are hidden units. We propose a novel neural network parametrization which considerably reduces the number of free parameters. It is based on the idea that we can first learn or provide a distributed representation for each input feature (e.g. for each position in the genome where variations are observed in data), and then learn (with another neural network called the parameter prediction network) how to map a feature’s distributed representation (based on the feature’s identity not its value) to the vector of parameters specific to that feature in the classifier neural network (the weights which link the value of the feature to each of the hidden units). This approach views the problem of producing the parameters associated with each feature as a multi-task learning problem. We show experimentally on a population stratification task of interest to medical studies that the proposed approach can significantly reduce both the number of parameters and the error rate of the classifier.
30
+
31
+ # 1 INTRODUCTION
32
+
33
+ Medical datasets often involve a dire imbalance between the number of training examples and the number of input features, especially when genomic information is used as input to the trained predictor. This is problematic in the context where we want to apply deep learning (which typically involves large models) to precision medicine, i.e., making patient-specific predictions using a potentially large set of input features to better characterize the patient. This paper proposes a novel approach, called Diet Networks, to reparametrize neural networks to considerably reduce their number of free parameters when the input is very high-dimensional and orders of magnitude larger than the number of training examples.
34
+
35
+ Genomics is the study of the genetic code encapsulated as DNA in all living organisms’ cells. Genomes contain the instructions to produce and regulate all the functional components needed to guide the development and adaptation of living organisms. In the last decades, advances in genomic technologies resulted in an explosion of available data, making it more interesting to apply advanced machine learning techniques such as deep learning. Learning tasks involving genomic data and already tackled by deep learning include: using Convolutional Neural Networks (CNNs) to learn the functional activity of DNA sequences (Basset package, Kelley et al. (2016), predicting effects of noncoding DNA (DeepSEA, Zhou & Troyanskaya (2015)), investigating the regulatory role of RNA binding proteins in alternative splicing (Alipanahi et al., 2015), inferring gene expression patterns (Chen et al., 2016; Singh et al., 2016) and population genetic parameters (Sheehan & Song, 2016) among others (see Leung et al. (2016) for a detailed example). Noticeably, most of these techniques are based on sequence data where convolutional or recurrent networks are appropriate. When the full DNA sequence is unavailable, such as when data is acquired through genotyping, other methods need to be used. All this work shows that deep learning can be used to tackle genomic-related tasks, paving the road towards a better understanding of the biological impact of DNA variation.
36
+
37
+ Applying deep learning to human genetic variation holds the promise of identifying individuals at risk for medical conditions. Modern genotyping technologies usually target millions of simple variants across the genome, called single nucleotide polymorphisms (SNPs). These genetic mutations result from substitutions from one nucleotide to another (eg. A to C), where both versions exist within a population. In modern studies, as many as 5 millions SNPs can be acquired for every participant. These datasets differ from other types of genomic data because they focus on the genetic differences between individuals which represents a space of high dimensionality where sequencecontext information is unavailable. In medical genetics, these variants are tested for their association with a trait of interest, an approach termed genome-wide association study (GWAS). This methodology aims at finding genetic variants implicated in disease susceptibility, etiology and treatment.
38
+
39
+ An important confounding factor in GWAS is population stratification, which arises because both disease prevalence and genetic profiles vary from one population to the other. Although most GWAS have been restricted to homogeneous populations, dimensionality reduction techniques are generally used to account for population-level genetic differences (Price et al., 2006). Our experiments compare such dimensionality reduction techniques (based on principal components analysis, PCA) to the proposed Diet Network parametrization, as well as with standard deep networks.
40
+
41
+ Recently, several machine learning methods have been successfully applied to detect population stratification, based on the presence of systematic differences in genetic variation between populations. For instance, Support Vector Machines (SVM) models have been used multiple times to infer recent genetic ancestry of sub-continental populations (Haasl et al. (2013)), and local ancestry in admixed populations (SupportMix, Omberg et al. (2012), 23andMe, Inc.). However SVM methods are very sensitive to the the kernel choice and the parameters. They also tend to overfit the model selection criterion which usually induces a limitation in its predictive power.
42
+
43
+ In this work, we are interested in predicting the genetic ancestry of an individual from their SNP data using a novel deep learning approach, Diet Networks, which allow us to considerably reduce the number of free parameters. Therefore, we propose to tackle this problem by introducing a multi-task architecture in which the problem of predicting the appropriate parameters for each input feature is considered like a task in itself, and the same parameter prediction network is used for all of the hundreds of thousands of input features. This parameter prediction network learns to predict these feature-specific parameters as a function of a distributed representation of the feature identity, or feature embedding. The feature embedding can be learned as part of end-to-end training or using other datasets or a priori knowledge about the features. What is important is that two features which are similar in some appropriate sense (in terms of their interactions with other features or other variables observed in any dataset) end up having similar embeddings, and thus a similar parameter vector as output of the parameter prediction network. A practical advantage of this approach is that the parameter prediction network can generalize to new features for which there is no labeled training data (without the target to be predicted by the classifier), so long as it is possible to derive an embedding for that feature (for example using just the unlabeled observations of co-occurences of that feature with other features in human genomes).
44
+
45
+ An interesting consideration is that from the point of the parameter prediction network, each feature is an example: more features now allow to better train the parameter prediction network. It is like if we were considering not the data matrix itself but its transpose. This is actually how the Diet Network implementation processes the data, by using the transpose of the matrix of input values as the input part of the learning task for the parameter prediction network.
46
+
47
+ The idea of having two networks interacting with each other and with one producing parameters for the other is well rooted in the machine learning literature (Bengio et al., 1991; Schmidhuber, 1992; Gomez & Schmidhuber, 2005; Stanley et al., 2009; Denil et al., 2013; Andrychowicz et al., 2016). Recent efforts in the same direction include works such as (Bertinetto et al., 2016; Brabandere et al., 2016; Ha et al., 2016) that use a network to predict the parameters of a Convolutional Neural Network (CNN). Brabandere et al. (2016) introduce a dynamic filter module that generates network filters conditioned on an input. Bertinetto et al. (2016) propose to learn the parameters of a deep model in one shot, by training a second network to predict the parameters of the first from a single exemplar. Hypernetworks (Ha et al., 2016) explore the idea of using a small network to predict the parameters of another network, training them in an end-to-end fashion. The small network takes as input the feature embedding from the previous layer and learns the parameters of the current layer.
48
+
49
+ To the best of our knowledge, deep learning has never been used so far to tackle the problem of ancestry prediction based on SNP data. Compared to other approaches that attempt to learn model parameters using a parameter prediction network, our main goal is to reduce the large number of parameters required by the model, by considering the input features themselves as sub-tasks in a multi-task view of the learning problem, as opposed to constructing a model with even higher capacity, as seen, e.g. in (Ha et al., 2016). Our approach is thus based on building an embedding of these tasks (the features) in order to further reduce the number of parameters.
50
+
51
+ We evaluate our method on a publicly available dataset for ancestry prediction, the 1000 Genomes dataset1, that best represents the human population diversity. Because population-specific differences in disease and drug response are widespread, identifying an individual’s ancestry heritage based on SNP data is a very important task to help detect biological causation and achieve good predictive performance in precision medicine. Most importantly, ancestry-aware approaches in precision genomics will reduce the hidden risks of genetic testing, by preventing spurious diagnosis and ineffective treatment.
52
+
53
+ # 2 METHOD
54
+
55
+ In this section, we describe the Diet Networks as well as the feature embeddings used by the model.
56
+
57
+ # 2.1 MODEL
58
+
59
+ Our model aims at reducing the number of free parameters that a network trained on fat data would typically have.
60
+
61
+ Let $\mathbf { X } \in \mathbb { R } ^ { N \times N _ { d } }$ be a matrix of data, with $N$ samples and $N _ { d }$ features, where $N \ll N _ { d }$ (e. g. $N$ being approximately 100 times smaller than $N _ { d . }$ ). We build a multi-layer perceptron (MLP), which takes $\mathbf { X }$ as input, computes a hidden representation and outputs a prediction $\hat { \mathbf Y }$ . Optionally, the MLP may generate a reconstruction $\hat { \mathbf X }$ of the input data from the hidden representation. Figure 1(a) illustrates this basic network architecture. Let $\mathbf { x _ { i } }$ be one data sample, i.e. a row in $\mathbf { X }$ . The standard formulations to compute its hidden representation $\mathbf { h _ { i } }$ , output prediction $\hat { \mathbf { y } } _ { \mathbf { i } }$ and reconstruction $\hat { \bf x } _ { \bf i }$ are given by
62
+
63
+ $$
64
+ \mathbf { h _ { i } } = f ( \mathbf { x _ { i } } ) , \quad \hat { \mathbf { y _ { i } } } = g ( \mathbf { h _ { i } } ) , \quad \hat { \mathbf { x _ { i } } } = r ( \mathbf { h _ { i } } ) ,
65
+ $$
66
+
67
+ where $f , g$ and $r$ are non-linear functions.
68
+
69
+ ![](images/5a4c7493d56a4be3b5a2927448f69fa77c0f63af1cd91a8b998d8317bc19d848.jpg)
70
+ Figure 1: Our model is composed of 3 networks, one basic and two auxiliary networks: (a) a basic discriminative network with optional reconstruction path (dashed arrow), (b) a network that predicts the input fat layer parameters, and (c) a network that predicts the reconstruction fat layer parameters (if any). First layer in the ”prediction networks” (b, c) represents embedding (Emb.). Each MLP block may contain any number of hidden layers. ${ \bf W _ { e } }$ and $\mathbf { \hat { W } _ { d } ^ { T } }$ represent the parameters of the fat hidden layer and the fat reconstruction layer of the basic network (a), respectively. These parameters are predicted by auxiliary networks (b) and (c) – also called parameter prediction networks – to reduce the number of free parameters of (a).
71
+
72
+ The number of parameters of the first hidden layer of the architecture grows linearly with the dimensionality of the input data:
73
+
74
+ $$
75
+ \mathbf { h _ { i } ^ { ( 1 ) } } = f _ { 1 } ( \mathbf { x _ { i } } \mathbf { W _ { e } } + \mathbf { b _ { e } } ) ,
76
+ $$
77
+
78
+ where ${ \bf W _ { e } }$ and $\mathbf { b _ { e } }$ are the layer’s parameters. Using fat data such as the one described in Section 1, leads to a parameter explosion in this layer, hereafter referred to as fat hidden layer. To give the reader an intuition, consider the case of having an input with $N _ { d } = 3 0 0 K$ , and a hidden layer with $N _ { h } ^ { 1 } = 1 0 0$ , the number of parameters of such a layer would be 30M. The same happens to the number of parameters of the optional reconstruction layer, hereafter referred to as fat reconstruction layer.
79
+
80
+ In order to mitigate this effect, we introduce an auxiliary network to predict the fat layers’ parameters. The auxiliary network takes as input the transposed data matrix $\mathbf { X ^ { \mathrm { T } } }$ , extracts a feature embedding and learns a function of this embedding, to be used as parameters of a fat layer:
81
+
82
+ $$
83
+ ( \mathbf { W _ { e } } ) _ { \mathbf { j } : } = \phi ( \mathbf { e _ { j } } ) ,
84
+ $$
85
+
86
+ where $\mathbf { e _ { j } }$ represents the embedding of a feature in $\mathbf { X ^ { \mathrm { T } } }$ , $\phi$ is a non-linear function and $( \mathbf { W _ { e } } ) _ { \mathbf { j } : }$ is the $j$ -th row of ${ \bf W _ { e } }$ . This means that each feature is associated with the vector of values it takes in the dataset (e.g. across the patients). Other representations could be used, e.g., derived from other datasets in which those features interact. Figure 1(b) shows a prediction network which is an auxiliary network that predicts the parameters of the fat hidden layer of our basic network. Following the same spirit, Figure 1(c) highlights the interaction between a second prediction network that predicts the fat reconstruction layer parameters and the basic network. The architectures of both auxiliary networks may share the initial feature embedding.
87
+
88
+ The feature embeddings used in the auxiliary networks allow us to substantially reduce the number of free parameters of the fat layers of the basic architecture. The auxiliary network should predict a matrix of weights of size $N _ { d } \times N _ { h } ^ { 1 }$ from a feature embedding. Consider a feature embedding that would transform each $N$ -dimensional feature into a $N _ { f }$ -dimensional vector, where $N _ { f } < N$ . The auxiliary network would learn a function $\phi : \mathcal { R } ^ { N _ { f } } \mathbb { R } ^ { N _ { h } ^ { 1 } }$ . Thus, the fat hidden layer of our basic architecture would have $N _ { f } \times N _ { h } ^ { 1 }$ free parameters (assuming a single layer MLP in the auxiliary network), instead of $N _ { d } \times N _ { h } ^ { 1 }$ . Following our previous example, where $N _ { d } = 3 0 0 K$ and $N _ { h } ^ { 1 } = 1 0 0$ , using an auxiliary network with previously-obtained feature embeddings of dimensionality $N _ { f } =$ 500 would reduce the number of free parameters of the basic network by a factor of 600 (from 30M to 50K).
89
+
90
+ The model is trained end-to-end by minimizing the following objective function
91
+
92
+ $$
93
+ \mathcal { H } ( \hat { \mathbf { Y } } , \mathbf { Y } ) + \gamma | | \hat { \mathbf { X } } - \mathbf { X } | | _ { 2 } ^ { 2 } ,
94
+ $$
95
+
96
+ where $\mathcal { H }$ refers to the cross-entropy, $\mathbf { Y }$ to the true classification labels and $\gamma$ is a tunable parameter to balance the supervised and the reconstruction losses.
97
+
98
+ # 2.2 FEATURE EMBEDDINGS
99
+
100
+ The feature embeddings used by the auxiliary networks can be either pre-computed or learnt offline, as well as learnt jointly with the rest of the architecture. In theory, any kind of embedding could be used, as long as we keep in mind that the goal is to reduce the number of free parameters of the basic model. In this work, we considered random projections (Bingham & Mannila, 2001), histograms (which are akin to bag-of-words representations), feature embeddings learnt offline (Mikolov et al., 2013) and feature embeddings jointly learnt with the rest of the proposed architecture.
101
+
102
+ Random projection: Randomly initializing an MLP defines a random projection. By using such a projection to encode the high-dimensional feature space into a more manageable lower-dimensional space, we were able to obtain decent results.
103
+
104
+ Per class histogram: For a given SNP, we can define a histogram of the values it can take over the whole population. Once normalized, this yields 3 values per SNP, corresponding to the proportion of the population having the values 0, 1 and 2 respectively for that SNP. After initial tests showed this was too coarse a representation for the dataset, we instead chose to consider the per-class proportion of the three values. With 26 classes in the 1000 Genomes dataset, this yields an embedding of size 78 for each feature. By this method, the matrix $\mathbf { X ^ { \mathrm { T } } }$ is summarized as a $N _ { d } \times 7 8$ matrix, where $N _ { d }$ is the number of SNPs in the dataset.
105
+
106
+ SNPtoVec: In Mikolov et al. (2013), the authors propose a word embedding that allows good reconstruction of the words’ context (surrounding words) by a neural network. SNPs do not have a similarly well-defined positional context (SNPs close together in our ordering might very well be independent) so our embedding is instead built by training a denoising autoencoder (DAE) (Vincent et al., 2008) on the matrix X. Thus, the DAE learns to recover the values of missing SNPs by leveraging their similarities and cooccurences with other SNPs. Once the DAE is trained, we obtain an encoding for each feature by feeding to the DAE an input where only that feature is active (the other features are set to 0s) and computing the hidden representation of the autoencoder for that single-feature input.
107
+
108
+ Embedding learnt end-to-end from raw data: In this case, we consider the feature embedding to be another MLP, whose input corresponds to the values that a SNP takes for each of the training samples and, whose parameters are learnt jointly with the rest of the network. Note that the layer(s) corresponding to the feature embedding are shared among auxiliary networks. For experiments reported in Section 4, we used a single hidden layer as embedding.
109
+
110
+ # 3 DATA: THE 1000 GENOMES PROJECT
111
+
112
+ The 1000 Genomes project is the first project to sequence the genomes of a large number of people in populations worldwide, yielding the largest public catalog of human genetic variants to date Consortium (2015). This allowed large-scale comparison of DNA sequences from populations, thanks to the presence of genetic variation. Individuals of the 1000 Genomes project are samples taken from 26 populations over the world, which are grouped into 5 geographical regions. Figure 2(a) shows a histogram derived from the 1000 Genomes data, depicting the frequency of individuals per population (ethnicity). Analogously, Figure 2(b) depicts the frequency of individuals per geographical region.
113
+
114
+ In this dataset, we included 315,345 genetic variants with frequencies of at least $5 \%$ in 3,450 individuals sampled worldwide from 26 populations, interrogated using microarray genotyping technology: the Genome-Wide Human SNP Array 6.0 by Affymetrix. The mutated state is established by comparison to the Genome Reference Consortium human genome (build 37). Since individuals have 2 copies of each genomic position, a sampled individual can have 0, 1 or 2 copies of a genetic mutation, hereafter referred to as an individual genotype. We excluded SNPs positioned on the sex chromosomes and only included SNPs in approximate linkage equilibrium with each other, such that genotypes at neighboring positions are only weakly correlated $( r ^ { 2 } < 0 . 5 )$ .
115
+
116
+ ![](images/09ea8294618b9993a70f96d30ca2f1331641175c150a60f545d07b117b6f0da7.jpg)
117
+ Figure 2: The 1000 Genomes population distribution:(a) Ethnicity; (b) Geographical Region.
118
+
119
+ # 4 EXPERIMENTS
120
+
121
+ In this section, we describe the model architectures, and report and discuss the obtained results.
122
+
123
+ ![](images/0ccd4f6db366387a241d01be92e4ff7d2439249520117517a01010e0b34e0731.jpg)
124
+ Figure 3: Results of our best model: (a) Confusion matrix per ethnicity; (b) Confusion matrix per large geographical region. The 1000 Genomes legend for population abbreviations can be found in the appendix.
125
+
126
+ # 4.1 MODEL ARCHITECTURE
127
+
128
+ We experimented with simple models both in the auxiliary networks and the basic architecture, which yielded very promising results. We designed a basic architecture with 2 hidden layers followed by a softmax layer to perform ancestry prediction. We trained this architecture with and without the assistance of the auxiliary network. Similarly, the auxiliary networks were build by stacking a hidden layer on top of one of the feature embeddings described in Section 2.2. In the reported experiments, all hidden layers have 100 units. All models were trained by means of stochastic gradient descent with adaptive learning rate (Tieleman & Hinton, 2012), both for $\gamma = 0$ and $\gamma = 1 0$ , using dropout, limiting the norm of the weights to 1 and/or applying weight decay to reduce overfitting.2.
129
+
130
+ # 4.2 RESULTS
131
+
132
+ Given the relatively small amount of samples in the 1000 Genomes data, we report results obtained by 5-fold cross validation of the model. We split the data into 5 folds of equal size. A single fold is retained for test, whereas three of the remaining folds are used as training data and the final fold is used as validation data. We repeated the process 5 times (one per fold) and report the means and standard deviations of results on the different test sets.
133
+
134
+ Table 1 summarizes the results obtained for each model. First, we observe that, for most of Diet Network architectures, training with an reconstruction term in the loss $( \gamma > 0 )$ ) reduces the misclassification error and provides a lower standard deviation over the folds, suggesting more robustness to variations in the learnt feature embedding.
135
+
136
+ Training the models end-to-end, with no pre-computed feature embedding, yielded higher misclassification error than simply training the basic model, which could be attributed to the fact that adding the prediction networks makes a difficult, high-dimensional optimization problem even harder. As a general trend, adding pre-computed feature embeddings achieved better performance (lower error), while allowing to significantly reduce the number of free parameters in the fat layers of the model. Among the tested feature embeddings, random projections achieved good results, highlighting the potential of the model when reducing the number of free parameters.
137
+
138
+ Using the SNP2Vec embedding, trained to exploit the similarities and co-occurences between the SNPs, in conjunction with the Diet Networks framework obtains slightly better results than the model using a random projection. The addition of the reconstruction criterion does not appear to reduce the number of errors made by the model but it does appear to reduce the variance of the results, as observed on the other models.
139
+
140
+ Despite its simplicity, the per class histogram encoding (when used with a reconstruction criterion) yielded the best results. Note that this encoding is the one with the fewest number of free parameters in the fat layers, with a reduction factor of almost 4000 w.r.t. the analogous basic model (with reconstruction). Figure 3(a) shows the mean results obtained with the histogram embedding. As shown in the figure, when considering the ethnicity, the main misclassifications involve ethnicities likely to display very close genetic proximity, such as British from England and Scotland, and Utah residents with Northern and Western ancestry (likely to be immigrants from England), or Indian Telugu and Sri Lankan Tamil for instance. However, the model achieves almost $100 \%$ accuracy when considering the 5 geographical regions.
141
+
142
+ We also compared the performance of our model to the principal component analysis (PCA) approach, commonly used in the genomics domain, to select subgroups of individuals in order to perform more homogeneous analysis. The number of principal components (PCs) is chosen according to their significance, and usually varies from one dataset to another, being 10 the de facto standard for small datasets. However, in the case of the 1000 Genomes dataset, we could go up to $5 0 \mathrm { P C s }$ . Therefore, we trained a linear classifier on top of PCA features, considering 10 and $5 0 \mathrm { P C s }$ , $1 0 0 \mathrm { P C s }$ to match the number of feature used in the other experiments, as well as $2 0 0 \mathrm { P C s }$ . Using $2 0 0 ~ \mathrm { P C s }$ yielded better performance, but going beyond that saturated in terms of misclassification error (see SectionC in Appendix for more details). Adding hidden layers to the classifier didn’t help either (see reported results for several MLP configurations before the linear classifier).
143
+
144
+ # 5 CONCLUSION
145
+
146
+ In this paper, we proposed Diet Networks, a novel network parametrization, which considerably reduces the number of free parameters in the fat layers of a model when the input is very high dimensional. We showed how using the parameter prediction networks, yielded better generalization in terms of misclassification error. Notably, when using pre-computed feature embeddings that maximally reduced the number of free parameters, we were able to obtain our best results. We validated our approach on the publicly available 1000 genomes dataset, addressing the relevant task of ancestry prediction based on SNP data. This work demonstrated the potential of deep learning models to tackle domain-specific tasks where there is a mismatch between the number of samples and their high dimensionality.
147
+
148
+ Table 1: Results for 1000 Genomes ancestry prediction. Raw end2end, random projection and SNP2Vec embeddings have dimensionality 100, whereas per class histograms has dimensionality 78. Note that the reported number of free parameters corresponds to the free parameters of the fat layers of the models.
149
+
150
+ <table><tr><td rowspan=1 colspan=1>Model &amp; Embedding</td><td rowspan=1 colspan=1>MeanMisclassif.Error.(%)</td><td rowspan=1 colspan=1>#of free parameters</td></tr><tr><td rowspan=1 colspan=1>Basic</td><td rowspan=1 colspan=1>8.31 ± 1.83</td><td rowspan=1 colspan=1>31.5M</td></tr><tr><td rowspan=1 colspan=1>Raw end2end</td><td rowspan=1 colspan=1>8.88 ±1.42</td><td rowspan=1 colspan=1>217.2k</td></tr><tr><td rowspan=1 colspan=1>Random Projection</td><td rowspan=1 colspan=1>9.03±1.20</td><td rowspan=1 colspan=1>10.1k</td></tr><tr><td rowspan=1 colspan=1>SNP2Vec</td><td rowspan=1 colspan=1>7.60 ± 1.28</td><td rowspan=1 colspan=1>10.1k</td></tr><tr><td rowspan=1 colspan=1>Per class histograms</td><td rowspan=1 colspan=1>7.88 ± 1.40</td><td rowspan=1 colspan=1>7.9k</td></tr><tr><td rowspan=1 colspan=1>Basic with reconstruction</td><td rowspan=1 colspan=1>7.76 ± 1.38</td><td rowspan=1 colspan=1>63M</td></tr><tr><td rowspan=1 colspan=1>Raw end2end with reconstruction</td><td rowspan=1 colspan=1>8.28 ± 1.92</td><td rowspan=1 colspan=1>227.3k</td></tr><tr><td rowspan=1 colspan=1>Random Projection with reconstruction</td><td rowspan=1 colspan=1>8.03±1.03</td><td rowspan=1 colspan=1>20.2k</td></tr><tr><td rowspan=1 colspan=1>SNP2Vecwith reconstruction</td><td rowspan=1 colspan=1>7.88 ±0.72</td><td rowspan=1 colspan=1>20.2k</td></tr><tr><td rowspan=1 colspan=1>Per class histograms with reconstruction</td><td rowspan=1 colspan=1>7.44 ± 0.45</td><td rowspan=1 colspan=1>15.8k</td></tr><tr><td rowspan=1 colspan=1>Traditionalapproaches</td><td rowspan=1 colspan=2>Mean Misclassif. Error. (%)</td></tr><tr><td rowspan=1 colspan=1>PCA (10 PCs)</td><td rowspan=1 colspan=2>20.56 ± 3.20</td></tr><tr><td rowspan=1 colspan=1>PCA (50 PCs)</td><td rowspan=1 colspan=2>12.29 ± 0.89</td></tr><tr><td rowspan=1 colspan=1>PCA (100 PCs)</td><td rowspan=1 colspan=2>10.52 ± 0.25</td></tr><tr><td rowspan=1 colspan=1>PCA (200 PCs)</td><td rowspan=1 colspan=2>9.33±1.24</td></tr><tr><td rowspan=1 colspan=1>PCA(100 PCs) + MLP(50)</td><td rowspan=1 colspan=2>12.67±0.67</td></tr><tr><td rowspan=1 colspan=1>PCA(100 PCs)+MLP(100)</td><td rowspan=1 colspan=2>12.18 ±1.75</td></tr><tr><td rowspan=1 colspan=1>PCA(100 PCs)+MLP(100,100)</td><td rowspan=1 colspan=2>11.95 ± 2.29</td></tr></table>
151
+
152
+ Given the high accuracy achieved in the ancestry prediction task, we believe that deep learning techniques can improve standard practices in the analysis of human polymorphism data. We expect that these techniques will allow us to tackle the more challenging problem of conducting genetic association studies. Hence, we expect to further develop our method to conduct population-aware analyses of SNP data in disease cohorts. The increased power of deep learning methods to identify the genetic basis of common diseases could lead to better patient risk prediction and will improve our overall understanding of disease etiology.
153
+
154
+ # ACKNOWLEDGMENTS
155
+
156
+ The authors would like to thank the developers of Theano Theano Development Team (2016) and Lasagne Lasagne (2016). We acknowledge the support of the following agencies for research funding and computing support: Imagia, CIFAR, Canada Research Chairs, Compute Canada and Calcul Quebec. J.G.H. is an EPAC/Linacre Junior Research Fellow funded by the Human Frontiers ´ Program (LT-001017/2013-L). Special thanks to Valeria Romero-Soriano, Xavier Grau-Bov \` e and ´ Margaux Luck for their patience sharing genomic biology expertise; as well as to Michal Drozdzal, Caglar Gulcehre and Simon Jegou for useful discussions and support. ´
157
+
158
+ # REFERENCES
159
+
160
+ 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, 2015.
161
+
162
+ Marcin Andrychowicz, Misha Denil, Sergio Gomez, Matthew W. Hoffman, David Pfau, Tom Schaul, and Nando de Freitas. Learning to learn by gradient descent by gradient descent. Technical report, Google DeepMind, 2016.
163
+
164
+ Y. Bengio, S. Bengio, and J. Cloutier. Learning a synaptic learning rule. 1991 Neural Networks for Computing Conference, Snowbird, 1991.
165
+
166
+ Luca Bertinetto, Joao F. Henriques, Jack Valmadre, Philip H. S. Torr, and Andrea Vedaldi. Learning ˜ feed-forward one-shot learners. CoRR, abs/1606.05233, 2016.
167
+
168
+ Ella Bingham and Heikki Mannila. Random projection in dimensionality reduction: Applications to image and text data. In Proceedings of the Seventh ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD ’01, pp. 245–250. ACM, 2001. doi: 10.1145/ 502512.502546.
169
+
170
+ Bert De Brabandere, Xu Jia, Tinne Tuytelaars, and Luc Van Gool. Dynamic filter networks. CoRR, abs/1605.09673, 2016.
171
+
172
+ Yifei Chen, Yi Li, Rajiv Narayan, Aravind Subramanian, and Xiaohui Xie. Gene expression inference with deep learning. Bioinformatics, 2016. doi: 10.1093/bioinformatics/btw074.
173
+
174
+ The 1000 Genomes Project Consortium. A global reference for human genetic variation. Nature, 2015. doi: 10.1038/nature15393.
175
+
176
+ Misha Denil, Babak Shakibi, Laurent Dinh, Marc’Aurelio Ranzato, and Nando de Freitas. Predicting parameters in deep learning. arXiv:1306.0543, 2013.
177
+
178
+ Faustino Gomez and Juergen Schmidhuber. Evolving modular fast-weight networks for control. In Proceedings of the Fifteenth International Conference on Artificial Neural Networks: ICANN-05, pp. 383–389, 2005.
179
+
180
+ David Ha, Andrew Dai, and Quoc V. Le. Hypernetworks. CoRR, abs/1609.09106, 2016.
181
+
182
+ Ryan J Haasl, Catherine A McCarty, and Bret A Payseur. Genetic ancestry inference using support vector machines, and the active emergence of a unique american population. European Journal of Human Genetics, 2013. doi: 10.1038/ejhg.2012.258.
183
+
184
+ David R Kelley, Jasper Snoek, and John Rinn. Basset: Learning the regulatory code of the accessible genome with deep convolutional neural networks. bioRxiv, 2016. doi: 10.1101/028399. URL http://biorxiv.org/content/early/2016/02/18/028399.
185
+
186
+ Lasagne. Lasagne. https://github.com/Lasagne/Lasagne, 2016.
187
+
188
+ Michael K. K. Leung, Andrew Delong, Babak Alipanahi, and Brendan J. Frey. Machine Learning in Genomic Medicine: A Review of Computational Problems and Data Sets. Proceedings of the IEEE, 104(1):176–197, January 2016. ISSN 0018-9219. doi: 10.1109/jproc.2015.2494198. URL http://dx.doi.org/10.1109/jproc.2015.2494198.
189
+
190
+ T. Mikolov, I. Sutskever, K. Chen, G.S. Corrado, and J. Dean. Distributed representations of words and phrases and their compositionality. In NIPS’2013, pp. 3111–3119. 2013.
191
+
192
+ Larsson Omberg, Jacqueline Salit, Neil Hackett, Jennifer Fuller, Rebecca Matthew, Lotfi Chouchane, Juan L Rodriguez-Flores, Carlos Bustamante, Ronald G Crystal, and Jason G Mezey. Inferring genome-wide patterns of admixture in qataris using fifty-five ancestral populations. BMC Genetics, 2012. doi: 10.1186/1471-2156-13-49.
193
+
194
+ Alkes L Price, Nick J Patterson, Robert M Plenge, Michael E Weinblatt, Nancy A Shadick, and D Reich. Principal components analysis corrects for stratification in genome-wide association studies. Nature Genetics, 2006. doi: 10.1038/ng1847.
195
+
196
+ Jurgen Schmidhuber. Learning to control fast-weight memories: An alternative to dynamic recurrent ¨ networks. Neural Comput., 4(1):131–139, 1992.
197
+
198
+ Sara Sheehan and Yun S Song. Deep learning for population genetic inference. PLoS Comput Biol, 2016. doi: 10.1371/journal.pcbi.1004845.
199
+
200
+ Ritambhara Singh, Jack Lanchantin, Gabriel Robins, and Yanjun Qi. Deepchrome: deep-learning for predicting gene expression from histone modifications. Bioinformatics, 2016. doi: 10.1093/ bioinformatics/btw427.
201
+
202
+ Kenneth O. Stanley, David B. D’Ambrosio, and Jason Gauci. A hypercube-based encoding for evolving large-scale neural networks. Artif. Life, 15(2):185–212, April 2009.
203
+
204
+ Theano Development Team. Theano: A Python framework for fast computation of mathematical expressions. arXiv e-prints, abs/1605.02688, May 2016. URL http://arxiv.org/abs/ 1605.02688.
205
+
206
+ T. Tieleman and G. Hinton. Lecture 6.5—RmsProp: Divide the gradient by a running average of its recent magnitude. COURSERA: Neural Networks for Machine Learning, 2012.
207
+
208
+ Pascal Vincent, Hugo Larochelle, Yoshua Bengio, and Pierre-Antoine Manzagol. Extracting and composing robust features with denoising autoencoders. In Andrew McCallum and Sam Roweis (eds.), Proceedings of the 25th Annual International Conference on Machine Learning (ICML 2008), pp. 1096–1103. Omnipress, 2008.
209
+
210
+ Jian Zhou and Olga Troyanskaya. Predicting effects of noncoding variants with deep learningbased sequence model. Nature Methods, 2015. doi: 10.1038/nmeth.3547.
211
+
212
+ # A THE 1000 GENOMES PROJECT LEGENDS
213
+
214
+ A.1 POPULATION ETHNICITY LEGEND
215
+
216
+ ACB: African Caribbeans in Barbados
217
+ ASW: Americans of African Ancestry in SW USA
218
+ BEB: Bengali from Bangladesh
219
+ CDX: Chinese Dai in Xishuangbanna
220
+ CEU: Utah Residents (CEPH) with Northern and Western Ancestry
221
+ CHB: Han Chinese in Bejing
222
+ CHS: Southern Han Chinese
223
+ CLM: Colombians from Medellin
224
+ ESN: Esan in Nigeria
225
+ FIN: Finnish in Finland
226
+ GBR: British in England and Scotland
227
+ GIH: Gujarati Indian from Houston
228
+ GWD: Gambian in Western Divisions in the Gambia
229
+ IBS: Iberian Population in Spain
230
+ ITU: Indian Telugu from the UK
231
+ JPT: Japanese in Tokyo
232
+ KHV: Kinh in Ho Chi Minh City
233
+ LWK: Luhya in Webuye
234
+ MSL: Mende in Sierra Leone
235
+ MXL: Mexican Ancestry from Los Angeles
236
+ PEL: Peruvians from Lima
237
+ PJL: Punjabi from Lahore
238
+ PUR: Puerto Ricans
239
+ STU: Sri Lankan Tamil from the UK
240
+ TSI: Toscani in Italia
241
+ YRI: Yoruba in Ibadan
242
+
243
+ A.2 GEOGPRAHICAL REGION LEGEND
244
+
245
+ AFR: African
246
+ AMR: Ad Mixed American
247
+ EAS: East Asian
248
+ EUR: European
249
+ SAS: South Asian
250
+
251
+ # B OBTAINING THE 1000 GENOMES DATA
252
+
253
+ SNP data for the 1000G dataset was downloaded from ftp://ftp.1000genomes.ebi.ac. uk:21/vol1/ftp/release/20130502/supporting/hd_genotype_chip/
254
+
255
+ − ALL . wgs . n h g r i c o r i e l l a f f y 6 . 2 0 1 4 0 8 2 5 . g e n o t y p e s h a s p e d . v c f . g z
256
+
257
+ − a f f y s a m p l e s . 2 0 1 4 1 1 1 8 . p a n e l
258
+
259
+ # Representative commands:
260
+
261
+ With PLINK v1.90b2n 64-bit https://www.cog-genomics.org/plink2
262
+
263
+ # c o n v e r t v c f t o p l i n k f o r m a t ( b e d ) , a n d o n l y k e e p i n g common m a r k e r s ( m i n o r a l l e l e f r e q u e n c y $>$ 0 . 0 5 i n c o m b i n e d s a m p l e )
264
+ $>$ p l i n k −−v c f \$ p a t h / ALL . wgs . n h g r i c o r i e l l a f f y 6 . 2 0 1 4 0 8 2 5 . g e n o t y p e s h a s p e d . v c f . g z −−maf 0 . 0 5 −−o u t $\$ 1$ p a t h / a f f y 6 b i a l l e l i c s n p s m a f 0 0 5 a u t −−n o t −c h r X Y MT −−make−b e d
265
+ # p r o d u c e a p r u n e d s u b s e t o f m a r k e r s t h a t a r e i n a p p r o x i m a t e l i n k a g e e q u i l i b r i u m w i t h e a c h o t h e r
266
+ $>$ p l i n k −− b f i l e \$ p a t h / a f f y 6 b i a l l e l i c s n p s m a f 0 0 5 a u t −−i n d e p − p a i r w i s e 50 5 0 . 5 −−o u t $\$ 5$ p a t h / a f f y 6 b i a l l e l i c s n p s m a f 0 0 5 a u t
267
+ # e x c l u d e m a r k e r s t o g e t p r u n e d s u b s e t
268
+ $>$ p l i n k −− b f i l e \$ p a t h / a f f y 6 b i a l l e l i c s n p s m a f 0 0 5 a u t −−e x c l u d e $\$ 9$ p a t h / a f f y 6 b i a l l e l i c s n p s m a f 0 0 5 a u t . p r u n e . o u t −−r e c o d e A −− o u t $\$ 5$ p a t h / a f f y 6 b i a l l e l i c s n p s m a f 0 0 5 t h i n n e d a u t A
269
+
270
+ For information on how to download this pre-processed dataset directly, please email Adriana Romero or Pierre Luc Carrier.
271
+
272
+ # C PCA COMPONENTS AND MISCLASSIFICATION ERROR
273
+
274
+ In this section, we analyze the influence of increasing the number of PCs used to perform classification. Figure 4 depicts the obtained results when considering 100, 200, 400, 800 and $1 0 0 0 \mathrm { P C s }$ . As shown in the figure, the best validation error comes with PC200. Further increasing the number of PCs improves the training error but does not generalize well on the validation set.
275
+
276
+ ![](images/3c15c086e405ed2263ab05bb546dd4339ac37174db86a7f53d642a5af2568ee2.jpg)
277
+ Figure 4: PCA: Train and validation misclassification error for different numbers of PCs.
md/train/SkEqro0ctQ/SkEqro0ctQ.md ADDED
@@ -0,0 +1,410 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HIERARCHICAL INTERPRETATIONS FOR NEURAL NETWORK PREDICTIONS
2
+
3
+ Chandan Singh∗
4
+ Department of EECS
5
+ UC Berkeley
6
+ c singh@berkeley.edu
7
+
8
+ W. James Murdoch∗ Department of Statistics UC Berkeley jmurdoch@berkeley.edu
9
+
10
+ Bin Yu
11
+ Department of Statistics, EECS
12
+ UC Berkeley
13
+ binyu@berkeley.edu
14
+
15
+ # ABSTRACT
16
+
17
+ Deep neural networks (DNNs) have achieved impressive predictive performance due to their ability to learn complex, non-linear relationships between variables. However, the inability to effectively visualize these relationships has led to DNNs being characterized as black boxes and consequently limited their applications. To ameliorate this problem, we introduce the use of hierarchical interpretations to explain DNN predictions through our proposed method: agglomerative contextual decomposition (ACD). Given a prediction from a trained DNN, ACD produces a hierarchical clustering of the input features, along with the contribution of each cluster to the final prediction. This hierarchy is optimized to identify clusters of features that the DNN learned are predictive. We introduce ACD using examples from Stanford Sentiment Treebank and ImageNet, in order to diagnose incorrect predictions, identify dataset bias, and extract polarizing phrases of varying lengths. Through human experiments, we demonstrate that ACD enables users both to identify the more accurate of two DNNs and to better trust a DNN’s outputs. We also find that ACD’s hierarchy is largely robust to adversarial perturbations, implying that it captures fundamental aspects of the input and ignores spurious noise.
18
+
19
+ # 1 INTRODUCTION
20
+
21
+ Deep neural networks (DNNs) have recently demonstrated impressive predictive performance due to their ability to learn complex, non-linear, relationships between variables. However, the inability to effectively visualize these relationships has led DNNs to be characterized as black boxes. Consequently, their use has been limited in fields such as medicine (e.g. medical image classification (Litjens et al., 2017)), policy-making (e.g. classification aiding public policy makers (Brennan & Oliver, 2013)), and science (e.g. interpreting the contribution of a stimulus to a biological measurement (Angermueller et al., 2016)). Moreover, the use of black-box models like DNNs in industrial settings has come under increasing scrutiny as they struggle with issues such as fairness (Dwork et al., 2012) and regulatory pressure (Goodman & Flaxman, 2016).
22
+
23
+ To ameliorate these problems, we introduce the use of hierarchical interpretations to explain DNN predictions. Our proposed method, agglomerative contextual decomposition $( \mathsf { A C D } ) ^ { 1 }$ , is a general technique that can be applied to a wide range of DNN architectures and data types. Given a prediction from a trained DNN, ACD produces a hierarchical clustering of the input features, along with the contribution of each cluster to the final prediction. This hierarchy is optimized to identify clusters of features that the DNN learned are predictive (see Fig 1).
24
+
25
+ The development of ACD consists of two novel contributions. First, importance scores for groups of features are obtained by generalizing contextual decomposition (CD), a previous method for obtaining importance scores for LSTMs (Murdoch et al., 2018). This work extends CD to arbitrary DNN architectures, including convolutional neural networks (CNNs). Second, most importantly, we introduce the idea of hierarchical saliency, where a group-level importance measure, in this case CD, is used as a joining metric in an agglomerative clustering procedure. While we focus on DNNs and use CD as our importance measure, this concept is general, and could be readily applied to any model with a suitable measure for computing importances of groups of variables.
26
+
27
+ We demonstrate the utility of ACD on both long short term memory networks (LSTMs) (Hochreiter & Schmidhuber, 1997) trained on the Stanford Sentiment Treebank (SST) (Socher et al., 2013) and CNNs trained on MNIST (LeCun, 1998) and ImageNet (Russakovsky et al., 2015). Through human experiments, we show that ACD produces intuitive visualizations that enable users to better reason about and trust DNNs. In particular, given two DNN models, we show that users can use the output of ACD to select the model with higher predictive accuracy, and that overall they rank ACD as more trustworthy than prior interpretation methods. In addition, we demonstrate that ACD’s hierarchy is robust to adversarial perturbations (Szegedy et al., 2013) in CNNs.
28
+
29
+ ![](images/43a9adeb38b67f264edc357fd7cfe4d70298cfe4c47973b9f4a1011ef7d0544f.jpg)
30
+ Figure 1: ACD illustrated through the toy example of predicting the phrase “not very good” as negative. Given the network and prediction, ACD constructs a hierarchy of meaningful phrases and provides importance scores for each identified phrase. In this example, ACD identifies that “very” modifies “good” to become the very positive phrase “very good”, which is subsequently negated by ”not” to produce the negative phrase “not very good”. Best viewed in color.
31
+
32
+ # 2 BACKGROUND
33
+
34
+ Interpreting DNNs is a growing field (Murdoch et al., 2019) spanning a range of techniques including feature visualization (Olah et al., 2017; Yosinski et al., 2015), analyzing learned weights (Tsang et al., 2017) and others (Frosst & Hinton, 2017; Andreas et al., 2016; Zhang et al., 2017). Our work focuses on local interpretations, where the task is to interpret individual predictions made by a DNN.
35
+
36
+ Local interpretation Most prior work has focused on assigning importance to individual features, such as pixels in an image or words in a document. There are several methods that give feature-level importance for different architectures. They can be categorized as gradient-based (Springenberg et al., 2014; Sundararajan et al., 2017; Selvaraju et al., 2016; Baehrens et al., 2010), decompositionbased (Murdoch & Szlam, 2017; Shrikumar et al., 2016; Bach et al., 2015) and others (Dabkowski & Gal, 2017; Fong & Vedaldi, 2017; Ribeiro et al., 2016; Zintgraf et al., 2017), with many similarities among the methods (Ancona et al., 2018; Lundberg & Lee, 2017).
37
+
38
+ By contrast, there are relatively few methods that can extract the interactions between features that a DNN has learned. In the case of LSTMs, Murdoch et al. (2018) demonstrated the limitations of prior work on interpretation using word-level scores, and introduced contextual decomposition (CD), an algorithm for producing phrase-level importance scores from LSTMs. Another simple baseline is occlusion, where a group of features is set to some reference value, such as zero, and the importance of the group is defined to be the resulting decrease in the prediction value (Zeiler & Fergus, 2014; Li et al., 2016). Given an importance score for groups of features, no existing work addresses how to search through the many possible groups of variables in order to find a small set to show to users. To address this problem, this work introduces hierarchical interpretations as a principled way to search for and display important groups.
39
+
40
+ Hierarchical importance Results from psychology and philosophy suggest that people prefer explanations that are simple but informative (Harman, 1965; Read & Marcus-Newhall, 1993) and include the appropriate amount of detail (Keil, 2006). However, there is no existing work that is both powerful enough to capture interactions between features, and simple enough to not require a user to manually search through the large number of available feature groups. To remedy this, we propose a hierarchical clustering procedure to identify and visualize, out of the considerable number of feature groups, which ones contain meaningful interactions and should be displayed to the end user. In doing so, ACD aims to be informative enough to capture meaningful feature interactions while displaying a sufficiently small subset of all feature groups to maintain simplicity.
41
+
42
+ # 3 METHOD
43
+
44
+ This section introduces ACD through two contributions: Sec 3.1 proposes a generalization of CD from LSTMs to arbitrary DNNs, and Sec 3.2 explains the main contribution: how to combine these CD scores with hierarchical clustering to produce ACD.
45
+
46
+ # 3.1 CONTEXTUAL DECOMPOSITION (CD) IMPORTANCE SCORES FOR GENERAL DNNS
47
+
48
+ In order to generalize CD to a wider range of DNNs, we first reformulate the original CD algorithm into a more generic setting than originally presented. For a given DNN $f ( x )$ , we can represent its output as a SoftMax operation applied to logits $g ( x )$ . These logits, in turn, are the composition of $L$ layers $g _ { i }$ , such as convolutional operations or ReLU non-linearities.
49
+
50
+ $$
51
+ f ( x ) = { \mathrm { S o f t M a x } } { \big ( } g ( x ) { \big ) } = { \mathrm { S o f t M a x } } { \big ( } g _ { L } { \big ( } g _ { L - 1 } ( \ldots ( g _ { 2 } ( g _ { 1 } ( x ) ) ) ) { \big ) } { \big ) }
52
+ $$
53
+
54
+ Given a group of features $\{ x _ { j } \} _ { j \in S }$ , our generalized CD algorithm, $g ^ { C D } ( x )$ , decomposes the logits $g ( x )$ into a sum of two terms, $\beta ( x )$ and $\gamma ( x ) . ~ \beta ( x )$ is the importance measure of the feature group $\{ x _ { j } \} _ { j \in S }$ , and $\gamma ( x )$ captures contributions to $g ( x )$ not included in $\beta ( x )$ .
55
+
56
+ $$
57
+ \begin{array} { c } { { g ^ { C D } ( x ) = ( \beta ( x ) , \gamma ( x ) ) } } \\ { { \beta ( x ) + \gamma ( x ) = g ( x ) } } \end{array}
58
+ $$
59
+
60
+ To compute the CD decomposition for $g ( x )$ , we define layer-wise CD decompositions $g _ { i } ^ { C D } ( x ) =$ $( \beta _ { i } , \gamma _ { i } )$ for each layer $g _ { i } ( x )$ . Here, $\beta _ { i }$ corresponds to the importance measure of $\{ x _ { j } \} _ { j \in S }$ to layer $i$ , and $\gamma _ { i }$ corresponds to the contribution of the rest of the input to layer $i$ . To maintain the decomposition we require $\beta _ { i } + \gamma _ { i } = g _ { i } ( x )$ for each $i$ . We then compute CD scores for the full network by composing these decompositions.
61
+
62
+ $$
63
+ g ^ { C D } ( x ) = g _ { L } ^ { C D } ( g _ { L - 1 } ^ { C D } ( . . . ( g _ { 2 } ^ { C D } ( g _ { 1 } ^ { C D } ( x ) ) ) ) )
64
+ $$
65
+
66
+ Previous work (Murdoch et al., 2018) introduced decompositions $g _ { i } ^ { C D }$ for layers used in LSTMs. The generalized CD described here extends CD to other widely used DNNs, by introducing layerwise CD decompositions for convolutional, max-pooling, ReLU non-linearity and dropout layers. Doing so generalizes CD scores from LSTMs to a wide range of neural architectures, including CNNs with residual and recurrent architectures.
67
+
68
+ At first, these decompositions were chosen through an extension of the CD rules detailed in Murdoch et al. (2018), yielding a similar algorithm to that developed concurrently by Godin et al. (2018). However, we found that this algorithm did not perform well on deeper, ImageNet CNNs. We subsequently modified our CD algorithm by partitioning the biases in the convolutional layers between $\gamma _ { i }$ and $\beta _ { i }$ in Equation 5, and modifying the decomposition used for ReLUs in Equation 10. We show the effects of these two changes in Supplement S7, and give additional intuition in Supplement S1.
69
+
70
+ When $g _ { i }$ is a convolutional or fully connected layer, the layer operation consists of a weight matrix $W$ and a bias $b$ . The weight matrix can be multiplied with $\beta _ { i - 1 }$ and $\gamma _ { i - 1 }$ individually, but the bias must be partitioned between the two. We partition the bias proportionally based on the absolute value of the layer activations. For the convolutional layer, this equation yields only one activation of the output; it must be repeated for each activation.
71
+
72
+ $$
73
+ \begin{array} { r } { \beta _ { i } = W \beta _ { i - 1 } + \frac { \left| W \beta _ { i - 1 } \right| } { \left| W \beta _ { i - 1 } \right| + \left| W \gamma _ { i - 1 } \right| } \cdot b } \\ { \gamma _ { i } = W \gamma _ { i - 1 } + \frac { \left| W \gamma _ { i - 1 } \right| } { \left| W \beta _ { i - 1 } \right| + \left| W \gamma _ { i - 1 } \right| } \cdot b } \end{array}
74
+ $$
75
+
76
+ When $g _ { i }$ is a max-pooling layer, we identify the indices, or channels, selected by max-pool when run by $g _ { i } ( x )$ , denoted max idxs below, and use the decompositions for the corresponding channels.
77
+
78
+ $$
79
+ \begin{array} { c } { { m a x \_ i d x s = \underset { i d x s } { \mathrm { a r g m a x \ [ m a x p o o l ( } \beta _ { i - 1 } + \gamma _ { i - 1 } ; i d x s ) ] } } } \\ { { \beta _ { i } = \beta _ { i - 1 } [ m a x \_ i d x s ] } } \\ { { \gamma _ { i } = \gamma _ { i - 1 } [ m a x \_ i d x s ] } } \end{array}
80
+ $$
81
+
82
+ Finally, for the ReLU, we update our importance score $\beta _ { i }$ by computing the activation of $\beta _ { i - 1 }$ alone and then update $\gamma _ { i }$ by subtracting this from the total activation.
83
+
84
+ $$
85
+ \begin{array} { r l } & { \beta _ { i } = \mathrm { R e L U } ( \beta _ { i - 1 } ) } \\ & { \gamma _ { i } = \mathrm { R e L U } ( \beta _ { i - 1 } + \gamma _ { i - 1 } ) - \mathrm { R e L U } ( \beta _ { i - 1 } ) } \end{array}
86
+ $$
87
+
88
+ For a dropout layer, we simply apply dropout to $\beta _ { i - 1 }$ and $\gamma _ { i - 1 }$ individually, or multiplying each by a scalar. Computationally, a CD call is comparable to a forward pass through the network $f$ .
89
+
90
+ # 3.2 AGGLOMERATIVE CONTEXTUAL DECOMPOSITION (ACD)
91
+
92
+ Given the generalized CD scores introduced above, we now introduce the clustering procedure used to produce ACD interpretations. At a high-level, our method is equivalent to agglomerative hierarchical clustering, where the CD interaction is used as the joining metric to determine which clusters to join at each step. This procedure builds the hierarchy by starting with individual features and iteratively combining them based on the interaction scores provided by CD. The displayed ACD interpretation is the hierarchy, along with the CD importance score at each node.
93
+
94
+ More precisely, algorithm 1 describes the exact steps in the clustering procedure. After initializing by computing the CD scores of each feature individually, the algorithm iteratively selects all groups of features within ${ \mathrm { k } } \%$ of the highest-scoring group (where $k$ is a hyperparameter, fixed at 95 for images and 90 for text) and adds them to the hierarchy.
95
+
96
+ Each time a new group is added to the hierarchy, a corresponding set of candidate groups is generated by adding individual contiguous features to the original group. For text, the candidate groups correspond to adding one adjacent word onto the current phrase, and for images adding any adjacent pixel onto the current image patch. Candidate groups are ranked according to the CD interaction score, which is the difference between the score of the candidate and original groups.
97
+
98
+ ACD terminates after an application-specific criterion is met. For sentiment classification, we stop once all words are selected. For images, we stop after some predefined number of iterations and then merge the remaining groups one by one using the same selection criteria described above.
99
+
100
+ Algorithm 1 is not specific to DNNs; it requires only a method to obtain importance scores for groups of input features. Here, we use CD scores to arrive at the ACD algorithm, which makes the method specific to DNNs, but given a feature group scoring function, Algorithm 1 can yield interpretations for any predictive model. CD is a natural score to use for DNNs as it aggregates saliency at different scales and converges to the final prediction once all the units have been selected.
101
+
102
+ # Algorithm 1 Agglomeration algorithm.
103
+
104
+ <table><tr><td colspan="2">AigontnmnrTAggionerationargorunn.</td></tr><tr><td>ACD(Example x, model, hyperparameter k, function CD(x, blob; model)) # initialize</td><td></td></tr><tr><td>tree = Tree()</td><td># tree to output</td></tr><tr><td>scoresQueue =PriorityQueue()</td><td># scores,sorted by importance</td></tr><tr><td>for feature in x :</td><td></td></tr><tr><td>scoresQueue.push(feature,priority=CD(x, feature; model))</td><td></td></tr><tr><td></td><td></td></tr><tr><td># iteratively build up tree while scoresQueue is not empty :</td><td></td></tr><tr><td>selectedGroups = scoresQueue.popTopKPercentile(k)</td><td># pop off top k elements</td></tr><tr><td>tree.add(selectedGroups)</td><td># Add top k elements to the tree</td></tr><tr><td></td><td></td></tr><tr><td colspan="2"># generate new groups of features based on current groups and add them to the queue</td></tr><tr><td colspan="2">for selectedGroup in selectedGroups :</td></tr><tr><td colspan="2"></td></tr><tr><td colspan="2">candidateGroups = getCandidateGroups(selectedGroup)</td></tr><tr><td colspan="2">for candidateGroup in candidateGroups :</td></tr><tr><td colspan="2">scoresQueue.add(candidateGroup, priority=CD(x,candidateGroup;model)-CD(x,selectedGroup;</td></tr><tr><td colspan="2">model))</td></tr><tr><td colspan="2">return tree</td></tr></table>
105
+
106
+ # 4 RESULTS
107
+
108
+ We now present empirical validation of ACD on both LSTMs trained on SST and CNNs trained on MNIST and ImageNet. First, we introduce the reader to our visualization in Sec 4.2, and how it can (anecdotally) be used to understand models in settings such as diagnosing incorrect predictions, identifying dataset bias, and identifying representative phrases of differing lengths. We then provide quantitative evidence of the benefits of ACD in Sec 4.3 through human experiments and demonstrating the stability of ACD to adversarial perturbations.
109
+
110
+ # 4.1 EXPERIMENTAL DETAILS
111
+
112
+ We first describe the process for training the models from which we produce interpretations. As the objective of this paper is to interpret the predictions of models, rather than increase their predictive accuracy, we use standard best practices to train our models. All models are implemented using PyTorch. For SST, we train a standard binary classification LSTM model2, which achieves $8 6 . 2 \%$ accuracy. On MNIST, we use the standard PyTorch example3, which attains accuracy of $9 7 . 7 \%$ . On ImageNet, we use a pre-trained VGG-16 DNN architecture Simonyan & Zisserman (2014) which attains top-1 accuracy of $4 2 . 8 \%$ . When using ACD on ImageNet, for computational reasons, we start the agglomeration process with 14-by-14 superpixels instead of individual pixels. We also smooth the computed image patches by adding pixels surrounded by the patch. The weakened models for the human experiments are constructed from the original models by randomly permuting a small percentage of their weights. For SST/MNIST/ImageNet, $2 5 / 2 5 / 0 . 8 \%$ of weights are randomized, reducing test accuracy from $8 5 . 8 / 9 7 . 7 / 4 2 . 8 \%$ to $7 9 . 8 / 7 9 . 6 / 3 2 . 3 \%$ .
113
+
114
+ # 4.2 QUALITATIVE EXPERIMENTS
115
+
116
+ Before providing quantitative evidence of the benefits of ACD, we first introduce the visualization and demonstrate its utility in interpreting a predictive model’s behavior. To qualitatively evaluate ACD, in Supplement S3 we show the results of several more examples selected using the same criterion as in our human experiments described below.
117
+
118
+ # 4.2.1 UNDERSTANDING PREDICTIVE MODELS USING ACD
119
+
120
+ In the following examples, we demonstrate the use of ACD to diagnose incorrect predictions in SST and identify dataset bias in ImageNet. These examples are only a few of the potential uses of ACD.
121
+
122
+ Table 1: Top-scoring phrases of different lengths extracted by ACD on SST’s validation set. The positive/negative phrases identified by ACD are all indeed positive/negative.
123
+
124
+ <table><tr><td>Length</td><td>Positive</td><td>Negative</td></tr><tr><td>1</td><td>pleasurable, sexy, glorious</td><td>nowhere, grotesque, sleep</td></tr><tr><td>3</td><td> amazing accomplishment., great fun.</td><td>bleak and desperate, conspicuously lacks.</td></tr><tr><td>5</td><td>a pretty amazing accomplishment.</td><td>ultimately a pointless endeavour.</td></tr><tr><td>8</td><td>presents it with an unforgettable visual panache.</td><td>my reaction in a word: disappointment.</td></tr></table>
125
+
126
+ Text example - diagnosing incorrect predictions In the first example, we show the result of running ACD for our SST LSTM model in Figure 2. We can use this ACD visualization to quickly diagnose why the LSTM made an incorrect prediction. In particular, note that the ACD summary of the LSTM correctly identifies two longer phrases and their corresponding sentiment a great ensemble cast (positive) and n’t lift this heartfelt enterprise out of the ordinary (negative). It is only when these two phrases are joined that the LSTM inaccurately predicts a positive sentiment. This suggests that the LSTM has erroneously learned a positive interaction between these two phrases. Prior methods would not be capable of detecting this type of useful information.
127
+
128
+ ![](images/70858e0bb301c5010c159143f2b09c724bc80b179d2d7bf05e27772a81507ca6.jpg)
129
+ Figure 2: ACD interpretation of an LSTM predicting sentiment. Blue is positive sentiment, white is neutral, red is negative. The bottom row displays CD scores for individual words in the sentence. Higher rows display important phrases identified by ACD, along with their CD scores, converging to the model’s (incorrect) prediction in the top row. (Best viewed in color)
130
+
131
+ Vision example - identifying dataset bias Fig 3 shows an example using ACD for an ImageNet VGG model. Using ACD, we can see that to predict “puck”, the CNN is not just focusing on the puck in the image, but also on the hockey player’s skates. Moreover, by comparing the fifth and sixth plots in the third row, we can see that the network is only able to distinguish between the class “puck” and the other top classes when the orange skate and green puck patches merge into a single orange patch. This suggests that the CNN has learned that skates are a strong corroborating features for pucks. While intuitively reasonable in the context of ImageNet, this may not be desirable behavior if the model were used in other domains.
132
+
133
+ # 4.2.2 IDENTIFYING TOP-SCORING PHRASES
134
+
135
+ When feasible, a common means of scrutinizing what a model has learned is to inspect its most important features, and interactions. In Table 1, we use ACD to show the top-scoring phrases of different lengths for our LSTM trained on SST. These phrases were extracted by running ACD separately on each sample in SST’s validation set. The score of each phrase was then computed by averaging over the score it received in each occurrence in a ACD hierarchy. The extracted phrases are clearly reflective of the corresponding sentiment, providing additional evidence that ACD is able to capture meaningful positive and negative phrases. Additional phrases are given in Supplement S2.
136
+
137
+ ![](images/3924c07f33cdf890a66a501de3e1ece64184f84c05ed93519d85598ea7d45287.jpg)
138
+ Figure 3: ACD interpretation for a VGG network prediction, described in 4.2.1. ACD shows that the CNN is focusing on skates to predict the class “puck”, indicating that the model has captured dataset bias. The top row shows the original image, logits for the five top-predicted classes, and the CD superpixel-level scores for those classes. The second row shows separate image patches ACD has identified as being independently predictive of the class “puck”. Starting from the left, each image shows a successive iteration in the agglomeration procedure. The third row shows the CD scores for each of these patches, where patch colors in the second row correspond to line colors in the third row. ACD successfully finds important regions for the target class (such as the puck), and this importance increases as more pixels are selected. Best viewed in color.
139
+
140
+ # 4.3 QUANTITATIVE EXPERIMENTS
141
+
142
+ Having introduced our visualization and provided qualitative evidence of its uses, we now provide quantitative evidence of the benefits of ACD.
143
+
144
+ # 4.3.1 HUMAN EXPERIMENTS
145
+
146
+ We now demonstrate through human experiments that ACD allows users to better trust and reason about the accuracy of DNNs. Human subjects consist of eleven graduate students at the author’s institution, each of whom has taken a class in machine learning. Each subject was asked to fill out a survey with two types of questions: whether, using ACD, they could identify the more accurate of two models and whether they trusted a models output. In both cases, similar questions were asked on three datasets (SST, MNIST and ImageNet), and ACD was compared against three baselines: CD (Murdoch et al., 2018), Integrated Gradients (IG) (Sundararajan et al., 2017), and occlusion (Li et al., 2016; Zeiler & Fergus, 2014). The exact survey prompts are provided in Supplement S4.
147
+
148
+ Identifying an accurate model The objective of this section was to determine if subjects could use a small number of interpretations produced by ACD in order to identify the more accurate of two models. For each question in this section, two example predictions were chosen. For each of these two predictions, subjects were given interpretations from two different models (four total), and asked to identify which of the two models had a higher predictive accuracy. Each subject was asked to make this comparison using three different sets of examples for each combination of dataset and interpretation method, for 36 total comparisons. To remove variance due to examples, the same three sets of examples were used across all four interpretation methods.
149
+
150
+ The predictions shown were chosen to maximize disagreement between models, with SST also being restricted to sentences between five and twenty words, for ease of visualization. To prevent subjects from simply picking the model that predicts more accurately for the given example, for each question a user is shown two examples: one where only the first model predicts correctly and one where only the second model predicts correctly. The two models considered were the accurate models of the previous section and a weakened version of that same model (details given in Sec 4.1).
151
+
152
+ ![](images/dbda9e49f3ac52adc6d32ec1c19bc8431237051a0362e5dedba7ef347f9bc081.jpg)
153
+ Figure 4: Results for human studies. A. Binary accuracy for whether a subject correctly selected the more accurate model using different interpretation techniques B. Average rank (from 1 to 4) of how much different interpretation techniques helped a subject to trust a model, higher ranks are better.
154
+
155
+ Fig 4A shows the results of the survey. For SST, humans were better able to identify the strongly predictive model using ACD compared to other baselines, with only ACD and CD outperforming random selection $( 5 0 \% )$ . Based on a one-sided two-sample t-test, the gaps between ACD and IG/Occlusion are significant, but not the gap between ACD and CD. In the simple setting of MNIST, ACD performs similarly to other methods. When applied to ImageNet, a more complex dataset, ACD substantially outperforms prior, non-hierarchical methods, and is the only method to outperform random chance, although the gaps between ACD and other methods are only statistically suggestive (p-values fall between 0.15 and 0.07).
156
+
157
+ Evaluating trust in a model In this section, the goal is to gauge whether ACD helps a subject to better trust a model’s predictions, relative to prior techniques. For each question, subjects were shown interpretations of the same prediction using four different interpretation methods, and were asked to rank the interpretations from one to four based on how much they instilled trust in trust the model. Subjects were asked to do this ranking for three different examples in each dataset, for nine total rankings. The interpretations were produced from the more accurate model from the previous section, and the examples were chosen using the same criteria as the previous section, except they were restricted to examples correctly predicted by the more accurate model.
158
+
159
+ Fig 4B shows the average ranking received by each method/dataset pair. ACD substantially outperforms other baselines, particularly for ImageNet, achieving an average rank of 3.5 out of 4, where higher ranks are better. As in the prior question, we found that the hierarchy only provided benefits in the more complicated ImageNet setting, with results on MNIST inconclusive. For both SST and ImageNet, the difference in mean ranks between ACD and all other methods is statistically significant (p-value less than 0.005) based on a permutation test, while on MNIST only the difference between ACD and occlusion is significant.
160
+
161
+ # 4.3.2 ACD HIERARCHY IS ROBUST TO ADVERSARIAL PERTURBATIONS
162
+
163
+ While there has been a considerable amount of work on adversarial attacks, little effort has been devoted to qualitatively understanding this phenomenon. In this section, we provide evidence that, on MNIST, the hierarchical clustering produced by ACD is largely robust to adversarial perturbations. This suggests that ACD’s hierarchy captures fundamental features of an image, and is largely immune to the spurious noise favored by adversarial examples.
164
+
165
+ To measure the robustness of ACD’s hierarchy, we first qualitatively compare the interpretations produced by ACD on both an unaltered image and an adversarially perturbed version of that image. Empirically, we found that the extracted hierarchies are often very similar, see Supplement S5. To generalize these observations, we introduce a metric to quantify the similarity between two ACD hierarchies. This metric allows us to make quantitative, dataset-level statements about the stability of ACD feature hierarchies with respect to adversarial inputs. Given an ACD hierarchy, we compute a ranking of the input image’s pixels according to the order in which they were added to the hierarchy. To measure the similarity between the ACD hierarchies for original and adversarial images, we compute the correlation between their corresponding rankings. As ACD hierarchies are class-specific, we average the correlations for the original and adversarially altered predictions.
166
+
167
+ Table 2: Correlation between pixel ranks for different adversarial attacks. ACD achieves consistently high correlation across different attack types, indicating that ACD hierarchies are largely robust to adversarial attacks. Using occlusion in place of CD produces substantially less stable hierarchies.
168
+
169
+ <table><tr><td>Attack Type</td><td>ACD</td><td>Agglomerative Occlusion</td></tr><tr><td>Saliency (Papernot et al., 2016)</td><td>0.762</td><td>0.259</td></tr><tr><td>Gradient attack</td><td>0.662</td><td>0.196</td></tr><tr><td>FGSM (Goodfellow et al., 2014)</td><td>0.590</td><td>0.131</td></tr><tr><td>Boundary (Brendel et al.,2017)</td><td>0.684</td><td>0.155</td></tr><tr><td>DeepFool (Moosavi Dezfooli et al., 2016)</td><td>0.694</td><td>0.202</td></tr></table>
170
+
171
+ We display the correlations for five different attacks (computed using the Foolbox package Rauber et al. (2017), examples shown in Supplement S6), each averaged over 100 randomly chosen predictions, in Table 2. As ACD is the first local interpretation technique to compute a hierarchy, there is little prior work available for comparison. As a baseline, we use our agglomeration algorithm with occlusion in place of CD. The resulting correlations are substantially lower, indicating that features detected by ACD are more stable to adversarial attacks than comparable methods. These results provide evidence that ACD’s hierarchy captures fundamental features of an image, and is largely immune to the spurious noise favored by adversarial examples.
172
+
173
+ # 5 CONCLUSION
174
+
175
+ In this work, we introduce agglomerative contextual decomposition (ACD), a novel hierarchical interpretation algorithm. ACD is the first method to use a hierarchy to interpret individual neural network predictions. Doing so enables ACD to automatically detect and display non-linear contributions to individual DNN predictions, something prior interpretation methods are unable to do. The benefits of capturing the non-linearities inherent in DNNs are demonstrated through human experiments and examples of diagnosing incorrect predictions and dataset bias. We also demonstrate that ACD’s hierarchy is robust to adversarial perturbations in CNNs, implying that it captures fundamental aspects of the input and ignores spurious noise.
176
+
177
+ # REFERENCES
178
+
179
+ Marco Ancona, Enea Ceolini, Cengiz Oztireli, and Markus Gross. Towards better understanding of gradient-based attribution methods for deep neural networks. In 6th International Conference on Learning Representations (ICLR 2018), 2018.
180
+
181
+ Jacob Andreas, Marcus Rohrbach, Trevor Darrell, and Dan Klein. Neural module networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 39–48, 2016.
182
+
183
+ Christof Angermueller, Tanel Parnamaa, Leopold Parts, and Oliver Stegle. Deep learning for com- ¨ putational biology. Molecular systems biology, 12(7):878, 2016.
184
+
185
+ Sebastian Bach, Alexander Binder, Gregoire Montavon, Frederick Klauschen, Klaus-Robert M ´ uller, ¨ and Wojciech Samek. On pixel-wise explanations for non-linear classifier decisions by layer-wise relevance propagation. PloS one, 10(7):e0130140, 2015.
186
+
187
+ David Baehrens, Timon Schroeter, Stefan Harmeling, Motoaki Kawanabe, Katja Hansen, and KlausRobert MA˜ zller. How to explain individual classification decisions. ˇ Journal of Machine Learning Research, 11(Jun):1803–1831, 2010.
188
+
189
+ Wieland Brendel, Jonas Rauber, and Matthias Bethge. Decision-based adversarial attacks: Reliable attacks against black-box machine learning models. arXiv preprint arXiv:1712.04248, 2017.
190
+
191
+ Tim Brennan and William L Oliver. The emergence of machine learning techniques in criminology. Criminology & Public Policy, 12(3):551–562, 2013.
192
+
193
+ Piotr Dabkowski and Yarin Gal. Real time image saliency for black box classifiers. arXiv preprint arXiv:1705.07857, 2017.
194
+
195
+ Cynthia Dwork, Moritz Hardt, Toniann Pitassi, Omer Reingold, and Richard Zemel. Fairness through awareness. In Proceedings of the 3rd innovations in theoretical computer science conference, pp. 214–226. ACM, 2012.
196
+
197
+ Ruth C Fong and Andrea Vedaldi. Interpretable explanations of black boxes by meaningful perturbation. arXiv preprint arXiv:1704.03296, 2017.
198
+
199
+ Nicholas Frosst and Geoffrey Hinton. Distilling a neural network into a soft decision tree. arXiv preprint arXiv:1711.09784, 2017.
200
+
201
+ Frederic Godin, Kris Demuynck, Joni Dambre, Wesley De Neve, and Thomas Demeester. Explain- ´ ing character-aware neural networks for word-level prediction: Do they discover linguistic rules? In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 3275–3284, 2018.
202
+
203
+ Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
204
+
205
+ Bryce Goodman and Seth Flaxman. European union regulations on algorithmic decision-making and a” right to explanation”. arXiv preprint arXiv:1606.08813, 2016.
206
+
207
+ Gilbert H Harman. The inference to the best explanation. The philosophical review, 74(1):88–95, 1965.
208
+
209
+ Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997.
210
+
211
+ Frank C Keil. Explanation and understanding. Annu. Rev. Psychol., 57:227–254, 2006.
212
+
213
+ Yann LeCun. The mnist database of handwritten digits. http://yann. lecun. com/exdb/mnist/, 1998.
214
+
215
+ Jiwei Li, Will Monroe, and Dan Jurafsky. Understanding neural networks through representation erasure. arXiv preprint arXiv:1612.08220, 2016.
216
+
217
+ Geert Litjens, Thijs Kooi, Babak Ehteshami Bejnordi, Arnaud Arindra Adiyoso Setio, Francesco Ciompi, Mohsen Ghafoorian, Jeroen AWM van der Laak, Bram van Ginneken, and Clara I Sanchez. A survey on deep learning in medical image analysis. ´ Medical image analysis, 42: 60–88, 2017.
218
+
219
+ Scott M Lundberg and Su-In Lee. A unified approach to interpreting model predictions. In Advances in Neural Information Processing Systems, pp. 4768–4777, 2017.
220
+
221
+ Seyed Mohsen Moosavi Dezfooli, Alhussein Fawzi, and Pascal Frossard. Deepfool: a simple and accurate method to fool deep neural networks. In Proceedings of 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), number EPFL-CONF-218057, 2016.
222
+
223
+ W James Murdoch and Arthur Szlam. Automatic rule extraction from long short term memory networks. arXiv preprint arXiv:1702.02540, 2017.
224
+
225
+ W James Murdoch, Peter J Liu, and Bin Yu. Beyond word importance: Contextual decomposition to extract interactions from lstms. arXiv preprint arXiv:1801.05453, 2018.
226
+
227
+ W. James Murdoch, Chandan Singh, Karl Kumbier, Reza Abbasi-Asl, and Bin Yu. Interpretable machine learning: definitions, methods, and applications. arXiv preprint arXiv:1901.04592, 2019.
228
+
229
+ Chris Olah, Alexander Mordvintsev, and Ludwig Schubert. Feature visualization. Distill, 2(11):e7, 2017.
230
+
231
+ Nicolas Papernot, Patrick McDaniel, Somesh Jha, Matt Fredrikson, Z Berkay Celik, and Ananthram Swami. The limitations of deep learning in adversarial settings. In Security and Privacy (EuroS&P), 2016 IEEE European Symposium on, pp. 372–387. IEEE, 2016.
232
+
233
+ Jonas Rauber, Wieland Brendel, and Matthias Bethge. Foolbox v0. 8.0: A python toolbox to benchmark the robustness of machine learning models. arXiv preprint arXiv:1707.04131, 2017.
234
+
235
+ Stephen J Read and Amy Marcus-Newhall. Explanatory coherence in social explanations: A parallel distributed processing account. Journal of Personality and Social Psychology, 65(3):429, 1993.
236
+
237
+ 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.
238
+
239
+ 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.
240
+
241
+ Ramprasaath R Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, and Dhruv Batra. Grad-cam: Visual explanations from deep networks via gradient-based localization. See https://arxiv. org/abs/1610.02391 v3, 7(8), 2016.
242
+
243
+ Avanti Shrikumar, Peyton Greenside, Anna Shcherbina, and Anshul Kundaje. Not just a black box: Learning important features through propagating activation differences. arXiv preprint arXiv:1605.01713, 2016.
244
+
245
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
246
+
247
+ 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.
248
+
249
+ Jost Tobias Springenberg, Alexey Dosovitskiy, Thomas Brox, and Martin Riedmiller. Striving for simplicity: The all convolutional net. arXiv preprint arXiv:1412.6806, 2014.
250
+
251
+ Mukund Sundararajan, Ankur Taly, and Qiqi Yan. Axiomatic attribution for deep networks. ICML, 2017.
252
+
253
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
254
+
255
+ Michael Tsang, Dehua Cheng, and Yan Liu. Detecting statistical interactions from neural network weights. arXiv preprint arXiv:1705.04977, 2017.
256
+
257
+ Jason Yosinski, Jeff Clune, Anh Nguyen, Thomas Fuchs, and Hod Lipson. Understanding neural networks through deep visualization. arXiv preprint arXiv:1506.06579, 2015.
258
+
259
+ Matthew D Zeiler and Rob Fergus. Visualizing and understanding convolutional networks. In European conference on computer vision, pp. 818–833. Springer, 2014.
260
+
261
+ Quanshi Zhang, Ruiming Cao, Feng Shi, Ying Nian Wu, and Song-Chun Zhu. Interpreting cnn knowledge via an explanatory graph. arXiv preprint arXiv:1708.01785, 2017.
262
+
263
+ Luisa M Zintgraf, Taco S Cohen, Tameem Adel, and Max Welling. Visualizing deep neural network decisions: Prediction difference analysis. arXiv preprint arXiv:1702.04595, 2017.
264
+
265
+ # ACD SUPPLEMENT
266
+
267
+ ![](images/114f381df6fe9d65332fbb65fbf954156c8ee8be6580594e548c781875982e7a.jpg)
268
+
269
+ ![](images/847e5a33bb996a529bb5e1d0d673e4fcd22521a79da77e6d76d024755ae1ef98.jpg)
270
+ Figure S1: Intuition for CD run on a corner-shaped blob compared to build-up and occlusion. CD decomposes a DNN’s feedforward pass into a part from the blob of interest (top row) and everything else (second row). Left column shows original image with overlaid blob. Other columns show DNN activations summed over the filter dimension. Top and third rows are on same color scale. Second and bottom rows are
271
+ Figure S2: Comparing unit-level CD scores for the correct class to scores from baseline methods. In each case, the model correctly predicts the label, shown on the y axis. Blue is positive, white is neutral, and red is negative. Best viewed in color.
272
+
273
+ Fig S1 gives intuition for CD on the VGG-16 ImageNet model described in Sec 4. CD keeps track of the contributions of the blob and non-blob throughout the network. This is intuitively similar to the occlusion and build-up methods, shown in the bottom two rows. The build-up method sets everything but the patch of interest to a references value (often zero). These rows compare the CD decomposition to perturbing the input as in the occlusion and build-up methods. They are similar in early layers, but differences become apparent in later layers.
274
+
275
+ Table S1: Top-scoring phrases of different lengths extracted by ACD on SST’s validation set. The positive/negative phrases identified by ACD are all indeed positive/negative Fig S2 compares the $7 \mathbf { x } 7$ superpixel-level scores for four images comparing different methods for obtaining importance scores. CD scores better find information relevant to predicting the correct class.
276
+
277
+ <table><tr><td>Length</td><td>Positive</td><td>Negative</td></tr><tr><td>1</td><td>&#x27;pleasurable&#x27;,&#x27;sexy’,&#x27;glorious&#x27;,&#x27;delight&#x27;, &#x27;unforgettable&#x27;</td><td>&#x27;nowhere&#x27;,&#x27;grotesque’,&#x27;sleep’,&#x27;mun- dane&#x27;,&#x27;clich&#x27;</td></tr><tr><td>3</td><td>&#x27;amazing accomplishment .,&#x27;great fun .&#x27;, &#x27;good fun &#x27;, &#x27;language sexy :,&#x27;are mag- nificent &#x27;</td><td>&#x27;very bad .&#x27;,&#x27;: disappointment .&#x27;,&#x27;quite bad ’,conspicuously lacks &#x27;,&#x27;bleak and des- perate&#x27;</td></tr><tr><td>5</td><td>&#x27;apretty amazing accomplishment&#x27;, &#x27;clearly,great fun.,&#x27;richness of its per- formances .,&#x27;a delightful coming-of-age story.&#x27;,&#x27;an unforgettable visual panache .</td><td>&#x27;ultimately a pointless endeavor &#x27;,&#x27;this is so bad .,&#x27;emotion closer to pity ?, &#x27;fat waste of time .&#x27;,&#x27;sketch gone horribly wrong.&#x27;</td></tr><tr><td>8</td><td>&#x27;presents it with an unforgettable visual panache .&#x27;,&#x27;film is packed with informa- tion and impressions .&#x27;,&#x27;entertains by pro- viding good,lively company .</td><td>&#x27;myreaction in a word :disappointment ’,&quot;s slow - very,very slow ”,&#x27;a dull , ridiculous attempt at heart-tugging .</td></tr><tr><td>12</td><td>&#x27;in delicious colors,and the costumes and sets are grand .,&#x27;part stevens glides through on some solid performances and witty dialogue .&#x27;,&#x27;mamet enthusiast and for anyone who appreciates intelligent , stylish moviemaking.</td><td>&quot;actors provide scant reason to care in this crude ’7Os throwback .”, &#x27;more often just feels generic,derivative and done to death .&#x27;,&#x27;its storyline with glitches casual fans could correct in their sleep .</td></tr><tr><td>15</td><td>&#x27;serry shows a remarkable gift for story- telling with this moving ,effective little film .&#x27;,&#x27;,lathan and diggs are charming and have chemistry both as friends and lovers .&#x27;</td><td>&#x27;level that one enjoysa bad slasher flick, primarily because it is dull .,&#x27;technicality that strains credulity and leaves the viewer haunted by the waste of potential .</td></tr></table>
278
+
279
+ # S2 TOP SCORING ACD PHRASES
280
+
281
+ Here we provide an extended version of Table S1, containing the top 5 phrases of each length for positive/negative polarities. These were extracted using ACD from an LSTM trained on SST.
282
+
283
+ # S3 ACD EXAMPLES
284
+
285
+ We provide additional, automatically selected, visualizations produced by ACD. These examples were chosen using the same criteria as the human experiments describes in Sec 4.3.1. All examples are best viewed in color.
286
+
287
+ SST top-predicted examples. Here, the model used and figure produced correspond to Fig 2.
288
+
289
+ <table><tr><td rowspan=1 colspan=1>it offers</td><td rowspan=1 colspan=1>little</td><td rowspan=1 colspan=1>beyond</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1>momentary</td><td rowspan=1 colspan=1>joys</td><td rowspan=1 colspan=1>of</td><td rowspan=1 colspan=1>pretty and</td><td rowspan=1 colspan=1>weightless</td><td rowspan=1 colspan=2>intellectualentertainment</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=4 colspan=1></td><td rowspan=1 colspan=1>little</td><td rowspan=1 colspan=1>beyond</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1>momentary</td><td rowspan=1 colspan=1>joys</td><td rowspan=1 colspan=1>of</td><td rowspan=1 colspan=1>pretty and</td><td rowspan=1 colspan=1>weightless</td><td rowspan=1 colspan=2>intellectual entertainment</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=2 colspan=2></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>momentary joys</td><td rowspan=1 colspan=1>of</td><td rowspan=1 colspan=1>pretty and</td><td rowspan=1 colspan=1>weightless</td><td rowspan=1 colspan=3>intellectualentertainment</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>weightless</td><td rowspan=1 colspan=3>intellectual entertainment</td></tr><tr><td rowspan=1 colspan=2>little beyond</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>momentary</td><td rowspan=1 colspan=1>joys</td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>entertainment</td></tr><tr><td rowspan=1 colspan=1>it offers</td><td rowspan=1 colspan=2>little beyond</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1>momentary</td><td rowspan=1 colspan=1>joys</td><td rowspan=1 colspan=1>of</td><td rowspan=1 colspan=1>pretty and</td><td rowspan=1 colspan=1>weightless</td><td rowspan=1 colspan=1>intellectual</td><td rowspan=1 colspan=1>entertainment</td><td rowspan=1 colspan=1></td></tr></table>
290
+
291
+ ![](images/bbffe188c85814a03a70861711afb4ad8256c2fa74c2eb57958a77539db4115f.jpg)
292
+ SST lowest-predicted examples. Here, the model used and figure produced correspond to Fig 2.
293
+
294
+ <table><tr><td>the</td><td>primitive</td><td>force</td><td>of</td><td>this</td><td>film seems</td><td>to</td><td>bubble</td><td>up</td><td>from</td><td>the</td><td>vast</td><td></td><td>collective memory</td><td>of</td><td>the</td><td>combatants</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>from</td><td>the</td><td></td><td>vast collective</td><td>memory</td><td>of</td><td>the</td><td>combatants</td></tr><tr><td>the</td><td>primitive</td><td>force</td><td>of</td><td>this</td><td>film</td><td>seems</td><td>bubble</td><td></td><td></td><td></td><td>vast</td><td>collective</td><td>memory</td><td>of</td><td>the</td><td>combatants</td></tr><tr><td>the</td><td>primitive</td><td>force</td><td>of</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>collective</td><td>memory</td><td>of</td><td>the</td><td>combatants</td></tr><tr><td></td><td>primitive</td><td>force</td><td>of</td><td></td><td>film</td><td>seems</td><td>bubble</td><td></td><td></td><td></td><td></td><td></td><td>memory</td><td>of</td><td>the</td><td>combatants</td></tr><tr><td></td><td>primitive</td><td>force</td><td></td><td></td><td>film</td><td>seems</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>combatants</td></tr><tr><td>the</td><td>primitive</td><td>force</td><td>of</td><td>this</td><td>film</td><td>seems</td><td>bubble</td><td>up</td><td>from</td><td>the</td><td>vast</td><td>collective</td><td>memory</td><td>of</td><td>the</td><td>combatants</td></tr><tr><td>50</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>50</td><td>much</td><td></td><td>facile</td><td>technique</td><td></td><td></td><td>such</td><td>cute</td><td></td><td>ideas</td><td></td><td>50</td><td></td><td>little</td><td>movie</td><td>:</td></tr><tr><td></td><td>much</td><td></td><td>facile</td><td>technique</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>much</td><td></td><td>facile</td><td>technique</td><td></td><td></td><td></td><td>cute</td><td></td><td>ideas</td><td>,</td><td>50</td><td></td><td>little</td><td>movie</td><td>,</td></tr><tr><td></td><td>much</td><td></td><td>facile</td><td>technique</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>50</td><td></td><td>little</td><td>movie</td><td></td></tr><tr><td></td><td></td><td></td><td>facile</td><td></td><td>technique</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>little</td><td>movie</td><td>,</td></tr><tr><td>50</td><td>much</td><td></td><td>facile</td><td>technique</td><td></td><td>4</td><td>such</td><td>cute</td><td></td><td>ideas</td><td></td><td>s0</td><td></td><td>little</td><td>movie</td><td></td></tr></table>
295
+
296
+ <table><tr><td rowspan=1 colspan=1>manages</td><td rowspan=1 colspan=1>to</td><td rowspan=1 colspan=1>show</td><td rowspan=1 colspan=1>life</td><td rowspan=1 colspan=1>in</td><td rowspan=1 colspan=1>all</td><td rowspan=1 colspan=1>of</td><td rowspan=1 colspan=1>its</td><td rowspan=1 colspan=1>banality</td><td rowspan=1 colspan=1>when</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1>intention</td><td rowspan=5 colspan=1>is quite the opposite</td></tr><tr><td rowspan=1 colspan=1>manages</td><td rowspan=1 colspan=1>to</td><td rowspan=1 colspan=1>show</td><td rowspan=1 colspan=1>life</td><td rowspan=1 colspan=1>in</td><td rowspan=1 colspan=1>all</td><td rowspan=1 colspan=1>of</td><td rowspan=1 colspan=1>its</td><td rowspan=1 colspan=1>banality</td><td rowspan=1 colspan=1>when</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1>intention</td></tr><tr><td rowspan=4 colspan=3></td><td rowspan=1 colspan=1>life</td><td rowspan=1 colspan=1>in</td><td rowspan=1 colspan=1>all</td><td rowspan=1 colspan=1>of</td><td rowspan=1 colspan=1>its</td><td rowspan=1 colspan=1>banality</td><td rowspan=1 colspan=1>when</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1>intention</td></tr><tr><td rowspan=3 colspan=3></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>its</td><td rowspan=1 colspan=1>banality</td><td rowspan=1 colspan=1>when</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1>intention</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>banality</td><td rowspan=1 colspan=1>when</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1>intention</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>banality when</td><td rowspan=1 colspan=1>the</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>quite the opposite</td></tr><tr><td rowspan=1 colspan=2>manages to</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>life in</td><td rowspan=1 colspan=1>all</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>banality</td><td rowspan=1 colspan=1>when</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2></td></tr><tr><td rowspan=1 colspan=2>manages to</td><td rowspan=1 colspan=1>show</td><td rowspan=1 colspan=2>life in</td><td rowspan=1 colspan=1>all</td><td rowspan=1 colspan=1>of</td><td rowspan=1 colspan=1>its</td><td rowspan=1 colspan=1>banality</td><td rowspan=1 colspan=1>when</td><td rowspan=1 colspan=3>the intention is quite the</td></tr></table>
297
+
298
+ MNIST top-predicted examples. Here, the model used is the same as in $\mathrm { S e c } 4 . 3 . 2 $ and the interpretation of the figure produced is the same as in Fig 3.
299
+
300
+ ![](images/b0a4576a05871421ac183fc4f838e1d5800f179935706140ecaa36827263982a.jpg)
301
+
302
+ ![](images/2477fa0b9b948ec6fe9017d9d0becfb532bb3abd5bf71d9608ff4351314e2395.jpg)
303
+
304
+ MNIST lowest-predicted examples. Here, the model used is the same as in Sec 4.3.2 and the interpretation of the figure produced is the same as in Fig 3.
305
+
306
+ ![](images/045180043b8e500b0b82410accc56a634117b3c506db7bc88c867f4ada818e59.jpg)
307
+
308
+ Imagenet top-predicted examples. Here, the model used and figure produced correspond to that in Fig 3.
309
+
310
+ ![](images/f46266f117f6103086e6849896814887d5286dc80e49f03c47a0bede5e1041e1.jpg)
311
+
312
+ ![](images/9f306bc4da198291fe9d480558ae5b0717c16c4706ac455245866765324e9fe5.jpg)
313
+ predictionlogits
314
+
315
+ CD (prairie ch) CD (ruffed gro) CD (partridge) CD (black grou) CD (robin,Ame)
316
+
317
+ ![](images/ce73e8b60cfceffb06cada34bae09de76684269bfd9f91e592692bcbd0d01eb8.jpg)
318
+
319
+ ![](images/5b3c9afef6d7dee6640e42bb403c27a355ba40164ec5f73529801b2dbb255b53.jpg)
320
+
321
+ ![](images/55a015ea8fc8d0200828d7a5d2e15b8067d4e64ced4272c156e960903ec0b490.jpg)
322
+
323
+ ![](images/fc021be5d0cb6e237fe29b04dc3035f9d380c403dc16962df4d302dda8525ac6.jpg)
324
+
325
+ ![](images/c18f17cc97601a941b9c56cdb7c2d0b672cc2b6497e1f7a8b714ec383dc2dbdf.jpg)
326
+
327
+ ![](images/5a8007675179efd6bcd8386558c3203a51a26482f46f2dfc700a581e3e880afd.jpg)
328
+
329
+ Imagenet lowest-predicted examples. Here, the model used and figure produced correspond to that in Fig 3.
330
+
331
+ ![](images/311319399f94b5f1894bb705863c0b3e7f9b13e022fab5cb823df98111c815b9.jpg)
332
+
333
+ ![](images/ca0ecc017e38eb8f49c8b7074888ecf98c6d48383c7534f32b9eeb9b1999df30.jpg)
334
+
335
+ ![](images/8b4d205208f7b5248f3ddc4b03affdb8b29f0a1e18acd5a698e6d1d7377074a6.jpg)
336
+
337
+ # S4 HUMAN EXPERIMENTS EXPERIMENTAL SETUP
338
+
339
+ Order of questions is randomized for each subject. Below are the instructions and questions given to the user (for brevity, the actual visualizations are omitted, but are similar to the visualizations shown in Supplement S3).
340
+
341
+ <table><tr><td>This survey aims to compare different interpretation techniques. In what follows, blue is positive, white is neutral,and red is negative.</td></tr></table>
342
+
343
+ # S4.1 SENTIMENT CLASSIFICATION
344
+
345
+ # S4.1.1 CHOOSING THE BETTER MODEL
346
+
347
+ In this section, the task is to compare two models that classify movie reviews as either positive (good movie) or negative (bad movie). One model has better predictive accuracy than the other.
348
+
349
+ In what follows, you will see visualizations of what both models have learned. These visualizations use different methods of identifying contributions to the final prediction of either individual words or groups of them. For each model, we show visualizations of two different examples.
350
+
351
+ In these visualizations, the color shows what the model thinks for individual words / groups of words. Blue is positive sentiment (e.g. ”great”, ”fantastic”) and red is negative sentiment (e.g. ”terrible”, ”miserable”).
352
+
353
+ Using these visualizations, please write A or B to select which model you think has higher predictive accuracy.
354
+
355
+ # S4.1.2 GAUGING TRUST
356
+
357
+ Now, we show results only from the good model. Your task is to compare different visualizations. For the following predictions, please select which visualization method leads you to trust the model the most.
358
+
359
+ Put a number next to each of the following letters ranking them in the order of how much they make you trust the model (1-4, 1 is the most trustworthy).
360
+
361
+ # S4.2 MNIST
362
+
363
+ # S4.2.1 CHOOSING THE BETTER MODEL
364
+
365
+ Now we will perform a similar challenge for vision. Your task is to compare two models that classify images into classes, in this case digits from 0-9. One model has higher predictive accuracy than the other.
366
+
367
+ In what follows, you will see visualizations of what both models have learned. These visualizations use different methods of identifying contributions to the final prediction of either individual pixels or groups of them. Using these visualizations, please select the model you think has higher accuracy.
368
+
369
+ For each prediction, the top row contains the raw image followed by five heat maps, and the title shows the predicted class. Each heatmap corresponds to a different class, with blue pixels indicating a pixel is a positive signal for that class, and red pixels indicating a negative signal. The first heatmap title shows the predicted class of the network - this is wrong half the time. In some cases, each visualization has an extra row, which shows groups of pixels, at multiple levels of granularity, that contribute to the predicted class.
370
+
371
+ Using these visualizations, please select which model you think has higher predictive accuracy, A or B.
372
+
373
+ # S4.2.2 GAUGING TRUST
374
+
375
+ Now, we show results only from the good model. Your task is to compare different visualizations. For the following predictions, please select which visualization method leads you to trust the model the most.
376
+
377
+ Put a number next to each of the following letters ranking them in the order of how much they make you trust the model (1-4, 1 is the most trustworthy).
378
+
379
+ # S4.2.3 CHOOSING THE MORE ACCURATE MODEL
380
+
381
+ Now we will perform a similar challenge for vision. Your task is to compare two models that classify images into classes (ex. balloon, bee, pomegranate). One model is better than the other in terms of predictive accuracy.
382
+
383
+ In what follows, you will see visualizations of what both models have learned. These visualizations use different methods of identifying contributions to the final prediction of either individual pixels or groups of them.
384
+
385
+ For each prediction, the top row contains the raw image followed by five heat maps, and the title shows the predicted class. Each heatmap corresponds to a different class, with blue pixels indicating a pixel is a positive signal for that class, and red pixels indicating a negative signal. The first heatmap title shows the predicted class of the network - this is wrong half the time. In some cases, each visualization has an extra row, which shows groups of pixels, at multiple levels of granularity, that contribute to the predicted class.
386
+
387
+ Using these visualizations, please select which model you think has higher predictive accuracy, A or B.
388
+
389
+ # S4.2.4 GAUGING TRUST
390
+
391
+ Now, we show results only from the more accurate model. Your task is to compare different visualizations. For the following predictions, please select which visualization method leads you to trust the model’s decision the most.
392
+
393
+ Put a number next to each of the following letters ranking them in the order of how much they make you trust the model (1-4, 1 is the most trustworthy).
394
+
395
+ S5 ACD ON ADVERSARIAL EXAMPLES
396
+
397
+ The hierarchies constructed by ACD to explain a prediction of 0 are substantially similar for both the original image and an adversarially perturbed image predicted to be a 6. Original image
398
+
399
+ ![](images/0766be086aaf891e1454c32cf61fd3eaf2abb62d616b821a38d4c11143bcc711.jpg)
400
+ Figure S3: Example of ACD run on an image of class 0 before and after an adversarial perturbation (a DeepFool attack). Best viewed in color.
401
+
402
+ ![](images/8c8366419730954d85012c48cd6f39038cea61b3b99120e5ec9a3162223cb4c5.jpg)
403
+ Figure S4: Examples of attacks for one image. Original image (left column) is correctly predicted as class 0. After each adversarial perturbation (middle column), the predicted class for the adversarial image (right column) is now altered.
404
+
405
+ # S7 GENERALIZING CD TO CNNS
406
+
407
+ Fig S5 qualitatively shows the change in behavior as the result of two modifications made to the naive extension of CD to CNNs, which was independently developed by Godin et al. (2018). During development of our general CD, two changes were made. First, we partitioned the bias between $\gamma _ { i }$ and $\beta _ { i }$ , as described in Equation 5. As can be seen in the second column, this qualitatively reduces the noise in the heat maps. Next, we replace the ReLU Shapely decomposition by the decomposition provided in Equation 10. In the third column, you can see that this effectively prevents the CD scores from becoming unrealistically large in areas that should not be influencing the model’s decision. When these two approaches are combined in the fourth column, they provide qualitatively sensible heatmaps with reasonably valued CD scores. When applied to the smaller models used on SST and MNIST, these changes don’t have large effects on the interpretations.
408
+
409
+ ![](images/de97701982e61b4adc1d445b31599763464bc1f8fd4ffd4e6a35480367a752a2.jpg)
410
+ Figure S5: Comparing unit-level CD scores to CD scores from the naive extension of CD to CNNs, independently developed by Godin et al. (2018). Labels under the bottom row signify the minimum and maximum scores from each column. Altering the bias partition and ReLU decomposition qualitatively improves scores (e.g. see scores in bottom row corresponding to the location of the crane), and avoids extremely large magnitudes (see values under left two columns). Blue is positive, white is neutral, and red is negative. In each case, scores are for the correct class, which the model predicts correctly (shown on the y axis).
md/train/SkVhlh09tX/SkVhlh09tX.md ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PAY LESS ATTENTION WITH LIGHTWEIGHT AND DYNAMIC CONVOLUTIONS
2
+
3
+ Felix $\mathbf { W u } ^ { * }$ Cornell University
4
+
5
+ Angela Fan, Alexei Baevski, Yann N. Dauphin, Michael Auli Facebook AI Research
6
+
7
+ # ABSTRACT
8
+
9
+ Self-attention is a useful mechanism to build generative models for language and images. It determines the importance of context elements by comparing each element to the current time step. In this paper, we show that a very lightweight convolution can perform competitively to the best reported self-attention results. Next, we introduce dynamic convolutions which are simpler and more efficient than self-attention. We predict separate convolution kernels based solely on the current time-step in order to determine the importance of context elements. The number of operations required by this approach scales linearly in the input length, whereas self-attention is quadratic. Experiments on large-scale machine translation, language modeling and abstractive summarization show that dynamic convolutions improve over strong self-attention models. On the WMT’14 English-German test set dynamic convolutions achieve a new state of the art of 29.7 BLEU.1
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ There has been much recent progress in sequence modeling through recurrent neural networks (RNN; Sutskever et al. 2014; Bahdanau et al. 2015; Wu et al. 2016), convolutional networks (CNN; Kalchbrenner et al. 2016; Gehring et al. 2016; 2017; Kaiser et al. 2017) and self-attention models (Paulus et al., 2017; Vaswani et al., 2017). RNNs integrate context information by updating a hidden state at every time-step, CNNs summarize a fixed size context through multiple layers, while as self-attention directly summarizes all context.
14
+
15
+ Attention assigns context elements attention weights which define a weighted sum over context representations (Bahdanau et al., 2015; Sukhbaatar et al., 2015; Chorowski et al., 2015; Luong et al., 2015). Source-target attention summarizes information from another sequence such as in machine translation while as self-attention operates over the current sequence. Self-attention has been formulated as content-based where attention weights are computed by comparing the current time-step to all elements in the context (Figure 1a). The ability to compute comparisons over such unrestricted context sizes are seen as a key characteristic of self-attention (Vaswani et al., 2017).
16
+
17
+ ![](images/13d2a5a765bcaf746bd19db6b98f82965f33cd9fe8fdcd167d82b6a2309204aa.jpg)
18
+ Figure 1: Self-attention computes attention weights by comparing all pairs of elements to each other (a) while as dynamic convolutions predict separate kernels for each time-step (b).
19
+
20
+ However, the ability of self-attention to model long-range dependencies has recently come into question (Tang et al., 2018) and the unlimited context size is computationally very challenging due to the quadratic complexity in the input length. Furthermore, in practice long sequences require the introduction of hierarchies (Liu et al., 2018).
21
+
22
+ In this paper, we introduce lightweight convolutions which are depth-wise separable (Sifre, 2014; Chollet, 2017; Kaiser et al., 2017), softmax-normalized and share weights over the channel dimension. The result is a convolution with several orders of magnitude fewer weights than a standard nonseparable convolution. Different to self-attention, lightweight convolutions reuse the same weights for context elements, regardless of the current time-step.
23
+
24
+ Dynamic convolutions build on lightweight convolutions by predicting a different convolution kernel at every time-step. The kernel is a function of the current time-step only as opposed to the entire context as in self-attention (Figure 1b). Dynamic convolutions are similar to locally connected layers in the sense that the weights change at every position, however, the difference is that weights are dynamically generated by the model rather than fixed after training (LeCun et al., 1998; Taigman et al., 2014; Chen et al., 2015). Our approach also bears similarity to location-based attention which does not access the context to determine attention weights, however, we do not directly take the attention weights from the previous time-step into account (Chorowski et al., 2015; Luong et al., 2015). Shen et al. (2018b) reduce complexity by performing attention within blocks of the input sequence and Shen et al. (2017; 2018c) perform more fine-grained attention over each feature. Shen et al. (2018a) and Gong et al. (2018) use input-dependent filters for text classification tasks.
25
+
26
+ Our experiments show that lightweight convolutions perform competitively to strong self-attention results and that dynamic convolutions can perform even better. On WMT English-German translation dynamic convolutions achieve a new state of the art of 29.7 BLEU, on WMT English-French they match the best reported result in the literature, and on IWSLT German-English dynamic convolutions outperform self-attention by 0.8 BLEU. Dynamic convolutions achieve $20 \%$ faster runtime than a highly-optimized self-attention baseline. For language modeling on the Billion word benchmark dynamic convolutions perform as well as or better than self-attention and on CNN-DailyMail abstractive document summarization we outperform a strong self-attention model.
27
+
28
+ # 2 BACKGROUND
29
+
30
+ We first outline sequence to sequence learning and self-attention. Our work builds on non-separable convolutions as well as depthwise separable convolutions.
31
+
32
+ Sequence to sequence learning maps a source sequence to a target sequence via two separate networks such as in machine translation (Sutskever et al., 2014). The encoder network computes representations for the source sequence such as an English sentence and the decoder network autoregressively generates a target sequence based on the encoder output.
33
+
34
+ The self-attention module of Vaswani et al. (2017) applies three projections to the input $X \in$ $\mathbb { R } ^ { n \times d }$ to obtain key (K), query (Q), and value (V) representations, where $n$ is the number of time steps, $d$ the input/output dimension (Figure 2a). It also defines a number of heads $H$ where each head can learn separate attention weights over $d _ { k }$ features and attend to different positions. The module computes dot-products between key/query pairs, scales to stabilize training, and then softmax normalizes the result. Finally, it computes a weighted sum using the output of the value projection (V):
35
+
36
+ $$
37
+ \mathrm { A t t e n t i o n } ( Q , K , V ) = \mathrm { s o f t m a x } ( \frac { Q K ^ { T } } { \sqrt { d _ { k } } } ) V
38
+ $$
39
+
40
+ Depthwise convolutions perform a convolution independently over every channel. The number of parameters can be reduced from $d ^ { 2 } k$ to $d k$ where $k$ is the kernel width. The output $O \in \mathbb { R } ^ { n \times d }$ of a depthwise convolution with weight $W \in \mathbb { R } ^ { d \times k }$ for element $i$ and output dimension $c$ is defined as:
41
+
42
+ $$
43
+ O _ { i , c } = \mathrm { D e p t h w i s e C o n v } ( X , W _ { c , : } , i , c ) = \sum _ { j = 1 } ^ { k } W _ { c , j } \cdot X _ { ( i + j - \lceil \frac { k + 1 } { 2 } \rceil ) , c }
44
+ $$
45
+
46
+ # 3 LIGHTWEIGHT CONVOLUTIONS
47
+
48
+ In this section, we introduce LightConv, a depthwise convolution which shares certain output channels and whose weights are normalized across the temporal dimension using a softmax. Compared to self-attention, LightConv has a fixed context window and it determines the importance of context elements with a set of weights that do not change over time steps. We will show that models equipped with lightweight convolutions show better generalization compared to regular convolutions and that they can be competitive to state-of-the-art self-attention models (§6). This is surprising because the common belief is that content-based self-attention mechanisms are necessary to obtaining stateof-the-art results in natural language processing applications. Furthermore, the low computational profile of LightConv enables us to formulate efficient dynamic convolutions (§4).
49
+
50
+ ![](images/e32d355bf92cc67704985b54c492b910910adc6f316a21b8764091874495bdae.jpg)
51
+ Figure 2: Illustration of self-attention, lightweight convolutions and dynamic convolutions.
52
+
53
+ LightConv computes the following for the $i$ -th element in the sequence and output channel $c$
54
+
55
+ $$
56
+ \operatorname { L i g h t C o n v } ( X , W _ { \lceil \frac { c H } { d } \rceil , : } , i , c ) = \operatorname { D e p t h w i s e C o n v } ( X , \operatorname { s o f t m a x } ( W _ { \lceil \frac { c H } { d } \rceil , : } ) , i , c )
57
+ $$
58
+
59
+ Weight sharing. We tie the parameters of every subsequent number of $\frac { d } { H }$ channels, which reduces the number of parameters by a factor of $\textstyle { \frac { d } { H } }$ . As illustration, a regular convolution requires 7,340,032 $( d ^ { 2 } \times k )$ weights for $d = 1 0 2 4$ and $k = 7$ , a depthwise separable convolution has 7,168 weights $( d \times k )$ , and with weight sharing, $H = 1 6$ , we have only 112 $\left( H \times k \right)$ weights. We will see that this vast reduction in the number of parameters is crucial to make dynamic convolutions possible on current hardware. Wang & Ji (2018) ties the weights of all channels $\mathrm { ( H } = 1 $ ).
60
+
61
+ Softmax-normalization. We normalize the weights $W \in \mathbb { R } ^ { H \times k }$ across the temporal dimension $k$ using a softmax operation:
62
+
63
+ $$
64
+ { \mathrm { s o f t m a x } } ( W ) _ { h , j } = { \frac { \displaystyle \exp W _ { h , j } } { \displaystyle \sum _ { j ^ { \prime } = 1 } ^ { k } \exp W _ { h , j ^ { \prime } } } }
65
+ $$
66
+
67
+ Module. Figure 2b shows the architecture of the module where we integrate LightConv. We first apply an input projection mapping from dimension $d$ to $2 d$ , followed by a gated linear unit (GLU; Dauphin et al. 2017), and the actual lightweight convolution. The GLU uses half of the inputs as gates by applying sigmoid units and then computes a pointwise product with the other inputs. We also apply an output projection of size $W ^ { O } \in \hat { \mathbb { R } } ^ { d \times d }$ to the output of LightConv.
68
+
69
+ Regularization. We found DropConnect to be a good regularizer for the LightConv module (Wan et al., 2013). Specifically, we drop every entry of the normalized weights sof tmax $( W )$ with probability $p$ and divide it by $1 - p$ during training. This amounts to removing some of the temporal information within a channel.
70
+
71
+ Implementation. Existing CUDA primitives for convolutions did not perform very well to implement LightConv and we found the following solution faster on short sequences: We copy and expand the normalized weights $W \in \mathbb { R } ^ { H \times k }$ to a band matrix of size $B H \times n \times n$ , where $B$ is the batch size. We then reshape and transpose the inputs to size $\begin{array} { r } { B H \times n \times \frac { d } { H } } \end{array}$ , and perform a batch matrix multiplication to get the outputs. We expect a dedicated CUDA kernel to be much more efficient.
72
+
73
+ # 4 DYNAMIC CONVOLUTIONS
74
+
75
+ A dynamic convolution has kernels that vary over time as a learned function of the individual time steps. A dynamic version of standard convolutions would be impractical for current GPUs due to their large memory requirements. We address this problem by building on LightConv which drastically reduces the number of parameters (§3).
76
+
77
+ DynamicConv takes the same form as LightConv but uses a time-step dependent kernel that is computed using a function f : Rd → RH×k:
78
+
79
+ $$
80
+ \mathrm { D y n a m i c C o n v } ( X , i , c ) = \mathrm { L i g h t C o n v } ( X , f ( X _ { i } ) _ { h , : } , i , c )
81
+ $$
82
+
83
+ we model $f$ with a simple linear module with learned weights $W ^ { Q } \in \mathbb { R } ^ { H \times k \times d }$ , i.e., $f ( X _ { i } ) =$ $\textstyle \sum _ { c = 1 } ^ { d } W _ { h , j , c } ^ { Q } X _ { i , c } .$ .
84
+
85
+ Similar to self-attention, DynamicConv changes the weights assigned to context elements over time. However, the weights of DynamicConv do not depend on the entire context, they are a function of the current time-step only. Self-attention requires a quadratic number of operations in the sentence length to compute attention weights, while the computation of dynamic kernels for DynamicConv scales linearly in the sequence length.
86
+
87
+ Our experiments (§6) show that models using DynamicConv match or exceed the performance of state-of-the-art models that use context-based self-attention. This challenges the typical intuitions about the importance of content-based self-attention in natural language processing applications.
88
+
89
+ # 5 EXPERIMENTAL SETUP
90
+
91
+ # 5.1 MODEL ARCHITECTURE
92
+
93
+ We use an encoder-decoder architecture for sequence to sequence learning (Sutskever et al., 2014) and we closely follow the architectural choices presented in Vaswani et al. (2017). Our self-attention baseline is the fairseq re-implementation of the Transformer Big architecture (Ott et al., 2018).2
94
+
95
+ The encoder and decoder networks have $N$ blocks each. Encoder blocks contain two sub-blocks: The first is a self-attention module (§2), a LightConv module (3), or a DynamicConv module $( \ S 4 )$ . The second sub-block is a feed-forward module: $R e L U ( W ^ { 1 } X + b _ { 1 } ) W ^ { 2 } + b _ { 2 }$ where $W ^ { 1 } \in \mathbb { R } ^ { d \times \breve { d } _ { f f } }$ , $W ^ { 2 } \in \mathbb { R } ^ { d _ { f f } \times d }$ and $d = 1 0 2 4$ , $d _ { f f } = 4 0 9 6$ unless otherwise stated. Sub-blocks are surrounded by residual connections (He et al., 2015) and layer normalization (Ba et al., 2016).
96
+
97
+ Decoder blocks are identical except that they have an additional source-target attention sub-block between the self-attention and feed-forward module. The source-target attention is equivalent to the self-attention module, except that the values and keys are projections over the encoder output for each source word.
98
+
99
+ Words are fed to the encoder and decoder networks in $d$ dimensional embeddings. We add sinusoidal position embeddings to encode the absolute position of each word in the sequence (Kaiser et al., 2017; Vaswani et al., 2017). The model computes a distribution over vocabulary $V$ by transforming the decoder output via a linear layer with weights $W ^ { V } \in \mathbb { R } ^ { d \times V }$ followed by softmax normalization.
100
+
101
+ LightConv and DynamicConv are identical to Transformer Big, except that self-attention modules are swapped with either fixed or dynamic convolutions. These models also use fewer parameters per block (cf. Figure 2b and Figure 2c) and we therefore increase the number of blocks to $N = 7$ for the encoder to roughly match the parameter count of Transformer Big. We generally set $H = 1 6$ . Both LightConv and DynamicConv set the the encoder and decoder kernel sizes to 3, 7, 15, 31x4 for each block respectively; except for the decoder where we have only three top layers with kernel size 31.
102
+
103
+ # 5.2 DATASETS AND EVALUATION
104
+
105
+ To get a thorough understanding of the limitations of LightConv and DynamicConv we evaluate on three different tasks: machine translation, language modeling and abstractive summarization.
106
+
107
+ Machine Translation. We report results on four benchmarks: For WMT English to German (EnDe) we replicate the setup of Vaswani et al. (2017), based on WMT’16 training data with 4.5M sentence pairs, we validate on newstest2013 and test on newstest2014.3 The vocabulary is a 32K joint source and target byte pair encoding (BPE; Sennrich et al. 2016). For WMT English to French (EnFr), we borrow the setup of Gehring et al. (2017) with 36M training sentence pairs from WMT’14, validate on newstes $2 0 1 2 + 2 0 1 3$ and test on newstest2014. The 40K vocabulary is based on a joint source and target BPE factorization.
108
+
109
+ For WMT English to Chinese (Zh-En), we pre-process the WMT’17 training data following Hassan et al. (2018) resulting in 20M sentence pairs. We develop on devtest2017 and test on newstest2017. For IWSLT’14 German-English (De-En) we replicate the setup of Edunov et al. (2018) for 160K training sentence pairs and 10K joint BPE vocabulary. For this benchmark only, data is lowercased.
110
+
111
+ For WMT En-De, WMT En-Fr, we measure case-sensitive tokenized BLEU.4 For WMT En-De only we apply compound splitting similar to Vaswani et al. (2017). For WMT Zh-En we measure detokenized BLEU to be comparable to Hassan et al. (2018).5
112
+
113
+ We train three random initializations of a each configuration and report test accuracy of the seed which resulted in the highest validation BLEU. Ablations are conducted on the validation set and we report the mean BLEU and standard deviation on this set. WMT En-De, WMT En-Fr are based on beam search with a beam width of 5, IWSLT uses beam 4, and WMT Zh-En beam 8 following Hassan et al. (2018). For all datasets, we tune a length penalty as well as the number of checkpoints to average on the validation set.
114
+
115
+ Language Modeling. We evaluate on the large-scale Billion word dataset (Chelba et al., 2013) which contains 768M tokens and has a vocabulary of nearly 800K types. Sentences in this dataset are shuffled and we batch sentences independently of each other. Models are evaluated in terms of perplexity on the valid and test portions.
116
+
117
+ Summarization. We test the model’s ability to process long documents on the CNN-DailyMail summarization task (Hermann et al., 2015; Nallapati et al., 2016) comprising over 280K news articles paired with multi-sentence summaries. Articles are truncated to 400 tokens (See et al., 2017) and we use a BPE vocabulary of 30K types (Fan et al., 2017). We evaluate in terms of F1-Rouge, that is Rouge-1, Rouge-2 and Rouge-L (Lin, 2004).6 When generating summaries, we follow standard practice in tuning the maximum output length, disallowing repeating the same trigram, and we apply a stepwise length penalty (Paulus et al., 2017; Fan et al., 2017; Wu et al., 2016).
118
+
119
+ # 5.3 TRAINING AND HYPERPARAMETERS
120
+
121
+ Translation. We use a dropout rate of 0.3 for WMT En-De and IWSLT De-En, 0.1 for WMT EnFr, and 0.25 for WMT Zh-En. WMT models are optimized with Adam and a cosine learning rate schedule (Kingma & Ba, 2015; Loshchilov & Hutter, 2016) where the learning rate is first linearly warmed up for 10K steps from $1 0 ^ { - 7 }$ to $1 0 ^ { - 3 }$ and then annealed following a cosine rate with a single cycle. For IWSLT’14 De-En, we use a schedule based on the inverse square root of the current step (Vaswani et al., 2017). We train the WMT models on 8 NVIDIA V100 GPUs for a total of 30K steps on WMT En-De, 40K steps for WMT Zh-En and 80K steps for WMT En-Fr. For IWSLT De-En we train for 50K steps on a single GPU.
122
+
123
+ We use floating point 16 precision and accumulate the gradients for 16 batches before applying an update (Ott et al., 2018), except for IWSLT where we do not accumulate gradients. Batches contain up to 459K source tokens and the same number of target tokens for both WMT En-De and WMT Zh-En, 655K for En-Fr, and 4K for IWSLT De-En. We use label smoothing with 0.1 weight for the uniform prior distribution over the vocabulary (Szegedy et al., 2015; Pereyra et al., 2017).
124
+
125
+ Language Modeling. We follow the same setup as for translation but remove the encoder module. For the Billion word benchmark we use an adaptive softmax output layer to reduce the computational burden of the large vocabulary (Grave et al., 2016; Press & Wolf, 2017) and tie it with variable sized input word embeddings (Anonymous et al., 2018). The first 60K types in the adaptive softmax have dimension 1024, the 100K types dimension 256, and the last 633K types have size 64.
126
+
127
+ Table 1: Machine translation accuracy in terms of BLEU for WMT En-De and WMT En-Fr on newstest2014.
128
+
129
+ <table><tr><td>Model</td><td>Param (En-De)</td><td>WMT En-De</td><td>WMTEn-Fr</td></tr><tr><td>Gehring et al. (2017)</td><td>216M</td><td>25.2</td><td>40.5</td></tr><tr><td>Vaswani et al. (2017)</td><td>213M</td><td>28.4</td><td>41.0</td></tr><tr><td>Ahmed et al. (2017)</td><td>213M</td><td>28.9</td><td>41.4</td></tr><tr><td>Chen et al. (2018)</td><td>379M</td><td>28.5</td><td>41.0</td></tr><tr><td>Shaw et al. (2018)</td><td>=</td><td>29.2</td><td>41.5</td></tr><tr><td>Ott et al. (2018)</td><td>210M</td><td>29.3</td><td>43.2</td></tr><tr><td>LightConv</td><td>202M</td><td>28.9</td><td>43.1</td></tr><tr><td>DynamicConv</td><td>213M</td><td>29.7</td><td>43.2</td></tr></table>
130
+
131
+ Table 2: Machine translation accuracy in terms of BLEU on IWSLT and WMT Zh-En.
132
+
133
+ <table><tr><td>Model</td><td>Param (Zh-En)</td><td>IWSLT</td><td>WMT Zh-En</td></tr><tr><td>Deng et al. (2018) Hassan et al. (2018)</td><td>=</td><td>33.1</td><td>1</td></tr><tr><td></td><td>1 292M</td><td>1</td><td>24.2</td></tr><tr><td>Self-attention baseline</td><td>285M</td><td>34.4 34.8</td><td>23.8</td></tr><tr><td>LightConv</td><td></td><td></td><td>24.3</td></tr><tr><td>DynamicConv</td><td>296M</td><td>35.2</td><td>24.4</td></tr></table>
134
+
135
+ We train on 32 GPUs with batches of 65K tokens for 975K updates. As optimizer we use Nesterov’s accelerated gradient method (Sutskever et al., 2013) with a momentum value of 0.99 and we renormalize gradients if their norm exceeds 0.1 (Pascanu et al., 2013). The learning rate is linearly warmed up from $1 0 ^ { - 7 }$ to 1 for 16K steps and then annealed using a cosine learning rate schedule (Loshchilov & Hutter, 2016) with one cycle.
136
+
137
+ Summarization. We train with Adam using the cosine learning rate schedule with a warmup of 10K steps and a period of 20K updates. We use weight decay 1e-3 and dropout 0.3.
138
+
139
+ # 6 RESULTS
140
+
141
+ # 6.1 MACHINE TRANSLATION
142
+
143
+ We first report results on WMT En-De and WMT En-Fr where we compare to the best results in the literature, most of which are based on self-attention. Table 1 shows that LightConv performs very competitively and only trails the state of the art result by 0.1 BLEU on WMT En-Fr; the state of the art is based on self-attention (Ott et al., 2018). This is despite the simplicity of LightConv which operates with a very small number of fixed weights over all time steps whereas self-attention computes dot-products with all context elements at every time-step.
144
+
145
+ DynamicConv outperforms the best known result on WMT En-De by 0.4 BLEU and achieves a new state of the art, whereas on WMT En-Fr it matches the state of the art. This shows that content-based self-attention is not necessary to achieve good accuracy on large translation benchmarks.
146
+
147
+ IWSLT is a much smaller benchmark and we therefore switch to a smaller architecture: $d _ { f f } = 1 0 2 4$ , $d = 5 1 2$ , and $H = 4$ . The self-attention baseline on this dataset is the best reported result in the literature (Table 2).7 LightConv outperforms this baseline by 0.4 BLEU and DynamicConv improves by 0.8 BLEU. We further run experiments on WMT Zh-En translation to evaluate on a non-European language. LightConv outperforms the baseline by 0.5 BLEU and DynamicConv by 0.6 BLEU.
148
+
149
+ Table 3: Ablation on WMT English-German newstest2013. $( + )$ indicates that a result includes all preceding features. Speed results based on beam size 4, batch size 256 on an NVIDIA P100 GPU.
150
+
151
+ <table><tr><td>Model</td><td>Param</td><td>BLEU</td><td>Sent/sec</td></tr><tr><td>Vaswani et al. (2017)</td><td>213M</td><td>26.4</td><td>=</td></tr><tr><td>Self-attention baseline (k=inf,H=16)</td><td>210M</td><td>26.9 ± 0.1</td><td>52.1 ± 0.1</td></tr><tr><td>Self-attention baseline (k=3,7,15,31x3, H=16)</td><td>210M</td><td>26.9 ± 0.3</td><td>54.9 ± 0.2</td></tr><tr><td>CNN (k=3)</td><td>208M</td><td>25.9 ± 0.2</td><td>68.1 ± 0.3</td></tr><tr><td>CNN Depthwise (k=3,H=1024)</td><td>195M</td><td>26.1 ± 0.2</td><td>67.1 ± 1.0</td></tr><tr><td>+ Increasing kernel (k=3,7,15,31x4,H=1024)</td><td>195M</td><td>26.4± 0.2</td><td>63.3 ± 0.1</td></tr><tr><td>+ DropConnect (H=1024)</td><td>195M</td><td>26.5 ± 0.2</td><td>63.3 ± 0.1</td></tr><tr><td>+ Weight sharing (H=16)</td><td>195M</td><td>26.5 ± 0.1</td><td>63.7 ± 0.4</td></tr><tr><td>+ Softmax-normalized weights [LightConv] (H=16)</td><td>195M</td><td>26.6 ± 0.2</td><td>63.6 ± 0.1</td></tr><tr><td>+ Dynamic weights [DynamicConv] (H=16)</td><td>200M</td><td>26.9 ± 0.2</td><td>62.6 ± 0.4</td></tr><tr><td>Note: DynamicConv(H=16) w/o softmax-normalization</td><td>200M</td><td>diverges</td><td></td></tr><tr><td>AAN decoder + self-attn encoder</td><td>260M</td><td>26.8 ± 0.1</td><td>59.5 ± 0.1</td></tr><tr><td>AAN decoder+ AAN encoder</td><td>310M</td><td>22.5 ± 0.1</td><td>59.2 ± 2.1</td></tr></table>
152
+
153
+ # 6.2 MODEL ABLATION
154
+
155
+ In this section we evaluate the impact of the various choices we made for LightConv (§3) and DynamicConv (§4). We first show that limiting the maximum context size of self-attention has no impact on validation accuracy (Table 3). Note that our baseline is stronger than the original result of Vaswani et al. (2017). Next, we replace self-attention blocks with non-separable convolutions (CNN) with kernel size 3 and input/output dimension $d = 1 0 2 4$ . The CNN block has no input and output projections compared to the baseline and we add one more encoder layer to assimilate the parameter count. This CNN with a narrow kernel trails self-attention by 1 BLEU.
156
+
157
+ We improve this result by switching to a depthwise separable convolution (CNN Depthwise) with input and output projections of size $d = 1 0 2 4$ . When we progressively increase the kernel width from lower to higher layers then this further improves accuracy. This narrows the gap to self-attention to only 0.5 BLEU. DropConnect gives a slight performance improvement and weight sharing does not decrease performance. Adding softmax normalization to the weights is only 0.3 BLEU below the accuracy of the baseline. This corresponds to LightConv. In Appendix A we compare softmaxnormalization to various alternatives. Finally, dynamic convolutions (DynamicConv) achieve the same validation accuracy as self-attention with slightly fewer parameters and at $20 \%$ higher inference speed. Softmax-normalization is important for DynamicConv since training diverged in our experiments when removing it. To make the models more comparable, we do not introduce GLU after the input projection.
158
+
159
+ For comparison, we re-implemented averaged attention networks (AAN; Zhang et al. 2018) which compute a uniform average over past model states instead of a weighted average as in self-attention. Our re-implementation is efficient: we measure 129 sentences/sec for a base transformer-AAN on newstest2014 compared to 20 sentences/sec for Zhang et al. (2018). Table 3 shows that our models outperform this approach. Note that AANs still use self-attention in the encoder network while as our approach does away with self-attention both in the encoder and decoder.
160
+
161
+ # 6.3 LANGUAGE MODELING
162
+
163
+ As second task we consider language modeling on the Billion word benchmark. The self-attention baseline has $N = 1 6$ blocks, each with a self-attention module and a feed-forward module using $d _ { f f } = 4 0 9 6$ and $d = 1 0 2 4$ . DynamicConv uses $N = 1 7$ blocks to assimilate the parameter count and we use kernel sizes 15x2, 31x4 and 63x11. Table 4 shows that DynamicConv achieves slightly better perplexity than our self-attention baseline which is very competitive.
164
+
165
+ Table 4: Language modeling results on the Google Billion Word test set. †does not include embedding and softmax layers
166
+
167
+ <table><tr><td>Model</td><td>Param</td><td>Valid</td><td>Test</td></tr><tr><td>2-layer LSTM-8192-1024 (J6zefowicz et al., 2016)</td><td>1</td><td>1</td><td>30.6</td></tr><tr><td>Gated Convolutional Model (Dauphin et al., 2017)</td><td>428M</td><td></td><td>31.9</td></tr><tr><td>Mixture of Experts (Shazeer et al., 2017)</td><td>4371M +</td><td>1</td><td>28.0</td></tr><tr><td>Self-attention baseline</td><td>331M</td><td>26.67</td><td>26.73</td></tr><tr><td>DynamicConv</td><td>339M</td><td>26.60</td><td>26.67</td></tr></table>
168
+
169
+ Table 5: Results on CNN-DailyMail summarization. We compare to likelihood trained approaches except for Celikyilmaz et al. (2018).
170
+
171
+ <table><tr><td>Model</td><td>Param</td><td>Rouge-1</td><td>Rouge-2</td><td>Rouge-l</td></tr><tr><td>LSTM (Paulus et al., 2017)</td><td>=</td><td>38.30</td><td>14.81</td><td>35.49</td></tr><tr><td>CNN (Fan et al., 2017)</td><td>1</td><td>39.06</td><td>15.38</td><td>35.77</td></tr><tr><td>Self-attention baseline</td><td>90M</td><td>39.26</td><td>15.98</td><td>36.35</td></tr><tr><td>LightConv</td><td>86M</td><td>39.52</td><td>15.97</td><td>36.51</td></tr><tr><td>DynamicConv</td><td>87M</td><td>39.84</td><td>16.25</td><td>36.73</td></tr><tr><td>RL (Celikyilmaz et al., 2018)</td><td>1</td><td>41.69</td><td>19.47</td><td>37.92</td></tr></table>
172
+
173
+ # 6.4 ABSTRACTIVE SUMMARIZATION
174
+
175
+ Finally, we evaluate on the CNN-DailyMail abstractive document summarization benchmark where we encode a document of up to 400 words and generate multi-sentence summaries. This tests the ability of our model to deal with longer sequences. We reduce model capacity by setting $d = 1 0 2 4$ , $d _ { f f } = 2 0 4 8$ , $H = 8$ , similar to the Transformer base setup of Vaswani et al. (2017).
176
+
177
+ Table 5 shows that LightConv outperforms the self-attention baseline as well as comparable previous work and DynamicConv performs even better. We also show results for a reinforcement learning approach (Celikyilmaz et al., 2018) and note that RL is equally applicable to our architecture.8
178
+
179
+ # 7 CONCLUSION
180
+
181
+ We presented lightweight convolutions which perform competitively to the best reported results in the literature despite their simplicity. They have a very small parameter footprint and the kernel does not change over time-steps. This demonstrates that self-attention is not critical to achieve good accuracy on the language tasks we considered.
182
+
183
+ Dynamic convolutions build on lightweight convolutions by predicting a different kernel at every time-step, similar to the attention weights computed by self-attention. The dynamic weights are a function of the current time-step only rather than the entire context.
184
+
185
+ Our experiments show that lightweight convolutions can outperform a strong self-attention baseline on WMT’17 Chinese-English translation, IWSLT’14 German-English translation and CNNDailyMail summarization. Dynamic convolutions improve further and achieve a new state of the art on the test set of WMT’14 English-German. Both lightweight convolution and dynamic convolution are $20 \%$ faster at runtime than self-attention. On Billion word language modeling we achieve comparable results to self-attention.
186
+
187
+ We are excited about the future of dynamic convolutions and plan to apply them to other tasks such as question answering and computer vision where inputs are even larger than the tasks we considered in this paper.
188
+
189
+ REFERENCES
190
+ Karim Ahmed, Nitish Shirish Keskar, and Richard Socher. Weighted transformer network for machine translation. arxiv, abs/1711.02132, 2017.
191
+ Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv, abs/1607.06450, 2016.
192
+ Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In Proc. of ICLR, 2015.
193
+ Asli Celikyilmaz, Antoine Bosselut, Xiaodong He, and Yejin Choi. Deep communicating agents for abstractive summarization. In Proc. of NAACL, 2018.
194
+ Ciprian Chelba, Tomas Mikolov, Mike Schuster, Qi Ge, Thorsten Brants, Phillipp Koehn, and Tony Robinson. One billion word benchmark for measuring progress in statistical language modeling. arXiv, 2013.
195
+ Mia Xu Chen, Orhan Firat, Ankur Bapna, Melvin Johnson, Wolfgang Macherey, George Foster, Llion Jones, Niki Parmar, Mike Schuster, Zhifeng Chen, Yonghui Wu, and Macduff Hughes. The best of both worlds: Combining recent advances in neural machine translation. arxiv, abs/1804.09849, 2018.
196
+ Yu-hsin Chen, Ignacio Lopez-Moreno, Tara N Sainath, Mirko Visontai, Raziel Alvarez, and Car-´ olina Parada. Locally-connected and convolutional neural networks for small footprint speaker recognition. In Proc. of Interspeech, 2015.
197
+ Franois Chollet. Xception: Deep learning with depthwise separable convolutions. In Proc. of CVPR, pp. 1800–1807, 2017.
198
+ Jan Chorowski, Dzmitry Bahdanau, Dmitriy Serdyuk, KyungHyun Cho, and Yoshua Bengio. Attention-based models for speech recognition. arXiv, abs/1506.07503, 2015.
199
+ Yann N. Dauphin, Angela Fan, Michael Auli, and David Grangier. Language modeling with gated convolutional networks. In Proc. of ICML, 2017.
200
+ Yuntian Deng, Yoon Kim, Justin Chiu, Demi Guo, and Alexander M Rush. Latent alignment and variational attention. arXiv, abs/1807.03756, 2018.
201
+ Sergey Edunov, Myle Ott, Michael Auli, David Grangier, and Marc’Aurelio Ranzato. Classical structured prediction losses for sequence to sequence learning. In Proc. of NAACL, 2018.
202
+ Maha Elbayad, Laurent Besacier, and Jakob Verbeek. Pervasive attention: 2d convolutional neural networks for sequence-to-sequence prediction. arXiv, abs/1808.03867, 2018.
203
+ Angela Fan, David Grangier, and Michael Auli. Controllable abstractive summarization. arXiv, abs/1711.05217, 2017.
204
+ Jonas Gehring, Michael Auli, David Grangier, and Yann N Dauphin. A Convolutional Encoder Model for Neural Machine Translation. arXiv, abs/1611.02344, 2016.
205
+ Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N Dauphin. Convolutional Sequence to Sequence Learning. In Proc. of ICML, 2017.
206
+ Sebastian Gehrmann, Yuntian Deng, and Alexander M Rush. Bottom-up abstractive summarization. arXiv, abs/1808.10792, 2018.
207
+ Jingjing Gong, Xipeng Qiu, Xinchi Chen, Dong Liang, and Xuanjing Huang. Convolutional interaction network for natural language inference. In Proc. of EMNLP, 2018.
208
+ Edouard Grave, Armand Joulin, Moustapha Cisse, David Grangier, and Herve Jegou. Efficient softmax approximation for gpus. arXiv, abs/1609.04309, 2016.
209
+ Jiatao Gu, James Bradbury, Caiming Xiong, Victor O.K. Li, and Richard Socher. Non-autoregressive neural machine translation. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=B1l8BtlCb.
210
+
211
+ Junliang Guo, Xu Tan, Di He, Tao Qin, Linli Xu, and Tie-Yan Liu. Non-autoregressive neural machine translation with enhanced decoder input. AAAI, 2019.
212
+
213
+ Hany Hassan, Anthony Aue, Chang Chen, Vishal Chowdhary, Jonathan Clark, Christian Federmann, Xuedong Huang, Marcin Junczys-Dowmunt, Will Lewis, Mu Li, Shujie Liu, Tie-Yan Liu, Renqian Luo, Arul Menezes, Tao Qin, Frank Seide, Xu Tan, Fei Tian, Lijun Wu, Shuangzhi Wu, Yingce Xia, Dongdong Zhang, Zhirui Zhang, and Ming Zhou. Achieving human parity on automatic chinese to english news translation. arXiv, abs/1803.05567, 2018.
214
+
215
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep Residual Learning for Image Recognition. In Proc. of CVPR, 2015.
216
+
217
+ Karl Moritz Hermann, Toma´s Ko ˇ cisk ˇ y, Edward Grefenstette, Lasse Espeholt, Will Kay, Mustafa ´ Suleyman, and Phil Blunsom. Teaching machines to read and comprehend. In Proc. of NIPS, 2015.
218
+
219
+ Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
220
+
221
+ Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring the ´ limits of language modeling. arXiv, abs/1602.02410, 2016.
222
+
223
+ Lukasz Kaiser, Aidan N. Gomez, and Franc¸ois Chollet. Depthwise separable convolutions for neural machine translation. arXiv, abs/1706.03059, 2017.
224
+
225
+ Lukasz Kaiser, Samy Bengio, Aurko Roy, Ashish Vaswani, Niki Parmar, Jakob Uszkoreit, and Noam Shazeer. Fast decoding in sequence models using discrete latent variables. In Proceedings of the 35th International Conference on Machine Learning (ICML), volume 80, pp. 2390–2399, 2018.
226
+
227
+ Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Koray Kavukcuoglu. Neural Machine Translation in Linear Time. arXiv, 2016.
228
+
229
+ Diederik P. Kingma and Jimmy Ba. Adam: A Method for Stochastic Optimization. In Proc. of ICLR, 2015.
230
+
231
+ Yann LeCun, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proc. of the IEEE, 86(11):2278–2324, 1998.
232
+
233
+ Jason Lee, Elman Mansimov, and Kyunghyun Cho. Deterministic non-autoregressive neural sequence modeling by iterative refinement. arXiv, abs/1802.06901, 2018.
234
+
235
+ Zhuohan Li, Di He, Fei Tian, Tao Qin, Liwei Wang, and Tie-Yan Liu. Hint-based training for non-autoregressive translation, 2019. URL https://openreview.net/forum?id $=$ r1gGpjActQ.
236
+
237
+ Chin-Yew Lin. Rouge: A package for automatic evaluation of summaries. In Workshop on Text Summarization Branches Out, 2004.
238
+
239
+ Peter J. Liu, Mohammad Saleh, Etienne Pot, Ben Goodrich, Ryan Sepassi, Lukasz Kaiser, and Noam Shazeer. Generating wikipedia by summarizing long sequences. arXiv, abs/1801.10198, 2018.
240
+
241
+ Ilya Loshchilov and Frank Hutter. SGDR: Stochastic Gradient Descent with Warm Restarts. arXiv, abs/1608.03983, 2016.
242
+
243
+ Minh-Thang Luong, Hieu Pham, and Christopher Manning. Effective approaches to attention-based neural machine translation. In Proc. of EMNLP, 2015.
244
+
245
+ Ramesh Nallapati, Bowen Zhou, Caglar Gulcehre, Bing Xiang, et al. Abstractive text summarization using sequence-to-sequence rnns and beyond. In Proc. of CONLL, 2016.
246
+
247
+ Myle Ott, Sergey Edunov, David Grangier, and Michael Auli. Scaling neural machine translation. In Proc. of WMT, 2018.
248
+
249
+ Razvan Pascanu, Tomas Mikolov, and Yoshua Bengio. On the difficulty of training recurrent neural networks. In Proc. of ICML, 2013.
250
+
251
+ Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive summarization. arXiv, abs/1705.04304, 2017.
252
+
253
+ Gabriel Pereyra, George Tucker, Jan Chorowski, Lukasz Kaiser, and Geoffrey E. Hinton. Regularizing neural networks by penalizing confident output distributions. In Proc. of ICLR Workshop, 2017.
254
+
255
+ Ofir Press and Lior Wolf. Using the output embedding to improve language models. In Proc. of EACL 2017, 2017.
256
+
257
+ Abigail See, Peter J Liu, and Christopher D Manning. Get to the point: Summarization with pointergenerator networks. In Proc. of ACL, 2017.
258
+
259
+ Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proc. of ACL, 2016.
260
+
261
+ Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. In Proc. of NAACL, 2018.
262
+
263
+ Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. In Proc. of ICLR, 2017.
264
+
265
+ Dinghan Shen, Martin Renqiang Min, Yitong Li, and Lawrence Carin. Learning context-sensitive convolutional filters for text processing. In Proc. of EMNLP, 2018a.
266
+
267
+ Tao Shen, Tianyi Zhou, Guodong Long, Jing Jiang, Shirui Pan, and Chengqi Zhang. Disan: Directional self-attention network for rnn/cnn-free language understanding. arXiv, abs/1709.04696, 2017.
268
+
269
+ Tao Shen, Tianyi Zhou, Guodong Long, Jing Jiang, and Chengqi Zhang. Bi-directional block selfattention for fast and memory-efficient sequence modeling. arXiv, abs/1804.00857, 2018b.
270
+
271
+ Tao Shen, Tianyi Zhou, Guodong Long, Jing Jiang, and Chengqi Zhang. Fast directional selfattention mechanism. arXiv, abs/1805.00912, 2018c.
272
+
273
+ Laurent Sifre. Rigid-motion scattering for image classification. Ph.D. thesis section 6.2, 2014.
274
+
275
+ Sainbayar Sukhbaatar, arthur szlam, Jason Weston, and Rob Fergus. End-to-end memory networks. In Proc. of NIPS, 2015.
276
+
277
+ Ilya Sutskever, James Martens, George E. Dahl, and Geoffrey E. Hinton. On the importance of initialization and momentum in deep learning. In ICML, 2013.
278
+
279
+ Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to Sequence Learning with Neural Networks. In Proc. of NIPS, 2014.
280
+
281
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the Inception Architecture for Computer Vision. arXiv, abs/1512.00567, 2015.
282
+
283
+ Yaniv Taigman, Ming Yang, Marc’Aurelio Ranzato, and Lior Wolf. Deepface: Closing the gap to human-level performance in face verification. In Proc. of CVPR, 2014.
284
+
285
+ Gongbo Tang, Mathias Mller, Annette Rios, and Rico Sennrich. Why self-attention? a targeted evaluation of neural machine translation architectures. In Proc. of EMNLP, 2018.
286
+
287
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention Is All You Need. In Proc. of NIPS, 2017.
288
+
289
+ Li Wan, Matthew Zeiler, Sixin Zhang, Yann Le Cun, and Rob Fergus. Regularization of neural networks using dropconnect. In Proc. of ICML, 2013.
290
+
291
+ Zhengyang Wang and Shuiwang Ji. Smoothed dilated convolutions for improved dense prediction. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 2486–2495. ACM, 2018.
292
+
293
+ 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, abs/1609.08144, 2016.
294
+
295
+ Biao Zhang, Deyi Xiong, and Jinsong Su. Accelerating neural transformer via an average attention network. arXiv, abs/1805.00631, 2018.
296
+
297
+ SUPPLEMENTARY MATERIAL
298
+
299
+ # A COMPARISON OF SOFTMAX-NORMALIZATION TO ALTERNATIVES
300
+
301
+ We compare our proposed softmax-normalization of weights to other alternatives in Table 6. For each setting, we use three seeds and report the mean and the standard deviation of the BLEU score on WMT English-German newstest2013. The softmax and norms are computed over the kernel dimension. Simply using the absolute value of the weights or squaring them does not make the training more stable, which shows that having all non-negative weights is not critical. Dividing the weights by the $\ell _ { 2 }$ -norm or bounding the weights with sigmoid or the hyperbolic tangent function also stablizes the training procedure; however, the softmax-normalization performs best.
302
+
303
+ Table 6: Alternatives to softmax-normalization in DynamicConv on WMT English-German newstest2013 $\begin{array} { r } { \check { \mathbf { \Pi } } \epsilon = 1 0 ^ { - 6 } \check { \mathbf { \Pi } } . } \end{array}$ ).
304
+
305
+ <table><tr><td>Method</td><td>BLEU</td></tr><tr><td>W (No normalization)</td><td>diverges</td></tr><tr><td>softmax(W)</td><td>26.9 ± 0.2</td></tr><tr><td>σ(W)</td><td>26.6 ± 0.3</td></tr><tr><td>tanh(W)</td><td>25.6 ± 0.2</td></tr><tr><td>W</td><td>diverges</td></tr><tr><td>IIW|1+e W</td><td>26.8 ± 0.2</td></tr><tr><td>1W||2+∈ power(W, 2)</td><td></td></tr><tr><td></td><td>diverges</td></tr><tr><td>abs(W) abs(W)</td><td>diverges</td></tr><tr><td>IW|l1+∈</td><td>diverges</td></tr><tr><td>abs(W) IW|l2+∈</td><td>26.7 ± 0.2</td></tr></table>
306
+
307
+ # B ON THE CURRENT STATE OF NON-AUTOREGRESSIVE GENERATION
308
+
309
+ In this section we compare DynamicConv to current non-autoregressive models in the literature. We measured generation speed for DynamicConv on a P100 GPU using batch size one to be comparable with other results. Results in the literature are based on either NVIDIA GTX-1080 GPUs or P100 GPUs. The effects of different GPU types is likely negligible because GPUs are vastly underutilized with batch size one.
310
+
311
+ Table 7 shows that DynamicConv with a single decoder layer outperforms all previously reported non-autoregressive results both in terms of speed as well as accuracy. Only two non-autoregressive concurrent efforts (Guo et al., 2019; Li et al., 2019) achieve a speedup over DynamicConv with a small drop in BLEU. Notably, both Guo et al. (2019) and Li et al. (2019) distill autoregressive models into non-autoregressive models (Hinton et al., 2015), in order to improve their results.
312
+
313
+ <table><tr><td>Model (batch size = 1, beam size = 1)</td><td>Param</td><td>BLEU</td><td>Sent/sec</td><td>Tok/sec</td></tr><tr><td>NAT (+ FT) (Gu et al., 2018)</td><td></td><td>17.7</td><td>25.6</td><td>=</td></tr><tr><td>NAT (+ FT + NPD=10) (Gu et al., 2018)</td><td></td><td>18.7</td><td>12.7</td><td>=</td></tr><tr><td>NAT (+ FT + NPD=10O) (Gu et al., 2018)</td><td></td><td>19.2</td><td>3.9</td><td></td></tr><tr><td>LT, Improved Semhash (Kaiser et al.,2018)</td><td></td><td>19.8</td><td>9.5</td><td>1</td></tr><tr><td>IRidec 二 :1 (Lee et al., 2018)</td><td></td><td>13.9</td><td>1</td><td>511.4</td></tr><tr><td>IR idec 二 :2 (Lee et al., 2018)</td><td></td><td>17.0</td><td>=</td><td>393.6</td></tr><tr><td>IR idec 二 : 5 (Lee et al., 2018)</td><td></td><td>20.3</td><td>=</td><td>139.7</td></tr><tr><td>IR idec 二 :10 (Lee et al., 2018)</td><td></td><td>21.6</td><td></td><td>90.4</td></tr><tr><td>IR Adaptive ( (Lee et al., 2018)</td><td></td><td>21.5</td><td>1</td><td>107.2</td></tr><tr><td>NART w/hints (Li et al., 2019)</td><td></td><td>21.1</td><td>38.5</td><td></td></tr><tr><td>NART w/ hints (B = 4, 9 candidates) (Li et al., 2019)</td><td></td><td>25.2</td><td>22.7</td><td>=</td></tr><tr><td>ENAT Embedding l gMapping (Guo et al.,2019) ENAT Embedding Mapping (rescoring 9 candidates)</td><td></td><td>20.7</td><td>41.7</td><td></td></tr><tr><td>(Guo et al., 2019)</td><td></td><td>24.3</td><td>20.4</td><td></td></tr><tr><td>Autoregressive (Gu et al., 2018)</td><td></td><td>22.7</td><td>2.5</td><td></td></tr><tr><td>Autoregressive (Lee et al., 2018)</td><td></td><td>23.8</td><td>1</td><td>= 54.0</td></tr><tr><td>Transformer (Li et al., 2019)</td><td></td><td>27.3</td><td>1.3</td><td></td></tr><tr><td>Transformer (Guo et al., 2019)</td><td>-</td><td>27.4</td><td>1.6</td><td>1 1</td></tr><tr><td>DynamicConv (1-decoder layer (k=31))</td><td>124M</td><td>26.1</td><td>15.2</td><td></td></tr><tr><td>DynamicConv (3-decoder layers (k=3,7,15))</td><td>153M</td><td>27.7</td><td>7.2</td><td>423.0 202.3</td></tr><tr><td>DynamicConv (6-decoder layers (k=3,7,15,31,31,31))</td><td>200M</td><td>28.5</td><td>3.9</td><td>110.9</td></tr></table>
314
+
315
+ Table 7: Inference speed of non-autoregressive models and small decoder versions of DynamicConv on WMT English-German newstest2014. For some models, the decoding speed (sent/sec) is derived by taking the inverse of the sentence generation latency in the literature.
md/train/Skgb5h4KPH/Skgb5h4KPH.md ADDED
@@ -0,0 +1,597 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FREQUENCY PRINCIPLE: FOURIER ANALYSIS SHEDSLIGHT ON DEEP NEURAL NETWORKS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We study the training process of Deep Neural Networks (DNNs) from the Fourier analysis perspective. We demonstrate a very universal Frequency Principle (FPrinciple) — DNNs often fit target functions from low to high frequencies — on high-dimensional benchmark datasets such as MNIST/CIFAR10 and deep neural networks such as VGG16. This F-Principle of DNNs is opposite to the behavior of most conventional iterative numerical schemes (e.g., Jacobi method), which exhibit faster convergence for higher frequencies for various scientific computing problems. With theories under an idealized setting, we illustrate that this F-Principle results from the smoothness/regularity of the commonly used activation functions. The F-Principle implies an implicit bias that DNNs tend to fit training data by a low-frequency function. This understanding provides an explanation of good generalization of DNNs on most real datasets and bad generalization of DNNs on parity function or a randomized dataset.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Understanding the training process of Deep Neural Networks (DNNs) is a fundamental problem in the area of deep learning. We find a common behavior of the gradient-based training process of DNNs, that is, a Frequency Principle (F-Principle):
12
+
13
+ # DNNs often fit target functions from low to high frequencies during the training process.
14
+
15
+ In another word, at the early stage of training, the low-frequencies are fitted and as iteration steps of training increase, the high-frequencies are fitted. For example, when a DNN is trained to fit $y = \sin ( \bar { x } ) + \sin ( 2 x )$ , its output would be close to $\sin ( x )$ at early stage and as training goes on, its output would be close to $\sin ( x ) + \sin ( 2 x )$ . F-Principle was observed empirically in synthetic low-dimensional data with MSE loss during DNN training ( $\mathrm { { X u } }$ et al., 2018; Rahaman et al., 2018). However, in deep learning, empirical phenomena could vary from one network structure to another, from one dataset to another and could exhibit significant difference between synthetic data and highdimensional real data. Therefore, the universality of the F-Principle remains an important problem for further study. Especially for high-dimensional real problems, because the computational cost of high-dimensional Fourier transform is prohibitive in practice, it is of great challenge to demonstrate the F-Principle. On the other hand, the mechanism underlying the F-Principle and its implication to the application of DNNs, e.g., design of DNN-based PDE solver, as well as their generalization ability are also important open problems to be addressed.
16
+
17
+ In this work, we design two methods, i.e., projection and filtering methods, to show that the FPrinciple exists in the training process of DNNs for high-dimensional benchmarks, i.e., MNIST (LeCun, 1998), CIFAR10 (Krizhevsky et al., 2010). The settings we have considered are i) different DNN architectures, e.g., fully-connected network, convolutional neural network (CNN), and VGG16 (Simonyan & Zisserman, 2014); ii) different activation functions, e.g., tanh and rectified linear unit (ReLU); iii) different loss functions, e.g., cross entropy, mean squared error (MSE), and loss energy functional in variational problems. These results demonstrate the universality of the F-Principle.
18
+
19
+ To facilitate the designs and applications of DNN-based schemes, we characterize a stark difference between DNNs and conventional numerical schemes on various scientific computing problems, where most of the conventional methods (e.g., Jacobi method) exhibit the opposite convergence behavior — faster convergence for higher frequencies. This difference implies that DNN can be adopted to accelerate the convergence of low frequencies for computational problems.
20
+
21
+ We also intuitively explain with theories under an idealized setting how the smoothness/regularity of commonly used activation functions contributes to the F-Principle. Note that this mechanism is rigorously demonstrated for DNNs of general settings in a subsequent work (Luo et al., 2019). Finally, we discuss that the F-Principle provides an understanding of good generalization of DNNs in many real datasets (Zhang et al., 2016) and poor generalization in learning the parity function (Shalev-Shwartz et al., 2017; Nye & Saxe, 2018), that is, the F-Principle which implies that DNNs prefer low frequencies, is consistent with the property of low frequencies dominance in many real datasets, e.g., MNIST/CIFAR10, but is different from the parity function whose spectrum concentrates on high frequencies. Compared with previous studies, our main contributions are as follows:
22
+
23
+ 1. By designing both the projection and filtering methods, we consistently demonstrate the F-Principle for MNIST/CIFAR10 over various architectures such as VGG16 and various loss functions.
24
+
25
+ 2. For the application of solving differential equations, we show that (i) conventional numerical schemes learn higher frequencies faster whereas DNNs learn lower frequencies faster by the FPrinciple, (ii) convergence of low frequencies can be greatly accelerated with DNN-based schemes.
26
+
27
+ 3. We present theories under an idealized setting to illustrate how smoothness/regularity of activation function contributes to the F-Principle.
28
+
29
+ 4. We discuss in detail the implication of the F-Principle to the generalization of DNNs that DNNs are implicitly biased towards a low frequency function and provide an explanation of good and poor generalization of DNNs for low and high frequency dominant target functions, respectively.
30
+
31
+ # 2 FREQUENCY PRINCIPLE
32
+
33
+ The concept of “frequency” is central to the understanding of F-Principle. In this paper, the “frequency” means response frequency NOT image (or input) frequency as explained in the following.
34
+
35
+ Image (or input) frequency (NOT used in the paper): Frequency of 2-d function $I : \mathbb { R } ^ { 2 } \mathbb { R }$ representing the intensity of an image over pixels at different locations. This frequency corresponds to the rate of change of intensity across neighbouring pixels. For example, an image of constant intensity possesses only the zero frequency, i.e., the lowest frequency, while a sharp edge contributes to high frequencies of the image.
36
+
37
+ Response frequency (used in the paper): Frequency of a general Input-Output mapping $f$ . For example, consider a simplified classification problem of partial MNIST data using only the data with label 0 and 1, $f ( x _ { 1 } , x _ { 2 } , \dot { \cdots } , x _ { 7 8 4 } ) : \mathbb { R } ^ { 7 8 4 } \to \{ 0 , 1 \}$ mapping 784-d space of pixel values to 1-d space, where $x _ { j }$ is the intensity of the $j$ -th pixel. Denote the mapping’s Fourier transform as $\hat { f } ( k _ { 1 } , k _ { 2 } , \cdots , k _ { 7 8 4 } )$ . The frequency in the coordinate $k _ { j }$ measures the rate of change of $f ( x _ { 1 } , x _ { 2 } , \cdot \cdot \cdot , x _ { 7 8 4 } )$ with respect to $x _ { j }$ , i.e., the intensity of the $j$ -th pixel. If $f$ possesses significant high frequencies for large $k _ { j }$ , then a small change of $x _ { j }$ in the image might induce a large change of the output (e.g., adversarial example). For a dataset with multiple classes, we can similarly define frequency for each output dimension. For real data, the response frequency is rigorously defined via the standard nonuniform discrete Fourier transform (NUDFT), see Appendix A.
38
+
39
+ Frequency Principle: DNNs often fit target functions from low to high (response) frequencies during the training process. An illustration of F-Principle using a function of 1-d input is in Appendix B. The F-Principle is rigorously defined through the frequency defined by the Fourier transform (Appendix A, Bracewell & Bracewell (1986)) and the converging speed defined by the relative error. By using high-dimensional real datasets, we then experimentally demonstrate F-Principle at the levels of both individual frequencies (projection method) and coarse-grained frequencies (filtering method).
40
+
41
+ # 3 F-PRINCIPLE IN MNIST/CIFAR10 THROUGH PROJECTION METHOD
42
+
43
+ Real datasets are very different from synthetic data used in previous studies. In order to utilize the F-Principle to understand and better use DNNs in real datasets, it is important to verify whether the F-Principle also holds in high-dimensional real datasets.
44
+
45
+ In thewhere ollowing experiments,is the size of dataset. mine the F-Principle in a training datasis a vector representing the image and $\{ ( \pmb { x } _ { i } , \pmb { y } _ { i } ) \} _ { i = 0 } ^ { n - 1 }$ $n$ $\pmb { x } _ { i } \in \mathbb { R } ^ { d }$ $\pmb { y } _ { i } \in \{ 0 , 1 \} ^ { 1 0 }$ output (a one-hot vector indicating the label for the dataset of image classification). $d$ is the dimension of the input $d = 7 8 4$ for MNIST and $d = 3 2 \times 3 2 \times 3$ for CIFAR10). Since the high dimensional discrete Fourier transform (DFT) requires prohibitively high computational cost, in this section, we only consider one direction in the Fourier space through a projection method for each examination.
46
+
47
+ # 3.1 EXAMINATION METHOD: PROJECTION
48
+
49
+ For a dataset $\{ ( \pmb { x } _ { i } , \pmb { y } _ { i } ) \} _ { i = 0 } ^ { n - 1 }$ we consider one entry of 10-d output, denoted by $y _ { i } \in \mathbb { R }$ . The high dimensional discrete non-uniform ourier transform of $\{ ( \pmb { x } _ { i } , y _ { i } ) \} _ { i = 0 } ^ { n - 1 }$ is $\begin{array} { r } { \hat { y } _ { \pmb { k } } = \frac { 1 } { n } \sum _ { i = 0 } ^ { n - 1 } y _ { i } \exp \left( - \mathrm { i } 2 \pi \pmb { k } \cdot \pmb { x } _ { i } \right) } \end{array}$ $\boldsymbol { k }$ grows exponentially on dimension $d$ . For illustration, in each examination, we consider a direction of $\boldsymbol { k }$ in the Fourier space, i.e., $\pmb { k } = k p _ { 1 } , p _ { 1 }$ is a chosen and fixed unit vector, hence |k| = k. Then we have yˆk = 1n Pn−1i=0 $\begin{array} { r } { \hat { y } _ { k } = \frac { 1 } { n } \sum _ { i = 0 } ^ { \bar { n } - 1 } y _ { i } \exp \left( - \mathrm { i } 2 \pi ( \pmb { p } _ { 1 } \cdot \pmb { x } _ { j } ) k \right) } \end{array}$ , which is essentially the 1-d Fourier transform of $\{ ( x _ { { p } _ { 1 } , i } , y _ { i } ) \} _ { i = 0 } ^ { n - 1 }$ , where $x _ { p _ { 1 } , i } = p _ { 1 } \cdot x _ { i }$ is the projection of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ on the direction $\pmb { p } _ { 1 }$ (Bracewell $\&$ Bracewell, 1986). For each training dataset, $\pmb { p } _ { 1 }$ is chosen as the first principle component of the input space. To examine the convergence behavior of different frequency components during the training, we compute the relative difference between the DNN output and the target function for selected important frequencies $k$ ’s at each recording step, that is, $\bar { \Delta _ { F } ( k ) } = | \hat { h } _ { k } - \hat { y } _ { k } | / | \hat { y } _ { k } |$ , where $\hat { y } _ { k }$ and $\hat { h } _ { k }$ are 1-d Fourier transforms of $\{ y _ { i } \} _ { i = 0 } ^ { n - 1 }$ and the corresponding DNN output $\{ h _ { i } \} _ { i = 0 } ^ { n - 1 }$ , respectively, along ${ \pmb p } _ { 1 }$ . Note that each response frequency component, $\hat { h } _ { k }$ of DNN output evolves as the training goes.
50
+
51
+ # 3.2 MNIST/CIFAR10
52
+
53
+ In the following, we show empirically that the F-Principle is exhibited in the selected direction during the training process of DNNs when applied to MNIST/CIFAR10 with cross-entropy loss. The network for MNIST is a fully-connected tanh DNN (784-400-200-10) and for CIFAR10 is two ReLU convolutional layers followed by a fully-connected DNN (800-400-400-400-10). All experimental details of this paper can be found in Appendix C. We consider one of the 10-d outputs in each case using non-uniform Fourier transform. As shown in Fig. 1(a) and 1(c), low frequencies dominate in both real datasets. During the training, the evolution of relative errors of certain selected frequencies (marked by black squares in Fig. 1(a) and 1(c)) is shown in Fig. 1(b) and 1(d). One can easily observe that DNNs capture low frequencies first and gradually capture higher frequencies. Clearly, this behavior is consistent with the F-Principle. For other components of the output vector and other directions of $\pmb { p }$ , similar phenomena are also observed.
54
+
55
+ ![](images/c54948a38c4b0beb443d07e6968dfc4de4d4583faa2cf89f74a5c67b51d73713.jpg)
56
+ Figure 1: Projection method. (a, b) are for MNIST, (c, d) for CIFAR10. (a, c) Amplitude $| \hat { y } _ { k } |$ vs. frequency. Selected frequencies are marked by black squares. (b, d) $\Delta _ { F } ( k )$ vs. training epochs for the selected frequencies.
57
+
58
+ # 4 F-PRINCIPLE IN MNIST/CIFAR10 THROUGH FILTERING METHOD
59
+
60
+ The projection method in the previous section enables us to visualize the F-Principle in one direction for each examination at the level of individual frequency components. However, demonstration by this method alone is insufficient because it is impossible to verify the F-Principle at all potentially informative directions for high-dimensional data. To compensate the projection method, in this section, we consider a coarse-grained filtering method which is able to unravel whether, in the radially averaged sense, low frequencies converge faster than high frequencies.
61
+
62
+ # 4.1 EXAMINATION METHOD: FILTERING
63
+
64
+ The idea of the filtering method is as follows. We split the frequency domain into two parts, i.e., a low-frequency part with $| k | \leq k _ { 0 }$ and a high-frequency part with $| k | > k _ { 0 }$ , where $| \cdot |$ is the length of a vector. The DNN is trained as usualCIFAR10. The DNN output is denoted as y the original dataset . During the training, $\{ ( { \pmb x } _ { i } , { \pmb y } _ { i } ) \} _ { i = 0 } ^ { n - 1 }$ , such as MNIST ore the convergence of $^ { h }$ relative errors of low- and high- frequency part, using the two measures below
65
+
66
+ $$
67
+ e _ { \mathrm { l o w } } = \left( \frac { \sum _ { { \boldsymbol { k } } } \mathbb { 1 } _ { | { \boldsymbol { k } } | \leq k _ { 0 } } | \hat { y } ( { \boldsymbol { k } } ) - \hat { h } ( { \boldsymbol { k } } ) | ^ { 2 } } { \sum _ { { \boldsymbol { k } } } \mathbb { 1 } _ { | { \boldsymbol { k } } | \leq k _ { 0 } } | \hat { y } ( { \boldsymbol { k } } ) | ^ { 2 } } \right) ^ { \frac { 1 } { 2 } } , \quad e _ { \mathrm { h i g h } } = \left( \frac { \sum _ { { \boldsymbol { k } } } ( 1 - \mathbb { 1 } _ { | { \boldsymbol { k } } | \leq k _ { 0 } } ) | \hat { y } ( { \boldsymbol { k } } ) - \hat { h } ( { \boldsymbol { k } } ) | ^ { 2 } } { \sum _ { { \boldsymbol { k } } } ( 1 - \mathbb { 1 } _ { | { \boldsymbol { k } } | \leq k _ { 0 } } ) | \hat { y } ( { \boldsymbol { k } } ) | ^ { 2 } } \right) ^ { \frac { 1 } { 2 } } ,
68
+ $$
69
+
70
+ respectively, where ˆ· indicates Fourier transform, ${ \mathbb { 1 } } _ { k \leq k _ { 0 } }$ is an indicator function, i.e.,
71
+
72
+ $$
73
+ \mathbb { 1 } _ { | k | \leq k _ { 0 } } = \left\{ { \begin{array} { l l } { 1 , } & { | k | \leq k _ { 0 } , } \\ { 0 , } & { | k | > k _ { 0 } . } \end{array} } \right.
74
+ $$
75
+
76
+ If we consistently observe $e _ { \mathrm { l o w } } < e _ { \mathrm { h i g h } }$ for different $k _ { 0 }$ ’s during the training, then in a mean sense, lower frequencies are first captured by the DNN, i.e., F-Principle.
77
+
78
+ However, because it is almost impossible to compute above quantities numerically due to high computational cost of high-dimensional Fourier transform, we alternatively use the Fourier transform of a Gaussian function $\hat { G } ^ { \delta } ( k )$ , where $\delta$ is the variance of the Gaussian function $G$ , to approximate $\mathbb { 1 } _ { | k | > k _ { 0 } }$ . This is reasonable due to the following two reasons. First, the Fourier transform of a Gaussian is still a Gaussian, i.e., ${ \hat { G } } ^ { \delta } ( k )$ decays exponentially as $| k |$ increases, therefore, it can approximate $\mathbb { 1 } _ { | k | \leq k _ { 0 } }$ by ${ \hat { G } } ^ { \delta } ( k )$ with a proper $\delta ( k _ { 0 } )$ (referred to as $\delta$ for simplicity). Second, the computation of $e _ { \mathrm { l o w } }$ and $e _ { \mathrm { h i g h } }$ contains the multiplication of Fourier transforms in the frequency domain, which is equivalent to the Fourier transform of a convolution in the spatial domain. We can equivalently perform the examination in the spatial domain so as to avoid the almost impossible high-dimensional Fourier transform. The low frequency part can be derived by
79
+
80
+ $$
81
+ \begin{array} { r } { \pmb { y } _ { i } ^ { \mathrm { l o w } , \delta } \triangleq ( \pmb { y } \ast \boldsymbol { G } ^ { \delta } ) _ { i } , } \end{array}
82
+ $$
83
+
84
+ where $^ *$ indicates convolution operator, and the high frequency part can be derived by
85
+
86
+ $$
87
+ \begin{array} { r } { \pmb { y } _ { i } ^ { \mathrm { h i g h } , \delta } \triangleq \pmb { y } _ { i } - \pmb { y } _ { i } ^ { \mathrm { l o w } , \delta } . } \end{array}
88
+ $$
89
+
90
+ Then, we can examine
91
+
92
+ $$
93
+ e _ { \mathrm { l o w } } = \left( \frac { \sum _ { i } | y _ { i } ^ { \mathrm { l o w } , \delta } - h _ { i } ^ { \mathrm { l o w } , \delta } | ^ { 2 } } { \sum _ { i } | y _ { i } ^ { \mathrm { l o w } , \delta } | ^ { 2 } } \right) ^ { \frac 1 2 } , \quad e _ { \mathrm { h i g h } } = \left( \frac { \sum _ { i } | y _ { i } ^ { \mathrm { h i g h } , \delta } - h _ { i } ^ { \mathrm { h i g h } , \delta } | ^ { 2 } } { \sum _ { i } | y _ { i } ^ { \mathrm { h i g h } , \delta } | ^ { 2 } } \right) ^ { \frac 1 2 } ,
94
+ $$
95
+
96
+ where $\boldsymbol { h } ^ { \mathrm { l o w } , \delta }$ and $h ^ { \mathrm { h i g h } , \delta }$ are obtained from the DNN output $^ { h }$ , which evolves as a function of training epoch, through the same decomposition. If $e _ { \mathrm { l o w } } < e _ { \mathrm { h i g h } }$ for different $\delta$ ’s during the training, F-Principle holds; otherwise, it is falsified. Next, we introduce the experimental procedure.
97
+
98
+ Step One: Training. Train the DNN by the original dataset $\{ ( \pmb { x } _ { i } , \pmb { y } _ { i } ) \} _ { i = 0 } ^ { n - 1 }$ , such as MNIST or CIFAR10. $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ is an image vector, $\mathbf { \nabla } _ { \mathbf { \psi } _ { 3 } } \psi _ { i }$ is a one-hot vector.
99
+
100
+ Step Two: Filtering. The low frequency part can be derived by
101
+
102
+ $$
103
+ { \pmb y } _ { i } ^ { \mathrm { l o w } , \delta } = \frac { 1 } { C _ { i } } \sum _ { j = 0 } ^ { n - 1 } { \pmb y } _ { j } G ^ { \delta } ( { \pmb x } _ { i } - { \pmb x } _ { j } ) ,
104
+ $$
105
+
106
+ where $\begin{array} { r } { C _ { i } = \sum _ { j = 0 } ^ { n - 1 } G ^ { \delta } ( \pmb { x } _ { i } - \pmb { x } _ { j } ) } \end{array}$ is a normalization factor and
107
+
108
+ $$
109
+ G ^ { \delta } ( \pmb { x } _ { i } - \pmb { x } _ { j } ) = \exp \left( - | \pmb { x } _ { i } - \pmb { x } _ { j } | ^ { 2 } / ( 2 \delta ) \right) .
110
+ $$
111
+
112
+ The high frequency part can be derived by $\pmb { y } _ { i } ^ { \mathrm { h i g h } , \delta } \triangleq \pmb { y } _ { i } - \pmb { y } _ { i } ^ { \mathrm { l o w } , \delta }$ . We also compute $h _ { i } ^ { \mathrm { l o w } , \delta }$ and $h _ { i } ^ { \mathrm { h i g h } , \delta }$ for each DNN output $\boldsymbol { h } _ { i }$ .
113
+
114
+ Step Three: Examination. To quantify the convergence of $\boldsymbol { h } ^ { \mathrm { l o w } , \delta }$ and $h ^ { \mathrm { h i g h } , \delta }$ , we compute the relative error $e _ { \mathrm { l o w } }$ and $e _ { \mathrm { h i g h } }$ at each training epoch through Eq. (3).
115
+
116
+ # 4.2 DNNS WITH VARIOUS SETTINGS
117
+
118
+ With the filtering method, we show the F-Principle in the DNN training process of real datasets for commonly used large networks. For MNIST, we use a fully-connected tanh-DNN (no softmax) with MSE loss; for CIFAR10, we use cross-entropy loss and two structures, one is small ReLU-CNN network, i.e., two convolutional layers, followed by a fully-connected multi-layer neural network with a softmax; the other is VGG16 (Simonyan & Zisserman, 2014) equipped with a 1024 fully-connected layer. These three structures are denoted as “DNN”, “CNN” and “VGG” in Fig. 2, respectively. All are trained by SGD from scratch. More details are in Appendix C.
119
+
120
+ We scan a large range of $\delta$ for both datasets. As an example, results of each dataset for several $\delta$ ’s are shown in Fig. 2, respectively. Red color indicates small relative error. In all cases, the relative error of the low-frequency part, i.e., $e _ { \mathrm { l o w } }$ , decreases (turns red) much faster than that of the high-frequency part, i.e., $e _ { \mathrm { h i g h } }$ . Therefore, as analyzed above, the low-frequency part converges faster than the high-frequency part. We also remark that, based on the above results on cross-entropy loss, the F-Principle is not limited to MSE loss, which possesses a natural Fourier domain interpretation by the Parseval’s theorem. Note that the above results holds for both SGD and GD.
121
+
122
+ ![](images/0b27fb9f7b284c06ec72325d8857b6f2104077b717f26513b80570ab7b3e1dc5.jpg)
123
+ Figure 2: F-Principle in real datasets. $e _ { \mathrm { l o w } }$ and $e _ { \mathrm { h i g h } }$ indicated by color against training epoch.
124
+
125
+ # 5 F-PRINCIPLE IN SOLVING DIFFERENTIAL EQUATION
126
+
127
+ Recently, DNN-based approaches have been actively explored for a variety of scientific computing problems, e.g., solving high-dimensional partial differential equations (E et al., 2017; Khoo et al., 2017; He et al., 2018; Fan et al., 2018) and molecular dynamics (MD) simulations (Han et al., 2017). However, the behaviors of DNNs applied to these problems are not well-understood. To facilitate the designs and applications of DNN-based schemes, it is important to characterize the difference between DNNs and conventional numerical schemes on various scientific computing problems. In this section, focusing on solving Poisson’s equation, which has broad applications in mechanical engineering and theoretical physics (Evans, 2010), we highlight a stark difference between a DNN-based solver and the Jacobi method during the training/iteration, which can be explained by the F-Principle.
128
+
129
+ Consider a 1-d Poisson’s equation:
130
+
131
+ $$
132
+ \begin{array} { r l } & { - \Delta u ( x ) = g ( x ) , \quad x \in \Omega \triangleq ( - 1 , 1 ) , } \\ & { u ( - 1 ) = u ( 1 ) = 0 . } \end{array}
133
+ $$
134
+
135
+ We consider the example with $g ( x ) = \sin ( x ) + 4 \sin ( 4 x ) - 8 \sin ( 8 x ) + 1 6 \sin ( 2 4 x )$ which has analytic solution $u _ { \mathrm { r e f } } ( x ) = g _ { 0 } ( x ) + c _ { 1 } x + c _ { 0 }$ , where $g _ { 0 } = \sin ( x ) + \sin ( 4 x ) / 4 - \sin ( 8 x ) / 8 + \sin ( 2 4 x ) / 3 6 ,$ $c _ { 1 } = ( g _ { 0 } ( - 1 ) - g _ { 0 } ( 1 ) ) / 2$ and $c _ { 0 } = - ( g _ { 0 } ( - 1 ) + g _ { 0 } ( 1 ) ) / 2$ . 1001 training samples $\{ x _ { i } \} _ { i = 0 } ^ { n }$ are evenly spaced with grid size $\delta x$ in $[ 0 , 1 ]$ . Here, we use the DNN output, $h ( x ; \theta )$ , to fit $u _ { \mathrm { r e f } } ( x )$ (Fig. 3(a)). A
136
+
137
+ ![](images/d241587fe6788ba5fc40badbaf0930d66b995bddd30fe42326b0cf999c5935ad.jpg)
138
+ Figure 3: Poisson’s equation. (a) $u _ { \mathrm { r e f } } ( x )$ . Inset: $| \hat { u } _ { \mathrm { r e f } } ( k ) |$ as a function of frequency. Frequencies peaks are marked with black dots. (b,c) $\Delta _ { F } ( k )$ computed on the inputs of training data at different epochs for the selected frequencies for DNN (b) and Jacobi (c). (d) $\| h - u _ { \mathrm { r e f } } \| _ { \infty }$ at different running time. Green stars indicate $\| h - u _ { \mathrm { r e f } } \| _ { \infty }$ using DNN alone. The dashed lines indicate $\| h - u _ { \mathrm { r e f } } \| _ { \infty }$ for the Jacobi method with different colors indicating initialization by different timing of DNN training.
139
+
140
+ DNN-based scheme is proposed by considering the following empirical loss function (E & Yu, 2018),
141
+
142
+ $$
143
+ I _ { \mathrm { e m p } } = \sum _ { i = 1 } ^ { n - 1 } \left( \frac { 1 } { 2 } | \nabla _ { x } h ( x _ { i } ) | ^ { 2 } - g ( x _ { i } ) h ( x _ { i } ) \right) \delta x + \beta \left( h ( x _ { 0 } ) ^ { 2 } + h ( x _ { n } ) ^ { 2 } \right) .
144
+ $$
145
+
146
+ The second term in $I _ { \mathrm { e m p } } ( h )$ is a penalty, with constant $\beta$ , arising from the Dirichlet boundary condition (7). After training, the DNN output well matches the analytical solution $u _ { \mathrm { r e f } }$ . Focusing on the convergence of three peaks (inset of Fig. 3(a)) in the Fourier transform of $u _ { \mathrm { r e f } }$ , as shown in Fig. 3(b), low frequencies converge faster than high frequencies as predicted by the F-Principle. For comparison, we also use the Jacobi method to solve problem (6). High frequencies converge faster in the Jacobi method (Details can be found in Appendix D), as shown in Fig. 3(c).
147
+
148
+ As a demonstration, we further propose that DNN can be combined with conventional numerical schemes to accelerate the convergence of low frequencies for computational problems. First, we solve the Poisson’s equation in Eq. (6) by DNN with $M$ optimization steps (or epochs), which needs to be chosen carefully, to get a good initial guess in the sense that this solution has already learned the low frequencies (large eigenvalues) part. Then, we use the Jacobi method with the new initial data for the further iterations. We use $\begin{array} { r } { \| h - u _ { \mathrm { r e f } } \| _ { \infty } \triangleq \operatorname* { m a x } _ { x \in \Omega } | h ( x ) - u _ { \mathrm { r e f } } ( x ) | } \end{array}$ to quantify the learning result. As shown by green stars in Fig. 3(d), $\| h - u _ { \mathrm { r e f } } \| _ { \infty }$ fluctuates after some running time using DNN only. Dashed lines indicate the evolution of the Jacobi method with initial data set to the DNN output at the corresponding steps. If $M$ is too small (stop too early) (left dashed line), which is equivalent to only using Jacobi, it would take long time to converge to a small error, because low frequencies converges slowly, yet. If $M$ is too big (stop too late) (right dashed line), which is equivalent to using DNN only, much time would be wasted for the slow convergence of high frequencies. A proper choice of $M$ is indicated by the initial point of orange dashed line, in which low frequencies are quickly captured by the DNN, followed by fast convergence in high frequencies of the Jacobi method.
149
+
150
+ This example illustrates a cautionary tale that, although DNNs has clear advantage, using DNNs alone may not be the best option because of its limitation of slow convergence at high frequencies. Taking advantage of both DNNs and conventional methods to design faster schemes could be a promising direction in scientific computing problems.
151
+
152
+ # 6 A PRELIMINARY THEORETICAL UNDERSTANDING
153
+
154
+ A subsequent theoretical work (Luo et al., 2019) provides a rigorous mathematical study of the FPrinciple at different frequencies for general DNNs (e.g., multiple hidden layers, different activation functions, high-dimensional inputs). The key insight is that the regularity of DNN converts into the decay rate of a loss function in the frequency domain. For an intuitive understanding of this key insight, we present theories under an idealized setting, which connect the smoothness/regularity of the activation function with different gradient and convergence priorities in frequency domain.
155
+
156
+ The activation function we consider is $\sigma ( x ) = \operatorname { t a n h } ( x )$ , which is smooth in spatial domain and its derivative decays exponentially with respect to frequency in the Fourier domain. For a DNN of one hidden layer with $m$ nodes, 1-d input $x$ and 1-d output: $\begin{array} { r } { h ( x ) = \sum _ { j = 1 } ^ { m } a _ { j } \sigma ( w _ { j } x + b _ { j } ) , \quad a _ { j } , w _ { j } , b _ { j } \in \sigma } \end{array}$ $\mathbb { R }$ . We also use the notation $\theta = \left\{ \theta _ { l j } \right\}$ with $\theta _ { 1 j } = a _ { j }$ , $\theta _ { 2 j } = w _ { j }$ , and $\theta _ { 3 j } = b _ { j }$ , $j = 1 , \cdots , m$ . The loss at frequency $k$ is $\begin{array} { r } { L ( k ) = \frac { 1 } { 2 } \left| \hat { h } ( k ) - \hat { f } ( k ) \right| ^ { 2 } } \end{array}$ , ˆ· is the Fourier transform, $f$ is the target function. The total loss function is defined as: this loss function in the Fourier do $\begin{array} { r } { L = \int _ { - \infty } ^ { + \infty } L ( k ) \mathrm { d } k } \end{array}$ . Note that according to Parseval’s theorem,e commonly used MSE loss. We have the following theorems (The proofs are at Appendix E.). Define $W = ( w _ { 1 } , w _ { 2 } , \cdot \cdot \cdot , w _ { m } ) ^ { T } \in \mathbb { R } ^ { m }$ .
157
+
158
+ Theorem 1. Considering a DNN of one hidden layer with activation function $\sigma ( x ) = \operatorname { t a n h } ( x )$ , for any frequencies $k _ { 1 }$ and $k _ { 2 }$ such that $| { \hat { f } } ( k _ { 1 } ) | > 0$ , $| { \hat { f } } ( k _ { 2 } ) | > 0 ;$ , and $| k _ { 2 } | > | k _ { 1 } | > 0 ;$ , there exist positive constants c and $C$ such that for sufficiently small $\delta$ , we have
159
+
160
+ $$
161
+ \frac { \mu ( \{ W : | \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } | > | \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } | f o r a l l \quad l , j \} \cap B _ { \delta } ) } { \mu ( B _ { \delta } ) } \geq 1 - C \exp ( - c / \delta ) ,
162
+ $$
163
+
164
+ where $B _ { \delta } \subset \mathbb { R } ^ { m }$ is a ball with radius $\delta$ centered at the origin and $\mu ( \cdot )$ is the Lebesgue measure.
165
+
166
+ Theorem 1 indicates that for any two non-converged frequencies, with small weights, the lowerfrequency gradient exponentially dominates over the higher-frequency ones. Due to Parseval’s theorem, the MSE loss in the spatial domain is equivalent to the L2 loss in the Fourier domain. To intuitively understand the higher decay rate of a lower-frequency loss function, we consider the training in the Fourier domain with loss function of only two non-zero frequencies.
167
+
168
+ Theorem 2. Considering a DNN of one hidden layer with activation function $\sigma ( x ) = \operatorname { t a n h } ( x )$ . Suppose the target function has only two non-zero frequencies $k _ { 1 }$ and $k _ { 2 }$ , that is, $| { \hat { f } } ( k _ { 1 } ) | > 0$ , $| \hat { f } ( k _ { 2 } ) | > 0$ , $| k _ { 2 } | > | k _ { 1 } | > 0$ , and $| { \hat { f } } ( k ) | = 0$ for $\boldsymbol { k } \neq k _ { 1 } , k _ { 2 }$ . Consider the loss function of $L = L ( k _ { 1 } ) + L ( k _ { 2 } )$ with gradient descent training. Denote
169
+
170
+ $$
171
+ \mathcal { S } = \left\{ \frac { \partial L ( k _ { 1 } ) } { \partial t } \leq 0 , \frac { \partial L ( k _ { 1 } ) } { \partial t } \leq \frac { \partial L ( k _ { 2 } ) } { \partial t } \right\} ,
172
+ $$
173
+
174
+ that is, $L ( k _ { 1 } )$ decreases faster than $L ( k _ { 2 } )$ . There exist positive constants c and $C$ such that for sufficiently small $\delta$ , we have
175
+
176
+ $$
177
+ \frac { \mu \left( \left\{ W : { \cal S } \mathrm { ~ \ h o l d s } \right\} \cap { \cal B } _ { \delta } \right) } { \mu ( { \cal B } _ { \delta } ) } \geq 1 - C \exp ( - c / \delta ) ,
178
+ $$
179
+
180
+ where $B _ { \delta } \subset \mathbb { R } ^ { m }$ is a ball with radius $\delta$ centered at the origin and $\mu ( \cdot )$ is the Lebesgue measure.
181
+
182
+ # 7 DISCUSSIONS
183
+
184
+ DNNs often generalize well for real problems (Zhang et al., 2016) but poorly for problems like fitting a parity function (Shalev-Shwartz et al., 2017; Nye & Saxe, 2018) despite excellent training accuracy for all problems. Understanding the differences between above two types of problems, i.e., good and bad generalization performance of DNN, is critical. In the following, we show a qualitative difference between these two types of problems through Fourier analysis and use the $F$ -Principle to provide an explanation different generalization performances of DNNs.
185
+
186
+ For MNIST/CIFAR10, we examine $\begin{array} { r l r } { \hat { y } _ { \mathrm { t o t a l } , k } } & { = } & { \frac { 1 } { n _ { \mathrm { t o t a l } } } \sum _ { i = 0 } ^ { n _ { \mathrm { t o t a l } } - 1 } y _ { i } \exp \left( - \mathrm { i } 2 \pi \pmb { k } \cdot \pmb { x } _ { i } \right) } \end{array}$ , where $\{ ( { \pmb x } _ { i } , y _ { i } ) \} _ { i = 0 } ^ { n _ { \mathrm { t o t a l } } - 1 }$ consists of both the training and test datasets with certain selected output component, at different directions of in the Fourier space. We find that $\hat { y } _ { \mathrm { t o t a l } , k }$ concentrates on the low frequencies along those examined directions. For illustration, $\hat { y } _ { \mathrm { t o t a l } , k }$ ’s along the first principle component are shown by green lines in Fig. 4(a, b) for MNIST/CIFAR10, respectively. When only the training dataset is used, $\hat { y } _ { \mathrm { t r a i n } , k }$ well overlaps with $\hat { y } _ { \mathrm { t o t a l } , k }$ at the dominant low frequencies.
187
+
188
+ For the parity function $\begin{array} { r } { f ( \pmb { x } ) = \prod _ { j = 1 } ^ { d } x _ { j } } \end{array}$ defined on $\Omega = \{ - 1 , 1 \} ^ { d }$ , its Fourier transform is ${ \hat { f } } ( \pmb { k } ) =$ $\begin{array} { r } { \frac { 1 } { 2 ^ { d } } \sum _ { x \in \Omega } \prod _ { j = 1 } ^ { d } x _ { j } \mathrm { e } ^ { - \mathrm { i } 2 \pi k \cdot x } = ( - \mathrm { i } ) ^ { d } \prod _ { j = 1 } ^ { d } \sin 2 \pi k _ { j } } \end{array}$ . Clearly, for $\pmb { k } \in [ - \frac { 1 } { 4 } , \frac { 1 } { 4 } ] ^ { d }$ , the power of the parity function concentrates at $k \in \{ - \frac { 1 } { 4 } , \frac { 1 } { 4 } \} ^ { d }$ and vanishes as $\mathbf k \to \mathbf 0$ , as illustrated in Fig. 4(c) for the direction of ${ \bf 1 } _ { d }$ . Given a randomly sampled training dataset $S \subset \Omega$ with $s$ points, the nonuniform
189
+
190
+ ![](images/052ee35d5ce055c3e7ff406efd4d14ade183f5977328a1c15075fd3146c67605.jpg)
191
+ Figure 4: Fourier analysis for different generalization ability. The plot is the amplitude of the Fourier coefficient against frequency $k$ . The red dots are for the training dataset, the green line is for the whole dataset, and the blue dashed line is for an output of well-trained DNN on the input of the whole dataset. For (c), $d = 1 0$ . The training data is 200 randomly selected points.
192
+
193
+ Fourier transform on $S$ is computed as $\begin{array} { r } { \hat { f } _ { S } ( \pmb { k } ) = \frac { 1 } { s } \sum _ { \pmb { x } \in S } \prod _ { j = 1 } ^ { d } x _ { j } \mathrm { e } ^ { - \mathrm { i } 2 \pi \pmb { k } \cdot \pmb { x } } } \end{array}$ . As shown in Fig. 4(c), ${ \hat { f } } ( \pmb { k } )$ and ${ \hat { f } } _ { S } ( { k } )$ significantly differ at low frequencies.
194
+
195
+ By experiments, the generalization ability of DNNs can be well reflected by the Fourier analysis. For the MNIST/CIFAR10, we observed the Fourier transform of the output of a well-trained DNN on $\{ \pmb { x } _ { i } \} _ { i = 0 } ^ { n _ { \mathrm { t o t a l } } - 1 }$ faithfully recovers the dominant low frequencies, as illustrated in Fig. 4(a) and 4(b), indicating a good generalization performance as observed in experiments. However, for the parity function, we observed that the Fourier transform of the output of a well-trained DNN on $\{ { \pmb x } _ { i } \} _ { i \in S }$ significantly deviates from ${ \hat { f } } ( \pmb { k } )$ at almost all frequencies, as illustrated in Fig. 4(c), indicating a bad generalization performance as observed in experiments.
196
+
197
+ The F-Principle implicates that among all the functions that can fit the training data, a DNN is implicitly biased during the training towards a function with more power at low frequencies. If the target function has significant high-frequency components, insufficient training samples will lead to artificial low frequencies in training dataset (see red line in Fig. 4(c)), which is the wellknown aliasing effect. Based on the F-Principle, as demonstrated in Fig. 4(c), these artificial low frequency components will be first captured to explain the training samples, whereas the high frequency components will be compromised by DNN. For MNIST/CIFAR10, since the power of high frequencies is much smaller than that of low frequencies, artificial low frequencies caused by aliasing can be neglected. To conclude, the distribution of power in Fourier domain of above two types of problems exhibits significant differences, which result in different generalization performances of DNNs according to the F-Principle.
198
+
199
+ # 8 RELATED WORK
200
+
201
+ There are different approaches attempting to explain why DNNs often generalize well. For example, generalization error is related to various complexity measures (Bartlett et al., 1999; Neyshabur et al., 2017; E et al., 2018), local properties (sharpness/flatness) of loss functions at minima (Keskar et al., 2016; Wu et al., 2017), stability of optimization algorithms (Hardt et al., 2015), and implicit bias of the training process (Soudry et al., 2018; Arpit et al., 2017; Xu et al., 2018). On the other hand, several works focus on the failure of DNNs (Shalev-Shwartz et al., 2017; Nye & Saxe, 2018), e.g., fitting the parity function, in which a well-trained DNN possesses no generalization ability. We propose that the Fourier analysis can provide insights into both success and failure of DNNs.
202
+
203
+ F-Principle was first discovered in (Xu et al., 2018; Rahaman et al., 2018) simultaneously through simple synthetic data and not very deep networks. In the revised version, Rahaman et al. (2018) examines the F-Principle in the MNIST dataset. However, they add noise to MNIST, which contaminates the labels and damages the structure of real data. They only examine not very deep (6-layer) fully connected ReLU network with MSE loss, while cross-entropy loss is widely used. This paper verified that F-Principle holds in the training process of MNIST and CIFAR10, both CNN and fully connected networks, very deep networks (VGG16) and various loss functions, e.g., MSE Loss, cross-entropy loss and variational loss function. In the aspect of theoretical study, based on the key mechanism found by the theoretical study in this paper, Luo et al. (2019) shows a rigorous proof of the F-Principle for general DNNs. The theoretical study of the gradient of $\operatorname { t a n h } ( x )$ in the Fourier domain is adopted by Rahaman et al. (2018), in which they generalize the analysis to ReLU and show similar results. Thm 1 is also used to analyze a nonlinear collaborative scheme for deep network training (Zhen et al., 2018). In the aspect of application, based on the study of the F-Principle in this paper, Cai et al. (2019) and Cai & Xu (2019) design DNN-based algorithms to solve high-dimensional and high-frequency problems.
204
+
205
+ # REFERENCES
206
+
207
+ Devansh Arpit, Stanislaw Jastrzebski, Nicolas Ballas, David Krueger, Emmanuel Bengio, Maxinder S Kanwal, Tegan Maharaj, Asja Fischer, Aaron Courville, Yoshua Bengio, et al. A closer look at memorization in deep networks. arXiv preprint arXiv:1706.05394, 2017. 8
208
+
209
+ Peter L Bartlett, Vitaly Maiorov, and Ron Meir. Almost linear vc dimension bounds for piecewise polynomial networks. In Advances in Neural Information Processing Systems, pp. 190–196, 1999. 8
210
+
211
+ Ronald Newbold Bracewell and Ronald N Bracewell. The Fourier transform and its applications, volume 31999. McGraw-Hill New York, 1986. 2, 3.1
212
+
213
+ Wei Cai and Zhi-Qin John Xu. Multi-scale deep neural networks for solving high dimensional pdes. arXiv preprint arXiv:1910.11710, 2019. 8
214
+
215
+ Wei Cai, Xiaoguang Li, and Lizuo Liu. A phase shift deep neural network for high frequency wave equations in inhomogeneous media. Arxiv preprint, arXiv:1909.11759, 2019. 8
216
+
217
+ Weinan E and Bing Yu. The deep ritz method: A deep learning-based numerical algorithm for solving variational problems. Communications in Mathematics and Statistics, 6(1):1–12, 2018. 5
218
+
219
+ Weinan E, Jiequn Han, and Arnulf Jentzen. Deep learning-based numerical methods for highdimensional parabolic partial differential equations and backward stochastic differential equations. Communications in Mathematics and Statistics, 5(4):349–380, 2017. 5
220
+
221
+ Weinan E, Chao Ma, and Lei Wu. A priori estimates of the generalization error for two-layer neural networks. arXiv preprint arXiv:1810.06397, 2018. 8
222
+
223
+ Lawrence C Evans. Partial differential equations. 2010. 5
224
+
225
+ Yuwei Fan, Lin Lin, Lexing Ying, and Leonardo Zepeda-Nunez. A multiscale neural network based ´ on hierarchical matrices. arXiv preprint arXiv:1807.01883, 2018. 5
226
+
227
+ Jiequn Han, Linfeng Zhang, Roberto Car, et al. Deep potential: A general representation of a many-body potential energy surface. arXiv preprint arXiv:1707.01478, 2017. 5
228
+
229
+ Moritz Hardt, Benjamin Recht, and Yoram Singer. Train faster, generalize better: Stability of stochastic gradient descent. arXiv preprint arXiv:1509.01240, 2015. 8
230
+
231
+ Juncai He, Lin Li, Jinchao Xu, and Chunyue Zheng. Relu deep neural networks and linear finite elements. arXiv preprint arXiv:1807.03973, 2018. 5
232
+
233
+ Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, and Ping Tak Peter Tang. On large-batch training for deep learning: Generalization gap and sharp minima. arXiv preprint arXiv:1609.04836, 2016. 8
234
+
235
+ Yuehaw Khoo, Jianfeng Lu, and Lexing Ying. Solving parametric pde problems with artificial neural networks. arXiv preprint arXiv:1707.03351, 2017. 5
236
+
237
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. C, 6
238
+
239
+ Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. Cifar-10 (canadian institute for advanced research). URL http://www. cs. toronto. edu/kriz/cifar. html, 2010. 1
240
+
241
+ Yann LeCun. The mnist database of handwritten digits. http://yann. lecun. com/exdb/mnist/, 1998. 1
242
+
243
+ Tao Luo, Zheng Ma, Zhi-Qin John Xu, and Yaoyu Zhang. Theory of the frequency principle for general deep neural networks. arXiv preprint arXiv:1906.09235, 2019. 1, 6, 8
244
+
245
+ Behnam Neyshabur, Srinadh Bhojanapalli, David McAllester, and Nati Srebro. Exploring generalization in deep learning. In Advances in Neural Information Processing Systems, pp. 5947–5956, 2017. 8
246
+
247
+ Maxwell Nye and Andrew Saxe. Are efficient deep representations learnable? 2018. 1, 7, 8
248
+
249
+ Nasim Rahaman, Devansh Arpit, Aristide Baratin, Felix Draxler, Min Lin, Fred A Hamprecht, Yoshua Bengio, and Aaron Courville. On the spectral bias of deep neural networks. arXiv preprint arXiv:1806.08734, 2018. 1, 8, B
250
+
251
+ Shai Shalev-Shwartz, Ohad Shamir, and Shaked Shammah. Failures of gradient-based deep learning. arXiv preprint arXiv:1703.07950, 2017. 1, 7, 8
252
+
253
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. 1, 4.2
254
+
255
+ Daniel Soudry, Elad Hoffer, Mor Shpigel Nacson, Suriya Gunasekar, and Nathan Srebro. The implicit bias of gradient descent on separable data. Journal of Machine Learning Research, 19(70), 2018. 8
256
+
257
+ Lei Wu, Zhanxing Zhu, and Weinan E. Towards understanding generalization of deep learning: Perspective of loss landscapes. arXiv preprint arXiv:1706.10239, 2017. 8
258
+
259
+ Zhi-Qin J Xu, Yaoyu Zhang, and Yanyang Xiao. Training behavior of deep neural network in frequency domain. arXiv preprint arXiv:1807.01251, 2018. 1, 8, B
260
+
261
+ Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv preprint arXiv:1611.03530, 2016. 1, 7
262
+
263
+ Hui-Ling Zhen, Xi Lin, Alan Z Tang, Zhenhua Li, Qingfu Zhang, and Sam Kwong. Nonlinear collaborative scheme for deep neural networks. arXiv preprint arXiv:1811.01316, 2018. 8
264
+
265
+ A RESPONSE FREQUENCY OF TRAINING DATA $\{ y _ { i } \} _ { i = 0 } ^ { n - 1 }$ ON INPUTS $\{ { \pmb x } _ { i } \} _ { i = 0 } ^ { n - 1 }$
266
+
267
+ In all our experiments, we consistently consider the response frequency defined for the mapping function $g$ between inputs and outputs, say $\mathbb { R } ^ { d } \to \mathbb { R }$ and any $\pmb { k } \in \bar { \mathbb { R } } ^ { d }$ via the standard nonuniform discrete Fourier transform (NUDFT)
268
+
269
+ $$
270
+ \hat { g } _ { \pmb { k } } = \frac { 1 } { n } \sum _ { i = 0 } ^ { n - 1 } g ( \pmb { x } _ { i } ) \mathrm { e } ^ { - \mathrm { i } 2 \pi \pmb { k } \cdot \pmb { x } _ { i } } ,
271
+ $$
272
+
273
+ which is a natural estimator of frequency composition of $g$ . (More details can be found in https: $/ / { \mathrm { e n } }$ .wikipedia.org/wiki/Non-uniform_discrete_Fourier_transform.) As $n \to \infty$ , $\begin{array} { r } { { \hat { g } } _ { \pmb { k } } \overset { \cdot } { } \int g ( \pmb { x } ) \mathrm { e } ^ { - \mathrm { i } \overline { { 2 } } \pi \pmb { k } \cdot \pmb { x } } \nu ( \pmb { x } ) \mathrm { d } \pmb { x } } \end{array}$ , where $\nu ( { \pmb x } )$ is the data distribution.
274
+
275
+ We restrict all the evaluation of Fourier transform in our experiments to NUDFT of $\{ { \bf { y } } _ { i } \} _ { i = 0 } ^ { n - 1 }$ at $\{ { \pmb x } _ { i } \} _ { i = 0 } ^ { n - 1 }$ for the following practical reasons.
276
+
277
+ (i) The information of target function is only available at $\{ { \pmb x } _ { i } \} _ { i = 0 } ^ { n - 1 }$ for training.
278
+
279
+ (ii) It allows us to perform the convergence analysis. As $t \infty$ , in general, $h ( \pmb { x } _ { i } , t ) \pmb { y } _ { i }$ for any $i$ $( h ( x _ { i } , t )$ is the DNN output), leading to $\hat { h } _ { k } \hat { y } _ { k }$ for any $\boldsymbol { k }$ . Therefore, we can analyze the convergence at different $\boldsymbol { k }$ by evaluating $\Delta _ { F } ( { \boldsymbol { k } } ) = | \hat { h } _ { \boldsymbol { k } } - \hat { y } _ { \boldsymbol { k } } | / | \hat { y } _ { \boldsymbol { k } } |$ during the training. If we use a different set of data points for frequency evaluation of DNN output, then $\Delta _ { F } ( k )$ may not converge to 0 at the end of training.
280
+
281
+ (iii) $\hat { y } _ { k }$ faithfully reflect the frequency structure of training data $\{ { \pmb x } _ { i } , { \pmb y } _ { i } \} _ { i = 0 } ^ { n - 1 }$ . Intuitively, high frequencies of $\hat { y } _ { k }$ correspond to sharp changes of output for some nearby points in the training data. Then, by applying a Gaussian filter and evaluating still at $\{ { \pmb x } _ { i } \} _ { i = 0 } ^ { n - 1 }$ , we obtain the low frequency part of training data with these sharp changes (high frequencies) well suppressed.
282
+
283
+ ![](images/6219e31bb9843da14549f41ae1b001786788bab17c1e47f5f50efbe39c5dd9b7.jpg)
284
+ Figure 5: 1d input. (a) $f ( x )$ . Inset : $| { \hat { f } } ( k ) |$ . (b) $\Delta _ { F } ( k )$ of three important frequencies (indicated by black dots in the inset of (a)) against different training epochs.
285
+
286
+ In practice, it is impossible to evaluate and compare the convergence of all $\boldsymbol { k } \in \mathbb { R } ^ { d }$ even with a proper cutoff frequency for a very large $d$ of $O ( 1 0 ^ { \bar { 2 } } )$ (MNIST) or $\bar { O } ( 1 0 ^ { 3 } )$ (CIFAR10) due to curse of dimensionality. Therefore, we propose the projection approach, i.e., fixing $\boldsymbol { k }$ at a specific direction and the filtering approach as detailed in Section 3 and 4, respectively.
287
+
288
+ # B ILLUSTRATION OF F-PRINCIPLE FOR 1-D SYNTHETIC DATA
289
+
290
+ To illustrate the phenomenon of F-Principle, we use 1-d synthetic data to show the evolution of relative training error at different frequencies during the training of DNN. we train a DNN to fit a 1-d target function $f ( x ) = \sin ( x ) + \sin ( 3 x ) + \sin ( 5 x )$ of three frequency components. On $n = 2 0 1$ evenly spaced training samples, i.e., $\{ x _ { i } \} _ { i = 0 } ^ { n - 1 }$ in $[ - 3 . 1 4 , 3 . 1 4 ]$ , the discrete Fourier transform (DFT) of $f ( x )$ or the DNN output (denoted by $h ( x ) _ { , } ^ { \cdot }$ ) is computed by $\begin{array} { r } { \hat { f } _ { k } = \frac { 1 } { n } \sum _ { i = 0 } ^ { n - 1 } f ( x _ { i } ) \mathrm { e } ^ { - \mathrm { i } 2 \pi i k / n } } \end{array}$ and $\begin{array} { r } { \hat { h } _ { k } = \frac { 1 } { n } \sum _ { i = 0 } ^ { n - 1 } h ( x _ { i } ) \mathrm { e } ^ { - \mathrm { i } 2 \pi j k / n } } \end{array}$ , where $k$ is the frequency. As shown in Fig. 5(a), the target function has three important frequencies as we design (black dots at the inset in Fig. 5(a)). To examine the convergence behavior of different frequency components during the training with MSE, we compute the relative difference between the DNN output and the target function for the three important frequencies $k$ ’s at each recording step, that is, $\bar { \Delta } _ { F } ( k ) = { | \hat { h } _ { k } - \hat { f } _ { k } | } / { | \hat { f } _ { k } | }$ , where $| \cdot |$ denotes the norm of a complex number. As shown in Fig. 5(b), the DNN converges the first frequency peak very fast, while converging the second frequency peak much slower, followed by the third frequency peak.
291
+
292
+ Next, we investigate the F-Principle on real datasets with more general loss functions other than MSE which was the only loss studied in the previous works ( $\mathrm { { X u } }$ et al., 2018; Rahaman et al., 2018). All experimental details can be found in Appendix. C.
293
+
294
+ # C EXPERIMENTAL SETTINGS
295
+
296
+ In Fig. 5, the parameters of the DNN is initialized by a Gaussian distribution with mean 0 and standard deviation 0.1. We use a tanh-DNN with widths 1-8000-1 with full batch training. The learning rate is 0.0002. The DNN is trained by Adam optimizer (Kingma & Ba, 2014) with the MSE loss function.
297
+
298
+ In Fig. 1, for MNIST dataset, the training process of a tanh-DNN with widths 784-400-200-10 is shown in Fig. 1(a) and 1(b). For CIFAR10 dataset, results are shown in Fig. 1(c) and 1(d) of a ReLU-CNN, which consists of one convolution layer of $3 \times 3 \times 6 4$ , a max pooling of $2 \times 2$ , one convolution layer of $3 \times 3 \times 1 2 8$ , a max pooling of $2 \times 2$ , followed by a fully-connected DNN with widths 800-400-400-400-10. For both cases, the output layer of the network is equipped with a softmax. The network output is a 10-d vector. The DNNs are trained with cross entropy loss by Adam optimizer (Kingma & Ba, 2014). (a, b) are for MNIST with a tanh-DNN. The learning rate is 0.001 with batch size 10000. After training, the training accuracy is 0.951 and test accuracy is 0.963. The amplitude of the Fourier coefficient with respect to the fourth output component at each frequency is shown in (a), in which the red dots are computed using the training data. Selected frequencies are marked by black squares. (b) $\Delta _ { F } ( k )$ at different training epochs for the selected frequencies. (c, d)
299
+
300
+ are for CIFAR10 dataset. We use a ReLU network of a CNN followed by a fully-connected DNN. The learning rate is 0.003 with batch size 512. (c) and (d) are the results with respect to the ninth output component. After training, the training accuracy is 0.98 and test accuracy is 0.72.
301
+
302
+ In Fig. 2, for MNIST, we use a fully-connected tanh-DNN with widths 784-400-200-10 and MSE loss; for CIFAR10, we use cross-entropy loss and a ReLU-CNN, which consists of one convolution layer of $3 \times 3 \times 3 2$ , a max pooling of $2 \times 2$ , one convolution layer of $3 \times 3 \times 6 4$ , a max pooling of $2 \times 2$ , followed by a fully-connected DNN with widths 400-10 and the output layer of the network is equipped with a softmax. The learning rate for MNIST and CIFAR10 is 0.015 and 0.003, respectively. The networks are trained by Adam optimizer (Kingma & Ba, 2014) with batch size 10000. For VGG16, the learning rate is $\mathrm { { \dot { 1 } 0 ^ { - 5 } } }$ . The network is trained by Adam optimizer (Kingma & Ba, 2014) with batch size 500.
303
+
304
+ In Fig. 3, the samples are evenly spaced in [0, 1] with sample size 1001. We use a DNN with widths 1-4000-500-400-1 and full batch training by Adam optimizer (Kingma & Ba, 2014). The learning rate is 0.0005. $\beta$ is 10. The parameters of the DNN are initialized following a Gaussian distribution with mean 0 and standard deviation 0.02.
305
+
306
+ In Fig. 4, the settings of (a) and (b) are the same as the ones in Fig. 1. For (c), we use a tanh-DNN with widths 10-500-100-1, learning rate 0.0005 under full batch-size training by Adam optimizer (Kingma & Ba, 2014). The parameters of the DNN are initialized by a Gaussian distribution with mean 0 and standard deviation 0.05.
307
+
308
+ # D CENTRAL DIFFERENCE SCHEME AND JACOBI METHOD
309
+
310
+ Consider a one-dimensional (1-d) Poisson’s equation:
311
+
312
+ $$
313
+ \begin{array} { c } { { - \Delta u ( x ) = g ( x ) , \quad x \in \Omega = ( - 1 , 1 ) } } \\ { { } } \\ { { u ( x ) = 0 , \quad x = - 1 , 1 . } } \end{array}
314
+ $$
315
+
316
+ $[ - 1 , 1 ]$ is uniformly discretized into $n + 1$ points with grid size $h = 2 / n$ . The Poisson’s equation in Eq. (9) can be solved by the central difference scheme,
317
+
318
+ $$
319
+ - \Delta u _ { i } = - \frac { u _ { i + 1 } - 2 u _ { i } + u _ { i - 1 } } { ( \delta x ) ^ { 2 } } = g ( x _ { i } ) , \quad i = 1 , 2 , \cdots , n ,
320
+ $$
321
+
322
+ resulting a linear system
323
+
324
+ $$
325
+ \mathbf { } A \mathbf { } u = g ,
326
+ $$
327
+
328
+ where
329
+
330
+ $$
331
+ \begin{array} { r } { A = \left( \begin{array} { c c c c c c } { 2 } & { - 1 } & { 0 } & { 0 } & { \cdots } & { 0 } \\ { - 1 } & { 2 } & { - 1 } & { 0 } & { \cdots } & { 0 } \\ { 0 } & { - 1 } & { 2 } & { - 1 } & { \cdots } & { 0 } \\ { \vdots } & { \vdots } & { \cdots } & & & { \vdots } \\ { 0 } & { 0 } & { \cdots } & { 0 } & { - 1 } & { 2 } \end{array} \right) _ { ( n - 1 ) \times ( n - 1 ) } , } \end{array}
332
+ $$
333
+
334
+ $$
335
+ \pmb { u } = \left( \begin{array} { c } { u _ { 1 } } \\ { u _ { 2 } } \\ { \vdots } \\ { u _ { n - 2 } } \\ { u _ { n - 1 } } \end{array} \right) , \quad \pmb { g } = ( \delta x ) ^ { 2 } \left( \begin{array} { c } { g _ { 1 } } \\ { g _ { 2 } } \\ { \vdots } \\ { g _ { n - 2 } } \\ { g _ { n - 1 } } \end{array} \right) , \quad x _ { i } = 2 \frac { i } { n } .
336
+ $$
337
+
338
+ A class of methods to solve this linear system is iterative schemes, for example, the Jacobi method. Let $\pmb { A } = \pmb { D } - \pmb { L } - \pmb { U }$ , where $_ { D }$ is the diagonal of $\pmb { A }$ , and $\pmb { L }$ and $U$ are the strictly lower and upper triangular parts of $^ { - A }$ , respectively. Then, we obtain
339
+
340
+ $$
341
+ \pmb { u } = \pmb { D } ^ { - 1 } ( \pmb { L } + \pmb { U } ) \pmb { u } + \pmb { D } ^ { - 1 } \pmb { g } .
342
+ $$
343
+
344
+ At step $t \in \mathbb { N }$ , the Jacobi iteration reads as
345
+
346
+ $$
347
+ \pmb { u } ^ { t + 1 } = \pmb { D } ^ { - 1 } ( \pmb { L } + \pmb { U } ) \pmb { u } ^ { t } + \pmb { D } ^ { - 1 } \pmb { g } .
348
+ $$
349
+
350
+ We perform the standard error analysis of the above iteration process. Denote $\pmb { u } ^ { * }$ as the true value obtained by directly performing inverse of $\pmb { A }$ in Eq. (11). The error at step $t + 1$ is $\boldsymbol { e } ^ { t + 1 } = \boldsymbol { u } ^ { t + 1 } - \boldsymbol { u } ^ { * }$ . Then, $e ^ { t + \tilde { 1 } } = R _ { J } \dot { e } ^ { t }$ , where $\begin{array} { r } { \dot { \pmb { R _ { J } } } = \pmb { D } ^ { - 1 } ( \pmb { L } + \pmb { U } ) } \end{array}$ . The converging speed of $e ^ { t }$ is determined by the eigenvalues of $R _ { J }$ , that is,
351
+
352
+ $$
353
+ \lambda _ { k } = \lambda _ { k } ( { \pmb R } _ { J } ) = \cos \frac { k \pi } { n } , \quad k = 1 , 2 , \cdots , n - 1 ,
354
+ $$
355
+
356
+ and the corresponding eigenvector ${ \pmb v } _ { k }$ ’s entry is
357
+
358
+ $$
359
+ v _ { k , i } = \sin { \frac { i k \pi } { n } } , i = 1 , 2 , \cdot \cdot \ , n - 1 .
360
+ $$
361
+
362
+ So we can write
363
+
364
+ $$
365
+ e ^ { t } = \sum _ { k = 1 } ^ { n - 1 } \alpha _ { k } ^ { t } { v } _ { k } ,
366
+ $$
367
+
368
+ where $\alpha _ { k } ^ { t }$ can be understood as the magnitude of $e ^ { t }$ in the direction of ${ \boldsymbol { v } } _ { k }$ . Then,
369
+
370
+ $$
371
+ e ^ { t + 1 } = \sum _ { k = 1 } ^ { n - 1 } \alpha _ { k } ^ { t } R _ { J } { \pmb v } _ { k } = \sum _ { k = 1 } ^ { n - 1 } \alpha _ { k } ^ { t } \lambda _ { k } { \pmb v } _ { k } .
372
+ $$
373
+
374
+ $$
375
+ \alpha _ { k } ^ { t + 1 } = \lambda _ { k } \alpha _ { k } ^ { t } .
376
+ $$
377
+
378
+ Therefore, the converging rate of $e ^ { t }$ in the direction of ${ \pmb v } _ { k }$ is controlled by $\lambda _ { k }$ . Since
379
+
380
+ $$
381
+ \cos { \frac { k \pi } { n } } = - \cos { \frac { ( n - k ) \pi } { n } } ,
382
+ $$
383
+
384
+ the frequencies $k$ and $( n - k )$ are closely related and converge with the same rate. Consider the frequency $k < n / 2$ , $\lambda _ { k }$ is larger for lower frequency. Therefore, lower frequency converges slower in the Jacobi method.
385
+
386
+ # E PROOF OF THEOREMS
387
+
388
+ The activation function we consider is $\sigma ( x ) = \operatorname { t a n h } ( x )$ .
389
+
390
+ $$
391
+ \sigma ( x ) = \operatorname { t a n h } ( x ) = { \frac { \mathrm { e } ^ { x } - \mathrm { e } ^ { - x } } { \mathrm { e } ^ { x } + \mathrm { e } ^ { - x } } } , \quad x \in \mathbb { R } .
392
+ $$
393
+
394
+ For a DNN of one hidden layer with $m$ nodes, 1-d input $x$ and 1-d output:
395
+
396
+ $$
397
+ h ( x ) = \sum _ { j = 1 } ^ { m } a _ { j } \sigma ( w _ { j } x + b _ { j } ) , \quad a _ { j } , w _ { j } , b _ { j } \in \mathbb { R } ,
398
+ $$
399
+
400
+ where $w _ { j } , a _ { j }$ , and $b _ { j }$ are called parameters, in particular, $w _ { j }$ and $a _ { j }$ are called weights, and $b _ { j }$ is also known as a bias. In the sequel, we will also use the notation $\boldsymbol { \theta } \doteq \{ \boldsymbol { \theta } _ { l j } \}$ with $\theta _ { 1 j } = a _ { j }$ , $\theta _ { 2 j } = w _ { j }$ , and $\theta _ { l j } = b _ { j }$ , $j = 1 , \cdots , m$ . Note that $\begin{array} { r } { \hat { \sigma } ( k ) = - \frac { \mathrm { i } \pi } { \sinh ( \pi k / 2 ) } } \end{array}$ where the Fourier transformation and its inverse transformation are defined as follows:
401
+
402
+ $$
403
+ \hat { f } ( k ) = \int _ { - \infty } ^ { + \infty } f ( x ) \mathrm { e } ^ { - \mathrm { i } k x } \mathrm { d } x , \quad f ( x ) = \frac { 1 } { 2 \pi } \int _ { - \infty } ^ { + \infty } \hat { f } ( k ) \mathrm { e } ^ { \mathrm { i } k x } \mathrm { d } k .
404
+ $$
405
+
406
+ The Fourier transform of $\sigma ( w _ { j } x + b _ { j } )$ with $w _ { j } , b _ { j } \in \mathbb { R } , j = 1 , \cdot \cdot \cdot , m$ reads as
407
+
408
+ $$
409
+ \widehat { \sigma ( w _ { j } \cdot + b _ { j } ) } ( k ) = \frac { 2 \pi \mathrm { i } } { | w _ { j } | } \exp \Big ( \frac { \mathrm { i } b _ { j } k } { w _ { j } } \Big ) \frac { 1 } { \exp ( - \frac { \pi k } { 2 w _ { j } } ) - \exp ( \frac { \pi k } { 2 w _ { j } } ) } .
410
+ $$
411
+
412
+ Thus
413
+
414
+ $$
415
+ \hat { h } ( k ) = \sum _ { j = 1 } ^ { m } \frac { 2 \pi a _ { j } \mathrm { i } } { | w _ { j } | } \exp \Big ( \frac { \mathrm { i } b _ { j } k } { w _ { j } } \Big ) \frac { 1 } { \exp \big ( - \frac { \pi k } { 2 w _ { j } } \big ) - \exp \big ( \frac { \pi k } { 2 w _ { j } } \big ) } .
416
+ $$
417
+
418
+ We define the amplitude deviation between DNN output and the target function $f ( x )$ at frequency $k$ as
419
+
420
+ $$
421
+ D ( k ) \triangleq { \hat { h } } ( k ) - { \hat { f } } ( k ) .
422
+ $$
423
+
424
+ Write $D ( k )$ as $D ( k ) = A ( k ) \mathrm { e } ^ { \mathrm { i } \phi ( k ) }$ , where $A ( k ) \in [ 0 , + \infty )$ and $\phi ( k ) \in \mathbb { R }$ are the amplitude and phase of $D ( k )$ , respectively. The loss at frequency $k$ is $\begin{array} { r } { L ( k ) = \frac { 1 } { 2 } \left| D ( k ) \right| ^ { 2 } } \end{array}$ , where $| \cdot |$ denotes the norm of a complex number. The total loss function is defined as: $\begin{array} { r } { L = \int _ { - \infty } ^ { + \infty } L ( k ) \mathrm { d } k } \end{array}$ . Note that according to Parseval’s theorem, this loss function in the Fourier domain is equal to the commonly used loss of mean squared error, that is, $\begin{array} { r } { L = \int _ { - \infty } ^ { + \infty } \frac { 1 } { 2 } ( h ( x ) - f ( x ) ) ^ { 2 } \mathrm { d } x } \end{array}$ . For readers’ reference, we list the partial derivatives of $L ( k )$ with respect to parameters
425
+
426
+ $$
427
+ \begin{array} { r l } & { \frac { \partial L ( k ) } { \partial a _ { j } } = \frac { 2 \pi } { w _ { j } } \sin \big ( \frac { b _ { j } k } { w _ { j } } - \phi ( k ) \big ) E _ { 0 } , } \\ & { \frac { \partial L ( k ) } { \partial w _ { j } } = \left[ \sin \big ( \frac { b _ { j } k } { w _ { j } } - \phi ( k ) \big ) \left( \frac { \pi ^ { 2 } a _ { j } k } { w _ { j } ^ { 3 } } E _ { 1 } - \frac { 2 \pi a _ { j } } { w _ { j } ^ { 2 } } \right) \right. } \\ & { \left. \phantom { \frac { \partial L ( k ) } { \partial a _ { j } } = } - \frac { 2 \pi a _ { j } b _ { j } k } { w _ { j } ^ { 3 } } \cos \big ( \frac { b _ { j } k } { w _ { j } } - \phi ( k ) \big ) \right] E _ { 0 } , } \\ & { \frac { \partial L ( k ) } { \partial b _ { j } } = \frac { 2 \pi a _ { j } b _ { j } k } { w _ { j } ^ { 2 } } \cos \big ( \frac { b _ { j } k } { w _ { j } } - \phi ( k ) \big ) E _ { 0 } , } \end{array}
428
+ $$
429
+
430
+ where
431
+
432
+ $$
433
+ \begin{array} { r l } & { E _ { 0 } = \frac { \mathrm { s g n } ( w _ { j } ) A ( k ) } { \mathrm { e x p } ( \frac { \pi k } { 2 w _ { j } } ) - \mathrm { e x p } ( - \frac { \pi k } { 2 w _ { j } } ) } , } \\ & { E _ { 1 } = \frac { \mathrm { e x p } ( \frac { \pi k } { 2 w _ { j } } ) + \mathrm { e x p } ( - \frac { \pi k } { 2 w _ { j } } ) } { \mathrm { e x p } ( \frac { \pi k } { 2 w _ { j } } ) - \mathrm { e x p } ( - \frac { \pi k } { 2 w _ { j } } ) } . } \end{array}
434
+ $$
435
+
436
+ The descent increment at any direction, say, with respect to parameter $\theta _ { l j }$ , is
437
+
438
+ $$
439
+ \frac { \partial L } { \partial \theta _ { l j } } = \int _ { - \infty } ^ { + \infty } \frac { \partial L ( k ) } { \partial \theta _ { l j } } \mathrm { d } k .
440
+ $$
441
+
442
+ The absolute contribution from frequency $k$ to this total amount at $\theta _ { l j }$ is
443
+
444
+ $$
445
+ \left. \frac { \partial L ( k ) } { \partial \theta _ { l j } } \right. \approx A ( k ) \exp \left( - | \pi k / 2 w _ { j } | \right) F _ { l j } ( \theta _ { j } , k ) ,
446
+ $$
447
+
448
+ where $\theta _ { j } \triangleq \{ w _ { j } , b _ { j } , a _ { j } \}$ , $\theta _ { l j } \in \theta _ { j }$ , $F _ { l j } ( \theta _ { j } , k )$ is a function with respect to $\theta _ { j }$ and $k$ , which can be found in one of Eqs. (24, 25, 26).
449
+
450
+ When the component at frequency $k$ where $\hat { h } ( k )$ is not close enough to $\hat { f } ( k ) , \mathrm { e x p } \left( - | \pi k / 2 w _ { j } | \right)$ would dominate $G _ { l j } ( \theta _ { j } , k )$ for a small $w _ { j }$ . Through the above framework of analysis, we have the following theorem. Define
451
+
452
+ $$
453
+ W = ( w _ { 1 } , w _ { 2 } , \cdot \cdot \cdot , w _ { m } ) ^ { T } \in \mathbb { R } ^ { m } .
454
+ $$
455
+
456
+ Theorem. Consider a one hidden layer DNN with activation function $\sigma ( x ) = \operatorname { t a n h } x$ . For any frequencies $k _ { 1 }$ and $k _ { 2 }$ such that $| \hat { f } ( k _ { 1 } ) | > 0 $ , $| \hat { f } ( k _ { 2 } ) | > 0$ , and $| k _ { 2 } | > | k _ { 1 } | > 0$ , there exist positive constants c and $C$ such that for sufficiently small $\delta$ , we have
457
+
458
+ $$
459
+ \frac { \mu \left( \left\{ W : \left| \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \right| > \left| \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } \right| \quad f o r a l l \quad l , j \right\} \cap B _ { \delta } \right) } { \mu ( B _ { \delta } ) }
460
+ $$
461
+
462
+ where $B _ { \delta } \subset \mathbb { R } ^ { m }$ is a ball with radius $\delta$ centered at the origin and $\mu ( \cdot )$ is the Lebesgue measure.
463
+
464
+ We remark that $c$ and $C$ depend on $k _ { 1 }$ , $k _ { 2 }$ $, | { \hat { f } } ( k _ { 1 } ) | , | { \hat { f } } ( k _ { 2 } ) | , \operatorname { s u p } | a _ { i } | , \operatorname { s u p } | b _ { i } | ,$ and $m$ .
465
+
466
+ Proof. To prove the statement, it is sufficient to show that $\mu ( S _ { l j , \delta } ) / \mu ( B _ { \delta } ) \le C \exp ( - c / \delta )$ for each $l , j$ , where
467
+
468
+ $$
469
+ S _ { l j , \delta } : = \left\{ W \in B _ { \delta } : \left| \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \right| \leq \left| \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } \right| \right\} .
470
+ $$
471
+
472
+ We prove this for $S _ { 1 j , \delta }$ , that is, $\theta _ { l j } = a _ { j }$ . The proofs for $\theta _ { l j } = w _ { j }$ and $b _ { j }$ are similar. Without loss of generality, we assume that $k _ { 1 } , k _ { 2 } > 0$ , $b _ { j } > 0$ , and $w _ { j } \neq 0$ , $j = 1 , \cdots , m$ . According to Eq. (24), the inequality $\begin{array} { r } { | \frac { \partial L ( k _ { 1 } ) } { \partial a _ { j } } | \leq | \frac { \partial L ( k _ { 2 } ) } { \partial a _ { j } } | } \end{array}$ is equivalent to
473
+
474
+ $$
475
+ \frac { A ( k _ { 2 } ) } { A ( k _ { 1 } ) } \lvert \frac { \exp ( \frac { \pi k _ { 1 } } { 2 w _ { j } } ) - \exp ( - \frac { \pi k _ { 1 } } { 2 w _ { j } } ) } { \exp ( \frac { \pi k _ { 2 } } { 2 w _ { j } } ) - \exp ( - \frac { \pi k _ { 2 } } { 2 w _ { j } } ) } \Biggr \rvert \cdot \left. \sin \left( \frac { b _ { j } k _ { 2 } } { w _ { j } } - \phi ( k _ { 2 } ) \right) \right. \geq \left| \sin \left( \frac { b _ { j } k _ { 1 } } { w _ { j } } - \phi ( k _ { 1 } ) \right) \right.
476
+ $$
477
+
478
+ Note that $\begin{array} { r } { | \hat { h } ( k ) | \le C \sum _ { j = 1 } ^ { m } \frac { | a _ { j } | } { | w _ { j } | } \exp \bigl ( - \frac { \pi k } { 2 | w _ { j } | } \bigr ) } \end{array}$ for $k > 0$ . Thus
479
+
480
+ $$
481
+ \operatorname * { l i m } _ { W \to 0 } \hat { h } ( k ) = 0 \quad \mathrm { a n d } \quad \operatorname * { l i m } _ { W \to 0 } D ( k ) = - \hat { f } ( k ) .
482
+ $$
483
+
484
+ Therefore,
485
+
486
+ $$
487
+ \operatorname* { l i m } _ { W \to 0 } A ( k ) = | \hat { f } ( k ) | \quad \mathrm { a n d } \quad \operatorname* { l i m } _ { W \to 0 } \phi ( k ) = \pi + \arg ( \hat { f } ( k ) ) .
488
+ $$
489
+
490
+ For $W \in B _ { \delta }$ with sufficiently small $\delta$ , $A ( k _ { 1 } ) > { \textstyle { \frac { 1 } { 2 } } } | { \hat { f } } ( k _ { 1 } ) | > 0$ and $A ( k _ { 2 } ) < 2 | \hat { f } ( k _ { 2 } ) |$ . Also note that $\begin{array} { r } { | \sin ( \frac { b _ { j } k _ { 2 } } { w _ { j } } - \phi ( k _ { 2 } ) ) | \leq 1 } \end{array}$ and that for sufficiently small $\delta$ ,
491
+
492
+ $$
493
+ \left| \frac { \exp ( \frac { \pi k _ { 1 } } { 2 w _ { j } } ) - \exp ( - \frac { \pi k _ { 1 } } { 2 w _ { j } } ) } { \exp ( \frac { \pi k _ { 2 } } { 2 w _ { j } } ) - \exp ( - \frac { \pi k _ { 2 } } { 2 w _ { j } } ) } \right| \leq 2 \exp \Big ( \frac { - \pi ( k _ { 2 } - k _ { 1 } ) } { 2 | w _ { j } | } \Big ) .
494
+ $$
495
+
496
+ Thus, inequality (32) implies that
497
+
498
+ $$
499
+ \Big | \sin \Big ( \frac { b _ { j } k _ { 1 } } { w _ { j } } - \phi ( k _ { 1 } ) \Big ) \Big | \le \frac { 8 | \hat { f } ( k _ { 2 } ) | } { | \hat { f } ( k _ { 1 } ) | } \exp \Big ( - \frac { \pi ( k _ { 2 } - k _ { 1 } ) } { 2 | w _ { j } | } \Big ) .
500
+ $$
501
+
502
+ Noticing that $\begin{array} { r } { \frac { 2 } { \pi } | x | \leq | \sin x | ( | x | \leq \frac { \pi } { 2 } ) } \end{array}$ and Eq. (34), we have for $W \in S _ { l j , \delta }$ , for some $q \in \mathbb { Z }$ ,
503
+
504
+ $$
505
+ \left| \frac { b _ { i } k _ { 1 } } { w _ { i } } - \mathrm { a r g } ( \hat { f } ( k _ { 1 } ) ) - q \pi \right| \leq \frac { 8 \pi | \hat { f } ( k _ { 2 } ) | } { | \hat { f } ( k _ { 1 } ) | } \exp \Big ( - \frac { \pi ( k _ { 2 } - k _ { 1 } ) } { 2 \delta } \Big )
506
+ $$
507
+
508
+ that is,
509
+
510
+ $$
511
+ - c _ { 1 } \exp ( - c _ { 2 } / \delta ) + q \pi + \arg ( \hat { f } ( k _ { 1 } ) ) \leq \frac { b _ { i } k _ { 1 } } { w _ { i } } \leq c _ { 1 } \exp ( - c _ { 2 } / \delta ) + q \pi + \arg ( \hat { f } ( k _ { 1 } ) ) ,
512
+ $$
513
+
514
+ where $\begin{array} { r } { c _ { 1 } = \frac { 8 \pi | \hat { f } ( k _ { 2 } ) | } { | \hat { f } ( k _ { 1 } ) | } } \end{array}$ and $c _ { 2 } = \pi ( k _ { 2 } - k _ { 1 } )$ . Define $I : = I ^ { + } \cup I ^ { - }$ where
515
+
516
+ $$
517
+ I ^ { + } : = \{ w _ { j } > 0 : W \in S _ { 1 j , \delta } \} , \quad I ^ { - } : = \{ w _ { j } < 0 : W \in S _ { 1 j , \delta } \} .
518
+ $$
519
+
520
+ For $w _ { j } > 0$ , we have for some $q \in \mathbb { Z }$ ,
521
+
522
+ $$
523
+ 0 < \frac { b _ { j } k _ { 1 } } { c _ { 1 } \exp ( - c _ { 2 } / \delta ) + q \pi + \arg ( \hat { f } ( k _ { 1 } ) ) } \leq w _ { j } \leq \frac { b _ { j } k _ { 1 } } { - c _ { 1 } \exp ( - c _ { 2 } / \delta ) + q \pi + \arg ( \hat { f } ( k _ { 1 } ) ) } .
524
+ $$
525
+
526
+ Since $W \in B _ { \delta }$ and $c _ { 1 } \exp ( - c _ { 2 } / \delta ) + \arg ( \hat { f } ( k _ { 1 } ) ) \leq 2 \pi$ , we have $\begin{array} { r } { \frac { b _ { j } k _ { 1 } } { 2 \pi + q \pi } \leq w _ { j } \leq \delta } \end{array}$ . Then Eq. (40) only holds for some large $q$ , more precisely, $\begin{array} { r } { q \ge q _ { 0 } : = \frac { b _ { j } k } { \pi \delta } - 2 } \end{array}$ bjkπδ − 2. Thus we obtain the estimate for the (one-dimensional) Lebesgue measure of $I ^ { + }$
527
+
528
+ $$
529
+ \begin{array} { r l } & { \mu ( I ^ { + } ) \leq \displaystyle \sum _ { q = q _ { 0 } } ^ { \infty } \left| \frac { b _ { j } k _ { 1 } } { - c _ { 1 } \exp ( - c _ { 2 } / \delta ) + q \pi + \arg ( \hat { f } ( k _ { 1 } ) ) } - \frac { b _ { j } k _ { 1 } } { c _ { 1 } \exp ( - c _ { 2 } / \delta ) + q \pi + \arg ( \hat { f } ( k _ { 1 } ) ) } \right| } \\ & { \quad \leq 2 | b _ { j } | k _ { 1 } c _ { 1 } \exp ( - c _ { 2 } / \delta ) \cdot \displaystyle \sum _ { q = q _ { 0 } } ^ { \infty } \frac { 1 } { ( q \pi + \arg ( \hat { f } ( k _ { 1 } ) ) ) ^ { 2 } - ( c _ { 1 } \exp ( - c _ { 2 } / \delta ) ) ^ { 2 } } } \\ & { \quad \leq C \exp ( - c / \delta ) . } \end{array}
530
+ $$
531
+
532
+ The similar estimate holds for $\mu ( I ^ { - } )$ , and hence $\mu ( \underline { { I } } ) \leq C \exp ( - c / \delta )$ . For $W \in B _ { \delta }$ , the $( m - 1 )$ dimensional vector $( w _ { 1 } , \cdot \cdot \cdot , w _ { j - 1 } , w _ { j + 1 } , \cdot \cdot \cdot , w _ { m } ) ^ { T }$ is in a ball with radius $\delta$ in $\mathbb { R } ^ { m - 1 }$ . Therefore, we final arrive at the desired estimate
533
+
534
+ $$
535
+ \frac { \mu ( S _ { 1 j , \delta } ) } { \mu ( B _ { \delta } ) } \leq \frac { \mu ( I ) \omega _ { m - 1 } \delta ^ { m - 1 } } { \omega _ { m } \delta ^ { m } } \leq C \exp ( - c / \delta ) ,
536
+ $$
537
+
538
+ where $\omega _ { m }$ is the volume of a unit ball in $\mathbb { R } ^ { m }$ .
539
+
540
+ Theorem. Considering a DNN of one hidden layer with activation function $\sigma ( x ) = \operatorname { t a n h } ( x )$ . Suppose the target function has only two non-zero frequencies $k _ { 1 }$ and $k _ { 2 }$ , that is, $| { \hat { f } } ( k _ { 1 } ) | > 0$ , $| \hat { f } ( k _ { 2 } ) | > 0 ;$ , and $| \boldsymbol { k } _ { 2 } | > | \boldsymbol { k } _ { 1 } | > 0$ , and $| { \hat { f } } ( k ) | = 0$ for $k \neq k _ { 1 } , k _ { 2 }$ . Consider the loss function of $L = L ( k _ { 1 } ) + L ( k _ { 2 } )$ with gradient descent training. Denote
541
+
542
+ $$
543
+ \mathcal { S } = \left\{ \frac { \partial L ( k _ { 1 } ) } { \partial t } \leq 0 , \frac { \partial L ( k _ { 1 } ) } { \partial t } \leq \frac { \partial L ( k _ { 2 } ) } { \partial t } \right\} ,
544
+ $$
545
+
546
+ that is, $L ( k _ { 1 } )$ decreases faster than $L ( k _ { 2 } )$ . There exist positive constants c and $C$ such that for sufficiently small $\delta$ , we have
547
+
548
+ $$
549
+ \frac { \mu \left( \left\{ W : { \cal S } \mathrm { ~ \ h o l d s } \right\} \cap { \cal B } _ { \delta } \right) } { \mu ( { \cal B } _ { \delta } ) } \geq 1 - C \exp ( - c / \delta ) ,
550
+ $$
551
+
552
+ where $B _ { \delta } \subset \mathbb { R } ^ { m }$ is a ball with radius $\delta$ centered at the origin and $\mu ( \cdot )$ is the Lebesgue measure.
553
+
554
+ Proof. By gradient descent algorithm, we obtain
555
+
556
+ $$
557
+ \begin{array} { l } { \displaystyle \frac { \partial L ( k _ { 1 } ) } { \partial t } = \sum _ { l , j } \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \frac { \partial \theta _ { l j } } { \partial t } } \\ { \displaystyle = - \sum _ { l , j } \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \frac { \partial ( L ( k _ { 1 } ) + L ( k _ { 2 } ) ) } { \partial \theta _ { l j } } } \\ { \displaystyle = - \sum _ { l , j } \left( \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \right) ^ { 2 } - \sum _ { l , j } \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } , } \end{array}
558
+ $$
559
+
560
+ $$
561
+ \frac { \partial L ( k _ { 2 } ) } { \partial t } = - \sum _ { l , j } \bigg ( \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } \bigg ) ^ { 2 } - \sum _ { l , j } \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } ,
562
+ $$
563
+
564
+ and
565
+
566
+ $$
567
+ \frac { \partial L } { \partial t } = \frac { \partial \left( L ( k _ { 1 } ) + L ( k _ { 2 } ) \right) } { \partial t } = - \sum _ { l , j } \left( \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } + \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } \right) ^ { 2 } \leq 0 .
568
+ $$
569
+
570
+ To obtain
571
+
572
+ $$
573
+ 0 < \frac { \partial L ( k _ { 1 } ) } { \partial t } - \frac { \partial L ( k _ { 2 } ) } { \partial t } = - \sum _ { l , j } \left[ \left( \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \right) ^ { 2 } - \left( \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } \right) ^ { 2 } \right] ,
574
+ $$
575
+
576
+ it is sufficient to have
577
+
578
+ $$
579
+ \left| \frac { \partial L ( k _ { 1 } ) } { \partial \theta _ { l j } } \right| > \left| \frac { \partial L ( k _ { 2 } ) } { \partial \theta _ { l j } } \right| .
580
+ $$
581
+
582
+ Eqs. (43, 44) also yield to
583
+
584
+ $$
585
+ \frac { \partial L ( k _ { 1 } ) } { \partial t } < 0 .
586
+ $$
587
+
588
+ Therefore, Eq. (45) is a sufficient condition for $s$ . Based on the theorem 1, we have proved the theorem 2. □
589
+
590
+ ![](images/8d3a8e2431446d5619f51b1ded986f1e92fff62c137fff4bce0786f9860bea9e.jpg)
591
+ Figure 6: F-Principle in fitting a natural image. The training data are all pixels whose horizontal indices are odd. We initialize DNN parameters by a Gaussian distribution with mean 0 and standard deviation 0.08 (small initial) or 1 (large initial). (a) True image. (b-g) correspond to the case of the small initial parameters. (f-h) correspond to the case of the large initial parameters. (b) DNN outputs of all pixels at different training epochs. (c, g) DNN outputs (blue) and the true gray-scale (red) of test pixels at the red dashed position in (a). (d) $| { \hat { h } } ( k ) |$ (green) at certain training epoch and $| { \hat { f } } ( k ) |$ (red) at the red dashed position in (a), as a function of frequency index. Selected peaks are marked by black dots. (e, h) $\Delta _ { F } ( k )$ computed by the training data at different epochs for the selected frequencies in (d). (f) DNN outputs of training pixels (left) and all pixels (right) after training. We use a tanh-DNN with widths 2-400-200-100-1. We train the DNN with the full batch and learning rate 0.0002. The DNN is trained by Adam optimizer (Kingma & Ba, 2014) with the MSE loss function.
592
+
593
+ # F MEMORIZING 2-D IMAGE
594
+
595
+ We train a DNN to fit a natural image (See Fig. 6(a)), a mapping from coordinate $( x , y )$ to gray scale strength, where the latter is subtracted by its mean and then normalized by the maximal absolute value. First, we initialize DNN parameters by a Gaussian distribution with mean 0 and standard deviation 0.08 (initialization with small parameters). From the snapshots during the training process, we can see that the DNN captures the image from coarse-grained low frequencies to detailed high frequencies (Fig. 6(b)). As an illustration of the F-Principle, we study the Fourier transform of the image with respect to $x$ for a fixed $y$ (red dashed line in Fig. 6(a), denoted as the target function $f ( x )$ in the spatial domain). The DNN can well capture this 1-d slice after training as shown in Fig. 6(c). Fig. 6(d) displays the amplitudes $| { \hat { f } } ( k ) |$ of the first 40 frequency components. Due to the small initial parameters, as an example in Fig. 6(d), when the DNN is fitting low-frequency components, high frequencies stay relatively small. As the relative error shown in Fig. 6(e), the first five frequency peaks converge from low to high in order.
596
+
597
+ Next, we initialize DNN parameters by a Gaussian distribution with mean 0 and standard deviation 1 (initialization with large parameters). After training, the DNN can well capture the training data, as shown in the left in Fig. 6(f). However, the DNN output at the test pixels are very noisy, as shown in the right in Fig. 6(f). For the pixels at the red dashed lines in Fig. 6(a), as shown in Fig. 6(g), the DNN output fluctuates a lot. Compared with the case of small initial parameters, as shown in Fig. 6(h), the convergence order of the first five frequency peaks do not have a clear order.
md/train/Skn9Shcxe/Skn9Shcxe.md ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HIGHWAY AND RESIDUAL NETWORKS LEARN UNROLLED ITERATIVE ESTIMATION
2
+
3
+ Klaus Greff The Swiss AI Lab IDSIA (USI-SUPSI)
4
+
5
+ Rupesh K. Srivastava & Jürgen Schmidhuber
6
+ The Swiss AI Lab IDSIA (USI-SUPSI) & NNAISENSE, Lugano, Switzerland
7
+ {klaus,rupesh,juergen}@idsia.ch
8
+
9
+ # ABSTRACT
10
+
11
+ The past year saw the introduction of new architectures such as Highway networks (Srivastava et al., 2015a) and Residual networks (He et al., 2015) which, for the first time, enabled the training of feedforward networks with dozens to hundreds of layers using simple gradient descent. While depth of representation has been posited as a primary reason for their success, there are indications that these architectures defy a popular view of deep learning as a hierarchical computation of increasingly abstract features at each layer.
12
+
13
+ In this report, we argue that this view is incomplete and does not adequately explain several recent findings. We propose an alternative viewpoint based on unrolled iterative estimation—a group of successive layers iteratively refine their estimates of the same features instead of computing an entirely new representation. We demonstrate that this viewpoint directly leads to the construction of Highway and Residual networks. Finally we provide preliminary experiments to discuss the similarities and differences between the two architectures.
14
+
15
+ # 1 INTRODUCTION
16
+
17
+ Deep learning can be thought of as learning many levels of representation of the input which form a hierarchy of concepts (Deng & Yu, 2014; Goodfellow et al., 2016; LeCun et al., 2015) (but note that this is not the only view: cf. Schmidhuber (2015)). With fixed computational budget, deeper architectures are believed to possess greater representational power and, consequently, higher performance than shallower models. Intuitively, each layer of a deep neural network computes a new level of representation. For convolutional networks, Zeiler & Fergus (2014) visualized the features computed by each layer, and demonstrated that they in fact become increasingly abstract with depth. We refer to this way of thinking about neural networks as the representation view, which probably dates back to Hubel & Wiesel (1962). The representation view links the layers in a network to the abstraction levels of their representations, and as such represents a pervasive assumption in many recent publications including He et al. (2015) who describe the success of their Residual networks like this: “Solely due to our extremely deep representations, we obtain a $2 8 \%$ relative improvement on the COCO object detection dataset.”
18
+
19
+ ![](images/c72bd1edfa4f620b0d47ab0e9d8ff30d77ec65bad1319f56b2b35cfd2577ead1.jpg)
20
+ Figure 1: Illustrating our usage of blocks and stages in Highway and Residual networks.
21
+
22
+ Surprisingly, increasing the depth of a network beyond a certain point often leads to a decline in performance even on the training set (Srivastava et al., 2015a). Since adding more layers cannot decrease representational power, this phenomenon is usually attributed to the vanishing gradient problem (Hochreiter, 1991). Therefore, even though deeper models are more powerful in principle, they often fall short in practice.
23
+
24
+ Recently, training feedforward networks with hundreds of layers has become feasible through the invention of Highway networks Srivastava et al. (2015a) and Residual networks (ResNets; He et al. 2015). The latter have been widely successful in computer vision, advancing the state of the art on many benchmarks and winning several pattern recognition competitions (He et al., 2015), while Highway networks have been used to improve language modeling (Kim et al., 2015; Jozefowicz et al., 2016; Zilly et al., 2016) and translation (Lee et al., 2016). Both architectures have been introduced with the explicit goal of training deeper models.
25
+
26
+ There are, however, some surprising findings that seem to contradict the applicability of the representation view to these very deep networks. For example, it has been reported that removing almost any layer from a trained Highway or Residual network has only minimal effect on its overall performance (Srivastava et al., 2015b; Veit et al., 2016). This idea has been extended to a layerwise dropout as a regularizer for ResNets (Huang et al., 2016b). But if each layer supposedly builds a new level of representation from the previous one, then removing any layer should critically disrupt the input for the following layer. So how is it possible that doing so seems to have only a negligible effect on the network output? Veit et al. (2016) even demonstrated that shuffling some of the layers in a trained ResNet barely affects performance.
27
+
28
+ It has been argued that ResNets are better understood as ensembles of shallow networks (Huang et al., 2016b; Veit et al., 2016; Abdi & Nahavandi, 2016). According to this interpretation, ResNets implicitly average exponentially many subnetworks, each of which only use a subset of the layers. But the question remains open as to how a layer in such a subnetwork can successfully operate with changing input representations. This, along with other findings, begs the question as to whether the representation view is appropriate for understanding these new architectures.
29
+
30
+ In this paper, we propose a new interpretation that reconciles the representation view with the operation of Highway and Residual networks: functional blocks1 in these networks do not compute entirely new representations; instead, they engage in an unrolled iterative estimation of representations that refine/improve upon their input representation, thus preserving feature identity. The transition to a new level of representation occurs when a dimensionality change—through projection—separates two groups of blocks which we refer to as a stage (Figure 1). Taking this perspective, we are able to explain previously elusive findings such as the effects of lesioning and shuffling. Furthermore, we formalize this notion and use it to directly derive Residual and Highway networks. Finally, we present some preliminary experiments to compare these two architectures and investigate some of their relative advantages and disadvantages.
31
+
32
+ # 2 CHALLENGING THE REPRESENTATION VIEW
33
+
34
+ This section provides a brief survey of some the findings and points of contention that seem to contradict a representation view of Highway and Residual networks.
35
+
36
+ Staying Close to the Inputs. The success of ResNets has been partly attributed to the fact that they obviate the need to learn the identity mapping, which is difficult. However, learning the negative identity (so that a feature can replaced by a higher level one) should be at least as difficult. The fact that the residual form is useful indicates that Residual blocks typically stay close to the input representation, rather than replacing it.
37
+
38
+ The analysis by Srivastava et al. (2015a) shows that in trained Highway networks, the activity of the transform gates is often sparse for each individual sample, while their average activity over all training samples is non-sparse. Most units learn to copy their inputs and only replace features selectively. Again, this means that most of the features are propagated unchanged rather than being combined and changed between layers—an observation that contradicts the idea of building a new level of abstraction at each layer.
39
+
40
+ ![](images/248158b1743dda819549c3d98d7aba61f66c22d696af5bc96bc30c387844b3c9.jpg)
41
+ Figure 2: (a) A single neural network layer that directly computes the desired representation. (b) The unrolled iterative estimation stage (e.g. from a Residual network) stretches the computation over three layers by first providing a noisy estimate of that representation, but then iteratively refines it over the next to layers. (c) A classic group of three layers can also distribute the computation, but they would produce a new representation at each layer. The iterative estimation stage in (b) can be seen as a middle ground between a single classic neural network layer, (a), and multiple classic layers, (c).
42
+
43
+ Lesioning. If it were true that each layer computes a completely new set of features, then removing a layer from a trained network would completely change the input distribution for the next layer. We would then expect to see the overall performance drop to almost chance level. This is in fact what Veit et al. (2016) find for the 15-layer VGG network on CIFAR-10: removing any layer from the trained network sets the classification error to around $90 \%$ . But the lesioning studies conducted on Highway networks (Srivastava et al., 2015a) and ResNets (Veit et al., 2016) paint an entirely different picture: only a minor drop in performance is observed for any removed layer. This drop is more pronounced for the early layers and the layers that change dimensionality (i.e. number of filter maps and map sizes), but performance is always still far superior to random guessing.
44
+
45
+ Huang et al. (2016b) take lesioning one step further and drop out entire ResNet layers as a regularizer during training. They describe their method as “[...] a training procedure that enables the seemingly contradictory setup to train short networks and use deep networks at test time”. The regularization effect of this procedure is explained as inducing an implicit ensemble of many shallow networks akin to normal dropout. Note that this explanation requires a departure from the representation view in that each layer has to cope with the possibility of having its entire input layer removed. Otherwise, most shallow networks in the ensemble would perform no better than chance level, just like the lesioned VGG net.
46
+
47
+ Reshuffling. The link between layers and representation levels may be most clearly challenged by an experiment in Veit et al. (2016) where the layers of a trained 110-layer ResNet are reshuffled. Remarkably, error increases smoothly with the amount of reshuffling, and many re-orderings result only in a small increase in error. Note, however, that only layers within a stage are reshuffled, since the dimensionality of the swapped layers must match. Veit et al. (2016) take these results as evidence that ResNets behave as ensembles of exponentially many shallow networks.
48
+
49
+ # 3 UNROLLED ITERATIVE ESTIMATION VIEW
50
+
51
+ The representation view has guided neural networks research by providing intuitions about the “meaning” of their computations. In this section we will augment the representation view to deal with the incongruities and hopefully enable future research on these very deep architectures to reap the same benefits. The target of our modification is the mapping of layers/blocks of the network to levels of abstraction.
52
+
53
+ At this point it is interesting to note that the one-to-one mapping of neural network layers to levels of abstraction is an implicit assumption rather than a stated part of the representation view. A recent deep learning textbook (Goodfellow et al., 2016) explicitly states: “[. . . ] the depth flowchart of the computations needed to compute the representation of each concept may be much deeper than the graph of the concepts themselves.” So in a strict sense the evidence from Section 2 does not in fact contradict a representation view of Residual and Highway networks. It only conflicts with the idea that each layer forms a new level of representation. We can therefore reconcile very deep networks with the representation view by explicitly giving up this assumption.
54
+
55
+ Unrolled Iterative Estimation. We propose to think of blocks in Highway and Residual networks as performing unrolled iterative estimation of representations. By that we mean that the blocks in a stage work together to estimate and iteratively refine a single level of representation. The first layer in that stage already provides a (rough) estimate for the final representation. Subsequent layer in the stage then refine that estimate without changing the level of representation. So if the first layer in a stage detects simple shapes, then the rest of the layers in that stage will work at that level too.
56
+
57
+ A good initial estimate for a representation should on average be correct even though it might have high variance. We can thus formalize the notion of "preserving feature identity" as being an unbiased estimator for the target representation. This means the units $\mathbf { \bar { \boldsymbol { a } } } _ { i } ^ { k }$ in different layers $k \in \{ 1 \ldots L \}$ are all estimators for the same latent feature $A _ { i }$ , where $A _ { i }$ refers to the (unknown) value towards which the $i$ -th feature is converging. The unbiased estimator condition can then be written as the expected difference between the estimator and the final feature:
58
+
59
+ $$
60
+ \underset { \mathbf { x } \in \mathbf { X } } { \mathbb { E } } [ a _ { i } ^ { k } - A _ { i } ] = 0 .
61
+ $$
62
+
63
+ Note that both the $a _ { i } ^ { k } \mathrm { s }$ and $A _ { i }$ depend on the samples $\mathbf { x }$ of the data-generating distribution $\boldsymbol { X }$ and are thus random variables. The fact that they both depend on the same $\mathbf { x }$ is also the reason we need to keep them within the same expectation and cannot just write $\mathbb { E } [ a _ { i } ^ { k } ] = A _ { i }$ .
64
+
65
+ Feature Identity. A stage that performs iterative estimation is different from one that computes a new level of representation at each block because it preserves the feature identity. They operate differently even if their structure and their final representations are equivalent, because of the way they treat intermediate representations. This is illustrated in Figure 2, where the iterative estimation stage, (b), is contrasted with a single classic block (a), and multiple classic blocks, (c). In the iterative estimation case (middle), all the blocks within the stage produce estimates of the same representation (indicated by having different shades of blue). Whereas, in a classical stage, (c), the intermediate representations would all be different (represented by different colors).
66
+
67
+ # 3.1 HIGHWAY AND RESIDUAL NETWORKS
68
+
69
+ Both Highway and Residual networks address the problem of training very deep architectures by improving the error flow via identity skip connections that allow units to copy their inputs on to the next layer unchanged. This design principle was originally introduced in Long Short-Term Memory (LSTM) recurrent networks (Hochreiter & Schmidhuber, 1997) and mathematically these architectures correspond to a simplified LSTM network, "unrolled" over time.
70
+
71
+ In Highway Networks, for each unit there are two additional gating units, which control how much (typically non-linear) transformation is applied (transform gate $T$ ) and how much to just copy of the activation from the corresponding unit in the previous layer (carry gate $C$ ). Let $H ( \mathbf { x } )$ be a nonlinear parametric function of the inputs, $\mathbf { x }$ , (typically an affine projection followed by pointwise non-linearity). Then a traditional feed-forward network layer can be written as:
72
+
73
+ $$
74
+ y ( \mathbf { x } ) = H ( \mathbf { x } ) .
75
+ $$
76
+
77
+ By adding two additional units, $T ( \mathbf { x } )$ and $C ( \mathbf { x } )$ a Highway layer can be written as:
78
+
79
+ $$
80
+ y ( \mathbf { x } ) = H ( \mathbf { x } ) \cdot T ( \mathbf { x } ) + \mathbf { x } \cdot C ( \mathbf { x } ) .
81
+ $$
82
+
83
+ Usually this is further simplified by coupling the gates, i.e. setting $C ( \mathbf { x } ) = 1 - T ( \mathbf { x } )$ :
84
+
85
+ $$
86
+ y ( \mathbf { x } ) = H ( \mathbf { x } ) \cdot T ( \mathbf { x } ) + \mathbf { x } \cdot ( 1 - T ( \mathbf { x } ) ) .
87
+ $$
88
+
89
+ ResNets simplify the Highway networks approach by reformulating the desired transformation as the input plus a residual $F ( \mathbf { x } )$ . The rationale behind this is that it is easier to optimize the residual form than the original function. For the extreme case where the desired function is the identity, this amounts to the trivial task of pushing the residual to zero:
90
+
91
+ $$
92
+ y ( \mathbf { x } ) = F ( \mathbf { x } ) + \mathbf { x } .
93
+ $$
94
+
95
+ As with Highway networks, Residual networks can be viewed as unfolded recurrent neural networks of the particular mathematical form (one with an identity self-connection) of an LSTM cell. This has been explicitly pointed out by Liao & Poggio (2016), who also argue that this could allow Residual networks to emulate recurrent processing in the visual cortex and thus adds to their biological plausibility. Setting $F ( \mathbf { x } ) = T ( \mathbf { x } ) [ H ( \mathbf { x } ) - \mathbf { x } ]$ converts Equation 5 to Equation 4 showing that both formulations differ only in the precise functional form for $F$ . Alternatively, Residual networks can be seen as a particular case of Highway networks where $C ( \mathbf { x } ) = T ( \mathbf { x } ) = \mathbf { 1 }$ and are not learned.
96
+
97
+ # 3.2 DERIVING RESIDUAL NETWORKS
98
+
99
+ Equation 1 can be used to directly derive the ResNet equation (Equation 5). First, it follows that the expected difference between outputs of two consecutive blocks in a stage is zero:
100
+
101
+ $$
102
+ \begin{array} { r } { \mathbb { E } [ a _ { i } ^ { k } - A _ { i } ] - \mathbb { E } [ a _ { i } ^ { k - 1 } - A _ { i } ] = 0 } \\ { \mathbb { E } [ a _ { i } ^ { k } - a _ { i } ^ { k - 1 } ] = 0 . } \end{array}
103
+ $$
104
+
105
+ If we write feature $a _ { i } ^ { k }$ as a combination of $a _ { i } ^ { k - 1 }$ and a residual $F _ { i }$ , it follows from Equation 7 that the residual has to be zero-mean:
106
+
107
+ $$
108
+ \begin{array} { c } { { a _ { i } ^ { k } = a _ { i } ^ { k - 1 } + F _ { i } } } \\ { { \implies \mathbb { E } [ F _ { i } ] = 0 . } } \end{array}
109
+ $$
110
+
111
+ Therefore, if the residual block $F$ has a zero mean over the training set, then Equation 1 holds and it can be said to maintain feature identity. Note that this is a reasonable assumption, especially when using batch normalization.
112
+
113
+ # 3.3 DERIVING HIGHWAY NETWORKS
114
+
115
+ The coupled Highway formula (Equation 4) can be directly derived as an alternative way of ensuring Equation 1 if we assume a $H _ { i }$ to be a new estimate of $A _ { i }$ . Highway layers then result from the optimal way to linearly combine the former estimate $a _ { i } ^ { k - 1 }$ with $H _ { i }$ such that the resulting $a _ { i } ^ { k }$ is a minimum variance estimate of $A _ { i }$ , i.e. requiring $\mathbb { E } [ a _ { i } ^ { k } - A _ { i } ] = 0$ and that $\mathrm { V a r } [ a _ { i } ^ { k } - A _ { i } ]$ is minimal.
116
+
117
+ Let $\alpha _ { 1 } = \mathrm { V a r } [ a _ { i } ^ { k } - A _ { i } ] - \mathrm { C o v } [ a _ { i } ^ { k } - A _ { i } , a _ { i } ^ { k } - H _ { i } ]$ and $\alpha _ { 2 } = \mathrm { V a r } [ H _ { i } - A _ { i } ] - \mathrm { C o v } [ a _ { i } ^ { k } - A _ { i } , a _ { i } ^ { k } - H _ { i } ]$ , then the optimal linear way of combining them is then given by the following estimator (see Section A.1 for derivation):
118
+
119
+ $$
120
+ a _ { i } ^ { k + 1 } = \frac { \alpha _ { 2 } } { \alpha _ { 1 } + \alpha _ { 2 } } a _ { i } ^ { k } + \frac { \alpha _ { 1 } } { \alpha _ { 1 } + \alpha _ { 2 } } H _ { i } .
121
+ $$
122
+
123
+ If we use a neural network to compute $H _ { i }$ and another one to compute $\begin{array} { r } { T _ { i } = \frac { \alpha _ { 1 } } { \alpha _ { 1 } + \alpha _ { 2 } } } \end{array}$ , then we recover the Highway formula:
124
+
125
+ $$
126
+ a _ { i } ^ { k } = H _ { i } \cdot T _ { i } + a _ { i } ^ { k - 1 } \cdot ( 1 - T _ { i } ) ,
127
+ $$
128
+
129
+ where $H _ { i }$ and $T _ { i }$ are both functions of the previous layer activations $\pmb { a } ^ { k - 1 }$ .
130
+
131
+ # 4 DISCUSSION
132
+
133
+ # 4.1 IMPLICATIONS FOR HIGHWAY NETWORKS
134
+
135
+ In Highway networks with coupled gates the mixing coefficients always sum to one. This ensures that the expectation of the new estimate will always be correct (cf. Equation 14). The precise value of mixing will only determine the variance of the new estimate. We can bound this variance to be less or equal to the variance of the previous layer by restricting both mixing coefficients to be positive. In Highway networks this is done by using the logistic sigmoid activation function for the transform gate $T _ { i }$ . This restriction is equivalent to the assumption of $\alpha _ { 1 }$ and $\alpha _ { 2 }$ having the same sign. This assumption holds, for example, if the error of the new estimate $H _ { i } - A _ { i }$ is independent of the old $a _ { i } ^ { k - 1 } - A _ { i }$ . Because in that case their covariance is zero and thus both alphas are positive.
136
+
137
+ Using the logistic sigmoid as activation function for the transform gate further means that the preactivation of $T _ { i }$ implicitly estimates $\log \left( { \frac { \alpha _ { 2 } } { \alpha _ { 1 } } } \right)$ . This is easy to see because the logistic sigmoid of that
138
+
139
+ ![](images/09b7434de4705a1639d5c3d95d17608800a3f37dc81b0d8ddeef20cf504d2412.jpg)
140
+ Figure 3: Experimental corroboration of Equation 1. The average estimation error – an empirical estimate of the LHS in Equation $1 -$ for each block of each stage ( $\mathbf { \bar { X } }$ -axis). It stays close to zero in all stages of a 50-layer ResNet trained on the ILSVRC-2015 dataset. The standard deviation of the estimation error decreases as depth increases in each stage (left to right), indicating iterative refinement of the representations.
141
+
142
+ term is
143
+
144
+ $$
145
+ \frac { 1 } { 1 + e ^ { \log ( \frac { \alpha _ { 2 } } { \alpha _ { 1 } } ) } } = \frac { 1 } { 1 + \frac { \alpha _ { 2 } } { \alpha _ { 1 } } } = \frac { \alpha _ { 1 } } { \alpha _ { 1 } + \alpha _ { 2 } } .
146
+ $$
147
+
148
+ For the simple case of independent estimates $( \mathrm { C o v } [ a _ { i } ^ { k } - A _ { i } , a _ { i } ^ { k } - H _ { i } ] = 0 )$ ), this gives us another way of understanding the transform gate bias: It controls our initial belief in the variance of the layers estimate as compared to the previous one. A low bias means that the layers on average produce a high variance estimate, and should thus only contribute little, which seems a reasonable assumption for initialization.
149
+
150
+ # 4.2 EXPERIMENTAL CORROBORATION OF ITERATIVE ESTIMATION VIEW
151
+
152
+ The primary prediction of the iterative estimation view is that the estimation error for Highway or Residual blocks within the same stage should be zero in expectation. To empirically test this claim, we extract the intermediate layer outputs for 5000 validation set images using the 50-layer ResNet trained on the ILSVRC-2015 dataset from He et al. (2015). These are then used to compute the empirical mean and standard deviation of the estimation error over the validation subset, for all blocks in the four Residual stages in the network. Finally the mean of the empirical mean and standard deviation is computed over the three spatial dimensions.
153
+
154
+ Figure 3 shows that for the first three stages, the mean estimation error is indeed close to zero. This indicates that it is valid to interpret the role of Residual blocks in this network as that of iteratively refining a representation. Moreover, in each stage the standard deviation of the estimation error decreases over successive blocks, indicating the convergence of the refinement procedure. We note that stage four (with three blocks) appears to be underestimating the representation values, indicating a probable weak link in the architecture.
155
+
156
+ # 4.3 VISUAL EVIDENCE & STAGE-WISE ESTIMATION OF FEATURES
157
+
158
+ ResNets (He et al., 2015) and many other derived architectures share some common characteristics: They are divided into stages of Residual blocks that share the same dimensionality. In between these stages the input dimensionality changes, typically by down-sampling and an increase in the number of channels. These stages typically also increase in length: the early stages consist of fewer layers compared to later ones.
159
+
160
+ We can now interpret these design choices from an iterative estimation point of view. From this perspective the level of representation stays the same within each stage, through the use of identity shortcut connections. Between stages, the level of representation is changed by the use of a projection to change dimensionality. This means that we expect the type of features that are detected to be very similar within a stage and jump in abstraction between stages. This view also suggests that the first few stages can be shorter, since low level representations tend to be relatively simple and need little iterative refinement. The features of later stages on the other hand are likely complex with numerous inter-dependencies and therefore benefit more from iterative refinement.
161
+
162
+ ![](images/3af1c9d6b4491436b6e6b02980dc723d1e9ab8d5fb1fe79d601e16612c6ecbac.jpg)
163
+ Figure 4: Feature visualization from Chu et al. (2017), reproduced with kind permission of the authors. It shows how the response of a single filter (unit) evolves over the three blocks (shown from left to right) of stage 1 in a 50-layer ResNet trained on ImageNet. On the left of each visualization are the top 9 patches from the ImageNet validation set that maximally activated that filter. To the right the corresponding guided backpropagation (Springenberg et al., 2014) visualizations are shown.
164
+
165
+ Many visualization studies (such as those by Zeiler & Fergus (2014)) have examined the activities in trained convolutional networks and found evidence supporting the representation view. However, these studies were conducted on networks not designed for iterative estimation. The interpretation above paints a different picture for networks which learn unrolled iterative estimation. In these networks, we should observe stages and not layers corresponding to levels of representation.
166
+
167
+ Indeed, visualization of Residual network features supports the iterative estimation view. In Figure 4 we reproduce visualizations from a study by Chu et al. (2017) who observe: “[. . . ] residual layers of the same dimensionality learn features that get refined and sharpened”. These visualizations show how the response of a single filter changes over three Residual blocks within the same stage of a 50-layer Residual network trained for image classification. Note that the filter appears to refine its response by including surrounding context, rather than changing it across blocks in the same stage. In the first block, the top nine activating patches for the filter include three light sources and six specular highlights. In later blocks, through the incorporation of spatial context, eight out of nine maximally activating patches are specular highlights. Similar refinement behavior is observed throughout the different stages of the network.
168
+
169
+ Another finding in line with this implication of the iterative estimation view is that in some cases sharing weights of the Residual blocks within a stage doesn’t deteriorate performance much (Liao & Poggio, 2016). Similarly Lu & Renals (2015) shared the weights of the transform and carry gates of a thin and deep highway network, while still achieving better performance than both normal deep neural networks and Residual networks.
170
+
171
+ # 4.4 REVISITING EVIDENCE AGAINST THE REPRESENTATION VIEW
172
+
173
+ Staying Close to the Inputs. When iteratively re-estimating a variable, staying close to the old value should be a more common operation than changing it significantly. This is the reason why the ResNet formulation makes sense: learning the identity is hard and it is needed frequently. It also explains sparse transform gate activity in trained Highway networks: These networks learn to dynamically and selectively update individual features, while keeping most of the representation intact.
174
+
175
+ Lesioning. Another implication of the iteration view is that processing in layers is incremental and somewhat interchangeable. Each layer (apart from the first) refines an already reasonable estimate of the representation. It follows that removing layers, like in the lesioning experiments, should have only a mild effect on the final result because doing so does not change the overall representation the next layer receives, only its quality. The following layer can still perform mostly the same operation, even with a somewhat noisy input. Layer dropout (Huang et al., 2016b) amplifies this effect by explicitly training the network to work with a variable number of iterations. By dropping random layers it further penalizes iterations relying on each other, which could be another explanation for the regularization effect of the technique.
176
+
177
+ Shuffling. The layers within a stage should also be interchangeable to a certain degree, because they all work with the same input and output representations. Of course, this interchangeability is not without limitations. The network could learn to depend on a specific order of refinements, which would be disturbed by shuffling and lesioning. But we can expect these effects to be moderate in many cases, which is indeed what has been reported in the literature.
178
+
179
+ Table 1: Comparison of several Highway network and Residual network variants.
180
+
181
+ <table><tr><td>Variant</td><td>Functional Form</td><td>Perplexity</td></tr><tr><td>Plain</td><td>H(x)</td><td>92.60</td></tr><tr><td>Residual</td><td>H(x)+x</td><td>91.32</td></tr><tr><td>T-Only</td><td>H(x):T(x) + x</td><td>82.94</td></tr><tr><td>C-Only</td><td>H(x)+x.C(x)</td><td>79.15</td></tr><tr><td>Coupled</td><td>H(x):T(x)+x·(1-T(x))</td><td>79.13</td></tr><tr><td>Full</td><td>H(x)·T(x)+x:C(x)</td><td>79.09</td></tr></table>
182
+
183
+ (a) Comparing of various variants of the Highway formulation for character-aware neural language models (Kim et al., 2015).
184
+
185
+ <table><tr><td>Variant</td><td>Top5 Error</td></tr><tr><td>Highway</td><td>10.03 ± 0.17</td></tr><tr><td>Highway-Full</td><td>10.21 ± 0.03</td></tr><tr><td>Resnet</td><td>9.40 ± 0.18</td></tr><tr><td>Highway + BN</td><td>7.53 ± 0.05</td></tr><tr><td>Highway-Full + BN</td><td>7.29 ± 0.11</td></tr><tr><td>Resnet+BN</td><td>7.17 ± 0.14</td></tr></table>
186
+
187
+ (b) Comparing ILSVRC-2012 top5 classification error. Mean and std over 3 runs.
188
+
189
+ # 5 COMPARATIVE CASE STUDIES
190
+
191
+ The preceding sections show that we can construct both Highway and Residual architectures mathematically grounded in learning unrolled iterative estimation. The common feature between these architectures is that they preserve feature identities, and the primary difference is that they have different biases towards switching feature identities. Unfortunately, since our current understanding of the computations required to solve complex problems is limited, it is extremely hard to say a priori which architecture may be more suitable for which type of problems. Therefore, in this section we perform two case studies comparing and contrasting their behavior experimentally. The studies are each based on applications for which Residual and Highway layers respectively have been effective.
192
+
193
+ # 5.1 IMAGE CLASSIFICATION
194
+
195
+ Deep Residual networks outperformed all other entries at the 2016 ImageNet classification challenge. In this study we compare the performance of 50-layer convolutional Highway and Residual networks for ImageNet classification. Our aim is not to examine the importance of depth for this task— shallower networks have already outperformed deep Residual networks on all original Residual network benchmarks (Huang et al., 2016a; Szegedy et al., 2016). Instead, our goal is to fairly compare the two architectures, and test the following claims regarding deep convolutional Highway networks (He et al., 2015; 2016; Veit et al., 2016):
196
+
197
+ 1. They are harder to train, leading to stalled training or poor results.
198
+ 2. They require extensive tuning of the initial bias, and even then produce much worse results compared to Residual networks.
199
+ 3. They are wasteful in terms of parameters since they utilize extra learned gates, doubling the total parameters for the same number of units compared to a Residual layer.
200
+
201
+ We train a 50-layer convolutional Highway network based on the 50-layer Residual network from He et al. (2015). The design of the two networks are identical (including use of batch normalization (BN) after every convolution operation), except that unlike Residual blocks, the Highway blocks use two sets of layers to learn $H$ and $T$ and then combine them using the coupled Highway formulation. We train two slight variations of the Highway network: Highway, in which $H$ has the same design as in a Residual block before addition i.e. Conv-BN-ReLU-Conv-BN-ReLU-Conv-BN, and Highway-Full, in which an additional third ReLU operation is added. The design of $T$ is Conv-BN-ReLU-Conv-BN-ReLU-Conv-BN-Sigmoid. As proposed initially for Highway layers, both $H$ and $T$ are learned using the same receptive fields and number of parameters. The transform gate biases are set to $- 1$ at the start of training. For fair comparison, the number of feature maps throughout the Highway network is reduced such that the total number of parameters is close to the Residual network. The training algorithm and learning rate schedule are kept the same as those used for the Residual network.
202
+
203
+ The plots in Figure 5a show that the Residual network fits the data better—its final training loss is lower than the Highway network. The final performance of both networks on the validation set (see Table 1b) is very similar, with the Residual network producing a slightly better top-5 classification error of $7 . 1 7 \%$ vs. $7 . 5 3 \%$ for the Highway network. The Highway-Full network produces even closer results with a mean error of $7 . 2 9 \%$ . These results contradict claims 1 and 2 above, since the Highway networks are easy to train without requiring any bias tuning. However, there is some support for claim 3 since the Highway network appears to slightly underfit compared to the Residual network, suggesting lower capacity for the same number of parameters.
204
+
205
+ Importance of Expressive Gating. The mismatch between the results above and claims 1 and 2 made by He et al. (2016) can be explained based on the importance of having sufficiently expressive transform gates. For experiments with Highway networks (which they refer to as Residual networks with exclusive gating), He et al. (2016) used $1 \times 1$ convolutions for the transform gate, instead of having the same receptive fields for the gates as the primary transformation $( H )$ , as done by Srivastava et al. (2015a). This change in design appears to be the primary cause of instabilities in learning since the gates can no longer function effectively. Therefore, it is important to use equally expressive transformations for $H$ and $T$ in Highway networks.
206
+
207
+ Role of Batch Normalization. Since both architectures have built-in ease of optimization compared to plain networks, it is interesting to investigate the necessity of batch normalization for training these networks. Our derivation in Section 3.2 suggest that BN in Residual networks could take the role of an inductive bias towards iterative estimation by keeping the expected mean of the residual zero (cf. Equation 9). To investigate its role we train the networks above without any batch normalization. The resulting training curves are shown in Figure 5b of the supplementary.
208
+
209
+ We find that without BN both networks reach an even lower training error than before while performing worse on the validation set indicating increased overfitting for both. This shows that BN is not necessary for training these networks and does not speed up learning. Interestingly, the effect is more pronounced for the Highway network, which now fits the data better than the ResNet. This contradicts claim 3, since a Highway network with the same number of parameters as a Residual network demonstrates slightly higher capacity. On the other hand both networks produce a higher validation error— $1 0 . 0 3 \%$ and $9 . 4 \bar { 0 } \%$ for the Highway and Residual network respectively—indicating a clear case of overfitting. This means that batch normalization provides regularization benefits that can’t easily be explained by either improved optimization nor by the inductive bias for Residual networks.
210
+
211
+ # 5.2 LANGUAGE MODELING
212
+
213
+ Next we compare different functional forms (or variants) of the Highway network formulation for the case of character-aware language modeling. Kim et al. (2015) have shown that utilizing a few Highway fully connected layers instead of conventional plain layers improves model performance for a variety of languages. The architecture consists of a stack of convolutional layers followed by Highway layers and then an LSTM layer which predicts the next word based on the history. Similar architectures have since been utilized for obtaining substantial improvements for large-scale language modeling (Jozefowicz et al., 2016) and character level machine translation (Lee et al., 2016). Highway layers with coupled gates have been used in all these studies.
214
+
215
+ Only two to four Highway layers were necessary to obtain significant modeling improvements in the studies above. Thus, it is reasonable to assume that the central advantage of using Highway layers for this task is not easing of credit assignment over depth, but an improved modeling bias. To test how well Residual and other variants of Highway networks perform, we compare several language models trained on the Penn Treebank dataset using the same setup and code provided by Kim et al. (2015). We use the LSTM-Char-Large model, only changing the two Highway layers to different variants. The following variants are tested:
216
+
217
+ Full The original Highway formulation based on the LSTM cell. We note that this variant uses more parameters than the others, since changing the layer size to reduce parameters would affect the rest of the network architecture as well.
218
+
219
+ Coupled The most commonly used Highway variant, derived in Section 3.3.
220
+
221
+ C-Only A Highway variant with a carry gate but no transform gate (always set to one).
222
+
223
+ T-Only A Highway variant with a transform gate but no carry gate (always set to one).
224
+
225
+ Residual The Residual form from He et al. (2015), in which both transform and carry gate are always one. For this variant we use four layers instead of two, to match the amount of computation/parameters of the other variants.
226
+
227
+ The test set perplexity of each model is shown in Table 1a. We find that the the Full, Coupled and C-Only variants have similar performance, better than the T-Only variant and substantially better than the Residual variant. The Residual variant results in performance close to that obtained by using a single plain layer, even though four Residual layers are used. Learned gating of the identity connection is crucial for improving performance for this task.
228
+
229
+ Recall that the Highway layers transform character-aware representations before feeding them into an LSTM layer. Thus the non-contextual word-level representations resulting from the convolutional layers are transformed into representations better suited for contextual language modeling. Since it is unlikely that the entire representation needs to change completely, this setting fits well with the iterative estimation perspective.
230
+
231
+ Interestingly, Table 1a shows a significant advantage for all variants with a multiplicative gate on the inputs. These results suggest that in this setting it is crucial to dynamically replace parts of the input representation. Some features need to be changed drastically conditioned on other detected features such as word type while other features need to be retained. As a result, even though Residual networks are compatible with iterative estimation, they may not be the best choice for tasks where mixing adaptive feature transform/replacement and reuse is required.
232
+
233
+ # 6 CONCLUSION
234
+
235
+ This paper offers a new perspective on Highway and Residual networks as performing unrolled iterative estimation. As an extension of the popular representation view, it stands in contrast to the optimization perspective from which these architectures have originally been introduced. According to the new view, successive layers (within a stage) cooperate to compute a single level of representation. Therefore, the first layer already computes a rough estimate of that representation, which is then iteratively refined by the successive layers. Unlike layers in a conventional neural network, which each compute a new representation, these layers therefore preserve feature identity.
236
+
237
+ We have further shown that both Residual and Highway networks can be directly derived from this new perspective. This offers a unified theory from which these architectures can be understood as two approaches to the same problem. This view further provides a framework from which to understand several surprising recent findings like resilience to lesioning, benefits of layer dropout, and the mild negative effects of layer reshuffling. Together with the derivations these results serve as compelling evidence for the validity of our new perspective.
238
+
239
+ Motivated by their conceptual similarities we set out to compare Highway and Residual networks. In preliminary experiments we found that they give very similar results for networks of equal size, thus refuting some claims that Highway networks would need more parameters, or that any form of gating impairs the performance of Residual networks. In another example, we found non-gated identity skip-connections to perform significantly worse, and offered a possible explanation: If the task requires dynamically replacing individual features, then the use of gating is beneficial.
240
+
241
+ The preliminary evidence presented in this report is meant as a starting point for further investigation. We hope that the unrolled iterative estimation perspective will provide valuable intuitions to help guide research into understanding, improving and possibly combining these exciting techniques.
242
+
243
+ # ACKNOWLEDGEMENTS
244
+
245
+ The authors wish to thank Faustino Gomez, Bas Steunebrink, Jonathan Masci, Sjoerd van Steenkiste and Christian Osendorfer for their feedback and support. We are grateful to NVIDIA Corporation for providing us a DGX-1 as part of the Pioneers of AI Research award. This research was supported by the EU project “INPUT” (H2020-ICT-2015 grant no. 687795).
246
+
247
+ REFERENCES
248
+ Abdi, Masoud and Nahavandi, Saeid. Multi-Residual Networks. arXiv:1609.05672 [cs], September 2016.
249
+ Chu, Brian, Yang, Daylen, and Tadinada, Ravi. Visualizing Residual Networks. arXiv:1701.02362 [cs], January 2017.
250
+ Deng, Li and Yu, Dong. Deep Learning Methods and Applications. Foundations and Trends in Signal Processing, pp. 199–200, 2014.
251
+ Goodfellow, Ian, Bengio, Yoshua, and Courville, Aaron. Deep Learning. Book in preparation for MIT Press, 2016.
252
+ He, Kaiming, Zhang, Xiangyu, Ren, Shaoqing, and Sun, Jian. Deep Residual Learning for Image Recognition. arXiv:1512.03385 [cs], December 2015.
253
+ He, Kaiming, Zhang, Xiangyu, Ren, Shaoqing, and Sun, Jian. Identity Mappings in Deep Residual Networks. In Computer Vision–ECCV 2016, 2016.
254
+ Hochreiter, Sepp. Untersuchungen zu dynamischen neuronalen Netzen. Diploma, Technische Universität München, pp. 91, 1991.
255
+ Hochreiter, Sepp and Schmidhuber, Jürgen. Long short-term memory. Neural computation, 9(8): 1735–1780, 1997.
256
+ Huang, Gao, Liu, Zhuang, and Weinberger, Kilian Q. Densely Connected Convolutional Networks. arXiv:1608.06993 [cs], August 2016a.
257
+ Huang, Gao, Sun, Yu, Liu, Zhuang, Sedra, Daniel, and Weinberger, Kilian. Deep Networks with Stochastic Depth. arXiv:1603.09382 [cs], March 2016b.
258
+ Hubel, David H. and Wiesel, Torsten N. Receptive fields, binocular interaction and functional architecture in the cat’s visual cortex. The Journal of physiology, 160(1):106–154, 1962.
259
+ Jozefowicz, Rafal, Vinyals, Oriol, Schuster, Mike, Shazeer, Noam, and Wu, Yonghui. Exploring the limits of language modeling. arXiv preprint arXiv:1602.02410, 2016.
260
+ Kim, Yoon, Jernite, Yacine, Sontag, David, and Rush, Alexander M. Character-aware neural language models. arXiv preprint arXiv:1508.06615, 2015.
261
+ LeCun, Yann, Bengio, Yoshua, and Hinton, Geoffrey. Deep learning. Nature, 521(7553):436–444, May 2015. ISSN 0028-0836. doi: 10.1038/nature14539.
262
+ Lee, Jason, Cho, Kyunghyun, and Hofmann, Thomas. Fully Character-Level Neural Machine Translation without Explicit Segmentation. arXiv preprint arXiv:1610.03017, 2016.
263
+ Liao, Qianli and Poggio, Tomaso. Bridging the Gaps Between Residual Learning, Recurrent Neural Networks and Visual Cortex. arXiv:1604.03640 [cs], April 2016.
264
+ Lu, Liang and Renals, Steve. Small-footprint Deep Neural Networks with Highway Connections for Speech Recognition. arXiv:1512.04280 [cs], December 2015.
265
+ Schmidhuber, Jürgen. Deep learning in neural networks: An overview. Neural Networks, 61:85–117, January 2015. ISSN 0893-6080. doi: 10.1016/j.neunet.2014.09.003.
266
+ Springenberg, Jost Tobias, Dosovitskiy, Alexey, Brox, Thomas, and Riedmiller, Martin. Striving for Simplicity: The All Convolutional Net. arXiv:1412.6806 [cs], December 2014.
267
+ Srivastava, Rupesh K, Greff, Klaus, and Schmidhuber, Juergen. Training Very Deep Networks. In Cortes, C., Lawrence, N. D., Lee, D. D., Sugiyama, M., and Garnett, R. (eds.), Advances in Neural Information Processing Systems 28, pp. 2377–2385. Curran Associates, Inc., 2015a.
268
+ Srivastava, Rupesh Kumar, Greff, Klaus, and Schmidhuber, Jürgen. Highway Networks. arXiv:1505.00387 [cs], May 2015b.
269
+
270
+ Szegedy, Christian, Ioffe, Sergey, Vanhoucke, Vincent, and Alemi, Alex. Inception-v4, InceptionResNet and the Impact of Residual Connections on Learning. arXiv:1602.07261 [cs], February 2016.
271
+
272
+ Veit, Andreas, Wilber, Michael, and Belongie, Serge. Residual Networks are Exponential Ensembles of Relatively Shallow Networks. arXiv:1605.06431 [cs], May 2016.
273
+
274
+ Zeiler, Matthew D. and Fergus, Rob. Visualizing and understanding convolutional networks. In European Conference on Computer Vision, pp. 818–833. Springer, 2014.
275
+
276
+ Zilly, Julian Georg, Srivastava, Rupesh Kumar, Koutník, Jan, and Schmidhuber, Jürgen. Recurrent Highway Networks. arXiv:1607.03474 [cs], July 2016.
277
+
278
+ ![](images/f0a9278a7a7c56b67639b1d680b954144ef134bf734070b5cf2e8ec24142110b.jpg)
279
+ Figure 5: Comparing 50-layer Highway vs. Residual networks on ILSVRC-2012 classification.
280
+
281
+ # A DERIVATION
282
+
283
+ A.1 OPTIMAL LINEAR ESTIMATOR
284
+
285
+ Assume two random variables $A$ and $B$ that are both noisy measurements of a third (latent) random variable $C$ :
286
+
287
+ $$
288
+ \mathbb { E } [ A - C ] = \mathbb { E } [ B - C ] = 0
289
+ $$
290
+
291
+ We call the corresponding variances $\mathrm { V a r } [ A - C ] = \sigma _ { A } ^ { 2 }$ and $\mathrm { V a r } [ B - C ] = \sigma _ { B } ^ { 2 }$ and covariance Cov[A, B] = σ2AB .
292
+
293
+ We are looking for the linear estimator $q ( A , B ) = q _ { 0 } + q _ { 1 } A + q _ { 2 } B$ of $C$ with $\mathbb { E } [ q - C ] = 0$ (unbiased) that has minimum variance.
294
+
295
+ $$
296
+ \begin{array} { r } { \mathbb { E } [ q ( A , B ) - C ] = 0 } \\ { \mathbb { E } [ q _ { 0 } + q _ { 1 } A + q _ { 2 } B - C ] = 0 } \\ { \mathbb { E } [ q _ { 0 } + q _ { 1 } A - q _ { 1 } C + q _ { 2 } B - q _ { 2 } C + ( q _ { 1 } + q _ { 2 } - 1 ) C ] = 0 } \\ { \mathbb { E } [ q _ { 0 } + q _ { 1 } ( A - C ) + q _ { 2 } ( B - C ) + ( q _ { 1 } + q _ { 2 } - 1 ) C ] = 0 } \\ { q _ { 0 } + ( q _ { 1 } + q _ { 2 } - 1 ) \mathbb { E } [ C ] = 0 } \\ { \mathbb { E } [ C ] ( 1 - q _ { 1 } - q _ { 2 } ) = q _ { 0 } } \end{array}
297
+ $$
298
+
299
+ for all $\mathbb { E } [ C ]$ which is possible iff:
300
+
301
+ $$
302
+ q _ { 0 } = 0 \mathrm { a n d } q _ { 1 } + q _ { 2 } = 1 .
303
+ $$
304
+
305
+ The second condition about minimal variance thus reduces to:
306
+
307
+ $$
308
+ \begin{array} { r l } { \underset { q _ { 1 } , q _ { 2 } } { \operatorname { m i n i m i z e } } } & { { } \mathrm { V a r } [ q _ { 1 } A + q _ { 2 } B - C ] } \\ { \mathrm { s u b j e c t } \mathrm { t o } } & { { } q _ { 1 } + q _ { 2 } = 1 } \end{array}
309
+ $$
310
+
311
+ We can solve this using Lagrangian multipliers. For that we need to take the derivative of the following term w.r.t. $q _ { 1 } , q _ { 2 }$ and $\lambda$ and set them to zero:
312
+
313
+ $$
314
+ \mathrm { V a r } [ q _ { 1 } A + q _ { 2 } B - C ] - \lambda ( q _ { 1 } + q _ { 2 } - 1 ) )
315
+ $$
316
+
317
+ The first equation is therefore:
318
+
319
+ $$
320
+ \begin{array} { r l r } & { } & { \frac { d } { d q _ { 1 } } ( \mathrm { V a r } [ q _ { 1 } A + q _ { 2 } B - C ] - \lambda ( q _ { 1 } + q _ { 2 } - 1 ) ) = 0 } \\ & { } & { \frac { d } { d q _ { 1 } } \mathrm { V a r } [ q _ { 1 } A + q _ { 2 } B - C ] - \lambda = 0 } \\ & { } & { \frac { d } { d q _ { 1 } } \mathrm { V a r } [ q _ { 1 } ( A - C ) + q _ { 2 } ( B - C ) ] - \lambda = 0 } \\ & { } & { \frac { d } { d q _ { 1 } } ( q _ { 1 } ^ { 2 } \mathrm { V a r } [ A - C ] + 2 q _ { 1 } q _ { 2 } \mathrm { C o v } [ A - C , B - C ] ) - \lambda = 0 } \\ & { } & { 2 q _ { 1 } \sigma _ { A } ^ { 2 } + 2 q _ { 2 } \sigma _ { A B } ^ { 2 } - \lambda = 0 } \end{array}
321
+ $$
322
+
323
+ Analogously we get:
324
+
325
+ and:
326
+
327
+ $$
328
+ \begin{array} { c } { { 2 q _ { 2 } \sigma _ { B } ^ { 2 } + 2 q _ { 1 } \sigma _ { A B } ^ { 2 } - \lambda = 0 } } \\ { { { } } } \\ { { q _ { 1 } + q _ { 2 } = 1 } } \end{array}
329
+ $$
330
+
331
+ Solving these equations gives us:
332
+
333
+ $$
334
+ \begin{array} { c } { { q _ { 1 } = \displaystyle \frac { \sigma _ { B } ^ { 2 } - \sigma _ { A B } ^ { 2 } } { \sigma _ { A } ^ { 2 } - 2 \sigma _ { A B } ^ { 2 } + \sigma _ { B } ^ { 2 } } } } \\ { { q _ { 2 } = \displaystyle \frac { \sigma _ { A } ^ { 2 } - \sigma _ { A B } ^ { 2 } } { \sigma _ { A } ^ { 2 } - 2 \sigma _ { A B } ^ { 2 } + \sigma _ { B } ^ { 2 } } } } \end{array}
335
+ $$
336
+
337
+ We can write our estimator in terms of $\alpha _ { 1 } = \sigma _ { B } ^ { 2 } - \sigma _ { A B } ^ { 2 }$ and $\alpha _ { 2 } = \sigma _ { A } ^ { 2 } - \sigma _ { A B } ^ { 2 }$ :
338
+
339
+ $$
340
+ q = \frac { \alpha _ { 1 } } { \alpha _ { 1 } + \alpha _ { 2 } } A + \frac { \alpha _ { 2 } } { \alpha _ { 1 } + \alpha _ { 2 } } B
341
+ $$
md/train/SyxnvsAqFm/SyxnvsAqFm.md ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # COMPUTATION-EFFICIENT QUANTIZATION METHODFOR DEEP NEURAL NETWORKS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Deep Neural Networks, being memory and computation intensive, are a challenge to deploy in smaller devices. Numerous quantization techniques have been proposed to reduce the inference latency/memory consumption. However, these techniques impose a large overhead on the training procedure or need to change the training process. We present a non-intrusive quantization technique based on re-training the full precision model, followed by directly optimizing the corresponding binary model. The quantization training process takes no longer than the original training process. We also propose a new loss function to regularize the weights, resulting in reduced quantization error. Combining both help us achieve full precision accuracy on CIFAR dataset using binary quantization. We also achieve full precision accuracy on WikiText-2 using 2 bit quantization. Comparable results are also shown for ImageNet. We also present a 1.5 bits hybrid model exceeding the performance of TWN LSTM model for WikiText-2.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Different variants of Deep Neural Networks have achieved state-of-the-art results in various domains from computer vision to language processing (Krizhevsky et al., 2012; Ren et al., 2015; Vaswani et al., 2017; Cho et al., 2014). However, newer models are becoming more memory and computation intensive to achieve performance improvements. For example, winner of ILSVRC 2015 ResNet (He et al., 2016) increased the number of layers by over $4 \mathbf { x }$ to gain less than $2 \%$ Top-1 accuracy improvement on ImageNet (Russakovsky et al., 2015). Compression techniques, such as knowledge distillation, pruning, low rank approximation and quantization, have been proposed to reduce the model size (Vapnik & Izmailov, 2015; Han et al., 2015; Sainath et al., 2013; Courbariaux et al., 2015). These compression techniques are evolving the field of model compression towards the goal of deploying DNN models on mobile-phone and other embedded devices.
12
+
13
+ Courbariaux et al. (2015) proposed the widely used technique for training quantized neural networks, where binary weights are used during forward and backward propagation, while full precision weights are preserved for accumulating gradients. Binary weights are approximated from full precision weights every iteration. (Zhou et al., 2018; 2017a) have proposed incremental quantization training procedure where the range for the weights is incrementally reduced. Choi et al. (2017) use Hessian weighted $\mathbf { k }$ -means clustering for quantization. Lee & Kim (2018) used iterative procedure of quantizing, de-quantizing and complete retraining of the full precision model, performed multiple times. All the techniques aimed to reduce the quantization error (error between full precision model and corresponding quantized model). However, most of these quantization techniques either adds extra set of hyper-parameters or modifies/lengthens the original training procedure.
14
+
15
+ Designing a neural network model consists of two main steps - choose a proper architecture/model given the characteristics of the task, and optimize the hyper-parameters for convergence and accuracy. Hyper-parameter search varies from number of layers in a model (Zoph et al., 2018) to learning rate (lr), batch-size (bs) combo (compare ResNet (He et al., 2016) and Inception (Szegedy et al., 2016) networks with altogether different hyper-parameter set). Courbariaux et al. (2015) requires updating the back-propagation procedure to train quantized networks. (Zhou et al., 2018; Lee & Kim, 2018) require very long training time because of multiple iterations of training and extra introduced hyper-parameters. Over time, focus on reducing the model size and the corresponding inference latency has led to either lengthening or major modifications to training procedure. Our Proposed quantization technique addresses these issues resulting in easy adoption of our technique.
16
+
17
+ Our contributions include but are not limited to
18
+
19
+ • A simple quantization training method based on re-training without requiring major modifications to the original training procedure. Training consists of two phases: phase1 trains the full precision model (with quantization) and phase2 trains the binary model constructed by phase1.
20
+ • Reduce the overhead of expensive quantization techniques as quantization is performed only every few steps (specifically once every 500 iterations for the experiments).
21
+ Maintained the total number of iterations and time required to train the quantized network compared to the full precision network.
22
+ • Achieve full precision accuracy for WikiText-2 and CIFAR dataset with 2-bit and 1-bit quantization respectively. Present a hybrid 1.5 bits LSTM models for WikiText-2 outperforming TWN LSTM model. Achieve performance comparable to existing works for ImageNet.
23
+
24
+ # 2 RELATED WORK
25
+
26
+ Quantization. Courbariaux et al. (2015) proposed the idea of training binary neural networks with quantized weights. Rastegari et al. (2016) introduced shared scaling factors to allow more range for binary values. (Hubara et al., 2016; Zhou et al., 2016; Lin et al., 2017; McDonnell, 2018; Hubara et al., 2018) built upon the training methodology along with introduction of binary activation units. Lee & Kim (2018) performs full precision retraining multiple times to train a quantized network. Ternary quantization was proposed (Zhu et al., 2017; Li et al., 2016; Wang et al., 2018) to mitigate the gap between full precision and quantized weight networks. Let $\mathbf { W } ~ \in ~ \mathbb { R } ^ { k \times c \times f \times f }$ represent a weight of a convolution layer $l$ with total n elements where $k , c , f$ represents output channels, input channels and size of the filter respectively. Rastegari et al. (2016) splits $\boldsymbol { \mathsf { W } }$ into binary weight $\mathsf { B } ^ { \mathsf { ^ { * } } } \in \{ - 1 , + 1 \} ^ { k \times c \times f \times f }$ and scaling factor $\pmb { \alpha } \in \mathbb { R } ^ { + k }$ shared per output, where
27
+
28
+ $$
29
+ \begin{array} { r } { \mathbf { B } = \mathrm { s i g n } ( \mathbf { W } ) \qquad \mathbf { \alpha } \mathbf { \alpha } = \langle \mathbf { B } , \mathbf { W } \rangle / n } \end{array}
30
+ $$
31
+
32
+ obtained by minimizing $\| \boldsymbol { \mathsf { W } } - \alpha \boldsymbol { \mathsf { B } } \| ^ { 2 }$ . Binary quantization is extended to ternary where ${ \textbf { \textsf { B } } } \in$ $\{ - 1 , 0 , + 1 \} ^ { n \times c \times k \times k }$ . Ternary quantization introduces a threshold factor $\triangle _ { l }$ to assign the ternary value to a weight. (Li et al., 2016; Zhu et al., 2017; Wang et al., 2018) have proposed various methodologies to evaluate the threshold. Lee & Kim (2018) performed ternary quantization by combining pruning and binary quantization.
33
+
34
+ Binary quantization was extended to multi-bit quantization using a greedy methodology by Guo et al. (2017). For k-bit quantization, minimizing $\| \hat { \pmb { \mathsf { W } } } _ { i } - \pmb { \alpha } _ { i } \pmb { \mathsf { B } } _ { i } \|$ for $\mathrm { i ^ { \mathrm { t h } } }$ bit quantization resulted in,
35
+
36
+ $$
37
+ \mathbf { B } _ { i } = \mathrm { s i g n } ( \hat { \mathsf { W } } _ { i } ) \qquad \quad \alpha _ { i } = \langle \bar { \mathbf { B } } _ { i } , \hat { \mathsf { W } } _ { i } \rangle / n \qquad \mathrm { w h e r e } \ \hat { \mathsf { W } } _ { i } = \mathsf { W } - \sum _ { j = 1 } ^ { i - 1 } \alpha _ { j } \mathsf { B } _ { j }
38
+ $$
39
+
40
+ referred as the greedy approach. Greedy approach was improved by refined method, where $\alpha _ { i }$ is computed by using $( ( \bar { \mathbf { B } } _ { i } ^ { \bar { T } } \bar { \mathbf { B } } _ { i } ) ^ { - 1 } \mathbf { B } _ { i } ^ { T } \mathbf { W } ) ^ { T }$ . Xu et al. (2018) improved refined method by performing a binary search on the given refined $\alpha$ set and alternately evaluating $_ { \pmb { \alpha } }$ and $\mathsf { B }$ . Low precision networks have also been proposed to reduce the gap with quantized activation units (Zhuang et al. (2018)). Quantization has also been applied to RNNs and Long Short Term Memory (LSTM) models as well (Hou et al. (2017); Guo et al. (2017); Zhou et al. (2017b); Xu et al. (2018); Lee & Kim (2018)). We use greedy quantization in this work due to its simple operations (although alternating yields the better results at the cost of higher computation overhead). Next section describes our quantization training procedure in detail.
41
+
42
+ # 3 ITERATIVE QUANTIZATION
43
+
44
+ Choromanska et al. (2015) shows that minima of high quality (measured by test accuracy) for largesize networks occur in a well-defined band. Choromanska et al. (2015) also conjectured that training using methods like stochastic gradient descent, simulated annealing converges to a minimum in the band. Minima in the band can have varying flatness, where flat minima have smaller error introduced to the accuracy upon adding distortion to the weight (Hochreiter & Schmidhuber (1995)). However, exploring through multiple minima has been a challenging task. Simulated annealing1 (Kirkpatrick et al., 1983) explores through various minima, but does not aim to find wider minima. Motivated from simulated annealing, we propose a training technique to enable exploration of wider minimum among multiple minima. The technique allows escaping from relatively sharper minima and aims to find wider minima in the band. Our training procedure consists of two phases. Phase1 trains the full precision network with quantization. Phase2 fine-tunes the binary network obtained from phase1.
45
+
46
+ ![](images/9efa46e16b18fee62c60b979af66244a91330ef53ccc53fb6f3a2e243ae747cb.jpg)
47
+ Figure 1: (a) Quantization Training algorithm (b) Convergence of accuracy using step training (Phase1) for ResNet32 on CIFAR-10 dataset.
48
+
49
+ ![](images/84024054c2c1e3286f40377cbf68edc35652c29b9ba3de8895c2ef2d7eb3ecd4.jpg)
50
+
51
+ # 3.1 PHASE1: STEP TRAINING
52
+
53
+ The goal of phase1 is to produce a full precision model with optimized B and reduced quantization error (error between full precision and quantized model). Phase1 does not modify the original training procedure. Instead, in addition to the original training, phase1 just adds an extra distortion step using quantization (referred as quantized-distortion step), performed once every few iterations. Applying quantized-distortion to the weights consists of 3 parts - quantize the weights of each layer (quantization), convert the quantized weights back to full precision format (de-quantization), and update the full precision model with the de-quantized weights. Quantized-distortion is performed once every Quantized Step Size (QSS) iterations. Original training procedure combined with quantization-distortion is referred as Step Training (Figure 1a). Step training is performed in phase1 until the convergence of training (in principle).
54
+
55
+ Full precision training of the network for QSS iterations explores the curvature of the local convex surface of the current local minimum. Applying quantized-distortion post-training moves the model to the quantized lattice point on the training contour. Suppose that the quantized lattice point exist outside the curvature around a sharp minimum. Then, the network escapes such sharper minima in phase1. In contrast to existing quantization training methods, step training does not store quantized weights. Instead, step training updates and replaces full precision weights with their quantized version every few iterations.
56
+
57
+ Quantization Step Size. QSS determines the amount of retraining to be done between two quantized-distortion steps. QSS needs to be big enough to compensate for the error added by the distortion and let the network explore the current local curvature. However, QSS should not be too large to diverge the weights far away from a nearby quantized lattice point. Comparing big vs small QSS - big QSS allows the weights to explore farther allowing the binary representation of the weights to change (weights need large amount of updates to change their sign). On the other hand, small QSS allows the training to exploit the current local curvature and fine-tune $_ { \pmb { \alpha } }$ .
58
+
59
+ ![](images/68e711244922900fd4ad02d10085b063fa5b367094411f95821593a9c36ebdba.jpg)
60
+ Figure 2: (left) Histogram of bit flips for all the weights of ResNet32 for CIFAR-10. (right) weights flipping their signs over the course of step training. Weight is randomly chosen from layer 30 of ResNet32 for CIFAR-10. Larger learning rate allows for more exploration and flipping of weights while small learning rate allows for fine-tuning and final convergence.
61
+
62
+ We observe that for a training procedure with fixed learning rate, starting with a big QSS and reducing QSS over the training period results in better convergence. However, the same behavior can be approximated with a fixed QSS and a varying learning rate. Figure 1b shows the movement of accuracy using step training with step-wise reducing learning rate and fixed QSS for ResNet32 on CIFAR-10. Larger learning rate enables larger amount of updates (and hence more curvature exploration) given the same gradient from the back propagation (fluctuations in the accuracy). On the other hand, smaller learning rate helps exploit (fine-tune the parameters inside the current minimum) as shown by a smoother rise in accuracy. Hence, we use fixed QSS (500 iterations) in the rest of the manuscript, although one can use varying QSS for further fine-tuning.
63
+
64
+ Convergence of B. We observe that B converges earlier compared to $_ { \pmb { \alpha } }$ during step training. Such an observation is demonstrated in our experiment with step training for CIFAR-10 with ResNet32. Figure 2 shows the movement of weight with step training2. Initially, the sign bits of the weight flip frequently (with higher learning rate). However, with smaller learning rate (after 80K iterations for CIFAR-10), B do not change and only $_ { \pmb { \alpha } }$ is optimized.
65
+
66
+ Convergence of $_ { \pmb { \alpha } }$ . Let $\pmb { \mathsf { W } }$ be a tensor of full precision weights with n elements. $\boldsymbol { \mathsf { W } }$ is quantized into $\mathsf { B }$ (binary tensor) and $_ { \pmb { \alpha } }$ (shared scaling factors). Step training updates $\boldsymbol { \mathsf { W } }$ every iteration. On the other hand, $( \boldsymbol { \mathsf { B } } , \alpha )$ are calculated every QSS iterations. Let $\triangle \boldsymbol { \mathsf { W } }$ denote the total update accumulated for $\boldsymbol { \mathsf { W } }$ since the last distortion step. Let $\triangle \alpha$ denote the change between the new $_ { \pmb { \alpha } }$ and the $_ \alpha$ calculated at previous distortion step. For binary quantization, the updated $_ \alpha$ is given by
67
+
68
+ $$
69
+ \pmb { \alpha } + \triangle \pmb { \alpha } = \frac { 1 } { n } \sum \vert \pmb { W } + \triangle \pmb { W } \vert
70
+ $$
71
+
72
+ where $| . |$ is the absolute function. Starting from a common absolute quantized value $( \alpha )$ , the weights sharing the same $\alpha$ update independently $( \forall i , j w _ { i } , w _ { j } \in \mathbf { W }$ , $\partial w _ { i } / \bar { \partial } w _ { j } = 0 ,$ ). With large QSS, as the weights diverge from $\alpha$ , the update for $\alpha$ becomes inefficient and noisy. Although phase1 results in optimized $\mathbf { B }$ , phase1 does not completely optimize $_ { \pmb { \alpha } }$ (within the limited number of iterations). Need for improved convergence of $_ { \pmb { \alpha } }$ forms the motivation for phase2.
73
+
74
+ # 3.2 PHASE2: $_ { \pmb { \alpha } }$ TRAINING
75
+
76
+ Phase2 starts by converting the full precision trained model from phase1 to the corresponding binary model. The full precision weights $\boldsymbol { \mathsf { W } }$ in phase1 are replaced with the corresponding binary version, $_ \alpha$ and $\mathsf { B }$ in the model. $\mathbf { B }$ is fixed and only $_ { \pmb { \alpha } }$ is trained. Phase2 only constructs the binary model and does not construct the full precision model. Phase2 is faster compared to phase1 due to fewer training parameters, use of binary weights, and no quantized-distortion step. Phase2 is performed with a smaller learning rate after the bit-flips do not occur anymore in phase1. Similar to phase1, phase2 also uses the original training procedure but with fewer number of trainable parameters.
77
+
78
+ In the complete training procedure, we first perform phase1 followed by phase2. The trained binary model at the end of phase2 represents the output of the complete training procedure. This complete training procedure uses the same number of iterations as that in the original training procedure. As a result, the total training time combining phase1 and phase2 is equivalent to the original full precision training time.
79
+
80
+ # 3.3 SPECIAL CARE FOR CNNS
81
+
82
+ This section compares different ways to apply quantization on a 4D tensor kernel. Quantization for a 2D weight matrix $W$ with n elements outputs a binary 2D matrix $B \in \{ - 1 , + 1 \} ^ { n }$ and shared scaling factor $_ \alpha$ per row of $W$ . All the weights in a row share the same $\alpha$ , where $\alpha \in \alpha$ . Further, a row in the matrix can be split into $t$ sub-rows (referred as tables), where each table has a different $\alpha$ . For quantizing a 4D tensor kernel $\pmb { \mathsf { W } } \in \mathbb { R } ^ { k \times \overset { \cdot } { c } \times f \times f }$ in a convolution layer, $\boldsymbol { \mathsf { W } }$ is reshaped to 2D matrix $\dot { W } \in \mathbb { R } ^ { k \times c f f }$ (Rastegari et al., 2016) $k$ is the number of output features, $c$ is the number of inputs features and $f$ is the filter size). There are total $k \alpha$ , each shared by $c \times f \times f$ number of weights. Each output feature in the convolution layer has $c \times f \times f$ weights. Thus, there is only 1 $\alpha$ shared by all the weights for an output feature. As the quantized weights can only take the value of $\left\{ + \alpha , - \alpha \right\}$ , all the inputs for an output feature can only be weighted by the same absolute factor $\alpha$ . Hence, the representative power of the quantized network is limited.
83
+
84
+ To alleviate this problem, we convert the 4D tensor $\boldsymbol { \mathsf { W } }$ to 2D matrix differently. $\pmb { \mathsf { W } }$ is transposed to $f \times k \times c \times f$ and then reshaped to 2D matrix $\mathbb { R } ^ { f \times k c f }$ (referred as skewed matrix). Next, each row of size $k \times c \times f$ is split into $k / f$ sub-rows. Each sub-row has a different $\alpha$ . Total number of $\alpha$ remains the same as above $( k )$ . Furthermore, the inputs for an output feature can now be weighted by $f$ number of unique $\alpha$ . Note that some $\alpha$ will be shared among different output features as well. In our experiments, skewed matrix shows better results. Section 5.1 shows the benefit in accuracy using the skewed matrix for quantization.
85
+
86
+ # 4 K-MEANS LOSS AND SHUFFLING
87
+
88
+ This section aims to limit the divergence of weights from each other during training to get more accurate estimation of $\alpha$ . $L _ { 2 }$ regularization (in the form of $L _ { 2 }$ loss) is frequently used in training of neural networks. $L _ { 2 }$ loss prevents the weights from exploding and suppresses the magnitude of the weights. However, $L _ { 2 }$ loss does apply any restriction on the variance of the weights. As $_ \alpha$ is obtained using Equation 1, higher variance in weights results in higher quantization error. We aim to reduce quantization error by introducing $L _ { K M }$ loss function to reduce the variance of the weights. Let $\boldsymbol { \mathsf { W } } _ { i }$ represent all the weights in a layer $i$ . Let $\mathbf { \pmb { w } } \in \mathbb { W } _ { i }$ be a subset of weights sharing common $\alpha$ ( $\pmb { w }$ are referred as clusters from now). The new loss is represented as:
89
+
90
+ $$
91
+ L _ { K M } = \frac { c } { \| \mathbf { W } \| ^ { 0 } } \sum _ { \forall \pmb { w } \in \mathbb { W } } \| \pmb { w } - \mathrm { a v g } ( | \pmb { w } | ) \| ^ { 2 }
92
+ $$
93
+
94
+ where c is a constant, $\mathrm { a v g ( . ) }$ computes the average of the inputs. $L _ { K M }$ divides the weights $\boldsymbol { \mathsf { W } }$ into different clusters $\pmb { w }$ with common $\alpha$ and limits the divergence of weights from the cluster average of its absolute values $_ { \pmb { \alpha } }$ . $L _ { K M }$ restricts the independent movement of weights. Similar with $L _ { 2 }$ loss, a diverged weight increases the $L _ { K M }$ . In addition, a diverged weight also shifts the cluster average, increasing the $L _ { K M }$ loss further. Thus $L _ { K M }$ encourages a lower variance in the weights with common $\alpha$ and improve quantization as a result. The constant factor $c$ is set to be the same as weight decay rate (the constant for $L _ { 2 }$ loss is reduced to mitigate the effect of $L _ { 2 }$ ).
95
+
96
+ Shuffling. $L _ { K M }$ can be extended for multiple tables, where a row of a quantized matrix has multiple shared $_ { \pmb { \alpha } }$ . With multiple tables, let $\textbf { \em w }$ correspond to a subset of row, where the subset shares the common $\alpha$ . $L _ { K M }$ helps in better approximation for $_ \alpha$ by forcing a predetermined group of weights to exhibit low variance. We could also achieve a better approximation for $_ { \pmb { \alpha } }$ by re-arranging the weights so that similar values are grouped together. Note that rearranging is applicable for DNNs with multiple tables only.
97
+
98
+ Let the weight matrix between two fully connected layers $l ^ { i }$ and $l ^ { i - 1 }$ be represented by $W ^ { i , i - 1 }$ . Two nodes in a layer $l ^ { i }$ given as $l _ { j } ^ { i }$ and $l _ { k } ^ { i }$ can be swapped by switching the rows $j , k$ of weight matrix $W ^ { i , i - 1 }$ and the columns $j , k$ of $W ^ { i + 1 , i }$ . The layout of the weight matrix can be set to cluster the desired weights without impacting the output of the network. Swapping the nodes in layer $l ^ { i }$ , $l ^ { i - 1 }$ swaps the rows and columns of $\breve { W } ^ { i , i - 1 }$ respectively. Thus, nodes in each layer can be swapped independently. K-means clustering is used to find an optimized configuration of weights in terms of grouping similar values together first. And then the nodes in the layer are swapped to enforce such configuration, reducing the quantization error. The methodology of finding and applying the optimal swapping configuration is termed as shuffling of nodes.
99
+
100
+ Because applying shuffling of nodes to the current layer requires a layer before and after the current layer, we introduce a shuffle layer in the start and end of the network to allow shuffling in first and last layer of the network. The shuffle layer stores the shuffle configuration and behaves as a mapping layer. The overhead of the shuffle layer is less than $1 \%$ of the model size (same as the size of bias in a layer). Shuffling is applied in the weight distortion step in phase1, when quantizing the weights.
101
+
102
+ # 5 EXPERIMENTS
103
+
104
+ Experiments are performed with CNNs and RNNs to show the effectiveness of the proposed method. All the experiments are performed using Tensorflow (Abadi et al., 2016) using 2 Titan X GPUs. Full precision models for CNNs are obtained from tensorflow models repository3, while RNN models are obtained from Verwimp et al. $( 2 0 1 7 ) ^ { 4 }$ . We quantize all the layers of the network unless specified otherwise. Iterative quantization training is performed on pre-trained full precision models. Greedy quantization using Equation 1 is used for all the experiments. Quantization Step Size is set to 500 constant throughout all the experiments.
105
+
106
+ # 5.1 CIFAR
107
+
108
+ ResNet32 is trained on CIFAR-10 (Krizhevsky, 2009) for $9 0 \mathrm { k }$ iterations, where the first $6 0 \mathrm { k }$ iterations are performed using step training and remaining 30k iterations are performed with $_ \alpha$ training. $60 \%$ pruning rate is set for ternary quantization. Training ResNet32 using our proposed quantization training method does not incur any increase in training time.
109
+
110
+ Table 1 shows the improvement by combining the techniques discussed in previous sections in an incremental manner for ResNet32. We use the $k \alpha$ for quantization following Rastegari et al. (2016) as default quantization mode $k$ is the number of output features for a convolution layer). Different QSS schedules were tried where QSS starts with a high value and is reduced over the training procedure. QSS schedule produces better accuracy compared to fixed QSS for step training. Note that, however, $_ \alpha$ training eliminates the need to fine-tune over the QSS and achieves the same accuracy. Number of tables for skewed mode have been set to have the same model size as default mode (resulting in the same number of $\alpha$ ).
111
+
112
+ Table 2 provides our final accuracy for CIFAR dataset with all the techniques combined using ResNet32 and WideResNet 28-10 models $7 0 \mathrm { x }$ bigger model size compared to ResNet32). Our model provides similar performance compared to TTQ (Zhu et al., 2017) using ResNet32. Our method achieves full precision accuracy for WideResNet 28-10 on both CIFAR-10 and CIFAR-100, compared to the results by McDonnell (2018) without changing the training procedure. We believe that WideResNet demonstrates smaller quantization error than ResNet32 because Li et al. (2018) reported that wider networks facilitates flatter minima.
113
+
114
+ # 5.2 WIKITEXT-2
115
+
116
+ LSTM model with 1 layer consisting of 512 nodes is used for WikiText-2 (Merity et al., 2017) dataset, with same hyper-parameter settings as followed by Xu et al. (2018). Performance is measured with Perplexity Per Word metric (PPW). Full precision PPW is 100.2. Activation quantization requires quantization to be performed every iteration for inference, wiping out the speed up obtained with quantized weights for inference. Activation quantization slows down training as well. Thus, we use 32bit activations while 3bit activations used by $\mathrm { X u }$ et al. (2018). Our 2-bit alternating quantization (greedy quantization replaced with alternating quantization in our proposed method) reaches full precision PPW (Table 3).
117
+
118
+ Table 1: Accuracy improvement by each method incrementally for ResNet32 on CIFAR-10.
119
+
120
+ <table><tr><td>Config</td><td>Accuracy %</td></tr><tr><td>Full Precision</td><td>92.47</td></tr><tr><td>Binary Step Training (BST)</td><td>88.18</td></tr><tr><td>BST without pre-trained</td><td>88.09</td></tr><tr><td>Ternary Step Training (TST)</td><td>89.27</td></tr><tr><td>TST + QSS schedule</td><td>90.45</td></tr><tr><td>TST +α training</td><td>90.4</td></tr><tr><td>TST + skewed matrix</td><td>91.3</td></tr><tr><td>TST+ skewed matrix + L KM</td><td>91.8</td></tr><tr><td>TST+ skewed matrix +LKM +α training</td><td>92.36</td></tr></table>
121
+
122
+ Table 2: Accuracy Comparison for CIFAR using ResNet32 and WideResNet for TWN and binary models. TTQ: Zhu et al. (2017) (TWN model), Wide-1b: McDonnell (2018) (binary model)
123
+
124
+ <table><tr><td>Config</td><td colspan="6">Accuracy %</td></tr><tr><td rowspan="2"></td><td colspan="2">CIFAR-10ResNet32</td><td colspan="2">CIFAR-10WideResNet</td><td colspan="2">CIFAR-100WideResNet</td></tr><tr><td>Ours</td><td>TTQ</td><td>Ours</td><td>Wide-1b</td><td>Ours</td><td>Wide-1b</td></tr><tr><td>FullPrecision</td><td>92.47</td><td>92.33</td><td>95</td><td>95.77</td><td>78.3</td><td>81.37</td></tr><tr><td>Binary Model</td><td>92.36</td><td>92.37</td><td>95.02</td><td>95.54</td><td>78.3</td><td>81.06</td></tr></table>
125
+
126
+ Table 3 compares the accuracy for multi-table models (multiple $\alpha$ per row of the matrix to be quantized) with TWN model (TWN method from Li et al. (2016) combined with our training method). Our multi-table model (8 tables for Embedding and Softmax layer, 16 tables for LSTM layer) combined with $L _ { K M }$ loss function generates PPW equivalent to TWN PPW. Multi-table model accounts to 1.5 bits per weight in total (after accumulating all the $_ { \pmb { \alpha } }$ and $\textbf { { B } }$ ). Applying $L _ { K M }$ reduces the model size by $2 5 \%$ from TWN (2 bit) to 1.5 bits with equivalent PPW. We also perform 1 bit quantization reaching 128.18 PPW.
127
+
128
+ Hybrid LSTM. In the WikiText-2 LSTM model, Embedding and Softmax layer each forms over $45 \%$ of the full precision model size. Therefore, we selectively optimize the number of quantization bits for each layer to achieve higher compression rate. 1 bit quantization was found to be sufficient for Embedding layer. However, other layers required more number of bits. We fix 1bit quantization for Embedding layer (1 table per row), TWN for Softmax layer and vary the number of quantization bits for LSTM layer. Using 2bit for LSTM layer (1.53 bits per weight in total) provides PPW better than our TWN greedy model, with $2 5 \%$ smaller model size.
129
+
130
+ # 5.3 ABLATION STUDY
131
+
132
+ Random Initialization. The distribution of bit-flips and convergence of accuracy for step training with randomly initialized model and with pre-trained model is observed to be similar (Figure 2). The accuracy gap between Binary Step Training model with pre-trained model and BST without pre-trained model less than $0 . 1 \%$ (Table 1).
133
+
134
+ One-Step Quantization. We experiment the degradation in accuracy with just one-step quantization (no retraining). ResNet32 with full precision accuracy of $9 2 . 4 7 \%$ on CIFAR-10 produces $4 4 . 3 3 \%$ accuracy. To examine the potential of $L _ { K M }$ , ResNet32 is again trained with random initialization in full precision mode with $L _ { K M }$ (without any form of quantization). Although, the full precision accuracy drops to $9 1 . 8 \%$ , one-step quantization accuracy goes up to $7 6 . 3 2 \%$ . Increasing the regularization constant for $L _ { K M }$ yields the one-step quantization accuracy as $8 4 . 5 1 \%$ .
135
+
136
+ Table 3: Comparison of Perplexity Per Word (PPW) for LSTM models on WikiText-2 dataset. Multitable models use 1 quantization bit with multiple tables (8 tables ( $8 \alpha$ per row) for Embedding and Softmax layer, 16 tables for LSTM layer). Hybrid models use 1 bit quantization for Embedding layer and TWN quantization for Softmax layer. 2 to 4 quantization bits for LSTM layer provides 1.53 to 1.65 bits per weight models. Results for Guo et al. (2017) are taken from Xu et al. (2018).
137
+
138
+ <table><tr><td>2-bit models</td><td>PPW</td><td>1.5-bits models</td><td>PPW</td><td>Hybrid models</td><td>PPW</td></tr><tr><td>Guo et al. (2017)</td><td>105.8</td><td>Multi-table</td><td>117.13</td><td>1.53 bit</td><td>108.1</td></tr><tr><td>Xu et al. (2018)</td><td>102.7</td><td>Multi-table + L KM</td><td>115.26</td><td>1.6 bit</td><td>105.46</td></tr><tr><td>Our Greedy</td><td>104.15</td><td>Multi-table + Shuffle</td><td>116.08</td><td>1.65 bit</td><td>103.58</td></tr><tr><td>Our Alternating</td><td>100.3</td><td>TWN</td><td>115.05</td><td></td><td></td></tr></table>
139
+
140
+ Table 4: Robustness of Step Training to Quantization Step Size for CIFAR-10 with ResNet32. Accuracy varies within a range of $3 \%$ with QSS ranging from 10 to 2500.
141
+
142
+ <table><tr><td>Quantization Step Size</td><td>10</td><td>50</td><td>100</td><td>500</td><td>1000</td><td>2500</td><td>5000</td><td>10000</td></tr><tr><td>Accuracy %</td><td>86.77</td><td>88.03</td><td>88.97</td><td>89.15</td><td>88.88</td><td>86.52</td><td>83.01</td><td>78.54</td></tr></table>
143
+
144
+ Robustness. Table 4 shows the robustness of iterative quantization with varying QSS over $2 \mathbf { x }$ in the order of magnitudes. As explained in section 3.1, varying learning rate can provide the same functionality as varying QSS. As most of the modern neural networks use special learning rate policy (such as exponential decay, step-wise decay), the training procedure is overall robust to the choice of QSS. The simplicity of the algorithm and robustness to the added hyper-parameter facilitate quick adoption of our proposed technique.
145
+
146
+ # 5.4 IMAGENET
147
+
148
+ Full precision ResNet18 is trained on ImageNet (Russakovsky et al., 2015) following the base repository3 with batch size of 256. Our binary model reaches $6 0 . 6 \%$ Top1 accuracy compared to full precision accuracy of $6 9 . 6 \%$ (Table 5). Our model shows comparable accuracy compared to existing quantization methods. We believe our model can reach higher accuracy by using layer-by-layer quantization as done by Zhou et al. (2018).
149
+
150
+ # 5.5 QUANTIZATION OVERHEAD
151
+
152
+ Let training time per iteration be defined as the combined time to perform forward-propagation and back-propagation on a batch of data. We evaluate the overhead of performing a quantization step once relative to the defined training time per iteration. All the timings are averaged over 1000 iterations, averaged over ResNet32 and WideResNet. We observed that overhead of using greedy quantization is the lowest $8 \%$ and $12 \%$ of the training time for 1bit and 2bit quantization). More sophisticated quantization methods using regression or iterative procedures, namely refined and alternating quantization, have overhead of ${ 5 } \mathbf { x }$ and $4 0 \mathrm { x }$ respectively over the training time. Table 3 compares the benefit of using these quantization methods, where alternating quantization shows the best performance despite the biggest overhead. As our training method, unlike existing methods, performs quantization once every 500 iterations, the overhead of the quantization is reduced by $5 0 0 \mathrm { x }$ . As a result, the overhead of the most expensive quantization remains to be $10 \%$ of the training time.
153
+
154
+ Table 5: Accuracy Comparison for Imagenet using ResNet18 for 1 bit quantization.
155
+
156
+ <table><tr><td>Config</td><td>Top1 Accuracy</td></tr><tr><td>Full Precision</td><td>69.6</td></tr><tr><td>Li et al. (2016) Dong et al. (2017)</td><td>57.5 58.36</td></tr><tr><td>Our binary model</td><td>60.6</td></tr><tr><td>Rastegari et al. (2016)</td><td>60.8</td></tr><tr><td></td><td></td></tr><tr><td>Zhou et al. (2018)</td><td>64.72</td></tr></table>
157
+
158
+ # 6 CONCLUSION
159
+
160
+ In this work, we have presented an iterative quantization technique performing quantization once every few steps, combined with binary model $_ { \pmb { \alpha } }$ training. Step training explores flatter minima while escaping sharp minima and $_ \alpha$ training performs exploitation of the chosen minima. We also presented a loss function $L _ { K M }$ which allows weights to be adjusted for improved quantization. We demonstrated full precision accuracy recovery with CIFAR and WikiText-2 dataset with our quantized models. We also presented a hybrid model with 1.5 bits performing better than the our TWN model.
161
+
162
+ # REFERENCES
163
+
164
+ Mart´ın Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, Manjunath Kudlur, Josh Levenberg, Rajat Monga, Sherry Moore, Derek G. Murray, Benoit Steiner, Paul Tucker, Vijay Vasudevan, Pete Warden, Martin Wicke, Yuan Yu, and Xiaoqiang Zheng. Tensorflow: A system for largescale machine learning. In Proceedings of the 12th USENIX Conference on Operating Systems Design and Implementation, OSDI’16, pp. 265–283, Berkeley, CA, USA, 2016. USENIX Association. ISBN 978-1-931971-33-1.
165
+
166
+ Kyunghyun Cho, Bart van Merrienboer, C¸ alar G ¨ ulc¸ehre, Dzmitry Bahdanau, Fethi Bougares, Holger ¨ Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder–decoder for statistical machine translation. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 1724–1734, Doha, Qatar, October 2014. Association for Computational Linguistics.
167
+
168
+ Yoojin Choi, Mostafa El-Khamy, and Jungwon Lee. Towards the limit of network quantization. In International Conference on Learning Representations, 2017.
169
+
170
+ Anna Choromanska, MIkael Henaff, Michael Mathieu, Gerard Ben Arous, and Yann LeCun. The Loss Surfaces of Multilayer Networks. In Guy Lebanon and S. V. N. Vishwanathan (eds.), Proceedings of the Eighteenth International Conference on Artificial Intelligence and Statistics, volume 38 of Proceedings of Machine Learning Research, pp. 192–204, San Diego, California, USA, 09–12 May 2015. PMLR.
171
+
172
+ Matthieu Courbariaux, Yoshua Bengio, and Jean-Pierre David. Binaryconnect: Training deep neural networks with binary weights during propagations. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett (eds.), Advances in Neural Information Processing Systems 28, pp. 3123–3131. Curran Associates, Inc., 2015.
173
+
174
+ Yinpeng Dong, Jianguo Li, and Renkun Ni. Learning accurate low-bit deep neural networks with stochastic quantization. In British Machine Vision Conference 2017, BMVC 2017, London, UK, September 4-7, 2017, 2017.
175
+
176
+ Ian J. Goodfellow, Oriol Vinyals, and Andrew M. Saxe. Qualitatively characterizing neural network optimization problems. In International Conference on Learning Representations, 2015.
177
+
178
+ Yiwen Guo, Anbang Yao, Hao Zhao, and Yurong Chen. Network sketching: Exploiting binary structure in deep cnns. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), July 2017.
179
+
180
+ Song Han, Jeff Pool, John Tran, and William Dally. Learning both weights and connections for efficient neural network. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett (eds.), Advances in Neural Information Processing Systems 28, pp. 1135–1143. Curran Associates, Inc., 2015.
181
+
182
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770– 778, 2016.
183
+
184
+ Sepp Hochreiter and Jrgen Schmidhuber. Simplifying neural nets by discovering flat minima. In Advances in Neural Information Processing Systems 7, pp. 529–536. MIT Press, 1995.
185
+
186
+ Lu Hou, Quanming Yao, and James T. Kwok. Loss-aware binarization of deep networks. In International Conference on Learning Representations, 2017.
187
+
188
+ Itay Hubara, Matthieu Courbariaux, Daniel Soudry, Ran El-Yaniv, and Yoshua Bengio. Binarized neural networks. In D. D. Lee, M. Sugiyama, U. V. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems 29, pp. 4107–4115. Curran Associates, Inc., 2016.
189
+
190
+ Itay Hubara, Matthieu Courbariaux, Daniel Soudry, Ran El-Yaniv, and Yoshua Bengio. Quantized neural networks: Training neural networks with low precision weights and activations. Journal of Machine Learning Research, 18(187):1–30, 2018.
191
+
192
+ Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In Proceedings of the 32Nd International Conference on International Conference on Machine Learning - Volume 37, ICML’15, pp. 448–456. JMLR.org, 2015.
193
+
194
+ Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, and Ping Tak Peter Tang. On large-batch training for deep learning: Generalization gap and sharp minima. In International Conference on Learning Representations, 2017.
195
+
196
+ S. Kirkpatrick, C. D. Gelatt, and M. P. Vecchi. Optimization by simulated annealing. SCIENCE, 220(4598):671–680, 1983.
197
+
198
+ Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, 2009.
199
+
200
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In F. Pereira, C. J. C. Burges, L. Bottou, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 25, pp. 1097–1105. Curran Associates, Inc., 2012.
201
+
202
+ Dongsoo Lee and Byeongwook Kim. Retraining-based iterative weight quantization for deep neural networks. CoRR, abs/1805.11233, 2018.
203
+
204
+ Fengfu Li, Bo Zhang, and Bin Liu. Ternary weight networks. CoRR, abs/1605.04711, 2016.
205
+
206
+ Hao Li, Zheng Xu, Gavin Taylor, and Tom Goldstein. Visualizing the loss landscape of neural nets, 2018.
207
+
208
+ Xiaofan Lin, Cong Zhao, and Wei Pan. Towards accurate binary convolutional neural network. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems 30, pp. 345–353. Curran Associates, Inc., 2017.
209
+
210
+ Mark D. McDonnell. Training wide residual networks for deployment using a single bit for each weight. In International Conference on Learning Representations, 2018.
211
+
212
+ Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. In International Conference on Learning Representations, 2017.
213
+
214
+ Mohammad Rastegari, Vicente Ordonez, Joseph Redmon, and Ali Farhadi. Xnor-net: Imagenet classification using binary convolutional neural networks. In Bastian Leibe, Jiri Matas, Nicu Sebe, and Max Welling (eds.), Computer Vision – ECCV 2016, pp. 525–542, Cham, 2016. Springer International Publishing. ISBN 978-3-319-46493-0.
215
+
216
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett (eds.), Advances in Neural Information Processing Systems 28, pp. 91–99. Curran Associates, Inc., 2015.
217
+
218
+ Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211–252, 2015. doi: 10.1007/s11263-015-0816-y.
219
+
220
+ T. N. Sainath, B. Kingsbury, V. Sindhwani, E. Arisoy, and B. Ramabhadran. Low-rank matrix factorization for deep neural network training with high-dimensional output targets. In 2013 IEEE International Conference on Acoustics, Speech and Signal Processing, pp. 6655–6659, May 2013. doi: 10.1109/ICASSP.2013.6638949.
221
+
222
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, pp. 2818–2826. IEEE Computer Society, 2016.
223
+
224
+ Vladimir Vapnik and Rauf Izmailov. Learning using privileged information: Similarity control and knowledge transfer. Journal of Machine Learning Research, 16:2023–2049, 2015.
225
+
226
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin. Attention is all you need. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems 30, pp. 5998–6008. Curran Associates, Inc., 2017.
227
+
228
+ Lyan Verwimp, Joris Pelemans, Hugo Van hamme, and Patrick Wambacq. Character-word lstm language models. In EACL, 2017.
229
+
230
+ Peisong Wang, Qinghao Hu, Yifan Zhang, Chunjie Zhang, Yang Liu, and Jian Cheng. Two-step quantization for low-bit neural networks. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018.
231
+
232
+ Chen Xu, Jianqiang Yao, Zhouchen Lin, Wenwu Ou, Yuanbin Cao, Zhirong Wang, and Hongbin Zha. Alternating multi-bit quantization for recurrent neural networks. In International Conference on Learning Representations, 2018.
233
+
234
+ Aojun Zhou, Anbang Yao, Yiwen Guo, Lin Xu, and Yurong Chen. Incremental network quantization: Towards lossless cnns with low-precision weights. In International Conference on Learning Representations, 2017a.
235
+
236
+ Aojun Zhou, Anbang Yao, Kuan Wang, and Yurong Chen. Explicit loss-error-aware quantization for low-bit deep neural networks. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018.
237
+
238
+ Shuchang Zhou, Zekun Ni, Xinyu Zhou, He Wen, Yuxin Wu, and Yuheng Zou. Dorefa-net: Training low bitwidth convolutional neural networks with low bitwidth gradients. CoRR, abs/1606.06160, 2016.
239
+
240
+ Shuchang Zhou, Yuzhi Wang, He Wen, Qinyao He, and Yuheng Zou. Balanced quantization: An effective and efficient approach to quantized neural networks. 32:667–682, 06 2017b.
241
+
242
+ Chenzhuo Zhu, Song Han, Huizi Mao, and William J. Dally. Trained ternary quantization. In International Conference on Learning Representations, 2017.
243
+
244
+ Bohan Zhuang, Chunhua Shen, Mingkui Tan, Lingqiao Liu, and Ian Reid. Towards effective lowbitwidth convolutional neural networks. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018.
245
+
246
+ Barret Zoph, Vijay Vasudevan, Jonathon Shlens, and Quoc V. Le. Learning transferable architectures for scalable image recognition. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018.
247
+
248
+ # APPENDIX
249
+
250
+ # A UPDATE TO $\pmb { \alpha }$ IN PHASE2
251
+
252
+ For lower learning rates, as $\mathbf { B }$ are fixed, $( w \cdot ( w + \triangle w ) ) > 0 )$ , where $w \in \mathbb { W }$ . Equation 3 is correspondingly updated to -
253
+
254
+ $$
255
+ \alpha + \triangle \alpha = \frac { 1 } { n } \sum | \boldsymbol { \mathsf { W } } + \triangle \boldsymbol { \mathsf { W } } | = \frac { 1 } { n } \sum | \boldsymbol { \mathsf { W } } | + \frac { 1 } { n } \sum \triangle \boldsymbol { \mathsf { W } } \circ \boldsymbol { \mathsf { B } }
256
+ $$
257
+
258
+ whewre $\circ$ is Hadamard product. Equation 5 shows that updates to $\boldsymbol { \mathsf { W } }$ are directly merged into $_ \alpha$ (after $\mathsf { B }$ has converged). Thus, the training procedure for quantization with low learning rate can be more efficient by optimizing $_ { \pmb { \alpha } }$ only, compared with optimizing both $\mathbf { B }$ and $_ { \pmb { \alpha } }$ . Phase2 presents such an efficient optimization method.
259
+
260
+ # B TRAINING DETAILS
261
+
262
+ We provide more details on the training procedure for the networks for all the datasets.
263
+
264
+ # B.1 CIFAR
265
+
266
+ CIFAR dataset consists of 50000 training images with 10000 test images. Each image is of size $3 2 \mathrm { x } 3 2 $ . CIFAR-10 dataset classifies the corpus of images into 10 disjoint classes. CIFAR-100 classifies the image set into 100 fine-grained disjoint classes.
267
+
268
+ ResNet. ResNet32 and WideResNet 28-10 were both trained for 90k iterations with batch size of 128. Step-wise decay learning schedule was used. With initial learning rate of 0.1, learning rate was decayed with 0.1 at 40k, 60k and $8 0 \mathrm { k }$ iterations each. Momentum training optimizer was used for training with momentum set 0.9. 0.0005 was set as weight decay rate. Training was pre-processed with random cropping and random horizontal flipping. Evaluation data was pre-processed with a single central crop only. Quantization Step Size was set as 500 during step training.
269
+
270
+ Pruning. ResNet32 was pruned with $60 \%$ as the final sparsity, with an initial sparsity of $20 \%$ . Pruning was started with a pre-trained model. Pruning was gradually increased at en exponential rate (exponential factor of 3) with the pruning being performed every 100 iterations. Re-training for pruning for performed for 40k iterations.
271
+
272
+ # B.2 WIKITEXT-2
273
+
274
+ WikiText-2 contains 2088k training, $2 1 7 \mathrm { k }$ validation and $2 4 5 \mathrm { k }$ test tokens, with a vocabulary of $3 3 \mathrm { k }$ words. The model for Wikitext-2 consisted of 1 LSTM layer with 512 units. Initial learning rate was set as 20. Learning rate was decayed by 1.2 every 2 epochs. Training was terminated once the learning rate was less than 0.001 or maximum of 80 epochs was reached. The absolute gradient norm was set at 0.25. The network was unrolled for 30 time steps. Training was performed with a dropout ratio of 0.5. Weights were clipped to an absolute maximum of 1.0. Quantization Step Size was set as 500 during step training.
275
+
276
+ Divergence with Greedy Quantization. Using greedy quantization with 2bit quantization for LSTM model always diverged the training with WikiText-2 dataset. To make the model converge up to some extent, we used 1bit quantized model as an initialization for 2 bit quantization. Although, 1bit initialized model converges for a few epochs but also diverges after 10-15 epochs. The results reported in Table 3 for 2 bit greedy quantization follow initializing with 1bit quantized model. The divergence in network with greedy quantization is the reason for using TWN for Softmax layer (and not 2bit quantization) in our hybrid model.
277
+
278
+ # B.3 IMAGENET
279
+
280
+ ImageNet consists of 1281176 training images with 50000 validation images, classified into 1000 classes. ResNet18 network was used for training. Training data was pre-processed with random cropping and random horizontal flipping. However, validation data was pre-processed with 1 single central crop. Step-wise decay learning rate schedule was followed with initial learning rate of 0.1 and decayed at epochs 30, 60, 80 and 90 by a factor of 0.1. The complete training procedure was performed for 100 epochs with a batch size of 256. Momentum training optimizer was used for training with momentum set 0.9. 0.0005 was set as weight decay rate. Quantization Step Size was set as 500 during step training.
281
+
282
+ ![](images/73277cf427dd67f429e415fddfe65da591c214b27b974e4c03867158a607437c.jpg)
283
+ Figure 3: Comparing different skewed and default quantization mode (Rastegari et al., 2016) with multiple tables. Skewed quantization mode converts a 4d tensor $\pmb { \mathsf { W } } \in \dot { \mathbb { R } } ^ { k \times c \times \overline { { f } } \times f }$ into $\scriptstyle { \dot { \mathbb { R } } } ^ { f \times k c { \dot { f } } }$ , and default quantization mode convert into $\mathbb { R } ^ { k \times c f f }$ (where $\mathbf { k }$ is number of output features, c is number of input features, fxf is the filter size). For a kernel of shape $1 2 8 \mathrm { x } 1 2 8 \mathrm { x } 3 \mathrm { x } 3$ , skewed mode with 42 tables has a memory footprint equivalent to default quantization mode.
284
+
285
+ ![](images/3c3929a73913a80050e31aafdfa3617efadbbe83b1c7b3299e53703e85418861.jpg)
286
+ (a) Performing node shuffling for a layer in DNN
287
+
288
+ ![](images/1b85d376c9dfd6f6002d72152e2beaef16033d2c4562de5ebd89991d13c9241c.jpg)
289
+ (b) Performing node shuffling for the first layer of DNN
290
+ Figure 4: Performing node shuffling for a layer in DNN. (a) Node shuffling for a layer in between 2 layers is performed by switching the row and columns of the previous and next weight matrix. (b) Node shuffling for the first layer of DNN is performed using shuffle layer. Shuffle layer maps the input to match the shuffling order with a very small overhead. Shuffle layers can also be added for RNN/LSTM layer to performing shuffling of layers independently in the weight matrices of RNN/LSTM layer.
291
+
292
+ # B.4 BATCH NORMALIZATION
293
+
294
+ Batch normalization (Ioffe & Szegedy, 2015) parameters ( $\dot { \mu }$ and $\sigma$ ) are updated using moving average. Consequently, the effect of quantized-distortion performed even 100 iterations earlier would have less than $1 \%$ effect on the BN parameters (with momentum $_ { 1 = 0 . 9 9 }$ ). As a result, BN parameters are not suited well for quantized model and results in drop in evaluation accuracy for the quantized model. To avoid the drop in evaluation accuracy by BN, the BN parameters are re-evaluated over 1 train epoch (keeping the other parameters fixed) before performing evaluation for the phase1. Phase2 does not require any special care for batch normalization as there is no distortion step.
295
+
296
+ ![](images/c892c49c74078cf42dc5647d606d620fd63b4825293fda0d9187f135f44be412.jpg)
297
+ Figure 5: Convergence of weight when training using Step Training. Compares two scenarios where (a) bit flips once and (b) bit does not flips during the course of step training. Step training was performed for ResNet32 using CIFAR-10 dataset.
298
+
299
+ ![](images/7a02a71403592d5c16fcd2c4ec56d1bef8bf13ede36e2b5580b75ec4aafde3b6.jpg)
300
+ Figure 6: (a) Shows the convergence of quantization error with decrease in learning rate. The distance between consecutive quantization weights (QSS iterations apart) and distance between corresponding full precision weights is also shown. Distance between consecutive quantization weights is directly correlated with the number of weight flips (Figure 2). (b) Shows the movement of loss with step training for ResNet32 using CIFAR-10 dataset. The loss rises for the last learning rate as distortion causes more damage compared what training with the small learning rate can repair.
301
+
302
+ ![](images/049edc2e340afc9f908558269628d7c9b4890e713e6e9441db9e635ba16d3af2.jpg)
303
+ Figure 7: (a) Shows the same behavior of histogram of total bit flips for step training with or without pre-trained model for ResNet32 with CIFAR-10 dataset. (b) Parametric 1-D plots as described in (Goodfellow et al., 2015; Keskar et al., 2017). $Q _ { i }$ denote the weight set after performing quantizeddistortion for the $\mathrm { i ^ { \mathrm { t h } } }$ time while performing step training. $F P _ { i }$ correspond to the full precision weight set just before performing the $\mathrm { i ^ { \mathrm { t h } } }$ quantized-distortion. The plot is for cross entropy along a line segment containing the two points. Specifically for $a \in [ 0 , 1 ]$ , we plot $f ( a Q _ { i } + ( 1 - a ) F \bar { P _ { i } } )$ . The same is plotted for $F P _ { i }$ and $Q _ { i + 1 }$ .
304
+
305
+ ![](images/35f987ee67e7abacf49740d2d9f50aeca7c8b89ee96f645f5233f04a60623a88.jpg)
306
+ Figure 8: (a) Parametric 1-D plots quantized weight sets at different learning rates while performing step training. Step training is performed with $1 6 0 \mathrm { k }$ iterations, with learning rate decayed by 0.1 every 40k steps to investigate the effects of 4 different learning rates. All the quantized points are sampled randomly at different iterations at different learning rate. $Q _ { 1 }$ is obtained at learning rate 0.1, $Q _ { 2 }$ at 0.01, $Q _ { 3 }$ at 0.001 and $Q _ { 4 }$ at 0.0001. (b) Starting from these quantized weight sets, the model is retrained using full precision training method for the remainder of the iterations. This retraining gives us $F P _ { 1 } , F P _ { 2 } , F P _ { 3 } , F P _ { 4 }$ . The rise in the loss function along the path between two full precision points shows the existence of full precision weights in different local minimum.
307
+
308
+ ![](images/8db582feabec0a018824c60442d0efadba8dc1e50e9634e31cce9873fa939a86.jpg)
309
+ Figure 9: Distribution of weights of the WikiText-2 LSTM model for full precision and quantized trained model.
md/train/TR-Nj6nFx42/TR-Nj6nFx42.md ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A PAC-BAYESIAN APPROACH TO GENERALIZATION BOUNDS FOR GRAPH NEURAL NETWORKS
2
+
3
+ Renjie Liao1,2, Raquel Urtasun1,2,3, Richard Zemel1,2,3
4
+ University of Toronto1, Vector Institute3, Canadian Institute for Advanced Research3
5
+ {rjliao, urtasun, zemel}@cs.toronto.edu
6
+
7
+ # ABSTRACT
8
+
9
+ In this paper, we derive generalization bounds for two primary classes of graph neural networks (GNNs), namely graph convolutional networks (GCNs) and message passing GNNs (MPGNNs), via a PAC-Bayesian approach. Our result reveals that the maximum node degree and the spectral norm of the weights govern the generalization bounds of both models. We also show that our bound for GCNs is a natural generalization of the results developed in (Neyshabur et al., 2017) for fully-connected and convolutional neural networks. For MPGNNs, our PACBayes bound improves over the Rademacher complexity based bound (Garg et al., 2020), showing a tighter dependency on the maximum node degree and the maximum hidden dimension. The key ingredients of our proofs are a perturbation analysis of GNNs and the generalization of PAC-Bayes analysis to non-homogeneous GNNs. We perform an empirical study on several synthetic and real-world graph datasets and verify that our PAC-Bayes bound is tighter than others.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Graph neural networks (GNNs) (Gori et al., 2005; Scarselli et al., 2008; Bronstein et al., 2017; Battaglia et al., 2018) have become very popular recently due to their ability to learn powerful representations from graph-structured data, and have achieved state-of-the-art results in a variety of application domains such as social networks (Hamilton et al., 2017; Xu et al., 2018), quantum chemistry (Gilmer et al., 2017; Chen et al., 2019a), computer vision (Qi et al., 2017; Monti et al., 2017), reinforcement learning (Sanchez-Gonzalez et al., 2018; Wang et al., 2018), robotics (Casas et al., 2019; Liang et al., 2020), and physics (Henrion et al., 2017). Given a graph along with node/edge features, GNNs learn node/edge representations by propagating information on the graph via local computations shared across the nodes/edges. Based on the specific form of local computation employed, GNNs can be divided into two categories: graph convolution based GNNs (Bruna et al., 2013; Duvenaud et al., 2015; Kipf & Welling, 2016) and message passing based GNNs (Li et al., 2015; Dai et al., 2016; Gilmer et al., 2017). The former generalizes the convolution operator from regular graphs (e.g., grids) to ones with arbitrary topology, whereas the latter mimics message passing algorithms and parameterizes the shared functions via neural networks.
14
+
15
+ Due to the tremendous empirical success of GNNs, there is increasing interest in understanding their theoretical properties. For example, some recent works study their expressiveness (Maron et al., 2018; Xu et al., 2018; Chen et al., 2019b), that is, what class of functions can be represented by GNNs. However, only few works investigate why GNNs generalize so well to unseen graphs. They are either restricted to a specific model variant (Verma & Zhang, 2019; Du et al., 2019; Garg et al., 2020) or have loose dependencies on graph statistics (Scarselli et al., 2018).
16
+
17
+ On the other hand, GNNs have close ties to standard feedforward neural networks, e.g., multi-layer perceptrons (MLPs) and convolutional neural networks (CNNs). In particular, if each i.i.d. sample is viewed as a node, then the whole dataset becomes a graph without edges. Therefore, GNNs can be seen as generalizations of MLPs/CNNs since they model not only the regularities within a sample but also the dependencies among samples as defined in the graph. It is therefore natural to ask if we can generalize the recent advancements on generalization bounds for MLPs/CNNs (Harvey et al., 2017; Neyshabur et al., 2017; Bartlett et al., 2017; Dziugaite & Roy, 2017; Arora et al., 2018; 2019) to GNNs, and how would graph structures affect the generalization bounds?
18
+
19
+ In this paper, we answer the above questions by proving generalization bounds for the two primary classes of GNNs, i.e., graph convolutional networks (GCNs) (Kipf & Welling, 2016) and messagepassing GNNs (MPGNNs) (Dai et al., 2016; Jin et al., 2018).
20
+
21
+ Our generalization bound for GCNs shows an intimate relationship with the bounds for MLPs/CNNs with ReLU activations (Neyshabur et al., 2017; Bartlett et al., 2017). In particular, they share the same term, i.e., the product of the spectral norms of the learned weights at each layer multiplied by a factor that is additive across layers. The bound for GCNs has an additional multiplicative factor $d ^ { ( l - 1 ) / 2 }$ where $d - 1$ is the maximum node degree and $l$ is the network depth. Since MLPs/CNNs are special GNNs operating on graphs without edges (i.e., $d - 1 = 0$ ), the bound for GCNs coincides with the ones for MLPs/CNNs with ReLU activations (Neyshabur et al., 2017) on such degenerated graphs. Therefore, our result is a natural generalization of the existing results for MLPs/CNNs.
22
+
23
+ Our generalization bound for message passing GNNs reveals that the governing terms of the bound are similar to the ones of GCNs, i.e., the geometric series of the learned weights and the multiplicative factor $d ^ { l - 1 }$ . The geometric series appears due to the weight sharing across message passing steps, thus corresponding to the product term across layers in GCNs. The term $d ^ { l - 1 }$ encodes the key graph statistics. Our bound improves the dependency on the maximum node degree and the maximum hidden dimension compared to the recent Rademacher complexity based bound (Garg et al., 2020). Moreover, we compute the bound values on four real-world graph datasets (e.g., social networks and protein structures) and verify that our bounds are tighter.
24
+
25
+ In terms of the proof techniques, our analysis follows the PAC-Bayes framework in the seminal work of (Neyshabur et al., 2017) for MLPs/CNNs with ReLU activations. However, we make two distinctive contributions which are customized for GNNs. First, a naive adaptation of the perturbation analysis in (Neyshabur et al., 2017) does not work for GNNs since ReLU is not 1-Lipschitz under the spectral norm, i.e., $\| \mathrm { R e L U } ( X ) \| _ { 2 } \leq \| X \| _ { 2 }$ does not hold for some real matrix $X$ . Instead, we construct the recursion on certain node representations of GNNs like the one with maximum $\ell _ { 2 }$ norm, so that we can perform perturbation analysis with vector 2-norm. Second, in contrast to (Neyshabur et al., 2017) which only handles the homogeneous networks, i.e., $f ( a x ) = a f ( x )$ when $a \geq 0$ , we properly construct a quantity of the learned weights which 1) provides a way to satisfy the constraints of the previous perturbation analysis and 2) induces a finite covering on the range of the quantity so that the PAC-Bayes bound holds for all possible weights. This generalizes the analysis to non-homogeneous GNNs like typical MPGNNs.
26
+
27
+ The rest of the paper is organized as follows. In Section 2, we introduce background material necessary for our analysis. We then present our generalization bounds and the comparison to existing results in Section 3. We also provide an empirical study to support our theoretical arguments in Section 4. At last, we discuss the extensions, limitations and some open problems.
28
+
29
+ # 2 BACKGROUND
30
+
31
+ In this section, we first explain our analysis setup including notation and assumptions. We then describe the two representative GNN models in detail. Finally, we review the PAC-Bayes analysis.
32
+
33
+ # 2.1 ANALYSIS SETUP
34
+
35
+ In the following analysis, we consider the $K$ -class graph classification problem which is common in the GNN literature, where given a graph sample $z$ , we would like to classify it into one of the predefined $K$ classes. We will discuss extensions to other problems like graph regression in Section 5. Each graph sample $z$ is a triplet of an adjacency matrix $A$ , node features $\mathbf { \bar { \boldsymbol { X } } } \in \mathbf { \overline { { \mathbb { R } } } } ^ { n \times h _ { 0 } }$ and output label $y \in \bar { \mathbb { R } } ^ { 1 \times K }$ , i.e. $z = ( A , X , y )$ , where $n$ is the number of nodes and $h _ { 0 }$ is the input feature dimension. We start our discussion by defining our notations. Let $\mathbb { N } _ { k } ^ { + }$ be the first $k$ positive integers, i.e., $\mathbb { N } _ { k } ^ { + } = \{ 1 , 2 , \dots , k \}$ , $| \cdot | _ { p }$ the vector $p$ -norm and $\| \cdot \| _ { p }$ the operator norm induced by the vector $p$ -norm. Further, $\| \cdot \| _ { F }$ denotes the Frobenius norm of a matrix, $e$ the base of the natural logarithm function log, $A [ i , j ]$ the $( i , j )$ -th element of matrix $A$ and $A [ i , : ]$ the $i$ -th row. We use parenthesis to avoid the ambiguity, e.g., $( A B ) [ i , j ]$ means the $( i , j )$ -th element of the product matrix $A B$ . We then introduce some terminologies from statistical learning theory and define the sample space as $\mathcal { Z }$ , $z = ( A , X , y ) \in \mathcal { Z }$ where $X \in { \mathcal { X } }$ (node feature space) and $A \in { \mathcal { G } }$ (graph space), data distribution $\mathcal { D } , z \stackrel { i i d } { \sim } \mathcal { D }$ , hypothesis (or model) $f _ { w }$ where $f _ { w } \in \mathcal { H }$ (hypothesis class), and training set $S$ with size $m$ , $S = \{ z _ { 1 } , \dots , z _ { m } \}$ . We make the following assumptions which also appear in the literature:
36
+
37
+ A1 Data, i.e., triplets $( A , X , y )$ , are i.i.d. samples drawn from some unknown distribution $\mathcal { D }$ .
38
+
39
+ A2 The maximum hidden dimension across all layers is $h$ .
40
+ A3 Node feature of any graph is contained in a $\ell _ { 2 }$ -ball with radius $B$ . Specifically, we have $\forall i \in \mathbb { N } _ { n } ^ { + }$ , the $i$ -th node feature $\begin{array} { r } { X [ i , : ] \in \mathcal { X } _ { B , h _ { 0 } } = \{ x \in \mathbb { R } ^ { h _ { 0 } } | \sum _ { j = 1 } ^ { h _ { 0 } } { x _ { j } ^ { 2 } } ^ { * } \leq B ^ { 2 } \} } \end{array}$ .
41
+ A4 We only consider simple graphs (i.e., undirected, no loops1, and no multi-edges) with maximum node degree as $d - 1$ .
42
+
43
+ Note that it is straightforward to estimate $B$ and $d$ empirically on real-world graph data.
44
+
45
+ # 2.2 GRAPH NEURAL NETWORKS (GNNS)
46
+
47
+ In this part, we describe the details of the GNN models and the loss function we used for the graph classification problem. The essential idea of GNNs is to propagate information over the graph so that the learned representations capture the dependencies among nodes/edges. We now review two classes of GNNs, GCNs and MPGNNs, which have different mechanisms for propagating information. We choose them since they are the most popular variants and represent two common types of neural networks, i.e., feedforward (GCNs) and recurrent (MPGNNs) neural networks. We discuss the extension of our analysis to other GNN variants in Section 5. For ease of notation, we define the model to be $f _ { w } \in \mathcal { H } : \dot { \mathcal { X } } \times \mathcal { G } \to \mathbb { R } ^ { K }$ where $w$ is the vectorization of all model parameters.
48
+
49
+ GCNs: Graph convolutional networks (GCNs) (Kipf & Welling, 2016) for the $K$ -class graph classification problem can be defined as follows,
50
+
51
+ $$
52
+ \begin{array} { l l } { { H _ { k } = \sigma _ { k } \left( \tilde { L } H _ { k - 1 } W _ { k } \right) } } & { { \qquad ( k \mathrm { - t h ~ G r a p h ~ C o n v o l u t i o n ~ L a y e r } ) } } \\ { { { } } } & { { { } } } \\ { { H _ { l } = \frac { 1 } { n } { \bf 1 } _ { n } H _ { l - 1 } W _ { l } } } & { { \qquad ( \mathrm { R e a d o u t ~ L a y e r } ) , } } \end{array}
53
+ $$
54
+
55
+ where $k \in \mathbb { N } _ { l - 1 } ^ { + }$ , $H _ { k } \in \mathbb { R } ^ { n \times h _ { k } }$ are the node representations/states, $\mathbf { 1 } _ { n } \in \mathbb { R } ^ { 1 \times n }$ is a all-one vector, $l$ is the number of layers.2 and $W _ { j }$ is the weight matrix of the $j$ -th layer. The initial node state is the observed node feature $H _ { 0 } = X$ . For both GCNs and MPGNNs, we consider $l > 1$ since otherwise the model degenerates to a linear transformation which does not leverage the graph and is trivial to analyze. Due to assumption A2, $W _ { j }$ is of size at most $h \times h$ , i.e., $\bar { h _ { k } } \le \bar { h , \forall k } \in \mathbb { N } _ { l - 1 } ^ { + }$ . The graph Laplacian $\tilde { L }$ is defined as, ${ \tilde { A } } = I + A$ , $\tilde { L } = D ^ { - \frac { 1 } { 2 } } \tilde { A } D ^ { - \frac { 1 } { 2 } }$ where $D$ is the degree matrix of $\bar { A }$ . Note that the maximum eigenvalue of $\tilde { L }$ is 1 in this case. We absorb the bias into the weight by appending constant 1 to the node feature. Typically, GCNs use ReLU as the non-linearity, i.e., $\bar { \sigma _ { i } } \bar { ( x ) ^ { } } = \mathrm { m a x } ( 0 , x ) , \forall i = 1 , \cdot \cdot \cdot , l - 1$ . We use the common mean-readout to obtain the graph representation where $H _ { l - 1 } \in \mathbb { R } ^ { n \times h _ { l - 1 } }$ , $W _ { l } \in \mathbb { R } ^ { h _ { l - 1 } \times K }$ , and $H _ { l } \in \mathbb { R } ^ { 1 \times K }$ .
56
+
57
+ MPGNNs: There are multiple variants of message passing GNNs, e.g., (Li et al., 2015; Dai et al., 2016; Gilmer et al., 2017), which share the same algorithmic framework but instantiate a few components differently, e.g., the node state update function. We choose the same class of models as in (Garg et al., 2020) which are popular in the literature (Dai et al., 2016; Jin et al., 2018) in order to fairly compare bounds. This MPGNN model can be written in matrix forms as follows,
58
+
59
+ <table><tr><td>Mk = g(CJutHk-1)</td><td>(k-th step Message Computation)</td></tr><tr><td>Mk = CinMk</td><td>(k-th step Message Aggregation)</td></tr><tr><td>Hk =𝜙(XW1+ρ(Mk) W2)</td><td>(k-th step Node State Update)</td></tr><tr><td>H= =1nHt-1Wi n</td><td>(Readout Layer),</td></tr></table>
60
+
61
+ where $k \in \mathbb { N } _ { l - 1 } ^ { + }$ , $H _ { k } \ \in \ \mathbb { R } ^ { n \times h _ { k } }$ are node representations/states and $H _ { l } ~ \in ~ \mathbb { R } ^ { 1 \times K }$ is the output representation. Here we initialize $H _ { 0 } = \mathbf { 0 }$ . W.l.o.g., we assume $\forall k \in \mathbb { N } _ { l - 1 } ^ { + }$ , $H _ { k } \in \mathbb { R } ^ { n \times h }$ and $M _ { k } \in \mathbb { R } ^ { n \times h }$ since $h$ is the maximum hidden dimension. $C _ { \mathrm { i n } } \in \mathbb { R } ^ { n \times c }$ and $C _ { \mathrm { o u t } } \in \mathbb { R } ^ { n \times c }$ ( $\dot { } c$ is the number of edges) are the incidence matrices corresponding to incoming and outgoing nodes3 respectively. Specifically, rows and columns of $C _ { \mathrm { i n } }$ and $C _ { \mathrm { o u t } }$ correspond to nodes and edges respectively. $C _ { \mathrm { i n } } [ i , j ] = 1$ indicates that the incoming node of the $j$ -th edge is the $i$ -th node. Similarly, $C _ { \mathrm { o u t } } [ i , j ] = 1$ indicates that the outgoing node of the $j$ -th edge is the $i$ -th node. $g , \phi , \rho$ are nonlinear mappings, e.g., ReLU and Tanh. Technically speaking, $\mathbf { \bar { \rho } } _ { g } : \mathbb { R } ^ { h } \to \mathbb { R } ^ { h }$ , $\phi : \bar { \mathbb { R } ^ { h } } \overset { \cdot } { } \mathbb { R } ^ { h }$ , and $\rho : \mathbb { R } ^ { h } \dot { \mathbb { R } } ^ { h }$ operate on vector-states of individual node/edge. However, since we share these functions across nodes/edges, we can naturally generalize them to matrix-states, e.g., $\tilde { \phi } : \mathbb { R } ^ { n \times h } \mathbb { R } ^ { n \times h }$ where ${ \tilde { \phi } } ( X ) [ i , : ] = \phi ( X [ i , : ] )$ . By doing so, the same function could be applied to matrices with varying size of the first dimension. For simplicity, we use $g , \phi , \rho$ to denote such generalization to matrices. We denote the Lipschitz constants of $g , \phi , \rho$ under the vector 2-norm as $C _ { g } , C _ { \phi } , C _ { \rho }$ respectively. We also assume $g ( \mathbf { 0 } ) = \mathbf { 0 }$ , $\phi ( \mathbf { 0 } ) = \mathbf { 0 }$ , and $\rho ( \mathbf { 0 } ) = \mathbf { 0 }$ and define the percolation complexity as $\mathcal { C } = C _ { g } C _ { \phi } C _ { \rho } \Vert W _ { 2 } \Vert _ { 2 }$ following (Garg et al., 2020).
62
+
63
+ Multiclass Margin Loss: We use the multi-class $\gamma \cdot$ -margin loss following (Bartlett et al., 2017; Neyshabur et al., 2017). The generalization error is defined as,
64
+
65
+ $$
66
+ L _ { \mathcal { D } , \gamma } ( f _ { w } ) = \operatorname* { \mathbb { P } } _ { z \sim \mathcal { D } } \bigg ( f _ { w } ( X , A ) [ y ] \leq \gamma + \operatorname* { m a x } _ { j \neq y } f _ { w } ( X , A ) [ j ] \bigg ) ,
67
+ $$
68
+
69
+ where $\gamma > 0$ and $f _ { w } ( X , A )$ is the $l$ -th layer representations, i.e., $H _ { l } = f _ { w } ( X , A )$ . Accordingly, we can define the empirical error as,
70
+
71
+ $$
72
+ L _ { S , \gamma } ( f _ { w } ) = \frac { 1 } { m } \sum _ { z _ { i } \in S } \mathbf { 1 } \left( f _ { w } ( X , A ) [ y ] \leq \gamma + \operatorname* { m a x } _ { j \neq y } f _ { w } ( X , A ) [ j ] \right) .
73
+ $$
74
+
75
+ # 2.3 BACKGROUND OF PAC-BAYES ANALYSIS
76
+
77
+ PAC-Bayes (McAllester, 1999; 2003; Langford & Shawe-Taylor, 2003) takes a Bayesian view of the probably approximately correct (PAC) learning theory (Valiant, 1984). In particular, it assumes that we have a prior distribution $P$ over the hypothesis class $\mathcal { H }$ and obtain a posterior distribution $Q$ over the same support through the learning process on the training set. Therefore, instead of having a deterministic model/hypothesis as in common learning formulations, we have a distribution of models. Under this Bayesian view, we define the generalization error and the empirical error as,
78
+
79
+ $$
80
+ L _ { S , \gamma } ( Q ) = \mathbb { E } _ { w \sim Q } [ L _ { S , \gamma } ( f _ { w } ) ] , \qquad L _ { { \mathcal { D } } , \gamma } ( Q ) = \mathbb { E } _ { w \sim Q } [ L _ { { \mathcal { D } } , \gamma } ( f _ { w } ) ] .
81
+ $$
82
+
83
+ Since many interesting models like neural networks are deterministic and the exact form of the posterior $Q$ induced by the learning process and the prior $P$ is typically unknown, it is unclear how one can perform PAC-Bayes analysis. Fortunately, we can exploit the following result from the PAC-Bayes theory.
84
+
85
+ Theorem 2.1. (McAllester, 2003) (Two-sided) Let $P$ be a prior distribution over $\mathcal { H }$ and let $\delta \in \mathbf { \Xi }$ $( 0 , 1 )$ . Then, with probability $1 - \delta$ over the choice of an i.i.d. size- $m$ training set $S$ according to $\mathcal { D }$ , for all distributions $Q$ over $\mathcal { H }$ and any $\gamma > 0$ , we have
86
+
87
+ $$
88
+ L _ { \mathcal { D } , \gamma } ( Q ) \leq L _ { S , \gamma } ( Q ) + \sqrt { \frac { D _ { \mathrm { K L } } ( Q \| P ) + \ln \frac { 2 m } { \delta } } { 2 ( m - 1 ) } } .
89
+ $$
90
+
91
+ Here $D _ { \mathrm { K L } }$ is the KL-divergence. The nice thing about this result is that the inequality holds for all possible prior $P$ and posterior $Q$ distributions. Hence, we have the freedom to construct specific priors and posteriors so that we can work out the bound. Moreover, McAllester (2003); Neyshabur et al. (2017) provide a general recipe to construct the posterior such that for a large class of models, including deterministic ones, the PAC-Bayes bound can be computed. Taking a neural network as an example, we can choose a prior distribution with some known density, e.g., a fixed Gaussian, over the initial weights. After the learning process, we can add random perturbations to the learned weights from another known distribution as long as the KL-divergence permits an analytical form. This converts the deterministic model into a distribution of models while still obtaining a tractable KL divergence. Leveraging Theorem 2.1 and the above recipe, Neyshabur et al. (2017) obtained the following result which holds for a large class of deterministic models.
92
+
93
+ Lemma 2.2. (Neyshabur et al., 2017) 4 Let $f _ { w } ( x ) \ : \ x \to \ \mathbb { R } ^ { K }$ be any model with parameters $w$ , and let $P$ be any distribution on the parameters that is independent of the training data. For any $w$ , we construct a posterior $Q ( w + u )$ by adding any random perturbation u to $w$ , s.t., $\begin{array} { r } { \mathbb { P } ( \operatorname* { m a x } _ { x \in \mathcal { X } } | f _ { w + u } ( x ) - \bar { f } _ { w } ( x ) | _ { \infty } < \frac { \gamma } { 4 } ) > \frac { 1 } { 2 } } \end{array}$ . Then, for any $\gamma , \delta > 0$ , with probability at least $1 - \delta$ over an i.i.d. size-m training set $S$ according to $\mathcal { D }$ , for any $w$ , we have:
94
+
95
+ $$
96
+ L _ { \mathcal { D } , 0 } ( f _ { w } ) \leq L _ { S , \gamma } ( f _ { w } ) + \sqrt { \frac { 2 D _ { \mathrm { K L } } ( Q ( w + u ) \| P ) + \log \frac { 8 m } { \delta } } { 2 ( m - 1 ) } } .
97
+ $$
98
+
99
+ This lemma guarantees that, as long as the change of the output brought by the perturbations is small with a large probability, one can obtain the corresponding generalization bound.
100
+
101
+ # 3 GENERALIZATION BOUNDS
102
+
103
+ In this section, we present the main results: generalization bounds of GCNs and MPGNNs using a PAC-Bayesian approach. We then relate them to existing generalization bounds of GNNs and draw connections to the bounds of MLPs/CNNs. We summarize the key ideas of the proof in the main text and defer the details to the appendix.
104
+
105
+ # 3.1 PAC-BAYES BOUNDS OF GCNS
106
+
107
+ As discussed above, in order to apply Lemma 2.2, we must ensure that the change of the output brought by the weight perturbations is small with a large probability. In the following lemma, we bound this change using the product of the spectral norms of learned weights at each layer and a term depending on some statistics of the graph.
108
+
109
+ Lemma 3.1. (GCN Perturbation Bound) For any $B > 0 , l > 1$ , let $f _ { w } \in \mathcal { H } : \mathcal { X } \times \mathcal { G } \to \mathbb { R } ^ { K }$ be $a$ $l$ -layer GCN. Then for any $w$ , and $x \in \mathcal { X } _ { B , h _ { 0 } }$ , and any perturbation $u = \nu e c ( \{ U _ { i } \} _ { i = 1 } ^ { l } )$ such that $\forall i \in \mathbb { N } _ { l } ^ { + }$ , $\begin{array} { r } { \| U _ { i } \| _ { 2 } \leq \frac { 1 } { l } \| W _ { i } \| _ { 2 } } \end{array}$ , the change in the output of GCN is bounded as,
110
+
111
+ $$
112
+ | f _ { w + u } ( X , A ) - f _ { w } ( X , A ) | _ { 2 } \leq e B d ^ { \frac { l - 1 } { 2 } } \left( \prod _ { i = 1 } ^ { l } \| W _ { i } \| _ { 2 } \right) \sum _ { k = 1 } ^ { l } \frac { \| U _ { k } \| _ { 2 } } { \| W _ { k } \| _ { 2 } } .
113
+ $$
114
+
115
+ The key idea of the proof is to decompose the change of the network output into two terms which depend on two quantities of GNNs respectively: the maximum change of node representations $\begin{array} { r } { \operatorname* { m a x } _ { i } \left| H _ { l - 1 } ^ { \prime } [ i , : ] \stackrel { \cdot } { - } H _ { l - 1 } [ i , : ] \right| _ { 2 } } \end{array}$ and the maximum node representation $\bar { \mathrm { m a x } } _ { i } | H _ { l - 1 } [ i , : ] | _ { 2 }$ . Here the superscript prime denotes the perturbed model. These two terms can be bounded by an induction on the layer index. From this lemma, we can see that the most important graph statistic for the stability of GCNs is the maximum node degree, i.e., $d - 1$ . Armed with Lemma 3.1 and Lemma 2.2, we now present the PAC-Bayes generalization bound of GCNs as Theorem 3.2.
116
+
117
+ Theorem 3.2. (GCN Generalization Bound) For any $B > 0 , l > 1$ , let $f _ { w } \in \mathcal { H } : \mathcal { X } \times \mathcal { G } \to \mathbb { R } ^ { K }$ be a $l$ layer GCN. Then for any $\delta , \gamma > 0$ , with probability at least $1 - \delta$ over the choice of an i.i.d. size-m training set $S$ according to $\mathcal { D }$ , for any $w$ , we have,
118
+
119
+ $$
120
+ L _ { \mathcal { D } , 0 } ( f _ { w } ) \leq L _ { S , \gamma } ( f _ { w } ) + \mathcal { O } \left( \sqrt { \frac { B ^ { 2 } d ^ { l - 1 } l ^ { 2 } h \log ( l h ) \underset { i = 1 } { \overset { l } { \prod } } \| W _ { i } \| _ { 2 } ^ { 2 } \underset { i = 1 } { \overset { l } { \sum } } ( \| W _ { i } \| _ { F } ^ { 2 } / \| W _ { i } \| _ { 2 } ^ { 2 } ) + \log \frac { m l } { \delta } } { \gamma ^ { 2 } m } } \right) .
121
+ $$
122
+
123
+ 4 The constants slightly differ from the original paper since we use a two-sided version of Theorem 2.1.
124
+
125
+ Since it is easy to show GCNs are homogeneous, the proof of Theorem 3.2 follows the one for MLPs/CNNs with ReLU activations in (Neyshabur et al., 2017). In particular, we choose the prior distribution $P$ and the perturbation distribution to be zero-mean Gaussians with the same diagonal variance $\sigma$ . The key steps of the proof are: 1) constructing a quantity of learned weights $\beta \ : =$ $\textstyle ( \prod _ { i = 1 } ^ { l } \| W _ { i } \| _ { 2 } ) ^ { 1 / l } ; 2 )$ fixing any $\tilde { \beta }$ , considering all $\beta$ that are in the range $| \beta - \tilde { \beta } | \le \beta / l$ and choosing $\sigma$ which depends on $\tilde { \beta }$ so that one can apply Lemma 3.1 and 2.2 to obtain the PAC-Bayes bound; 3) taking a union bound of the result in the 2nd step by considering multiple choices of $\tilde { \beta }$ so that all possible values of $\beta$ (corresponding to all possible weight $w$ ) are covered. Although Lemma 2.2 and 3.1 have their own constraints on the random perturbation, above steps provide a way to set the variance $\sigma$ which satisfies these constraints and the independence w.r.t. learned weights. The latter is important since $\sigma$ is also the variance of the prior $P$ which should not depend on data.
126
+
127
+ # 3.2 PAC-BAYES BOUNDS OF MPGNNS
128
+
129
+ For MPGNNs, we again need to perform a perturbation analysis to make sure that the change of the network output brought by the perturbations on weights is small with a large probability. Following the same strategy adopted in proving Lemma 3.1, we prove the following Lemma.
130
+
131
+ Lemma 3.3. (MPGNN Perturbation Bound) For any $B > 0 , l > 1$ , let $f _ { w } \in \mathcal { H } : \mathcal { X } \times \mathcal { G } \to \mathbb { R } ^ { K }$ be $a$ $l$ -step MPGNN. Then for any $w$ , and $x \in \mathcal { X } _ { B , h _ { 0 } }$ , and any perturbation $\boldsymbol { u } = \nu e c ( \{ U _ { 1 } , U _ { 2 } , U _ { l } \} )$ such that $\begin{array} { r } { \eta = \operatorname* { m a x } \left( \frac { \| U _ { 1 } \| _ { 2 } } { \| W _ { 1 } \| _ { 2 } } , \frac { \| U _ { 2 } \| _ { 2 } } { \| W _ { 2 } \| _ { 2 } } , \frac { \| U _ { l } \| _ { 2 } } { \| W _ { l } \| _ { 2 } } \right) \le \frac { 1 } { l } } \end{array}$ , the change in the output of MPGNN is bounded as,
132
+
133
+ $$
134
+ | f _ { w + u } ( X , A ) - f _ { w } ( X , A ) | _ { 2 } \leq e B l \eta \| W _ { 1 } \| _ { 2 } \| W _ { l } \| _ { 2 } C _ { \phi } \frac { ( d \mathcal { C } ) ^ { l - 1 } - 1 } { d \mathcal { C } - 1 } ,
135
+ $$
136
+
137
+ where $\mathcal { C } = C _ { \phi } C _ { \rho } C _ { g } \Vert W _ { 2 } \Vert _ { 2 }$ .
138
+
139
+ The proof again involves decomposing the change into two terms which depend on two quantities respectively: the maximum change of node representations $\begin{array} { r } { \operatorname* { m a x } _ { i } \left| H _ { l - 1 } ^ { \prime } [ i , : ] - H _ { l - 1 } [ i , : ] \right| _ { 2 } ^ { . } } \end{array}$ and the maximum node representation $\begin{array} { r } { \operatorname* { m a x } _ { i } | H _ { l - 1 } [ i , : ] | _ { 2 } } \end{array}$ . Then we perform an induction on the layer index to obtain their bounds individually. Due to the weight sharing across steps, we have a form of geometric series $( ( d \mathcal { C } ) ^ { l - 1 } - 1 ) / ( \dot { d } \mathcal { C } - 1 )$ rather than the product of spectral norms of each layer as in GCNs. Technically speaking, the above lemma only works with $d \mathcal { C } \neq 1$ . We refer the reader to the appendix for the special case of $d { \boldsymbol { \mathcal { C } } } = 1$ . We now provide the generalization bound for MPGNNs.
140
+
141
+ Theorem 3.4. (MPGNN Generalization Bound) For any $B > 0 , l > 1$ , let $f _ { w } \in \mathcal { H } : \mathcal { X } \times \mathcal { G } \to \mathbb { R } ^ { K }$ be a $l$ -step MPGNN. Then for any $\delta , \gamma > 0$ , with probability at least $1 - \delta$ over the choice of an i.i.d. size-m training set $S$ according to $\mathcal { D }$ , for any $w$ , we have,
142
+
143
+ $$
144
+ \bar { \mathbf { \xi } } _ { \mathcal { D } , 0 } ( f _ { w } ) \le L _ { S , \gamma } ( f _ { w } ) + \mathcal { O } \left( \sqrt { \frac { B ^ { 2 } \left( \operatorname* { m a x } \left( \zeta ^ { - ( l + 1 ) } , ( \lambda \xi ) ^ { ( l + 1 ) / l } \right) \right) ^ { 2 } l ^ { 2 } h \log ( l h ) | w | _ { 2 } ^ { 2 } + \log \frac { m ( l + 1 ) } { \delta } } { \gamma ^ { 2 } m } } \right) ,
145
+ $$
146
+
147
+ where $\zeta = \operatorname* { m i n } \left( \| W _ { 1 } \| _ { 2 } , \| W _ { 2 } \| _ { 2 } , \| W _ { l } \| _ { 2 } \right) , | w | _ { 2 } ^ { 2 } = \| W _ { 1 } \| _ { F } ^ { 2 } + \| W _ { 2 } \| _ { F } ^ { 2 } + \| W _ { l } \| _ { F } ^ { 2 } , \mathcal { C } = C _ { \phi } C _ { \rho } C _ { g } \| W _ { 1 } \| _ { 2 } ^ { 2 } .$ , $\lambda = \| W _ { 1 } \| _ { 2 } \| W _ { l } \| _ { 2 }$ , and $\begin{array} { r } { \xi = C _ { \phi } \frac { ( d \mathcal { C } ) ^ { l - 1 } - 1 } { d \mathcal { C } - 1 } } \end{array}$ .
148
+
149
+ The proof also contains three steps: 1) since MPGNNs are typically non-homogeneous, e.g., when any of $\phi , \rho$ , and $g$ is a bounded non-linearity like Sigmoid or Tanh, we design a special quantity of learned weights $\beta = \operatorname* { m a x } ( \zeta ^ { - 1 } , ( \lambda \xi ) ^ { 1 / l } )$ . 2) fixing any $\tilde { \beta }$ , considering all $\beta$ that are in the range $| \beta - \tilde { \beta } | \leq \beta / ( l + 1 )$ and choosing $\sigma$ which depends on $\tilde { \beta }$ so that one can apply Lemma 3.3 and 2.2 to work out the PAC-Bayes bound; 3) taking a union bound of the previous result by considering multiple choices of $\tilde { \beta }$ so that all possible values of $\beta$ are covered. The case with $d \mathcal { C } = 1$ is again included in the appendix. The first step is non-trivial since we do not have the nice construction as in the homogeneous case, $i . e .$ ., normalizing the weights so that the spectral norms of weights across layers are the same while the network output is unchanged. Moreover, the quantity is vital to the whole proof framework since it determines whether one can 1) satisfy the constraints on the random perturbation (so that Lemma 2.2 and 3.3 are applicable) and 2) simultaneously induce a finite covering on its range (so that the bound holds for any $w$ ). Since it highly depends on the form of the perturbation bound and the network architecture, there seems to be no general recipe on how to construct such a quantity.
150
+
151
+ <table><tr><td>Statistics</td><td>Max Node Degree d-1</td><td>Max Hidden Dim h</td><td>Spectral Norm of Learned Weights</td></tr><tr><td>VC-Dimension (Scarselli et al., 2018)</td><td></td><td>(h4)</td><td></td></tr><tr><td>Rademacher Complexity (Garg et al., 2020)</td><td>0 (dl-1√log(d21-3))</td><td>O (h√ogh)</td><td> (xce√Iog(IW2|l2Xχ2))</td></tr><tr><td>Ours</td><td>O(d-1)</td><td>O(√hlogh)</td><td>O(1+1+√IWi² +/W2+/Wl)</td></tr></table>
152
+
153
+ Table 1: Comparison of generalization bounds for GNNs. “-” means inapplicable. $l$ is the network depth. Here $\mathcal { C } ~ = ~ C _ { \phi } C _ { \rho } C _ { g } \| W _ { 2 } \| _ { 2 }$ , $\begin{array} { r } { \xi = C _ { \phi } \frac { ( d \mathcal { C } ) ^ { l - 1 } - 1 } { d \mathcal { C } - 1 } } \end{array}$ , $\zeta = \operatorname* { m i n } \left( \| W _ { 1 } \| _ { 2 } , \| W _ { 2 } \| _ { 2 } , \| W _ { l } \| _ { 2 } \right)$ , and $\lambda = \| W _ { 1 } \| _ { 2 } \| W _ { l } \| _ { 2 }$ . More details about the comparison can be found in Appendix A.5.
154
+
155
+ # 3.3 COMPARISON WITH OTHER BOUNDS
156
+
157
+ In this section, we compare our generalization bounds with the ones in the GNN literature and draw connections with existing MLPs/CNNs bounds.
158
+
159
+ # 3.3.1 COMPARISON WITH EXISTING GNN GENERALIZATION BOUNDS
160
+
161
+ We compare against the VC-dimension based bound in (Scarselli et al., 2018) and the most recent Rademacher complexity based bound in (Garg et al., 2020). Our results are not directly comparable to (Du et al., 2019) since they consider a “infinite-wide” class of GNNs constructed based on the neural tangent kernel (Jacot et al., 2018), whereas we focus on commonly-used GNNs. Comparisons to (Verma & Zhang, 2019) are also difficult since: 1) they only show the bound for one graph convolutional layer, i.e., it does not depend on the network depth $l$ ; and 2) their bound scales as $\mathcal { O } \left( \lambda _ { \operatorname* { m a x } } ^ { 2 T } / m \right)$ , where $T$ is the number of SGD steps and $\lambda _ { \mathrm { m a x } }$ is the maximum absolute eigenvalue of Laplacian $L = D - A$ . Therefore, for certain graphs5, the generalization gap is monotonically increasing with $T$ , which cannot explain the generalization phenomenon. We compare different bounds by examining their dependency on three terms: the maximum node degree, the spectral norm of the learned weights, and the maximum hidden dimension. We summarize the overall comparison in Table 1 and leave the details such as how we convert bounds into our context to Appendix A.5.
162
+
163
+ Max Node Degree $( d - 1 )$ : The Rademacher complexity bound scales as $\mathcal { O } \left( d ^ { l - 1 } \sqrt { \log ( d ^ { 2 l - 3 } ) } \right)$ whereas ours scales as $\mathcal { O } ( d ^ { l - 1 } )$ . Many real-world graphs such as social networks tend to have large hubs (Barabasi et al. ´ , 2016), which lead to very large node degrees. Thus, our bound would be significantly better in these scenarios. It is noteworthy that if one further introduces some assumption, e.g., $\phi$ is a squashing function like tanh as shown in (Garg et al., 2020), then one can improve the above exponential dependency on the network depth $l$ for both Rademacher complexity and PAC-Bayes bounds.
164
+
165
+ Max Hidden Dimension $h$ : Our bound scales as $\mathcal { O } ( \sqrt { h \log h } )$ which is tighter than the Rademacher complexity bound $\mathcal { O } \left( h \sqrt { \log h } \right)$ and the VC-dimension bound $\mathcal { O } ( h ^ { 4 } )$ .
166
+
167
+ Spectral Norm of Learned Weights: As shown in Table 1, we cannot compare the dependencies on the spectral norm of learned weights without knowing the actual values of the learned weights. Therefore, we perform an empirical study in Section 4.
168
+
169
+ # 3.3.2 CONNECTIONS WITH EXISTING BOUNDS OF MLPS/CNNS
170
+
171
+ As described above, MLPs/CNNs can be viewed as special cases of GNNs. In particular, we have two ways to show the inclusion relationship. First, we can treat each i.i.d. sample as a node and the whole dataset as a graph without edges. Then conventional tasks (e.g., classification) become node-level tasks (e.g., node classification) on this graph. Second, we can treat each i.i.d. sample as a single-node graph. Then conventional tasks (e.g., classification) becomes graph-level tasks (e.g., graph classification). Since we focus on the graph classification, we adopt the second view. In particular, MLPs/CNNs with ReLU activations are equivalent to GCNs with the graph Laplacian $\overset { \vartriangle } { \boldsymbol { \tilde { L } } } = \boldsymbol { I }$ (hence $d = 1$ ). We leave the details of this conversion to Appendix A.6. We restate the PAC-Bayes bound for MLPs/CNNs with ReLU activations in (Neyshabur et al., 2017) as follows,
172
+
173
+ ![](images/cf18a0a173328712ae1d21a00076e376dcd3fc5e2728d54f05aca4e3eb535a40.jpg)
174
+ Figure 1: Bound evaluations on real-world datasets. The maximum node degrees $( i . e . , d - 1 )$ of four datasets from left to right are: 25 (PROTEINS), 88 (IMDB-M), 135 (IMDB-B), and 491 (COLLAB).
175
+
176
+ $$
177
+ L _ { \mathcal { D } , 0 } ( f _ { w } ) \le L s _ { , \gamma } ( f _ { w } ) + \mathcal { O } \left( \sqrt { \left( B ^ { 2 } l ^ { 2 } h \log ( l h ) \prod _ { i = 1 } ^ { l } \| W _ { i } \| _ { 2 } ^ { 2 } \sum _ { i = 1 } ^ { l } ( \| W _ { i } \| _ { F } ^ { 2 } / \| W _ { i } \| _ { 2 } ^ { 2 } ) + \log \frac { m l } { \delta } \right) / \gamma ^ { 2 } m \right) } .
178
+ $$
179
+
180
+ Comparing it with our bound for GCNs in Theorem 3.2, it is clear that we only add a factor $d ^ { l - 1 }$ to the first term inside the square root which is due to the underlying graph structure of the data. If we apply GCNs to single-node graphs, the two bounds coincide since $d = 1$ . Therefore, our Theorem 3.2 directly generalizes the result in (Neyshabur et al., 2017) to GCNs, which is a strictly larger class of models than MLPs/CNNs with ReLU activations.
181
+
182
+ # 4 EXPERIMENTS
183
+
184
+ In this section, we perform an empirical comparison between our bound and the Rademacher complexity bound for MPGNNs. We experiment on 6 synthetic datasets of random graphs (corresponding to 6 random graph models), 3 social network datasets (COLLAB, IMDB-BINARY, IMDBMULTI), and a bioinformatics dataset PROTEINS from (Yanardag & Vishwanathan, 2015). In particular, we create synthetic datasets by generating random graphs from the Erdos–R ˝ enyi model ´ and the stochastic block model with different settings (i.e., number of blocks and edge probabilities). All datesets focus on graph classifications. We repeat all experiments 3 times with different random initializations and report the means and the standard deviations. Constants are considered in the bound computation. More details of the experimental setup, dataset statistics, and the bound computation are provided in Appendix A.7.
185
+
186
+ As shown in Fig. 1 and Fig. 2, our bound is mostly tighter than the Rademacher complexity bound with varying message passing steps $l$ on both synthetic and real-world datasets. Generally, the larger the maximum node degree is, the more our bound improves7 over the Rademacher complexity bound $( c . f .$ , PROTEINS vs. COLLAB). This could be attributed to the better dependency on $d$ of our bound. For graphs with large node degrees (e.g., social networks like Twitter have influential users with lots of followers), the gap could be more significant. Moreover, with the number of steps/layers increasing, our bound also improves more in most cases. It may not be clear to read from the figures since the y-axis is in the log domain and its range differ from figure to figure. We also provide the numerical values of the bound evaluations in the appendix for an exact comparison. The number of steps is chosen to be no larger than 10 as GNNs are generally shown to perform well with just a few steps/layers (Kipf & Welling, 2016; Jin et al., 2018). We found $d \mathcal { C } > 1$ and the geometric series $( ( \bar { d } \mathcal { C } ) ^ { l - 1 } - 1 ) / ( \bar { d } \mathcal { C } - 1 ) \gg 1$ on all datasets which imply learned GNNs are not contraction mappings (i.e., $d \mathcal { C } < 1 \rangle$ ). This also explains why both bounds becomes larger with more steps. At last, we can see that bound values are much larger than 1 which indicates both bounds are still vacuous, similarly to the cases for regular neural networks in (Bartlett et al., 2017; Neyshabur et al., 2017).
187
+
188
+ ![](images/ddacf20645ab403baeb8121a9f3062c336868b88a79648be603d121a4934e518.jpg)
189
+ Figure 2: Bound evaluations on synthetic datasets. The maximum node degrees (i.e., $d - 1 )$ of datasets from left to right are: 25 (ER-1), 48 (ER-2), 69 (ER-3), 87 (ER-4), 25 (SBM-1), and 36 (SBM-2). ‘ER-X’ and ‘SBM-X’ denote the Erdos–R ˝ enyi model and the stochastic block model with ´ the $\mathbf { \delta } ^ { \bullet } \mathbf { X } ^ { \bullet }$ -th setting respectively. Please refer to the appendix for more details.
190
+
191
+ # 5 DISCUSSION
192
+
193
+ In this paper, we present generalization bounds for two primary classes of GNNs, i.e., GCNs and MPGNNs. We show that the maximum node degree and the spectral norms of learned weights govern the bound for both models. Our results for GCNs generalize the bounds for MLPs/CNNs in (Neyshabur et al., 2017), while our results for MPGNNs improve over the state-of-the-art Rademacher complexity bound in (Garg et al., 2020). Our PAC-Bayes analysis can be generalized to other graph problems such as node classification and link prediction since our perturbation analysis bounds the maximum change of any node representation. Other loss functions (e.g., ones for regression) could also work in our analysis as long as they are bounded.
194
+
195
+ However, we are far from being able to explain the practical behaviors of GNNs. Our bound values are still vacuous as shown in the experiments. Our perturbation analysis is in the worst-case sense which may be loose for most cases. We introduce Gaussian posterior in the PAC-Bayes framework to obtain an analytical form of the KL divergence. Nevertheless, the actual posterior induced by the prior and the learning process may likely to be non-Gaussian. We also do not explicitly consider the optimization algorithm in the analysis which clearly has an impact on the learned weights.
196
+
197
+ This work leads to a few interesting open problems for future work: (1) Is the maximum node degree the only graph statistic that has an impact on the generalization ability of GNNs? Investigating other graph statistics may provide more insights on the behavior of GNNs and inspire the development of novel models and algorithms. (2) Would the analysis still work for other interesting GNN architectures, such as those with attention (Velickovi ˇ c et al. ´ , 2017) and learnable spectral filters (Liao et al., 2019)? (3) Can recent advancements for MLPs/CNNs, e.g., the compression technique in (Arora et al., 2018) and data-dependent prior of (Parrado-Hernandez et al. ´ , 2012), help further improve the bounds for GNNs? (4) What is the impact of the optimization algorithms like SGD on the generalization ability of GNNs? Would graph structures play a role in the analysis of optimization?
198
+
199
+ # REFERENCES
200
+
201
+ Sanjeev Arora, Rong Ge, Behnam Neyshabur, and Yi Zhang. Stronger generalization bounds for deep nets via a compression approach. arXiv preprint arXiv:1802.05296, 2018.
202
+
203
+ Sanjeev Arora, Simon S Du, Wei Hu, Zhiyuan Li, and Ruosong Wang. Fine-grained analysis of optimization and generalization for overparameterized two-layer neural networks. arXiv preprint arXiv:1901.08584, 2019.
204
+
205
+ Albert-Laszl ´ o Barab ´ asi et al. ´ Network science. Cambridge university press, 2016.
206
+
207
+ Peter L Bartlett, Dylan J Foster, and Matus J Telgarsky. Spectrally-normalized margin bounds for neural networks. In NIPS, pp. 6240–6249, 2017.
208
+
209
+ Peter W Battaglia, Jessica B Hamrick, Victor Bapst, Alvaro Sanchez-Gonzalez, Vinicius Zambaldi, Mateusz Malinowski, Andrea Tacchetti, David Raposo, Adam Santoro, Ryan Faulkner, et al. Relational inductive biases, deep learning, and graph networks. arXiv preprint arXiv:1806.01261, 2018.
210
+
211
+ 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.
212
+
213
+ Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. arXiv preprint arXiv:1312.6203, 2013.
214
+
215
+ Sergio Casas, Cole Gulino, Renjie Liao, and Raquel Urtasun. Spatially-aware graph neural networks for relational behavior forecasting from sensor data. arXiv preprint arXiv:1910.08233, 2019.
216
+
217
+ Guangyong Chen, Pengfei Chen, Chang-Yu Hsieh, Chee-Kong Lee, Benben Liao, Renjie Liao, Weiwen Liu, Jiezhong Qiu, Qiming Sun, Jie Tang, et al. Alchemy: A quantum chemistry dataset for benchmarking ai models. arXiv preprint arXiv:1906.09427, 2019a.
218
+
219
+ Zhengdao Chen, Soledad Villar, Lei Chen, and Joan Bruna. On the equivalence between graph isomorphism testing and function approximation with gnns. In NeurIPS, pp. 15894–15902, 2019b.
220
+
221
+ Hanjun Dai, Bo Dai, and Le Song. Discriminative embeddings of latent variable models for structured data. In International conference on machine learning, pp. 2702–2711, 2016.
222
+
223
+ Simon S Du, Kangcheng Hou, Russ R Salakhutdinov, Barnabas Poczos, Ruosong Wang, and Keyulu Xu. Graph neural tangent kernel: Fusing graph neural networks with graph kernels. In NeurIPS, pp. 5723–5733, 2019.
224
+
225
+ David K Duvenaud, Dougal Maclaurin, Jorge Iparraguirre, Rafael Bombarell, Timothy Hirzel, Alan´ Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for learning molecular fingerprints. In NIPS, pp. 2224–2232, 2015.
226
+
227
+ Gintare Karolina Dziugaite and Daniel M Roy. Computing nonvacuous generalization bounds for deep (stochastic) neural networks with many more parameters than training data. arXiv preprint arXiv:1703.11008, 2017.
228
+
229
+ Vikas K Garg, Stefanie Jegelka, and Tommi Jaakkola. Generalization and representational limits of graph neural networks. arXiv preprint arXiv:2002.06157, 2020.
230
+
231
+ 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.
232
+
233
+ Marco Gori, Gabriele Monfardini, and Franco Scarselli. A new model for learning in graph domains. In Proceedings. 2005 IEEE International Joint Conference on Neural Networks, 2005., volume 2, pp. 729–734. IEEE, 2005.
234
+
235
+ Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NIPS, pp. 1024–1034, 2017.
236
+
237
+ Nick Harvey, Christopher Liaw, and Abbas Mehrabian. Nearly-tight vc-dimension bounds for piecewise linear neural networks. In Conference on Learning Theory, pp. 1064–1068, 2017.
238
+
239
+ Isaac Henrion, Johann Brehmer, Joan Bruna, Kyunghyun Cho, Kyle Cranmer, Gilles Louppe, and Gaspar Rochette. Neural message passing for jet physics. NIPS Workshop on Deep Learning for Physical Sciences, 2017.
240
+
241
+ Arthur Jacot, Franck Gabriel, and Clement Hongler. Neural tangent kernel: Convergence and gen- ´ eralization in neural networks. In NeurIPS, pp. 8571–8580, 2018.
242
+
243
+ Wengong Jin, Kevin Yang, Regina Barzilay, and Tommi Jaakkola. Learning multimodal graph-tograph translation for molecular optimization. arXiv preprint arXiv:1812.01070, 2018.
244
+
245
+ Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
246
+
247
+ John Langford and John Shawe-Taylor. Pac-bayes & margins. In NIPS, pp. 439–446, 2003.
248
+
249
+ Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. arXiv preprint arXiv:1511.05493, 2015.
250
+
251
+ Ming Liang, Bin Yang, Rui Hu, Yun Chen, Renjie Liao, Song Feng, and Raquel Urtasun. Learning lane graph representations for motion forecasting. In ECCV, 2020.
252
+
253
+ Renjie Liao, Zhizhen Zhao, Raquel Urtasun, and Richard Zemel. Lanczosnet: Multi-scale deep graph convolutional networks. In ICLR, 2019.
254
+
255
+ Haggai Maron, Heli Ben-Hamu, Nadav Shamir, and Yaron Lipman. Invariant and equivariant graph networks. arXiv preprint arXiv:1812.09902, 2018.
256
+
257
+ David McAllester. Simplified pac-bayesian margin bounds. In Learning theory and Kernel machines, pp. 203–215. Springer, 2003.
258
+
259
+ David A McAllester. Pac-bayesian model averaging. In Proceedings of the twelfth annual conference on Computational learning theory, pp. 164–170, 1999.
260
+
261
+ Federico Monti, Davide Boscaini, Jonathan Masci, Emanuele Rodola, Jan Svoboda, and Michael M Bronstein. Geometric deep learning on graphs and manifolds using mixture model cnns. In CVPR, pp. 5115–5124, 2017.
262
+
263
+ Behnam Neyshabur, Srinadh Bhojanapalli, and Nathan Srebro. A pac-bayesian approach to spectrally-normalized margin bounds for neural networks. arXiv preprint arXiv:1707.09564, 2017.
264
+
265
+ Emilio Parrado-Hernandez, Amiran Ambroladze, John Shawe-Taylor, and Shiliang Sun. Pac-bayes ´ bounds with data dependent priors. The Journal of Machine Learning Research, 13(1):3507– 3531, 2012.
266
+
267
+ Xiaojuan Qi, Renjie Liao, Jiaya Jia, Sanja Fidler, and Raquel Urtasun. 3d graph neural networks for rgbd semantic segmentation. In ICCV, 2017.
268
+
269
+ Alvaro Sanchez-Gonzalez, Nicolas Heess, Jost Tobias Springenberg, Josh Merel, Martin Riedmiller, Raia Hadsell, and Peter Battaglia. Graph networks as learnable physics engines for inference and control. arXiv preprint arXiv:1806.01242, 2018.
270
+
271
+ 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, 2008.
272
+
273
+ Franco Scarselli, Ah Chung Tsoi, and Markus Hagenbuchner. The vapnik–chervonenkis dimension of graph and recursive neural networks. Neural Networks, 108:248–259, 2018.
274
+
275
+ Joel A Tropp. User-friendly tail bounds for sums of random matrices. Foundations of computational mathematics, 12(4):389–434, 2012.
276
+
277
+ Leslie G Valiant. A theory of the learnable. Communications of the ACM, 27(11):1134–1142, 1984.
278
+
279
+ Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017.
280
+ Saurabh Verma and Zhi-Li Zhang. Stability and generalization of graph convolutional neural networks. In KDD, pp. 1539–1548, 2019.
281
+ Tingwu Wang, Renjie Liao, Jimmy Ba, and Sanja Fidler. Nervenet: Learning structured policy with graph neural networks. In ICLR, 2018.
282
+ Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
283
+ Pinar Yanardag and SVN Vishwanathan. Deep graph kernels. In KDD, pp. 1365–1374, 2015.
md/train/YUEFlzlG_0c/YUEFlzlG_0c.md ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Reliable Post hoc Explanations: Modeling Uncertainty in Explainability
2
+
3
+ Dylan Slack
4
+ UC Irvine
5
+ dslack@uci.edu
6
+
7
+ Sophie Hilgard Harvard University ash798@g.harvard.edu
8
+
9
+ Sameer Singh UC Irvine sameer@uci.edu
10
+
11
+ Himabindu Lakkaraju Harvard University hlakkaraju@hbs.edu
12
+
13
+ # Abstract
14
+
15
+ As black box explanations are increasingly being employed to establish model credibility in high stakes settings, it is important to ensure that these explanations are accurate and reliable. However, prior work demonstrates that explanations generated by state-of-the-art techniques are inconsistent, unstable, and provide very little insight into their correctness and reliability. In addition, these methods are also computationally inefficient, and require significant hyper-parameter tuning. In this paper, we address the aforementioned challenges by developing a novel Bayesian framework for generating local explanations along with their associated uncertainty. We instantiate this framework to obtain Bayesian versions of LIME and KernelSHAP which output credible intervals for the feature importances, capturing the associated uncertainty. The resulting explanations not only enable us to make concrete inferences about their quality (e.g., there is a $9 5 \%$ chance that the feature importance lies within the given range), but are also highly consistent and stable. We carry out a detailed theoretical analysis that leverages the aforementioned uncertainty to estimate how many perturbations to sample, and how to sample for faster convergence. This work makes the first attempt at addressing several critical issues with popular explanation methods in one shot, thereby generating consistent, stable, and reliable explanations with guarantees in a computationally efficient manner. Experimental evaluation with multiple real world datasets and user studies demonstrate that the efficacy of the proposed framework.1
16
+
17
+ # 1 Introduction
18
+
19
+ As machine learning (ML) models get increasingly deployed in domains such as healthcare and criminal justice, it is important to ensure that decision makers have a clear understanding of the behavior of these models. However, ML models that achieve state-of-the-art accuracy are typically complex black boxes that are hard to understand. As a consequence, there has been a surge in post hoc techniques for explaining black box models [1–10]. Most popular among these techniques are local explanation methods which explain complex black box models by constructing interpretable local approximations (e.g., LIME [2], SHAP [4], MAPLE [11], Anchors [1]). Due to their generality, these methods are being leveraged to explain a number of classifiers including deep neural networks and ensemble models in a variety of domains such as law, medicine, and finance [12, 13].
20
+
21
+ Existing local explanation methods, however, suffer from several drawbacks. Explanations generated using these methods may be unstable [14–18], i.e., negligibly small perturbations to an instance can result in substantially different explanations. These methods are also inconsistent [19] i.e., multiple runs on the same input instance with the same parameter settings may result in vastly different explanations. There are also no reliable metrics to ascertain the quality of the explanations
22
+
23
+ ![](images/d47efc4990be75e69296fffac100fa38760e5883dfb996999588185ce3d0e586.jpg)
24
+ (b) Explanation with 2000 perturbations
25
+
26
+ ![](images/3f716bc0fdf329c8651b34a0ee8151d109ef2249803f50f834c077a2687e7548.jpg)
27
+ Figure 1: Example explanations on for an instance from the COMPAS dataset, where vertical lines indicate the feature importance by LIME (red is negative effect, green is positive) and the shaded region visualizes the uncertainty estimated by BayesLIME. While LIME produces very different and contradictory feature importance for different number of perturbations (1a and 1b), BayesLIME provides more context. The overlapping uncertainty intervals in the explanation computed with 100 perturbations (1a) indicate that it is unclear which feature is the most important. However, the tighter uncertainty intervals in the explanation computed with 2K perturbations (1b) clearly indicates that Female is the most important.
28
+
29
+ (a) Explanation computed with 100 perturbations
30
+
31
+ output by these methods. Commonly used metrics such as explanation fidelity rely heavily on the implementation details of the explanation method (e.g., the perturbation function used in LIME) and do not provide a true picture of the explanation quality [20]. Furthermore, there exists little to no guidance on determining the values of certain hyperparameters that are critical to the quality of the resulting local explanations (e.g., number of perturbations in case of LIME). Local explanation methods are also computationally inefficient i.e., they typically require a large number of black box model queries to construct local approximations [21]. This can be prohibitively slow especially in case of complex neural models.
32
+
33
+ In this paper, we identify that modeling uncertainty in black box explanations is the key to addressing all the aforementioned challenges. To this end, we propose a novel Bayesian framework for generating local explanations along with their associated uncertainty. We instantiate this framework to obtain Bayesian versions of LIME and KernelSHAP, namely BayesLIME and BayesSHAP, that not only output point-wise estimates of feature importance but also their associated uncertainty in the form of credible intervals (See Figure 1). We derive closed form expressions for the posteriors of the explanations thereby eliminating the need for any additional computational complexity. The credible intervals produced by our framework not only allow us to make concrete inferences about the quality of the resulting explanations but also produce explanations that satisfy user specified levels of uncertainty (e.g., an end user may request for explanations that satisfy a certain $9 5 \%$ confidence level). In addition, the resulting explanations are also highly consistent and stable. To the best of our knowledge, this work makes the first attempt at addressing several critical challenges in popular explanation methods in one-shots, thereby generating consistent, stable, and reliable explanations with guarantees in a computationally efficient manner.
34
+
35
+ We carry out theoretical analysis that leverages the measures of uncertainty (credible intervals) produced by our framework to estimate the values of critical hyperparameters. More specifically, we derive a closed form expression for the number of perturbations required to generate explanations that satisfy desired levels of confidence. We also propose a novel sampling technique called focused sampling that leverages uncertainty to determine how to sample perturbations for faster convergence, thereby enabling our framework to generate explanations in a computationally efficient manner.
36
+
37
+ We evaluate the efficacy of the proposed framework on a variety of datasets including COMPAS, German Credit, ImageNet, and MNIST. Our results demonstrate that the explanations output by our framework are not only highly reliable, but also very consistent and stable $5 3 \%$ more stable than LIME/SHAP on an average). Our experimental results also confirm that we can accurately estimate the number of perturbations needed to generate explanations with a desired level of uncertainty, and that our uncertainty sampling technique speeds up the process of generating explanations by up to a factor of 2 relative to random sampling of perturbations. Lastly, we carry out a user study with 31 human subjects to evaluate the quality of the explanations generated by our framework, demonstrating that our explanations accurately capture the importance of the most influential features.
38
+
39
+ # 2 Notation & Background
40
+
41
+ Here we introduce notation and discuss two relevant prior approaches, LIME and KernelSHAP.
42
+
43
+ Notation Let $f : \mathbb { R } ^ { d } [ 0 , 1 ]$ denote a black box classifier that takes a data point $x$ with $d$ features, and returns the probability that $x$ belongs to a certain class. Our goal is to explain individual predictions of $f$ . Let $\phi \in \mathbb { R } ^ { d }$ denote the explanation in terms of feature importances for the prediction $f ( x )$ , i.e. coefficients $\phi$ are treated as the feature contributions to the black box prediction. Note that $\phi$ captures the coefficients of a linear model. Let $\mathcal { Z }$ be a set of $N$ randomly sampled instances (perturbations) around $x$ . The proximity between $x$ and any $z \in { \mathcal { Z } }$ is given by $\pi _ { x } ( z ) \in \mathbb { R }$ . We denote the vector of these distances over the $N$ perturbations in $\mathcal { Z }$ as $\Pi _ { x } ( \hat { \mathcal { Z } } ) \in \mathbb { R } ^ { \mathrm { \tilde { \cal N } } }$ . Let $Y \in [ 0 , 1 ]$ be the vector of the black box predictions $f ( z )$ corresponding to each of the $N$ instances in $\mathcal { Z }$ .
44
+
45
+ LIME [2] and KernelSHAP [4] are popular model-agnostic local explanation approaches that explain predictions of a classifier $f$ by learning a linear model $\phi$ locally around each prediction (i.e. $y \overset { \cdot } { \sim } \phi ^ { T } \overset { \cdot } { z } ,$ ). The objective function for both LIME and KernelSHAP constructs an explanation that approximates the behavior of the black box accurately in the vicinity (neighborhood) of $x$ .
46
+
47
+ $$
48
+ \underset { \phi } { \arg \operatorname* { m i n } } \sum _ { z \in \mathcal { Z } } [ f ( z ) - \phi ^ { T } z ] ^ { 2 } \pi _ { x } ( z ) .
49
+ $$
50
+
51
+ The above objective function has the following closed form solution:
52
+
53
+ $$
54
+ \hat { \phi } = ( \mathcal { Z } ^ { T } \mathrm { d i a g } ( \Pi _ { x } ( \mathcal { Z } ) ) \mathcal { Z } + \mathbb { I } ) ^ { - 1 } ( \mathcal { Z } ^ { T } \mathrm { d i a g } ( \Pi _ { x } ( \mathcal { Z } ) ) Y )
55
+ $$
56
+
57
+ The main difference between LIME and KernelSHAP lies in how $\pi _ { x } ( z )$ is chosen. In LIME, it is chosen heuristically: $\pi _ { x } ( z )$ is computed as the cosine or $l _ { 2 }$ distance. KernelSHAP leverages game theoretic principles to compute $\pi _ { x } ( z )$ , guaranteeing that explanations satisfy certain properties.
58
+
59
+ # 3 Our Framework: Bayesian Local Explanations
60
+
61
+ In this section, we introduce our Bayesian framework which is designed to capture the uncertainty associated with local explanations of black box models. First, we discuss the generative process and inference procedure for the framework. Then, we highlight how our framework can be instantiated to obtain Bayesian versions of LIME and SHAP. Lastly, we present detailed theoretical analysis for estimating the values of critical hyperparameters, and discuss how to efficiently construct highly accurate explanations with uncertainty guarantees using our framework.
62
+
63
+ # 3.1 Constructing Bayesian Local Explanations
64
+
65
+ Our goal here is to explain the behavior of a given black box model $f$ in the vicinity of an instance $x$ while also capturing the uncertainty associated with the explanation. To this end, we propose a Bayesian framework for constructing local linear model based explanations and capturing their associated uncertainty. We model the black box prediction of each perturbation $z$ as a linear combination of the corresponding feature values $( \phi ^ { \dot { T } } z )$ plus an error term () as shown in Eqn (4). While the weights of the linear combination $\phi$ capture the feature importances and thereby constitute our explanation, $\epsilon$ captures the error that arises due to the mismatch between our explanation $\phi$ and the local decision surface of the black box model $f$ . Our complete generative process is shown below:
66
+
67
+ $$
68
+ \begin{array} { r l r } & { } & { y | z , \phi , \epsilon \sim \phi ^ { T } z + \epsilon \qquad \epsilon \sim \mathcal { N } ( 0 , \displaystyle \frac { \sigma ^ { 2 } } { \pi _ { x } ( z ) } ) } \\ & { } & { \phi | \sigma ^ { 2 } \sim \mathcal { N } ( 0 , \sigma ^ { 2 } \mathbb { I } ) \qquad \sigma ^ { 2 } \sim \mathrm { I n v } - \chi ^ { 2 } ( n _ { 0 } , \sigma _ { 0 } ^ { 2 } ) . } \end{array}
69
+ $$
70
+
71
+ The error term is modeled as a Gaussian whose variance relies on the proximity function $\pi _ { x } ( z )$ i.e., $\begin{array} { r } { \epsilon \sim \mathcal { N } ( 0 , \frac { \sigma ^ { 2 } } { \pi _ { x } ( z ) } ) } \end{array}$ . This proximity function ensures that perturbations closer to the data point $x$ are modeled accurately, while allowing more room for error in case of perturbations that are farther away. $\pi _ { x } ( z )$ can be computed using cosine or $l _ { 2 }$ distance or other game theoretic principles similar to that of LIME and KernelSHAP (see Section 2). The conjugate priors on $\phi$ and $\bar { \sigma } ^ { 2 }$ are shown in Eqn (4). Note that, the distributions on error $\epsilon$ and feature importance $\phi$ both consider the parameter $\sigma ^ { 2 }$ . The fact that the prior on the feature importances considers $\sigma ^ { 2 }$ has an intuitive interpretation: if we have prior knowledge that the error of the explanation is small, we expect to be more confident about the feature importances. Similarly, if we have prior knowledge the error is large, we expect to be less confident about the feature importances.
72
+
73
+ Thus, our generative process corresponds to the Bayesian version of the weighted least squares formulation of LIME and KernelSHAP outlined in Eqn. (1), with additional terms to model uncertainty. As in Eqns. (4), the process captures two sources of uncertainty in local explanations: 1) feature importance uncertainty: the uncertainty associated with the feature importances $\phi$ , and (2) error uncertainty: the uncertainty associated with the error term $\epsilon$ which captures how well our explanation $\phi$ models the local decision surface of the underlying black box.
74
+
75
+ Inference Our inference process involves estimating the values of two key parameters: $\phi$ and $\sigma ^ { 2 }$ . By doing so, we can compute the local explanation as well as the uncertainties associated with feature importances and the error term. Posterior distributions on $\phi$ and $\sigma ^ { 2 }$ are normal and scaled Inv- $\chi ^ { 2 }$ , respectively, due to the corresponding conjugate priors [22]:
76
+
77
+ $$
78
+ \begin{array} { r l } & { \sigma ^ { 2 } | \mathcal { Z } , Y \sim \mathrm { S c a l e d - I n v - } \chi ^ { 2 } \left( n _ { 0 } + N , \frac { n _ { 0 } \sigma _ { 0 } ^ { 2 } + N s ^ { 2 } } { n _ { 0 } + N } \right) } \\ & { \phi | \sigma ^ { 2 } , \mathcal { Z } , Y \sim \mathrm { N o r m a l } ( \hat { \phi } , V _ { \phi } \sigma ^ { 2 } ) } \end{array}
79
+ $$
80
+
81
+ Further, $\hat { \phi } , V _ { \phi }$ , and $s ^ { 2 }$ can be directly computed:
82
+
83
+ $$
84
+ \begin{array} { r l } & { \hat { \phi } = V _ { \phi } ( \mathcal { Z } ^ { T } \mathrm { d i a g } ( \Pi _ { x } ( \mathcal { Z } ) ) Y ) } \\ & { V _ { \phi } = \left( \mathcal { Z } ^ { T } \mathrm { d i a g } ( \Pi _ { x } ( \mathcal { Z } ) ) \mathcal { Z } + \mathbb { I } \right) ^ { - 1 } } \\ & { s ^ { 2 } = \displaystyle \frac { 1 } { N } \left[ ( Y - \mathcal { Z } \hat { \phi } ) ^ { T } \mathrm { d i a g } ( \Pi _ { x } ( \mathcal { Z } ) ) ( Y - \mathcal { Z } \hat { \phi } ) + \hat { \phi } ^ { T } \hat { \phi } \right] } \end{array}
85
+ $$
86
+
87
+ Details of the complete inference procedure including derivations of Eqns. (5-7) are provided in the Appendix A. Note that our estimate of the posterior mean feature importances $\hat { \phi }$ (Eqn. (6)) is the same as that of the feature importances computed in case of LIME and KernelSHAP (Eqn. (2)).
88
+
89
+ Remark 3.1. If we use the same proximity function $\pi _ { x } ( z )$ in our framework as in LIME or KernelSHAP, the posterior mean of the feature importance $\hat { \phi }$ output by our framework $E q$ (6)) will be equivalent to the feature importances output by LIME or KernelSHAP, respectively.
90
+
91
+ Feature Importance Uncertainty To obtain the local feature importances and their associated uncertainty, we first compute the posterior mean of the local feature importances $\hat { \phi }$ using the closed form expression in Eqn. (7). We then estimate the credible interval (measure of uncertainty) around the mean feature importances by repeatedly sampling from the posterior distribution of $\phi$ (Eq (5)).
92
+
93
+ Error Uncertainty The error term $\epsilon$ can serve as a proxy for explanation quality because it captures the mismatch between the constructed explanation and the local decision surface of the underlying black box. We first calculate the marginal posterior distribution of $\epsilon$ by leveraging Eqn (4) and integrating out $\sigma ^ { 2 }$ . This results in a three parameter Student’s t distribution (derivation in appendix A):
94
+
95
+ $$
96
+ \epsilon | \mathcal { Z } , Y \sim t _ { ( \nu = n _ { 0 } + N ) } ( 0 , \frac { n _ { 0 } \sigma _ { 0 } ^ { 2 } + N s ^ { 2 } } { n _ { 0 } + N } ) .
97
+ $$
98
+
99
+ We then evaluate the probability density function (PDF) of the above posterior at 0, i.e., $P ( \epsilon = 0 )$ by substituting the value of $s ^ { 2 }$ computed using Eqn. (7) into the Student’s t distribution above (Eqn. (8)). The resulting expression gives us the probability density that the explanation output by our framework perfectly captures the local decision surface underlying the black box. This operation is performed in constant time, adding minimal overhead to non-Bayesian LIME and SHAP. We illustrate how these computed intervals capture the variance in the explanations in Figure 9.
100
+
101
+ Proposition 3.2. As the number of perturbations around $x$ goes to $\infty$ i.e., $N \to \infty$ : $( l )$ the estimate of $\phi$ converges to the true feature importance scores, and its uncertainty to 0. (2) uncertainty of the error term  converges to the bias of the local linear model $\phi$ . [Details in Appendix B]
102
+
103
+ BayesLIME and BayesSHAP Our framework can be instantiated to obtain the Bayesian version of LIME by setting the proximity function to $\pi _ { x } ( z ) = \exp ( - D ( x , z ) ^ { 2 } / \sigma ^ { 2 } )$ where $D$ is a distance metric
104
+
105
+ (e.g. cosine or $l _ { 2 }$ distance), and $n _ { 0 }$ and $\sigma _ { 0 } ^ { 2 }$ to small values $( 1 0 ^ { - 6 } )$ so that the prior is uninformative.
106
+ We compute feature importance uncertainty and error uncertainty for LIME’s feature importances.
107
+
108
+ Our framework can also be instantiated to obtain the Bayesian version of KernelSHAP by setting uninformative prior on $\sigma ^ { 2 }$ and d−1(d choose |z|)|z|(d−|z|) where |z| denotes the number of the variables in the variable combination represented by the data point $z$ i.e., the number of non-zero valued features in the vector representation of $z$ . Note that the original SHAP method views the problem of constructing a local linear model as estimating the Shapley values corresponding to each of the features [4]. These Shapley values represent the contribution of each of the features to the black box prediction i.e., $f ( x ) = \phi _ { 0 } + \sum \phi _ { i }$ . Therefore, the measures of uncertainty output by our method BayesSHAP capture the reliability of the estimated variable contributions.
109
+
110
+ To encourage BayesLIME and BayesSHAP explanations to be sparse, we can use dimensionality reduction or feature selection techniques as used by LIME and SHAP to obtain the top K features [2, 4, 23]. We can then construct our explanations using the data corresponding to these top K features.
111
+
112
+ # 3.2 Estimating the Number of Perturbations
113
+
114
+ One of the major drawbacks of approaches such as LIME and KernelSHAP is that they do not provide any guidance on how to choose the number of perturbations, a key factor in obtaining reliable explanations in an efficient manner. To address this, we leverage the uncertainty estimates output by our framework to compute perturbations-to-go $( G )$ , an estimate of how many more perturbations are required to obtain explanations that satisfy a desired level of certainty. This estimate thus predicts the computational cost of generating an explanation with a desired level of certainty and can help determine whether it is even worthwhile to do so. The user specifies the confidence level of the credible interval (denoted as $\alpha$ ) and the maximum width of the credible interval $( W )$ , e.g. “width of $9 5 \%$ credible interval should be less than $0 . 1 ^ { \mathfrak { s } }$ corresponds to $\alpha = 0 . 9 5$ and $W = 0 . 1$ . To estimate $G$ for the local explanation of a data point $x$ , we first generate $S$ perturbations around $x$ (where $S$ is small and chosen by the user) and fit a local linear model using our method2. This provides initial estimates of various parameters shown in Eqns (5)-(7) which can then be used to compute $G$ .
115
+
116
+ Theorem 3.3. Given $S$ seed perturbations, the number of additional perturbations required $( G )$ to achieve a credible interval width $W$ of feature importance for a data point $x$ at user-specified confidence level $\alpha$ can be computed as:
117
+
118
+ $$
119
+ G ( W , \alpha , x ) = \frac { 4 s _ { S } ^ { 2 } } { \bar { \pi } _ { S } \times \left[ \frac { W } { \Phi ^ { - 1 } ( \alpha ) } \right] ^ { 2 } } - S
120
+ $$
121
+
122
+ where $\bar { \pi } _ { S }$ is the average proximity $\pi _ { x } ( z )$ for the $S$ perturbations, $s _ { S } ^ { 2 }$ is the empirical sum of squared errors (SSE) between the black box and local linear model predictions, weighted by $\pi _ { x } ( z )$ , as in (7), and $\Phi ^ { - 1 } ( \alpha )$ is the two-tailed inverse normal CDF at confidence level $\alpha$ .
123
+
124
+ Proof (Sketch). To estimate $G$ , we first relate $W$ and $\alpha$ to $\operatorname { V a r } ( \phi _ { i } )$ , the marginal variance of the feature importance3 for any feature $i$ , obtained by integrating out $\sigma ^ { 2 }$ . Because Student’s t can be approximated by a Normal distribution for large degrees of freedom (here, $S$ should be large enough), we use the inverse normal CDF to calculate credible interval width at level $\alpha$ . We compute $V _ { \phi }$ from (6) using $\mathcal { Z }$ , treating its entries as Bernoulli distributed with probability 0.5. Due to the covariance structure of this sampling procedure, the resulting variance estimate after $N$ samples is the sample SSE $s _ { S } ^ { 2 }$ scaled by $\approx \frac { 4 } { \hat { \pi } _ { S } N }$ (derivation in appendix B). If we assume SSE scales linearly with $S$ , we can take this to be a reasonable estimate of $s _ { N } ^ { 2 }$ at any $N$ . We can then estimate $G$ as
125
+
126
+ $$
127
+ \left[ \frac { W } { \Phi ^ { - 1 } ( \alpha ) } \right] ^ { 2 } = \mathrm { V a r } ( \phi _ { i } ) = \frac { 4 s _ { S } ^ { 2 } } { \bar { \pi } _ { S } \times ( G + S ) } \Longrightarrow G = \frac { 4 s _ { S } ^ { 2 } } { \bar { \pi } _ { S } \times \left[ \frac { W } { \Phi ^ { - 1 } ( \alpha ) } \right] ^ { 2 } } - S .
128
+ $$
129
+
130
+ # 3.3 Focused Sampling of Perturbations
131
+
132
+ Perturbations-to-go $( G )$ provides us with an estimate of how many samples are required to achieve reliable explanations. However, if $G$ is large, querying the black-box model for its predictions on a large number of perturbations can be computationally expensive for larger models [24, 25]. To reduce this cost, we develop an alternative sampling procedure called focused sampling which leverages uncertainty estimates to query the black box in a more targeted fashion (instead of querying randomly), thereby reducing the computational cost associated with generating reliable explanations. Inspired by active learning [26], focused sampling strategically prioritizes perturbations whose predictions the explanation is most uncertain about, when querying the black box. This enables the focused sampling procedure to query the black box only for the predictions of the most informative perturbations and thereby learn an accurate explanation with far fewer queries to the black box.
133
+
134
+ To determine how uncertain our explanation $\phi$ is about the black box label for any given instance $z$ , we first compute the posterior predictive distribution for $z$ (derivation in Appendix A), given as $\boldsymbol { \hat { y } } ( z ) | \mathcal { Z } , \boldsymbol { Y } \sim t _ { ( \mathcal { V } = N ) } ( \boldsymbol { \hat { \phi } } ^ { T } \boldsymbol { z } , ( \boldsymbol { z } ^ { T } V _ { \phi } \boldsymbol { z } + 1 ) \boldsymbol { s } ^ { 2 } )$ . The variance of this three parameter student’s t distribution is,
135
+
136
+ $$
137
+ \mathrm { v a r } ( \hat { y } ( z ) ) = ( ( z ^ { T } V _ { \phi } z + 1 ) s ^ { 2 } ) ( N / ( N - 2 ) )
138
+ $$
139
+
140
+ We refer to this variance as the predictive variance $\mathrm { v a r } ( \hat { y } ( z ) )$ , and it captures how uncertain our explanation $\phi$ is about the black box prediction.
141
+
142
+ The focus sampling procedure first fits the explanation with an initial $S$ perturbations (where $S$ is a small number). We then iterate the following procedure until the desired explanation certainty level is reached. We draw a batch of $A$ candidate perturbations, compute their predictive variance with the Bayesian explanation, and induce a distribution over the perturbations by running softmax on the variances with tempurature parameter $\tau$ . We draw a batch of $B$ perturbations from this distribution and query the black box model for their labels. Finally, we refit the Bayesian explanation on all the labeled perturbations collected so far. We provide pseudocode for the uncertainty sampling procedure in Algorithm 1.
143
+
144
+ Algorithm 1 Focused sampling for local explanations
145
+
146
+ <table><tr><td colspan="2">Require: Model f,Data instance x, Number of perturbations N,Number of seed perturbations S,</td></tr><tr><td colspan="2">Batch size B,Pool size A, tempurature T 1: function FOCUSED SAMPLE</td></tr><tr><td></td><td>Initialize Z with S seed perturbations.</td></tr><tr><td>2:</td><td></td></tr><tr><td>3:</td><td>Fit on Z Using Eqn (6)</td></tr><tr><td>4:</td><td>fori←1toN-Sinincrements ofBdo</td></tr><tr><td>5:</td><td>Q ←Generate Acandidate perturbations Using Eqn (11)</td></tr><tr><td>6:</td><td>Compute var(y(z)) on Q</td></tr><tr><td>7:</td><td>Define Qdist as X exp(var(g(z))/τ)</td></tr><tr><td>8:</td><td>Qnew ← Draw B samples from Qdist</td></tr><tr><td>9:</td><td>Z ← ZU Qnew; Fit on Z Using Eqn (6)</td></tr><tr><td>10: end for</td><td></td></tr><tr><td>11: return $</td><td></td></tr><tr><td>12: end function</td><td></td></tr></table>
147
+
148
+ # 4 Experiments
149
+
150
+ We evaluate the proposed framework by first analyzing the quality of our uncertainty estimates i.e., feature importance uncertainty and error uncertainty. We also assess our estimates of required perturbations $( G )$ , and evaluate the computational efficiency of focused sampling. Last, we describe a user study with 31 subjects to assess the informativeness of the explanations output by our framework.
151
+
152
+ Setup We experiment with a variety of real world datasets spanning multiple applications (e.g., criminal justice, credit scoring) as well as modalities (e.g., structured data, images). Our first structured dataset is COMPAS [27], containing criminal history, jail and prison time, and demographic attributes of 6172 defendants, with class labels that represent whether each defendant was rearrested within 2 years of release. The second structured dataset is the German Credit dataset from the UCI repository [28] containing financial and demographic information (including account information, credit history, employment, gender) for 1000 loan applications, each labeled as a “good” or “bad” customer. We create 80/20 train/test splits for these two datasets, and train a random forest classifier (sklearn implementation with 100 estimators) as black box models for each (test accuracy of $8 2 . 8 \%$ and $7 2 . 5 \%$ , respectively). We also include popular image datasets–MNIST and Imagenet. For the MNIST [29] handwritten digits dataset, we train a 2-layer CNN to predict the digits (test accuracy of $9 9 . 2 \%$ ). For Imagenet [30], we use the off-the-shelf VGG16 model [31] as the black box. We select a sample of 100 images of the following classes French Bulldog, Scuba Diver, Corn, and Broccoli to use in the experiments. For generating explanations, we use standard implementations of the baselines LIME and KernelSHAP with default settings [2, 4]. For images, we construct super pixels as described in [2] and use them as features (number of super pixels is fixed to 20 per image). For our framework, the desired level of certainty is expressed as the width of the $9 5 \%$ credible interval.
153
+
154
+ <table><tr><td></td><td>BayesLIME</td><td>BayesSHAP</td><td></td><td>BayesLIME</td><td>BayesSHAP</td></tr><tr><td>TABULAR DATASETS</td><td></td><td></td><td>MNIST</td><td></td><td></td></tr><tr><td>COMPAS</td><td>95.5</td><td>87.9</td><td>Digit 1</td><td>95.8</td><td>98.4</td></tr><tr><td>German Credit</td><td>96.9</td><td>89.6</td><td>Digit 2</td><td>95.8</td><td>97.4</td></tr><tr><td>IMAGENET</td><td></td><td></td><td>Digit 3</td><td>95.2</td><td>96.3</td></tr><tr><td>Corn</td><td>94.6</td><td>91.8</td><td>Digit 4</td><td>97.2</td><td>90.1</td></tr><tr><td>Broccoli</td><td>91.4</td><td>89.2</td><td>Digit 5</td><td>95.2</td><td>95.6</td></tr><tr><td>French Bulldog</td><td>94.8</td><td>89.9</td><td>Digit 6</td><td>96.7</td><td>96.8</td></tr><tr><td>Scuba Diver</td><td>92.4</td><td>94.6</td><td>Digit 7</td><td>95.7</td><td>95.3</td></tr></table>
155
+
156
+ Table 1: Evaluating Credible Intervals. We report the $\%$ of time the $9 5 \%$ credible intervals with 100 perturbations include their true values (estimated on 10, 000 perturbations). Closer to 95.0 is better. Both BayesLIME and BayesSHAP are well calibrated.
157
+
158
+ Quality of Uncertainty Estimates A critical component of our explanations is the feature importance uncertainty. To evaluate the correctness of these estimates, we compute how often true feature importances lie within the $9 5 \%$ credible intervals estimated by BayesLIME and BayesSHAP. Note, that by true feature importance, we refer to the best fit linear model output using either the LIME or SHAP kernels. We evaluate the quality of our credible interval estimates by running our methods with 100 perturbations to estimate feature importances and taking the corresponding $9 5 \%$ credible intervals for each test instance. We compute what fraction of the true feature importances fall within our $9 5 \%$ credible intervals. Note, because there are no methods to provide uncertainty estimates for LIME and SHAP, we do not provide further baselines. Since we do not have access to the true feature importances of the complex black box models, following Prop 3.2, we use feature importances computed using a large value of $N$ $( N = 1 0 , 0 0 0 )$ , and treat the resulting estimates as ground truth.
159
+
160
+ Results for BayesLIME in Table 1 indicate that the true feature importances are close to ideal and indicate the estimates are well calibrated. While the estimates by BayesSHAP are somewhat less calibrated (true feature importances fall within our estimated $9 5 \%$ credible intervals about 89.2 to $9 8 . 4 \%$ of the time), they still are quite close to ideal. All in all, these results confirm that the credible intervals learned by our methods are well calibrated and therefore highly reliable in capturing the uncertainty of the feature importances. Lastly, though we set our priors to be uninformative in general, we also investigate how sensitive our uncertainty estimates are to hyperparameter choices in Figure 5 in the Appendix. We find that the explanation uncertainty becomes uncalibrated with strong priors. However, our explanations seem to be robust to hyperparameter choices in general.
161
+
162
+ Correctness of Estimated Number of Perturbations We assess whether our estimate of perturbations-to-go $G$ ; Section 3.2) is an accurate estimate of the additional number of perturbations needed to reach a desired level of feature importance certainty. We carry out this experiment on MNIST data for the digit $" 4 > "$ (additional datasets explored in Appendix C) and use $S = 2 0 0$ as the initial number of perturbations to obtain a preliminary explanation and its associated uncertainty estimates. We then leverage these estimates to compute $G$ for 6 different certainty levels. First, we observe significant differences in $G$ estimates across instances (details in appendix C) i.e. number of perturbations needed to obtain a particular level of certainty varied significantly across instances– ranging from 200-5, 000 for the lowest level of certainty to 200-20, 000 for higher levels of certainty. Next, for each image and certainty level, we run our method for the estimated number of perturbations $( G )$ to determine if the observed estimates of uncertainty (observed credible interval width $W$ ) match the desired levels of uncertainty (desired credible interval width $W$ ). Results in Figure 2 show that the observed and desired levels of certainty are well calibrated, demonstrating that $G$ estimates are reliable approximations of the additional number of perturbations needed.
163
+
164
+ ![](images/a1ce895bb1fbdbf243ad90abc4bbd6376035f01308ad9e7c0365cb10fc50cc0d.jpg)
165
+ Figure 2: Perturbations-to-go $( G )$ . We generate explanation with $G$ perturbations, where $G$ is computed using the desired credible interval width $\mathbf { \bar { X } }$ -axis), and compare desired levels to the observed credible interval width (y-axis) (blue line indicates ideal calibration). Results are averaged over 100 MNIST images of the digit $" 4 > "$ We see that $G$ provides a good approximation of the additional perturbations needed.
166
+
167
+ Efficiency of Focused Sampling Focused sampling uses the predictive variance to strategically choose perturbations that will reduce uncertainty in order to be labeled by the black box (section 3.3). Here, we will evaluate the efficiency of the focused sampling procedure. First, we assess whether focused sampling converges (as measured by error uncertainty $P ( \epsilon = 0 ) )$ ) more efficiently than random sampling. To this end, we experiment with BayesLIME on Imagenet data for the “French bulldog” class to carry out this analysis. This setting replicates scenarios where LIME is applied to a computationally expensive black box model, making it highly desirable to limit the number of perturbations to reduce total running time. We run each sampling strategy for 2,000 perturbations and plot the number of model queries versus error uncertainty. During focused sampling, we set the batch size $B$ to 50. The results in Figure 3 show that focused sampling results in faster convergence to reliable and high quality explanations; focused sampling stabilizes within a couple hundred model queries while random sampling takes over 1,000. Note, as the inefficiency of querying the black box model increases, the advantages of focused sampling decreasing total running time of the explanations will only become more pronounced. These results clearly demonstrate that focused sampling can significantly speed up the process of generating high quality local explanations. Additionally, in Appendix C, we also check if focused sampling causes any bias (due to sampling based on uncertainty estimates) that results in convergence to a different/wrong explanation, however our results clearly indicate that this is not the case.
168
+
169
+ Stability of BayesLIME & BayesSHAP Recall that LIME & SHAP are not stable: small changes to instances can produce substantially different explanations. We consider whether BayesLIME & BayesSHAP produce more stable explanations than their LIME & SHAP counterparts. To perform this analysis, we use the local Lipschitz metric for explanation stability [18]:
170
+
171
+ $$
172
+ \hat { L } ( x _ { i } ) = \operatorname * { a r g m a x } _ { x _ { j } \in N _ { \epsilon } ( x _ { i } ) } \frac { | | \phi _ { i } - \phi _ { j } | | _ { 2 } } { | | x _ { i } - x _ { j } | | _ { 2 } }
173
+ $$
174
+
175
+ where $x _ { i }$ refers to an instance, $N _ { \epsilon } ( x _ { i } )$ is the $\epsilon$ -ball centered at $x _ { i }$ , and $\phi _ { i }$ and $\phi _ { j }$ are the explanation parameters for $x _ { i }$ and $x _ { j }$ . Lower values indicate more stable explanations. We follow the setup outline by Alvarez-Melis and Jaakkola [18] and compute the local Lipschitz values, comparing both LIME & BayesLIME and SHAP & BayesSHAP across Compas, German Credit, MNIST digit $\cdot _ { 4 } \cdot \cdot$ , and Imagenet “French Bulldog.” We perform the comparison using the default number of perturbations in both LIME & SHAP, and use this same number in the respective Bayesian variants and set the batch size $B$ to half this value. We use focused sampling for BayesLIME and BayesSHAP, and report the $\%$ increase in stability of these approaches over LIME and SHAP for 40 test points. The results given in Figure 4 show a clear improvement (on average $5 3 \%$ ) in stability in all cases except German Credit for BayesSHAP. Further, we run a Wilcoxon signed-rank test and find our results are statistically significant in all cases $\mathrm { / e < 1 e { - } 2 ) }$ except for BayesSHAP for German Credit, where there is not a significant difference between the methods $\zeta _ { \rho } > 0 . 0 5 )$ . These results demonstrate BayesLIME and BayesSHAP are more stable than previous methods.
176
+
177
+ ![](images/dbdcf8d6b10a60e362cba9afcfbbaed135a2dd3c956ce32266eb747c42dae508.jpg)
178
+ Figure 3: Efficiency of focused sampling for 100 Imagenet “French bulldog” images, with random sampling as a baseline. We provide mean and standard error. We assess the efficiency of focused sampling by comparing error uncertainty over model queries and show quicker convergence than random sampling.
179
+
180
+ ![](images/988605277650e44dda266f35f97a56551dc27c3e649264948462a5108a6c7e8f.jpg)
181
+ Figure 4: Assessing the $\%$ increase in stability of BayesLIME and BayesSHAP over LIME and SHAP respectively. Our Bayesian methods are significant more stable $\rho \ < \ 1 { \mathrm { e } } { \mathrm { - } } 2$ according to Wilcoxon signed-rank test) except for BayesSHAP on German Credit, where there is not a significant difference between the methods $\zeta _ { \rho } > 0 . 0 5 )$ .
182
+
183
+ User Study We perform a user study with 31 subjects to compare BayesLIME and LIME explanations on MNIST. We evaluate the following: are explanations with low levels of uncertainty (i.e., most confident explanations) more meaningful to humans? To answer this question, we follow prior work and mask the most important features selected by BayesLIME and LIME [32, 4]. We ask users to guess the digit of the masked images. The better the explanation, the more difficult it should be for the users to get it right. Further, the choice to mask the important features is motivated by its success in prior work. We randomly select 15 correctly predicted test images, generate explanations by sweeping over a range of perturbation amounts $[ 1 \dot { 0 } ^ { 5 } , . . . , 1 0 ^ { 3 . 5 } ]$ incremented by 0.5. We choose the top explanation for each image based on either fidelity (for LIME) or $P ( \epsilon = 0 )$ (for BayesLIME). We sent the user study out to students and researchers with background in computer science. A screen shot of the task is shown in Figure 7 in the Appendix. We find that the explanations output by our methods focus on more informative parts of the image, since hiding them makes it difficult for humans to guess the digit. Users had an error rate of $2 5 . 7 \%$ for LIME, while it was $3 0 . 7 \%$ for BayesLIME, both with standard error 0.003 $\mathrm { \Delta } \rho = 0 . 0 2 8$ through a one-tailed two sample t-test). This result indicates that our method BayesLIME and the associated measure of explanation uncertainty result in more high quality and reliable explanations compared to LIME and its associated fidelity metric.
184
+
185
+ # 5 Related Work
186
+
187
+ Interpretability Methods A variety of interpretability methods have been proposed. Some methods that are inherently interpretable include additive models [33, 34], decision lists and sets [35, 36], and instance-based explanations [37]. However, black-box models are often more flexible, accurate, and easier to use; thus, there has been a lot of interest in constructing post hoc explanations[38]. These include LIME [2] and SHAP [4, 39], which are among the most popular due to their broad applicability and code availability, but saliency maps [5–8], permutation feature importance [40], and partial dependency plots [41] also follow this paradigm. Other approaches to post hoc explanations focus on rule-based models [1, 3], counterfactuals [42, 43], and influence functions [9].
188
+
189
+ Vulnerabilities of Post hoc Explanations Recent work has shed light on the downsides of post hoc explanation techniques. These methods are often highly sensitive to small changes in inputs [14], are susceptible to manipulation [15, 16, 44, 45], and are not faithful to the underlying black boxes [46]. Perturbation-based explanation methods such as LIME and SHAP are subject to additional criticisms: results vary between runs of the algorithms [18–20, 47, 21], and hyperparameters used to select the perturbations can greatly influence the resulting explanation [20]. Prior work has attempted to tackle the problem of instability in perturbation-based explanations by averaging over several explanations [48, 19], however, this is computationally expensive. Other works related to creating more trustworthy explanations include development of sanity checks for explainers [49, 17, 50]. These techniques represent an important step towards improved usability, given experimental evidence that humans are often too eager to accept inaccurate machine explanations [51–54]. Recent works theoretically analyze the sources of non-robustness in black box explanations [55–57].
190
+
191
+ Logical and Formal Reasoning Additional related works have considered explaining classifiers through identifying a subset of features that are “sufficient” to explain a prediction [58–62]. Though these methods offer strong guarantees surrounding which features ensure a prediction is achieved, they are not model agnostic. Further, they do not define feature importances associated with the local explanations nor consider ways to improve locally weighted explanations, such as LIME and SHAP.
192
+
193
+ Bayesian Methods in Explainable ML Few recent works have adopted Bayesian formulations to explain black box models [63–65]. Guo et al. [63] introduce a Bayesian non-parametric approach to fit a global surrogate model. Their formulation seeks to fit a mixture of generalizable explanations across instances. Zhao et al. [64] study whether incorporating informative priors improves the stability of the resulting explanations. However, neither of these works focus on modeling the uncertainty of local explanations. Further, these approaches also do not tackle the critical problems of estimating key hyperparameters or improving efficiency of computing explanations.
194
+
195
+ # 6 Conclusion
196
+
197
+ We developed a Bayesian framework for generating local explanations along with their associated uncertainty. We instantiated this framework to obtain Bayesian versions of LIME and SHAP that output pointwise estimates of feature importances as well as their associated credible intervals. These intervals enabled us to infer the quality of the explanations and output explanations that satisfied user specified levels of uncertainty. We carried out theoretical analysis that leverages these uncertainty measures (credible intervals) to estimate the values of critical hyperparameters (e.g., the number of perturbations). We also proposed a novel sampling technique called focused sampling that leverages uncertainty estimates to determine how to sample perturbations for faster convergence.
198
+
199
+ While the Bayesian framework addresses several critical challenges (i.e., consistency, stability, modeling uncertainty) associated with LIME and SHAP, there are still certain aspects where it would exhibit the same shortcomings as LIME and SHAP [4, 66]. For instance, if the local decision surface of a given black box classifier is highly non-linear, our framework, which relies on local linear approximations, may not be able to capture this non-linear decision surface accurately. In addition, if the perturbation sampling procedures used in LIME and SHAP are used in BayesLIME and BayesSHAP, they will likely be vulnerable to the attacks proposed by Slack et al. [15]. In the future, it would be interesting to extend our framework to produce global explanations with uncertainty guarantees and explore how uncertainty quantification can help calibrate user trust in model explanations.
200
+
201
+ # 7 Acknowledgments
202
+
203
+ We would like to thank the anonymous reviewers for their insightful feedback. This work is supported in part by the NSF awards #IIS-2008461, #IIS-2008956, and #IIS-2040989, and research awards from the Harvard Data Science Institute, Amazon, Bayer, Google, and the HPI Research Center in Machine Learning and Data Science at UC Irvine. The views expressed are those of the authors and do not reflect the official policy or position of the funding agencies.
204
+
205
+ References
206
+ [1] Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. Anchors: High-precision modelagnostic explanations. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
207
+ [2] Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. Why Should I Trust You? explaining the predictions of any classifier. In Knowledge Discovery and Data mining (KDD), 2016.
208
+ [3] Himabindu Lakkaraju, Ece Kamar, Rich Caruana, and Jure Leskovec. Faithful and customizable explanations of black box models. In Proceedings of the 2019 AAAI/ACM Conference on AI, Ethics, and Society, pages 131–138. ACM, 2019.
209
+ [4] Scott M Lundberg and Su-In Lee. A unified approach to interpreting model predictions. In Advances in Neural Information Processing Systems, pages 4765–4774, 2017.
210
+ [5] Karen Simonyan, Andrea Vedaldi, and Andrew Zisserman. Deep inside convolutional networks: Visualising image classification models and saliency maps. In Workshop at International Conference on Learning Representations, 2014.
211
+ [6] Mukund Sundararajan, Ankur Taly, and Qiqi Yan. Axiomatic attribution for deep networks. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pages 3319–3328. JMLR. org, 2017.
212
+ [7] Ramprasaath R Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, and Dhruv Batra. Grad-cam: Visual explanations from deep networks via gradient-based localization. In ICCV, 2017.
213
+ [8] Daniel Smilkov, Nikhil Thorat, Been Kim, Fernanda Viégas, and Martin Wattenberg. Smoothgrad: removing noise by adding noise. Workshop on Visualization for Deep Learning, ICML, 2017.
214
+ [9] Pang Wei Koh and Percy Liang. Understanding black-box predictions via influence functions. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pages 1885–1894. JMLR. org, 2017.
215
+ [10] Osbert Bastani, Carolyn Kim, and Hamsa Bastani. Interpretability via model extraction. FAT/ML Workshop 2017, 2017.
216
+ [11] Gregory Plumb, Denali Molitor, and Ameet S Talwalkar. Model agnostic supervised local explanations. In Neural Information Processing Systems, 2018.
217
+ [12] Radwa Elshawi, Mouaz H Al-Mallah, and Sherif Sakr. On the interpretability of machine learning-based model for predicting hypertension. BMC medical informatics and decision making, 19(1):146, 2019.
218
+ [13] Leanne S Whitmore, Anthe George, and Corey M Hudson. Mapping chemical performance on molecular structures using locally interpretable explanations. arXiv preprint arXiv:1611.07443, 2016.
219
+ [14] Amirata Ghorbani, Abubakar Abid, and James Zou. Interpretation of neural networks is fragile. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 3681–3688, 2019.
220
+ [15] Dylan Slack, Sophie Hilgard, Emily Jia, Sameer Singh, and Himabindu Lakkaraju. Fooling lime and shap: Adversarial attacks on post hoc explanation methods. Conference on Artificial Intelligence, Ethics, and Society (AIES), 2020.
221
+ [16] Ann-Kathrin Dombrowski, Maximilian Alber, Christopher J Anders, Marcel Ackermann, KlausRobert Müller, and Pan Kessel. Explanations can be manipulated and geometry is to blame. arXiv preprint arXiv:1906.07983, 2019.
222
+ [17] Julius Adebayo, Justin Gilmer, Michael Muelly, Ian Goodfellow, Moritz Hardt, and Been Kim. Sanity checks for saliency maps. In Advances in Neural Information Processing Systems, pages 9505–9515, 2018.
223
+
224
+ [18] David Alvarez-Melis and Tommi S. Jaakkola. On the robustness of interpretability methods. ICML Workshop on Human Interpretability in Machine Learning, 2018.
225
+
226
+ [19] Eunjin Lee, David Braines, Mitchell Stiffler, Adam Hudler, and Daniel Harborne. Developing the sensitivity of lime for better machine learning explanation. In Artificial Intelligence and Machine Learning for Multi-Domain Operations Applications, volume 11006, page 1100610. International Society for Optics and Photonics, 2019.
227
+
228
+ [20] Hui Fen Tan, Kuangyan Song, Madeilene Udell, Yiming Sun, and Yujia Zhang. “why should you trust my explanation?” understanding uncertainty in lime explanations. In ICML Workshop on AI for Social Good, 2019.
229
+
230
+ [21] Jianbo Chen, Le Song, Martin J. Wainwright, and Michael I. Jordan. L-shapley and c-shapley: Efficient model interpretation for structured data. In International Conference on Learning Representations, 2019.
231
+
232
+ [22] Andrew Moore. Locally weighted bayesian regression, January 1995.
233
+
234
+ [23] Kacper Sokol, Alexander Hepburn, Raúl Santos-Rodríguez, and Peter A. Flach. blimey: Surrogate prediction explanations beyond lime. NeurIPS HCML Workshop, 2019.
235
+
236
+ [24] Emily L. Denton, Wojciech Zaremba, Joan Bruna, Yann LeCun, and Rob Fergus. Exploiting linear structure within convolutional networks for efficient evaluation. In NIPS, 2014.
237
+
238
+ [25] Max Jaderberg, Andrea Vedaldi, and Andrew Zisserman. Speeding up convolutional neural networks with low rank expansions. BMVC 2014 - Proceedings of the British Machine Vision Conference 2014, 05 2014.
239
+
240
+ [26] Burr Settles. Active learning literature survey. 2010.
241
+
242
+ [27] Julia Angwin, Jeff Larson, Surya Mattu, and Lauren Kirchner. Machine bias. In ProPublica, 2016.
243
+
244
+ [28] Dheeru Dua and Casey Graff. Uci machine learning repository, 2017. URL http://archive. ics.uci.edu/ml.
245
+
246
+ [29] Yann LeCun, Corinna Cortes, and CJ Burges. Mnist handwritten digit database. ATT Labs [Online]. Available: http://yann.lecun.com/exdb/mnist, 2, 2010.
247
+
248
+ [30] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A Large-Scale Hierarchical Image Database. In CVPR09, 2009.
249
+
250
+ [31] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015.
251
+
252
+ [32] Patrick Schwab and Walter Karlen. Cxplain: Causal explanations for model interpretation under uncertainty. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 10220–10230. Curran Associates, Inc., 2019. URL http://papers.nips.cc/paper/ 9211-cxplain-causal-explanations-for-model-interpretation-under-uncertainty. pdf.
253
+
254
+ [33] Yin Lou, Rich Caruana, Johannes Gehrke, and Giles Hooker. Accurate intelligible models with pairwise interactions. In KDD, 2013.
255
+
256
+ [34] Berk Ustun, Stefano Traca, and Cynthia Rudin. Supersparse linear integer models for interpretable classification. arXiv preprint arXiv:1306.6677, 2013.
257
+
258
+ [35] Himabindu Lakkaraju, Stephen H Bach, and Jure Leskovec. Interpretable decision sets: A joint framework for description and prediction. In Knowledge Discovery and Data mining (KDD), 2016.
259
+
260
+ [36] Elaine Angelino, Nicholas Larus-Stone, Daniel Alabi, Margo Seltzer, and Cynthia Rudin. Learning certifiably optimal rule lists for categorical data. arXiv preprint arXiv:1704.01701, 2017.
261
+
262
+ [37] Been Kim, Cynthia Rudin, and Julie Shah. The bayesian case model: A generative approach for case-based reasoning and prototype classification. arXiv preprint arXiv:1503.01161, 2015.
263
+
264
+ [38] Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. Model-Agnostic Interpretability of Machine Learning. In ICML Workshop on Human Interpretability in Machine Learning (WHI), June 2016.
265
+
266
+ [39] Ian Covert and Su-In Lee. Improving kernelshap: Practical shapley value estimation using linear regression. In Arindam Banerjee and Kenji Fukumizu, editors, Proceedings of The 24th International Conference on Artificial Intelligence and Statistics, volume 130 of Proceedings of Machine Learning Research, pages 3457–3465. PMLR, 13–15 Apr 2021. URL https: //proceedings.mlr.press/v130/covert21a.html.
267
+
268
+ [40] Leo Breiman. Random forests. Machine learning, 45(1):5–32, 2001.
269
+
270
+ [41] Jerome H Friedman. Greedy function approximation: a gradient boosting machine. Annals of statistics, pages 1189–1232, 2001.
271
+
272
+ [42] Berk Ustun, Alexander Spangher, and Yang Liu. Actionable recourse in linear classification. In Proceedings of the Conference on Fairness, Accountability, and Transparency, FAT\* ’19, pages 10–19, 2019. ISBN 978-1-4503-6125-5.
273
+
274
+ [43] Sandra Wachter, Brent Mittelstadt, and Chris Russell. Counterfactual explanations without opening the black box: Automated decisions and the gdpr. Harv. JL & Tech., 31:841, 2017.
275
+
276
+ [44] Juyeon Heo, Sunghwan Joo, and Taesup Moon. Fooling neural network interpretations via adversarial model manipulation. In Advances in Neural Information Processing Systems 32, pages 2921–2932. 2019.
277
+
278
+ [45] Junlin Wang, Jens Tuyls, Eric Wallace, and Sameer Singh. Gradient-based Analysis of NLP Models is Manipulable. In Findings of the Association for Computational Linguistics: EMNLP (EMNLP Findings), page 247–258, 2020.
279
+
280
+ [46] Cynthia Rudin. Stop explaining black box machine learning models for high stakes decisions and use interpretable models instead. Nature Machine Intelligence, 1(5):206, 2019.
281
+
282
+ [47] Muhammad Rehman Zafar and Naimul Mefraz Khan. Dlime: a deterministic local interpretable model-agnostic explanations approach for computer-aided diagnosis systems. arXiv preprint arXiv:1906.10263, 2019.
283
+
284
+ [48] Chih-Kuan Yeh, Cheng-Yu Hsieh, Arun Suggala, David I Inouye, and Pradeep K Ravikumar. On the (in) fidelity and sensitivity of explanations. In Advances in Neural Information Processing Systems, pages 10965–10976, 2019.
285
+
286
+ [49] Oana-Maria Camburu, Eleonora Giunchiglia, Jakob Foerster, Thomas Lukasiewicz, and Phil Blunsom. Can i trust the explainer? verifying post-hoc explanatory methods. arXiv preprint arXiv:1910.02065, 2019.
287
+
288
+ [50] Mengjiao Yang and Been Kim. Bim: Towards quantitative evaluation of interpretability methods with ground truth. arXiv:1907.09701, 2019.
289
+
290
+ [51] Harmanpreet Kaur, Harsha Nori, Samuel Jenkins, Rich Caruana, Hanna Wallach, and Jennifer Wortman Vaughan. Interpreting interpretability: Understanding data scientists’ use of interpretability tools for machine learning. In CHI, April 2020.
291
+
292
+ [52] Fred Hohman, Andrew Head, Rich Caruana, Robert DeLine, and Steven M Drucker. Gamut: A design probe to understand how data scientists understand machine learning models. In Proceedings of the 2019 CHI Conference on Human Factors in Computing Systems, pages 1–13, 2019.
293
+
294
+ [53] Forough Poursabzi-Sangdeh, Daniel G Goldstein, Jake M Hofman, Jennifer Wortman Vaughan, and Hanna Wallach. Manipulating and measuring model interpretability. arXiv preprint arXiv:1802.07810, 2018.
295
+
296
+ [54] Himabindu Lakkaraju and Osbert Bastani. " how do i fool you?" manipulating user trust via misleading black box explanations. In Proceedings of the AAAI/ACM Conference on AI, Ethics, and Society, pages 79–85, 2020.
297
+
298
+ [55] Damien Garreau and Ulrike von Luxburg. Looking deeper into lime. arXiv preprint arXiv:2008.11092, 2020.
299
+
300
+ [56] Prasad Chalasani, Jiefeng Chen, Amrita Roy Chowdhury, Xi Wu, and Somesh Jha. Concise explanations of neural networks using adversarial training. In International Conference on Machine Learning, pages 1383–1391. PMLR, 2020.
301
+
302
+ [57] Alexander Levine, Sahil Singla, and Soheil Feizi. Certifiably robust interpretation in deep learning. arXiv preprint arXiv:1905.12105, 2019.
303
+
304
+ [58] Eric Wang, Pasha Khosravi, and Guy Van den Broeck. Probabilistic sufficient explanations. In IJCAI, 2021.
305
+
306
+ [59] Andy Shih, Arthur Choi, and Adnan Darwiche. A symbolic approach to explaining bayesian network classifiers. In Proceedings of the 27th International Joint Conference on Artificial Intelligence, IJCAI’18, page 5103–5111. AAAI Press, 2018. ISBN 9780999241127.
307
+
308
+ [60] Weijia Shi, Andy Shih, Adnan Darwiche, and Arthur Choi. On tractable representations of binary neural networks. In Diego Calvanese, Esra Erdem, and Michael Thielscher, editors, Proceedings of the 17th International Conference on Principles of Knowledge Representation and Reasoning, KR 2020, Rhodes, Greece, September 12-18, 2020, pages 882–892, 2020. doi: 10.24963/kr.2020/91. URL https://doi.org/10.24963/kr.2020/91.
309
+
310
+ [61] Yacine Izza, Alexey Ignatiev, and Joao Marques-Silva. 2020.
311
+
312
+ [62] Alexey Ignatiev, Nina Narodytska, and Joao Marques-Silva. Abduction-based explanations for machine learning models. Proceedings of the AAAI Conference on Artificial Intelligence, 33 (01):1511–1519, Jul. 2019. doi: 10.1609/aaai.v33i01.33011511. URL https://ojs.aaai. org/index.php/AAAI/article/view/3964.
313
+
314
+ [63] Wenbo Guo, Sui Huang, Yunzhe Tao, Xinyu Xing, and Lin Lin. Explaining deep learning models – a bayesian non-parametric approach. In Neural Information Processing Systems (NeurIPS). 2018.
315
+
316
+ [64] Xingyu Zhao, Xiaowei Huang, Valentin Robu, and David Flynn. Baylime: Bayesian local interpretable model-agnostic explanations. arXiv preprint arXiv:2012.03058, 2020.
317
+
318
+ [65] Kirill Bykov, Marina Höhne, Klaus-Robert Müller, Shinichi Nakajima, and Marius Kloft. How much can i trust you? – quantifying uncertainties in explaining neural networks. arXiv, 06 2020.
319
+
320
+ [66] Sushant Agarwal, Shahin Jabbari, Chirag Agarwal, Sohini Upadhyay, Steven Wu, and Himabindu Lakkaraju. Towards the unification and robustness of perturbation and gradient based explanations. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 110–119. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr. press/v139/agarwal21c.html.
321
+
322
+ [67] Ludwig Fahrmeir, Thomas Kneib, and Stefan Lang. Regression. Statistik und ihre Anwendungen. Springer, 2007. ISBN 978-3-540-33932-8.
323
+
324
+ [68] Christopher M. Bishop. Pattern Recognition and Machine Learning. Springer, 2006.
md/train/fIn4wLS2XzU/fIn4wLS2XzU.md ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Behavior From the Void: Unsupervised Active Pre-Training
2
+
3
+ Hao Liu UC Berkeley hao.liu@cs.berkeley.edu
4
+
5
+ Pieter Abbeel UC Berkeley pabbeel@cs.berkeley.edu
6
+
7
+ # Abstract
8
+
9
+ We introduce a new unsupervised pre-training method for reinforcement learning called APT, which stands for Active Pre-Training. APT learns behaviors and representations by actively searching for novel states in reward-free environments. The key novel idea is to explore the environment by maximizing a non-parametric entropy computed in an abstract representation space, which avoids challenging density modeling and consequently allows our approach to scale much better in environments that have high-dimensional observations (e.g., image observations). We empirically evaluate APT by exposing task-specific reward after a long unsupervised pre-training phase. In Atari games, APT achieves human-level performance on 12 games and obtains highly competitive performance compared to canonical fully supervised RL algorithms. On DMControl suite, APT beats all baselines in terms of asymptotic performance and data efficiency and dramatically improves performance on tasks that are extremely difficult to train from scratch.
10
+
11
+ # 1 Introduction
12
+
13
+ Reinforcement learning (RL) provides a general framework for solving challenging sequential decision-making problems. When combined with function approximation, it has achieved remarkable success in advancing the frontier of AI technologies. These landmarks include outperforming humans in computer games [40, 51, 64, 5] and solving complex robotic control tasks [3, 1]. Despite these successes, they have to train from scratch to maximize extrinsic reward for every encountered task. This is in sharp contrast with how intelligent creatures quickly adapt to new tasks by leveraging previously acquired behaviors. Unsupervised pre-training, a framework that trains models without expert supervision, has obtained promising results in computer vision [43, 23, 14] and natural language modeling [63, 16, 11]. The learned representation, when fine-tuned on the downstream tasks, can solve them efficiently in a few-shot manner. With the models and datasets growing, performance continues to improve predictably according to scaling laws.
14
+
15
+ Driven by the significance of massive unlabeled data, we consider an analogy setting of unsupervised pre-training in computer vision where labels are removed during training. The goal of pre-training is to have data efficient adaptation for some downstream task defined in the form of rewards. In RL with unsupervised pre-training, the agent is allowed to train for a long period without access to environment reward, and then only gets exposed to the reward during testing. We first test an array of existing methods for unsupervised pre-training to identity which gaps and challenges exist, we evaluate count-based bonus [10], which encourages the agent to visit novel states. We apply count-based bonus to $\mathrm { D r Q }$ [33] which is current state-of-the-art RL for training from pixels. We also evaluate ImageNet pre-trained representations. The results are shown in Figure 1. We can see that count-based bonus fails to outperform train $\mathrm { D r Q }$ from scratch. We hypothesize that the ineffectiveness stems from density modeling at the pixel level being difficult. ImageNet pre-training does not outperform training from scratch either, which has also been shown in previous research in real world robotics [29]. We believe the reason is that neither of existing methods can provide enough diverse data. Count-based exploration faces the difficult of estimating high dimensional data density while ImageNet dataset is out-of-distribution for DMControl.
16
+
17
+ To address the issue of obtaining diverse data for RL with unsupervised pre-training, we propose to actively collect novel data by exploring unknown areas in the task-agnostic environment. The underlying intuition is that a general exploration strategy has to visit, with high probability, any state where the agent might be rewarded in a subsequent RL task. Concretely, our approach relies on the entropy maximization principle [27, 53]. Our hope is that by doing so, the learned behavior and representation can be trained on the whole environment while being as task agnostic as possible. Since entropy maximization in high dimensional state space is intractable as an oracle density model is not available, we resort to the particle-based entropy estimator [55, 8]. This estimator is nonparametric and asymptotically unbiased. The key idea is computing the average of the Euclidean distance of each particle to its nearest neighbors for a set of samples. We consider an abstract representation space in order to make the distance meaningful. To learn such a representation space, we adapt the idea of contrastive representation learning [14] to encode image observations to a lower dimensional space. Building upon this insight, we propose Unsupervised Active Pre-Training (APT) since the agent is encouraged to actively explore and leverage the experience to learn behavior.
18
+
19
+ ![](images/3626fc8b63b5733e13d61b9dbb8abac6268cda4e6e208afc6ef0d8852059587f.jpg)
20
+ Figure 1: Comparison of state-of-the-art pixelbased RL with unsupervised pre-training. APT (ours) and count-based bonus (both based on DrQ [33]) are trained for a long unsupervised period (5M environment steps) without access to environment reward, and then gets exposure to the environment reward during testing. APT significantly outperform training DrQ from scratch, count-based bonus, and ImageNet pre-trained model.
21
+
22
+ Our approach can be applied to a wide-range of existing RL algorithms. In this paper we consider applying our approach to $_ \mathrm { D r Q }$ [33] which is a state-of-the-art visual RL algorithm. On the Atari 26 games subset, APT significantly improves DrQ’s data-efficiency, achieving $54 \%$ relative improvement. On the full suite of Atari 57 games [40], APT significantly outperforms prior state-of-the-art, achieving a median human-normalized score $3 \times$ higher than the highest score achieved by prior unsupervised RL methods and DQN. On DeepMind control suite, APT beats $_ \mathrm { D r Q }$ and unsupervised RL in terms of asymptotic performance and data efficiency and solving tasks that are extremely difficult to train from scratch. The contributions of our paper can be summarized as: (i) We propose a new approach for unsupervised pre-training for visual RL based a nonparametric particle-based entropy maximization. (ii) We show that our pre-training method significantly improves data efficiency of solving downstream tasks on DMControl and Atari suite.
23
+
24
+ # 2 Problem Setting
25
+
26
+ Reinforcement Learning (RL) An agent interacts with its uncertain environment over discrete timesteps and collects reward per action, modeled as a Markov Decision Process (MDP) [48], defined by $\langle S , \mathcal { A } , T , \rho _ { 0 } , r , \gamma \rangle$ where ${ \mathcal { S } } \subseteq \mathbb { R } ^ { n _ { s } }$ is a set of $n _ { \scriptscriptstyle { S } }$ -dimensional states, ${ \mathcal { A } } \subseteq \mathbb { R } ^ { n _ { \mathcal { A } } }$ is a set of $n _ { A }$ dimensional actions, $T : \mathcal { S } \times \mathcal { A } \times \mathcal { S } [ 0 , 1 ]$ is the state transition probability distribution. $\rho _ { 0 } : { \cal { S } } $ $[ 0 , 1 ]$ is the distribution over initial states, $r : S \times \mathcal { A } \mathbb { R }$ is the reward function, and $\gamma \in [ 0 , 1 )$ is the discount factor. At environment state $s \in S$ , the agent take actions $a \in { \mathcal { A } }$ , in the (unknown) environment dynamics defined by the transition probability $T ( s ^ { \prime } | s , a )$ , and the reward function yields e action as the d $a _ { t }$ performed in state ounted sum of futur $s _ { t }$ . We define the discounted return rewards collected by the agent. In $\begin{array} { r } { G ( s _ { t } , a _ { t } ) = \sum _ { l = 0 } ^ { \infty } \gamma ^ { \check { l } } r ( s _ { t + l } , a _ { t + l } ) } \end{array}$ value-based reinforcement learning, the agent learns an estimate of the expected discounted return, a.k.a, state-action value function $\begin{array} { r } { \mathsf { \tilde { Q } } ^ { \pi } ( s _ { t } , \mathsf { \tilde { a } } _ { t } ) = \mathbb { E } _ { s _ { t + 1 } , a _ { t + 1 } , \ldots } \left[ \sum _ { l = 0 } ^ { \infty } \gamma ^ { l } r ( \mathsf { \tilde { s } } _ { t + l } , a _ { t + l } ) \right] } \end{array}$ . A common way of deriving a new policy from a state-action value function is to act $\epsilon$ -greedily with respect to the action values (discrete) or to use policy gradient to maximize the value function (continuous).
27
+
28
+ Unsupervised Pre-Training RL In pretrained RL, the agent is trained in a reward-free MDP $\langle S , S _ { 0 } , A , T , \mathcal { G } \rangle$ for a long period followed by a short testing period with environment rewards $\mathbb { R }$ provided. The goal is to learn a pretrained agent that can quickly adapt to testing tasks defined by rewards to maximize the sum of expected future rewards in a zero-shot or few-shot manner. This is also known as the two phases learning in unsupervised pretraining RL [20]. The current state-of-the-art methods maximize the mutual information $( I )$ between policy-conditioning variable $( w )$ and the behavior induced by the policy in terms of state visitation (s).
29
+
30
+ $$
31
+ \operatorname* { m a x } I ( s ; w ) = \operatorname* { m a x } H ( w ) - H ( w \vert s ) ,
32
+ $$
33
+
34
+ where $w$ is sampled from a fixed distribution in practice as in DIAYN [17] and VISR [20]. The objective can then be simplified as max $- H ( w | s )$ . Due to it being intractable to directly maximize this negative conditional entropy, prior work propose to maximize the variational lower bound of the negative conditional entropy instead [7]. The training then amounts to learning a posterior of task variable conditioning on states $q ( w | s )$ .
35
+
36
+ $$
37
+ - H ( w | s ) \geq \mathbb { E } _ { s , w } \left[ \log q ( w | s ) \right] .
38
+ $$
39
+
40
+ Despite successful results in learning meaningful behaviors from reward-free interactions [e.g. 41, 18, 26, 17, 20], these methods suffer from insufficient exploration because they contain no explicit exploration.
41
+
42
+ Another category considers the alternative direction of maximizing the mutual information [12].
43
+
44
+ $$
45
+ \operatorname* { m a x } I ( s ; w ) = \operatorname* { m a x } H ( s ) - H ( s | w ) .
46
+ $$
47
+
48
+ This intractable quantity can be similarly lowered bound by a variational approximation [7].
49
+
50
+ $$
51
+ I ( s ; w ) \geq \mathbb { E } _ { s , w } \left[ q _ { \theta } ( s | w ) \right] - \mathbb { E } _ { s } \left[ \log p ( s ) \right] ,
52
+ $$
53
+
54
+ where $\mathbb { E } _ { s } \left[ \log p ( s ) \right]$ can then be approximated by a posterior of state given task variables $\mathbb { E } _ { s } \left[ \log p ( s ) \right] \approx \bar { \mathbb { E } _ { s , w } } \left[ \log q ( s | w ) \right]$ . Despite their successes, this category of methods do not explore sufficiently since the agent receives larger rewards for visiting known states than discovering new ones as theoretically and empirically evidenced by Campos et al. [12]. In addition, they have only been shown to work from explicit state-representations and it remains unclear how to modify to learning from pixels.
55
+
56
+ In the next section, we introduce a new nonparametric unsupervised pre-training method for RL which addresses these issues and outperforms prior state-of-the-arts on challenging visual-domain RL benchmarks.
57
+
58
+ # 3 Unsupervised Active Pre-Training for RL
59
+
60
+ We want to incentivize the agent with a reward $r _ { t }$ to maximize entropy in an abstract representation space. Prior work on maximizing entropy relies on estimating density of states which is challenging and non-trivial, instead, we take a two-step approach. First, we learn a mapping $f _ { \theta } : R ^ { n s } \to R ^ { n z }$ that maps state space to an abstract representation space first. Then, we propose a particle-based nonparametric approach to maximize the entropy by deploying state-of-the-art RL algorithms.
61
+
62
+ We introduce how to maximize entropy via particle-based approximation in Section 3.1, and describe how to learn representation from states in Section 3.2
63
+
64
+ # 3.1 Particle-Based Entropy Maximization
65
+
66
+ Our entropy maximization objective is built upon the nonparametric particle-based entropy estimator proposed by Singh et al. [55] and Beirlant [8] and has has been widely studied in statistics [28]. Its key idea is to measure the sparsity of the distribution by considering the distance between each sampled data point and its $k$ nearest neighbors. Concretely, assuming we have number of $n$ data points $\{ z _ { i } \} _ { i = 1 } ^ { n }$ from some unknown distribution, the particle-based approximation can be written as
67
+
68
+ $$
69
+ H _ { \mathrm { p a r t i c l e } } ( z ) = - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log \frac { k } { n \mathrm { v } _ { i } ^ { k } } + b ( k ) \propto \sum _ { i = 1 } ^ { n } \log \mathrm { v } _ { i } ^ { k } ,
70
+ $$
71
+
72
+ where $b ( k )$ is a bias correction term that only depends on the hyperparameter $k$ , and $\mathrm { v } _ { i } ^ { k }$ is the volume of the hypersphere of radius $\| z _ { i } - z _ { i } ^ { ( k ) } \|$ between $z _ { i }$ and its $k$ -th nearest neighbor $z _ { i } ^ { ( k ) } . \parallel \cdot \parallel$ is the Euclidean distance.
73
+
74
+ $$
75
+ \mathrm { v } _ { i } ^ { k } = \frac { \| z _ { i } - z _ { i } ^ { ( k ) } \| ^ { n _ { z } } \cdot \pi ^ { n _ { z } / 2 } } { \Gamma \left( n _ { \mathcal { Z } } / 2 + 1 \right) } ,
76
+ $$
77
+
78
+ ![](images/088a2e5327a5fc6614101c8e99926edea51d628f749e6def09ccd3359159faf0.jpg)
79
+ Figure 2: Diagram of the proposed method APT. On the left shows the objective of APT, which is to maximize the expected reward and minimize the contrastive loss. The contrastive loss learns an abstract representation from observations induced by the policy. We propose a particle-based entropy maximization based reward function such that we can deploy state-of-the-art RL methods to maximize entropy in an abstraction space of the induced by the policy. On the right shows the idea of our particle-based entropy, which measures the distance between each data point and its $\mathbf { k }$ nearest neighbors.
80
+
81
+ where $\Gamma$ is the gamma function. Intuitively, $\mathrm { v } _ { i } ^ { k }$ reflects the sparsity around each particle and equation (1) is proportional to the average of the volumes around each particle.
82
+
83
+ By substituting equation (2) into equation (1), we can simplify the particle-based entropy estimation as a sum of the log of the distance between each particle and its $k$ -th nearest neighbor.
84
+
85
+ $$
86
+ H _ { \mathrm { p a r t i c l e } } ( z ) \propto \sum _ { i = 1 } ^ { n } \log \| z _ { i } - z _ { i } ^ { ( k ) } \| ^ { n z } .
87
+ $$
88
+
89
+ Rather than using equation (3) as the entropy estimation, we find averaging the distance over all $k$ nearest neighbors leads to a more robust and stable result, yielding our estimation of the entropy.
90
+
91
+ $$
92
+ H _ { \mathrm { p a r t i c l e } } ( z ) : = \sum _ { i = 1 } ^ { n } \log \left( c + \frac { 1 } { k } \sum _ { z _ { i } ^ { ( j ) } \in \mathrm { N } _ { k } ( z _ { i } ) } \| z _ { i } - z _ { i } ^ { ( j ) } \| ^ { n \ : z } \right) ,
93
+ $$
94
+
95
+ where $\mathrm { N } _ { k } ( \cdot )$ denotes the $k$ nearest neighbors around a particle, $c$ is a constant for numerical stability (fixed to 1 in all our experiments).
96
+
97
+ We can view the particle-based entropy in equation (4) as an expected reward with the reward function being $\begin{array} { r } { r ( z _ { i } ) = \log \left( c + \frac { 1 } { k } \sum _ { z _ { i } ^ { ( j ) } \in \mathbb { N } _ { k } ( z _ { i } ) } \| z _ { i } - z _ { i } ^ { ( j ) } \| ^ { n _ { z } } \right) } \end{array}$ for each particle $z _ { i }$ . This makes it possible to deploy RL algorithms to maximize entropy, concretely, for a batch of transitions $\{ ( s , a , s ^ { \prime } ) \}$ sampled from the replay buffer. We consider the representation of each $s ^ { \prime }$ as a particle in the representation space and the reward function for each transition is given by
98
+
99
+ $$
100
+ r ( s , a , s ^ { \prime } ) = \log \left( c + \frac { 1 } { k } \sum _ { z ^ { ( j ) } \in \mathrm { N } _ { k } ( z = f _ { \theta } ( s ) ) } \| f _ { \theta } ( s ) - z ^ { ( j ) } \| ^ { n _ { z } } \right)
101
+ $$
102
+
103
+ In order to keep the rewards on a consistent scale, we normalize the intrinsic reward by dividing it by a running estimate of the mean of the intrinsic reward. See Figure 2 for illustration of the formulation.
104
+
105
+ # 3.2 Learning Contrastive Representations
106
+
107
+ Our aforementioned entropy maximization is modular of the representation learning method we choose to use, the representation learning part can be swapped out for different methods if necessary. However, for entropy maximization to work, the representation needs to contain a compressed representation of the state. Recent work, CURL [35], ATC [56] and SPR [52], show contrastive learning (with data augmentation) helps learn meaningful representations in RL. We choose contrastive representation learning since it maximally distinguishes an observation $s _ { t _ { 1 } }$ from alternative observations $s _ { t _ { 2 } }$ according to certain distance metric in representation space, we hypothesize is helpful for learning meaningful representations for our nearest neighbors based entropy maximization. Our contrastive learning is based on the contrastive loss from SimCLR [14], chosen for its simplicity. We also use the same set of image augmentations as in DrQ [33] consisting of small random shifts and color jitter. Concretely, we randomly sample a batch of states (images) from the replay buffer $\{ s _ { i } \} _ { i = 1 } ^ { n }$ . For each state $s _ { i }$ , we apply random data augmentation and obtain two randomly augmented views of the same state, denoted as key $s _ { i } ^ { k } = \mathrm { a u g } ( s _ { i } )$ and query $s _ { i } ^ { v } = \mathrm { a u g } ( s _ { i } )$ . The augmented observations are encoded into a small latent space using the encoder $z = f _ { \theta } ( \cdot )$ followed by a deterministic projection $h _ { \phi } ( \cdot )$ where a contrastive loss is applied. The goal of contrastive learning is to ensure that after the encoder and projection, $s _ { i } ^ { k }$ is relatively more close to $s _ { i } ^ { v }$ than any of the data points $\{ s _ { j } ^ { k } , s _ { j } ^ { v } \} _ { j = 1 , j \neq i } ^ { n }$
108
+
109
+ $$
110
+ \underset { \substack { \theta , \phi } } { \mathrm { n i n } } - \frac { 1 } { 2 n } \sum _ { i = 1 } ^ { n } \left[ \log \frac { \exp ( h _ { \phi } ( f _ { \theta } ( s _ { i } ^ { k } ) ) ^ { T } h _ { \phi } ( f _ { \theta } ( s _ { i } ^ { v } ) ) ) } { \sum _ { i = 1 } ^ { n } \mathbb { I } _ { [ j \neq i ] } ( \exp ( h _ { \phi } ( f _ { \theta } ( s _ { i } ^ { k } ) ) ^ { T } h _ { \phi } ( f _ { \theta } ( s _ { j } ^ { k } ) ) ) + \exp ( h _ { \phi } ( f _ { \theta } ( s _ { i } ^ { k } ) ) ^ { T } h _ { \phi } ( f _ { \theta } ( s _ { j } ^ { v } ) ) ) } \right] .
111
+ $$
112
+
113
+ Following $\mathrm { D r Q }$ , the representation encoder $f _ { \theta } ( \cdot )$ is implemented by the convolutional residual network followed by a fully-connected layer, a LayerNorm and a Tanh non-linearity. We decrease the output dimension of the fully-connected layer after the convnet from 50 to 15. We find it helps to use spectral normalization [39] to normalize the weights and use ELU [15] as the non-linearity in between convolutional layers.
114
+
115
+ Table 1 positions our new approach with respect to existing ones. Figure 2 shows the resulting model. Training proceeds as in other algorithms maximizing extrinsic reward: by learning neural encoder $f$ and computing intrinsic reward $r$ and then trying to maximize this intrinsic return by training the policy. Algorithm 1 shows the pseudo-code of APT, we highlight the changes from DrQ to APT in color.
116
+
117
+ # Algorithm 1: Training APT
118
+
119
+ <table><tr><td colspan="3">RandomlyInitialize f encoder RandomlyInitialize πand Qnetworks fore:=1, do</td></tr><tr><td colspan="3">fort:=1,Tdo Receive observation st from environment</td></tr><tr><td colspan="3">Take action at ~ π(*|st),receive observation St+1 and T from environment</td></tr><tr><td colspan="3">D ←DU(st,at,t,st) {(si,ai,,s)}-1 ~D</td></tr><tr><td colspan="3">Train neural encoder f on mini batch</td></tr><tr><td colspan="3">for each i=1..N do</td></tr><tr><td colspan="3">a~π(-|s)</td></tr><tr><td colspan="3">Qi=Qe(s,ai)</td></tr><tr><td colspan="3">Compute rAPr with equation (5)</td></tr><tr><td colspan="3">yi ← rAPT +γQi</td></tr><tr><td colspan="3">end</td></tr><tr><td colspan="3">lossQ =∑(Q(si,ai)-yi)²</td></tr><tr><td colspan="3">Gradient descent step on Q and π</td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3">end end</td></tr></table>
120
+
121
+ Table 1: Methods for pre-training RL in reward-free setting. Exploration: the method can explore efficiently. Visual: the method works well in visual RL. Off-policy: the method is compatible with off-policy RL optimization. ⋆ means only in state-based RL. c(s) is count-based bonus. $\psi ( s , a )$ : successor feature, $\phi ( s )$ : state representation.
122
+
123
+ <table><tr><td>Algorithm</td><td>Objective</td><td>Visual</td><td>Exploration</td><td>Off-policy</td><td>Pre-Trained model</td></tr><tr><td>MaxEnt [22]</td><td>maxH(s)</td><td>×</td><td>三</td><td>X</td><td>π(a|s)</td></tr><tr><td>CBB [10]</td><td>maxEs[c(s)]</td><td>×</td><td></td><td></td><td>π(a|s)</td></tr><tr><td>MEPOL [42]</td><td>maxH(s)</td><td></td><td></td><td></td><td>π(a|s)</td></tr><tr><td>VISR [20]</td><td>max-H(z|s)</td><td>x&gt;</td><td></td><td>X</td><td>(s,2),(s)</td></tr><tr><td>DIAYN [17]</td><td>max-H(z|s)+H(a|z,s)</td><td>X</td><td>X</td><td>√</td><td>π(a|s,)</td></tr><tr><td>DADS [54]]</td><td>max H(s) -H(s|z)</td><td>X</td><td>X</td><td>√</td><td>π(a|s,2),q(s&#x27;/s,z)</td></tr><tr><td>EDL [12]</td><td>maxH(s) -H(s|2)</td><td>X</td><td></td><td>√</td><td>π(a|s,2)</td></tr><tr><td>APT</td><td>max H(s)</td><td>√</td><td>√</td><td>√</td><td>π(a|s),Q(s,a)</td></tr></table>
124
+
125
+ # 4 Related Work
126
+
127
+ State Space Entropy Maximization. Maximizing entropy of policy has been widely studied in RL, from inverse RL [69] to optimal control [59, 60, 49] and actor-critic [19]. State space entropy maximization has been recently used as an exploration method by estimating density of states and maximizing entropy [22]. In Hazan et al. [22] they present provably efficient exploration algorithms under certain conditions. VAE [32] based entropy estimation has been deployed in lower dimensional observation space [36]. However, due to the difficulty of estimating density in high dimensional space such as Atari games, such parametric exploration methods struggle to work in more challenging visual domains. In contrast, our work turns to particle based entropy maximization in a contrastive representation space. Maximizing particle-based entropy has been shown to improved data efficiency in state-based RL as in MEPOL [42]. However, MEPOL’s entropy estimation depends on importance sampling and the optimization based on on-policy RL algorithms, hindering further applications to challenging visual domains. MEPOL also assumes having access to the semantic information of the state, making it infeasible and not obvious how to modify it to work from pixels. In contrast, our method is compatible with deploying state-of-the-art off-policy RL and representation learning algorithms to maximize entropy. Nonparametric entropy maximization has been studied in goal conditioned RL [66]. Pitis et al. [47] proposes maximizing entropy of achieved goals and demonstrates significantly improved success rates in long horizon goal conditioned tasks. The work by Badia et al. [6] also considers $\mathbf { k }$ -nearest neighbor based count bonus to encourage exploration, yielding improved performance in Atari games. K-nearest neighbor based exploration is shown to improve exploration and data efficiency in model-based RL [57]. Concurrently, it has been shown to be an effective unsupervised pre-training objective for transferring learning in RL [13], their large scale experiments further demonstrate the effectiveness of unsupervised pre-training.
128
+
129
+ Data Efficient RL. To improve upon the sample efficiency of deep RL methods, various methods have been proposed: Kaiser et al. [30] introduce a model-based agent (SimPLe) and show that it compares favorably to standard RL algorithms when data is limited. Hessel et al. [25], Kielak [31], van Hasselt et al. [61] show combining existing RL algorithms (Rainbow) can boost data efficiency. Data augmentation has also been shown to be effective for improving data efficiency in vision-based RL [34, 33]. Temporal contrastive learning combined with model-based learning has been shown to boost data efficiency [52]. Combining contrastive loss with RL has been shown to improve data efficiency in CPC [24] despite only marginal gains. CURL [35] show substantial data-efficiency gains while follow-up results from Kostrikov et al. [33] suggest that most of the benefits come from its use of image augmentation. Contrastive loss has been shown to learn useful pretrained representations when training on expert demonstration [56], however in our work the agent has to explore the world itself and exploit collect experience.
130
+
131
+ Unsupervised Pre-Training RL. A number of recent works have sought to improve reinforcement learning via the addition of an unsupervised pretraining stage, in which the agent improves its representations prior to beginning learning on the target task. One common approach has been to allow the agent a period of fully-unsupervised interaction with the environment during which the agent is trained to learn a set of skills associated with different paths through the environment, as in DIAYN [17], Proto-RL [67], MUSIC [68], APS [37], and VISR [20]. Others have proposed to use self-supervised objectives to generate intrinsic rewards encouraging agents to visit new states, e.g., Pathak et al. [46] use the disagreement between an ensemble of latent-space dynamics models. However, our work is trained to maximize the entropy of the states induced by the policy. By visiting any state where the agent might be rewarded in a subsequent RL task, our work performs better or comparably well as other more complex and specialized state-of-the-art methods.
132
+
133
+ # 5 Results
134
+
135
+ We test APT in DeepMind Control Suite [DMControl; 58] and the Atari suite [9]. During the the long period of pre-training with environment rewards removed, we use $\mathrm { D r Q }$ to maximize the entropy maximization reward defined in equation (5). The pre-trained value function $Q ( s , a )$ is fine-tuned to maximize task specific reward after being exposing to environment rewards during testing period. For our DeepMind control suite and Atari games experiments, we largely follow $\mathrm { D r Q }$ , except we perform two gradient steps per environment step instead of one. Our ablation studies confirm that these changes are not themselves responsible for our performance. Kornia [50] is used for efficient GPU-based data augmentations. Our model is implemented in Numpy [21] and PyTorch [45].
136
+
137
+ APT outperforms prior from scratch SOTA RL on DMControl. We evaluate the performance of different methods by computing the average success rate and episodic return at the end of training.
138
+
139
+ ![](images/fe8c8603ef53ddcac9640efceddfb07e4de9b9e5b04fe0e0e9b0cc4599df221b.jpg)
140
+ Figure 3: Results of different methods in environments from DMControl. All curves are the average of three runs with different seeds, and the shaded areas are standard errors of the mean.
141
+
142
+ The agent is allowed a long unsupervised pre-training phase (5M steps), followed by a short test phase exposing to downstream reward, during which the pre-trained model is fine-tuned. We follow the evaluation setting of DrQ and test APT on a subset of DMControl suite, which includes training Walker, Cheetah, Hopper for various locomotion tasks. Models are pre-trained on Cheetah, Hopper, and Walker, and subsequently fine-tuned on respective downstream tasks. We additionally design more challenging sparse reward tasks where the robot is required to accomplish tasks guided only by sparse feedback signal. The reason we opted to design new sparse reward tasks is to have more diverse downstream tasks. As far as we know, there is only one Cartpole Swingup Sparse that is a CartPole based sparse reward task. Due to its 2D nature being quite limited, we eventually decided to design distinguishable downstream tasks based on a little bit more complex environment, e.g. Hopper Jump etc. The details of the tasks are included in the supplementary material.
143
+
144
+ The learning process of RL agents becomes highly inefficient in sparse supervision tasks when relying on standard exploration techniques. This issue can be alleviated by introducing intrinsic motivation, i.e., denser reward signals that can be automatically computed, one approach that works well in high dimensional setting is count-based exploration [38, 44, 38].
145
+
146
+ The results are presented in Figure 3, APT significantly outperforms SOTA training from scratch (DrQ from scratch) and SOTA exploration method (count-based bonus) on every task. With only a few number of environment interactions, APT quickly adapt to downstream tasks and achieves higher return much more quicker than prior state-of-the-art RL algorithms. Notably, on the sparse reward tasks that are extremely difficult for training from scratch, APT yields significantly higher data efficiency and asymptotic performance.
147
+
148
+ APT outperforms from scratch SOTA RL in Atari. We test APT on the sample-efficient Atari setting [30, 61] which consists of the 26 easiest games in the Atari suite (as judged by above random performance for their algorithm).
149
+
150
+ We follow the evaluation setting in VISR, agents are allowed a long unsupervised training phase (250M steps) without access to rewards, followed by a short test phase with rewards. The test phase contains 100K environment steps – equivalent to $4 0 0 \mathrm { k }$ frames, or just under two hours – compared to the typical standard of 500M environment steps, or roughly 39 days of experience. We normalize the episodic return with respect to expert human scores to account for different scales of scores in each game, as done in previous works. The human-normalized scores (HNS) of an agent on a game is calculated as agent score−random scorehuman score−random score and aggregated across games by mean or median.
151
+
152
+ A full list of scores and aggregate metrics on the Atari 26 subset is presented in Table 2. The results on the full 57 Atari games suite is presented in supplementary material. For consistency with previous works, we report human and random scores from [25]. In the data-limited setting, APT achieves super-human performance on eight games and achieves scores higher than previous state-of-the-arts. In the full suite setting, APT achieves super-human performance on 15 games, compared to a maximum of 12 for any previous methods and achieves scores significantly higher than any previous methods.
153
+
154
+ Table 2: Performance of different methods on the 26 Atari games considered by [30] after 100K environment steps. The results are recorded at the end of training and averaged over 10 random seeds for APT. APT outperforms prior methods on all aggregate metrics, and exceeds expert human performance on 7 out of 26 games while using a similar amount of experience. Prior work has reported different numbers for some of the baselines, particularly SimPLe and DQN. To be rigorous, we pick the best number for each game across the tables reported in van Hasselt et al. [61] and Kielak [31].
155
+
156
+ <table><tr><td>Game</td><td>Random</td><td>Human</td><td>SimPLe</td><td>DER</td><td>CURL</td><td>DrQ</td><td>SPR</td><td>VISR</td><td>APT (ours)</td></tr><tr><td>Alien</td><td>227.8</td><td>7127.7</td><td>616.9</td><td>739.9</td><td>558.2</td><td>771.2</td><td>801.5</td><td>364.4</td><td>2614.8</td></tr><tr><td>Amidar</td><td>5.8</td><td>1719.5</td><td>88.0</td><td>188.6</td><td>142.1</td><td>102.8</td><td>176.3</td><td>186.0</td><td>211.5</td></tr><tr><td>Assault</td><td>222.4</td><td>742.0</td><td>527.2</td><td>431.2</td><td>600.6</td><td>452.4</td><td>571.0</td><td>12091.1</td><td>891.5</td></tr><tr><td>Asterix</td><td>210.0</td><td>8503.3</td><td>1128.3</td><td>470.8</td><td>734.5</td><td>603.5</td><td>977.8</td><td>6216.7</td><td>185.5</td></tr><tr><td>Bank Heist</td><td>14.2</td><td>753.1</td><td>34.2</td><td>51.0</td><td>131.6</td><td>168.9</td><td>380.9</td><td>71.3</td><td>416.7</td></tr><tr><td>BattleZone</td><td>2360.0</td><td>37187.5</td><td>5184.4</td><td>10124.6</td><td>14870.0</td><td>12954.0</td><td>16651.0</td><td>7072.7</td><td>7065.1</td></tr><tr><td>Boxing</td><td>0.1</td><td>12.1</td><td>9.1</td><td>0.2</td><td>1.2</td><td>6.0</td><td>35.8</td><td>13.4</td><td>21.3</td></tr><tr><td>Breakout</td><td>1.7</td><td>30.5</td><td>16.4</td><td>1.9</td><td>4.9</td><td>16.1</td><td>17.1</td><td>17.9</td><td>10.9</td></tr><tr><td>ChopperCommand</td><td>811.0</td><td>7387.8</td><td>1246.9</td><td>861.8</td><td>1058.5</td><td>780.3</td><td>974.8</td><td>800.8</td><td>317.0</td></tr><tr><td>Crazy Climber</td><td>10780.5</td><td>23829.4</td><td>62583.6</td><td>16185.2</td><td>12146.5</td><td>20516.5</td><td>42923.6</td><td>49373.9</td><td>44128.0</td></tr><tr><td>Demon Attack</td><td>107805</td><td>35829.4</td><td>62583.6</td><td>16185.3</td><td>12146.5</td><td>20516.5</td><td>42923.6</td><td>8994.9</td><td>5071.8</td></tr><tr><td>Freeway</td><td>0.0</td><td>29.6</td><td>20.3</td><td>27.9</td><td>26.7</td><td>9.8</td><td>24.4</td><td>-12.1</td><td>29.9</td></tr><tr><td>Frostbite</td><td>65.2</td><td>4334.7</td><td>254.7</td><td>866.8</td><td>1181.3</td><td>331.1</td><td>1821.5</td><td>230.9</td><td>1796.1</td></tr><tr><td>Gopher</td><td>257.6</td><td>2412.5</td><td>771.0</td><td>349.5</td><td>669.3</td><td>636.3</td><td>715.2</td><td>498.6</td><td>2590.4</td></tr><tr><td>Hero</td><td>1027.0</td><td>30826.4</td><td>2656.6</td><td>6857.0</td><td>6279.3</td><td>3736.3</td><td>7019.2</td><td>663.5</td><td>6789.1</td></tr><tr><td>Jamesbond</td><td>29.0</td><td>302.8</td><td>125.3</td><td>301.6</td><td>471.0</td><td>236.0</td><td>365.4</td><td>484.4</td><td>356.1</td></tr><tr><td>Kangaroo</td><td>52.0</td><td>3035.0</td><td>323.1</td><td>779.3</td><td>872.5</td><td>940.6</td><td>3276.4</td><td>1761.9</td><td>412.0</td></tr><tr><td>Krull</td><td>1598.0</td><td>2665.5</td><td>4539.9</td><td>2851.5</td><td>4229.6</td><td>4018.1</td><td>2688.9</td><td>3142.5</td><td>2312.0</td></tr><tr><td>Kung Fu Master</td><td>258.5</td><td>22736.3</td><td>17257.2</td><td>14346.1</td><td>14307.8</td><td>9111.0</td><td>13192.7</td><td>16754.9</td><td>17357.0</td></tr><tr><td>Ms Pacman</td><td>307.3</td><td>6951.6</td><td>1480.0</td><td>1204.1</td><td>1465.5</td><td>960.5</td><td>1313.2</td><td>558.5</td><td>2827.1</td></tr><tr><td>Pong</td><td>-20.7</td><td>14.6</td><td>12.8</td><td>-19.3</td><td>-16.5</td><td>-8.5</td><td>-5.9</td><td>-26.2</td><td>-8.0</td></tr><tr><td>Private Eye</td><td>24.9</td><td>69571.3</td><td>58.3</td><td>97.8</td><td>218.4</td><td>-13.6</td><td>124.0</td><td>98.3</td><td>96.1</td></tr><tr><td>Qbert</td><td>163.9</td><td>13455.0</td><td>1288.8</td><td>1152.9</td><td>1042.4</td><td>854.4</td><td>669.1</td><td>666.3</td><td>17671.2</td></tr><tr><td>Road Runner</td><td>11.5</td><td>7845.0</td><td>5640.6</td><td>9600.0</td><td>5661.0</td><td>8895.1</td><td>14220.5</td><td>6146.7</td><td>4782.1</td></tr><tr><td>Seaquest</td><td>68.4</td><td>42054.7</td><td>683.3</td><td>354.1</td><td>384.5</td><td>301.2</td><td>583.1</td><td>706.6</td><td>2116.7</td></tr><tr><td>Up N Down</td><td>533.4</td><td>11693.2</td><td>3350.3</td><td>2877.4</td><td>2955.2</td><td>3180.8</td><td>28138.5</td><td>10037.6</td><td>8289.4</td></tr><tr><td>Mean HNS</td><td>0.000</td><td>1.000</td><td>44.3</td><td>28.5</td><td>38.1</td><td>35.7</td><td>70.4</td><td>64.31</td><td>69.55</td></tr><tr><td>Median HNS # Superhuman</td><td>0.000 0</td><td>1.000 N/A</td><td>14.4 2</td><td>16.1 2</td><td>17.5 2</td><td>26.8 2</td><td>41.5 7</td><td>12.36 6</td><td>47.50 7</td></tr></table>
157
+
158
+ Unsupervised pre-training on top of $\mathrm { D r Q }$ leads a significant increase in performance(a $54 \%$ increase in median score, a $73 \%$ increase in mean score, and 5 more games with human-level performance), surpassing DQN which trained on hundreds of millions of sampling steps.
159
+
160
+ Compared with SPR [52] which is a recent state-of-the-art model-based data-efficient algorithm, APT achieves comparable mean and median scores. The SPR is based on Rainbow which combines more advances than DrQ which is significantly simpler. While the representation of SPR is also learned by contrastive learning, it trains a model-based dynamic to predict its own latent state representations multiple steps into the future. This temporal representation learning, as illustrated in the SPR paper, contributes to its impressive results compared with standard contrastive representation learning. We believe that it is possible to combine temporal contrastive representation learning of SPR with the effective nonparametric entropy maximization of APT, which is an interesting future direction.
161
+
162
+ APT outperforms prior unsupervised RL. Despite there being many different proposed unsupervised RL methods, their successes are only demonstrated in simple state based environments. Prior works train the agent for a period of fully-unsupervised interaction with the environment, during which the agent is trained to learn a set of skills associated with different paths through the environment, as in DIAYN [17] and VIC [18], or to maximize the diversity of the states it encounters, as in MEPOL [42] and Hazan et al. [22]. Until recently, VISR [20] achieves improved results in Atari games using pixels as input based using a successor feature based approach. In order to compare with prior unsupervised RL methods, we choose DIAYN due to it being based on mutual information maximization and its reported high performance in state-based RL, and MEPOL due to it being based on entropy maximization. We implement them to take pixels as input in Atari games. Our implementation was checked against publicly available code and we made a best effort attempt to tune the algorithms in Atari games. We test two variants of DIAYN and MEPOL, using or not using contrastive representation learning as in APT. In order to ensure a fair comparison, we test a variant of APT without contrastive representation learning.
163
+
164
+ The aggregated results are presented in Table 3, APT significantly outperforms prior state-based unsupervised RL algorithms DIAYN and MEPOL. Both baselines benefit from contrastive representation learning, but their scores are still significantly lower than APT’s score, confirming that the effectiveness of the off-policy entropy maximization in APT. Compared with the state-of-the-art method in Atari VISR, APT achieves significantly higher median score despite having a lower mean score. From the scores breakdown presented in supplementary file, APT performs significantly better than VISR in hard exploration games, while VISR achieves higher scores in dense reward games. We attribute this to that maximizing state entropy leads to more exploratory behavior while successor features enables quicker adaptation for dense reward feedback. It is possible to combine VISR and APT to have the best of both worlds, which we leave as a future work.
165
+
166
+ Table 3: Evaluation in Atari games. The amount of RL interaction utilized is 100K. M dn is the median of human-normalized scores, $M$ is the mean and $> H$ is the number of games with human-level performance. CL denotes training representation encoder using contrastive learning and data augmentation. On each subset, we mark as bold the highest score.
167
+
168
+ <table><tr><td></td><td colspan="3">26 Game Subset</td><td colspan="3">Full 57 Games</td></tr><tr><td>Algorithm</td><td>Mdn</td><td>M</td><td></td><td>&gt;H Mdn</td><td>M</td><td>&gt;H</td></tr><tr><td>CBB</td><td>1.23</td><td>21.94</td><td>3</td><td></td><td></td><td>1</td></tr><tr><td>MEPOL</td><td>0.34</td><td>17.94</td><td>2</td><td>一</td><td></td><td>1</td></tr><tr><td>DIAYN</td><td>1.34</td><td>25.39</td><td>2</td><td>2.95</td><td>23.90</td><td>6</td></tr><tr><td>CBB w/CL</td><td>1.78</td><td>17.34</td><td>2</td><td>1</td><td>1</td><td>1</td></tr><tr><td>MEPOL W/ CL</td><td>1.05</td><td>21.78</td><td>3</td><td>1</td><td>一</td><td></td></tr><tr><td>DIAYN w/ CL</td><td>1.76</td><td>28.44</td><td>2</td><td>3.28</td><td>25.14</td><td>6</td></tr><tr><td>VISR</td><td>9.50</td><td>128.07</td><td>7</td><td>6.81</td><td>102.31</td><td>11</td></tr><tr><td>APT w/o CL</td><td>21.23</td><td>28.12</td><td>3</td><td>28.65</td><td>41.12</td><td>9</td></tr><tr><td>APT</td><td>47.50</td><td>69.55</td><td>7</td><td>33.41</td><td>47.73</td><td>12</td></tr></table>
169
+
170
+ Ablation study. We conduct several ablation studies to measure the contribution of each component in our method. We test two variants of APT that use the same number of gradient steps per environment step and use the same activation function as in DrQ. Another variant of APT is based on randomly selected neighbors to compute particle-based entropy.
171
+
172
+ We also test a variant of APT that use a fixed randomly initialized encoder to study the impact of representation learning. Table 4 shows the performance of each variant of APT. Increasing gradient steps of updating value function from 1 to 2 and using ELU activation function yield higher scores. Using $\mathbf { k }$ -nearest neighbors is crucial to high scores, we believe the reason is randomly selected neighbors do not provide necessary incentive to explore. Using randomly initialized convolutional encoder downgrades performance significantly but still achieve higher score than $\mathrm { D r Q }$ , indicating our particlebased entropy maximization is robust and powerful.
173
+
174
+ Table 4: Scores on the 26 Atari games under consideration for variants of APT. Scores are averaged over 3 random seeds. All variants listed here use data augmentation.
175
+
176
+ <table><tr><td>Variant</td><td>Human-Normalized Score median mean</td></tr><tr><td>APT</td><td>47.50</td></tr><tr><td>APT w/o optim change</td><td>41.50</td></tr><tr><td>APT w/o arch change</td><td>45.71</td></tr><tr><td>APT w/ rand neighbor</td><td>20.80 33.24</td></tr><tr><td>APT w/ fixed encoder</td><td>24.97 41.08</td></tr></table>
177
+
178
+ Contrastive learning representation has
179
+ been shown to have the “uniformity on the hypersphere” property [65], this leads to the question that whether maximum entropy exploration in state space is important. To study this question, we have a variant of APT “Pos Reward APT” which receives a simple positive do not die signal but no particle-based entropy reward. We ran the experiments on MsPacman, we reduced the pretraining phase to 5M steps to reduce computation cost. The evaluation metrics are the number of ram states visited using [2] and the downstream zero shot performance on Atari game. APT visits nearly 27 times more unique ram states than “Pos Reward APT”, showing that the entropy intrinsic reward is indispensable for exploration. In downstream task evaluation over 3 random seeds, “Pos Reward APT $@ 0 ^ { , 9 }$ achieves reward 363.7, “APT $@ 0 ^ { , , }$ achieves reward 687.1, showing that the “do not die” signal is insufficient for exploration or learning pretrained behaviors and representations.
180
+
181
+ We consider a variant of APT that re-initialize the head of pretrained actor-critic. We have run experiments in five different Atari games, as shown in Table 5, pretrained heads
182
+
183
+ Table 5: Scores on 5 Atari games under consideration for different variants of fine-tuning. Scores are averaged over 3 random seeds.
184
+
185
+ <table><tr><td>Mean Reward (3 seeds)</td><td>Alien</td><td>Freeway</td><td>Qbert</td><td>Private Eye</td><td>MsPacman</td></tr><tr><td>APT (pretrained head)</td><td>2614.8</td><td>29.9</td><td>17671.2</td><td>96.1</td><td>2827.1</td></tr><tr><td>APT (random head)</td><td>1755.0</td><td>15.2</td><td>2138.3</td><td>61.3</td><td>1724.9</td></tr></table>
186
+
187
+ perform better than randomly initialized heads in 4 out of 5 games. The experiments demonstrate that finetuning from a pretrained actor-critic head accelerates learning. However, we believe that which one of the two is better depends on the alignment between downstream reward and intrinsic reward. It would be interesting to study how to better leverage downstream reward to finetune the pretrained model.
188
+
189
+ # 6 Discussion
190
+
191
+ Limitation: The fine-tuning strategy employed here (when combined with a value function) works best when the intrinsic and extrinsic rewards being of a similar scale. We believe the discrepancy between intrinsic reward scale and downstream reward scale possibly explain the suboptimal performance of APT in dense reward games. This is an interesting future direction to further improve APT, we hypothesize that reinitializing behaviors part (actor-critic heads) might be useful if the downstream reward scale is very different from pretraining reward scale. One of the principled ways could be adaptive normalization [62], it is an interesting future direction. One challenge of our method is the non-stationarity of the intrinsic reward, being non additive reward poses an interesting challenge for reinforcement learning methods. While our method outperforms training from scratch and prior works, we believe designing better optimization RL methods for maximizing our intrinsic reward can lead to more significant improvement.
192
+
193
+ Conclusion: A new unsupervised pre-training method for RL is introduced to address reward-free pre-training for visual RL, allowing the same task-agnostic pre-trained model to successfully tackle a broad set of RL tasks. Our major contribution is introducing a practical intrinsic reward derived from particle-based entropy maximization in abstract representation space. Empirical study on DMControl suite and Atari games show our method dramatically improves performance on tasks that are extremely difficult for training from scratch. Our method achieves the results of fully supervised canonical RL algorithms using a small fraction of total samples and outperforms data-efficient supervised RL methods.
194
+
195
+ For future work, there are a few ways in which our method can be improved. The long pre-training phase in our work is computationally intensive, since the exhaustive search and exploration is of high sample complexity. One way to remedy this is by combining our method with successful model-based RL and search approaches to reduce sample complexity. Furthermore, fine-tuning the whole pretrained model can make it prone to catastrophic forgetting. As such, it is worth studying alternative methods to leverage the pre-trained models such as keeping the pretrained model unchanged and combine it with a randomly initialized model.
196
+
197
+ # 7 Acknowledgment
198
+
199
+ This research was supported by DARPA Data-Driven Discovery of Models (D3M) program. We would like to thank Misha Laskin, Olivia Watkins, Qiyang Li, Lerrel Pinto, Kimin Lee and other members at RLL and BAIR for insightful discussion and giving constructive comments. We would also like to thank anonymous reviewers for their helpful feedback for previous versions of our work.
200
+
201
+ # References
202
+
203
+ [1] 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.
204
+ [2] A. Anand, E. Racah, S. Ozair, Y. Bengio, M. Côté, and R. D. Hjelm. Unsupervised state representation learning in atari. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 8766–8779, 2019. [3] M. Andrychowicz, D. Crow, A. Ray, J. Schneider, R. Fong, P. Welinder, B. McGrew, J. Tobin, P. Abbeel, and W. Zaremba. Hindsight experience replay. In Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pages 5048–5058, 2017. [4] J. L. Ba, J. R. Kiros, and G. E. Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016. [5] A. P. Badia, B. Piot, S. Kapturowski, P. Sprechmann, A. Vitvitskyi, Z. D. Guo, and C. Blundell. Agent57: Outperforming the atari human benchmark. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 507–517. PMLR, 2020.
205
+ [6] A. P. Badia, P. Sprechmann, A. Vitvitskyi, D. Guo, B. Piot, S. Kapturowski, O. Tieleman, M. Arjovsky, A. Pritzel, A. Bolt, and C. Blundell. Never give up: Learning directed exploration strategies. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020. [7] D. Barber and F. V. Agakov. The im algorithm: A variational approach to information maximization. In Advances in neural information processing systems, 2003. [8] J. Beirlant. Nonparametric entropy estimation: An overview. International Journal of the Mathematical Statistics Sciences, 6:17–39, 1997.
206
+ [9] M. G. Bellemare, Y. Naddaf, J. Veness, and M. Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47:253–279, 2013.
207
+ [10] M. G. Bellemare, S. Srinivasan, G. Ostrovski, T. Schaul, D. Saxton, and R. Munos. Unifying count-based exploration and intrinsic motivation. In Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems 2016, December 5-10, 2016, Barcelona, Spain, pages 1471–1479, 2016.
208
+ [11] T. B. Brown, B. Mann, N. Ryder, M. Subbiah, J. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, S. Agarwal, A. Herbert-Voss, G. Krueger, T. Henighan, R. Child, A. Ramesh, D. M. Ziegler, J. Wu, C. Winter, C. Hesse, M. Chen, E. Sigler, M. Litwin, S. Gray, B. Chess, J. Clark, C. Berner, S. McCandlish, A. Radford, I. Sutskever, and D. Amodei. Language models are few-shot learners. In Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
209
+ [12] V. Campos, A. Trott, C. Xiong, R. Socher, X. Giró-i-Nieto, and J. Torres. Explore, discover and learn: Unsupervised discovery of state-covering skills. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 1317–1327. PMLR, 2020.
210
+ [13] V. Campos, P. Sprechmann, S. S. Hansen, A. Barreto, C. Blundell, A. Vitvitskyi, S. Kapturowski, and A. P. Badia. Coverage as a principle for discovering transferable behavior in reinforcement learning, 2021.
211
+ [14] T. Chen, S. Kornblith, M. Norouzi, and G. E. Hinton. A simple framework for contrastive learning of visual representations. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 1597–1607. PMLR, 2020.
212
+ [15] D. Clevert, T. Unterthiner, and S. Hochreiter. Fast and accurate deep network learning by exponential linear units (elus). In 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016.
213
+ [16] J. Devlin, M.-W. Chang, K. Lee, and K. 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, 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423.
214
+ [17] B. Eysenbach, A. Gupta, J. Ibarz, and S. Levine. Diversity is all you need: Learning skills without a reward function. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019.
215
+ [18] K. Gregor, D. J. Rezende, and D. Wierstra. Variational intrinsic control. arXiv preprint arXiv:1611.07507, 2016.
216
+ [19] T. Haarnoja, A. Zhou, P. Abbeel, and S. Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmässan, Stockholm, Sweden, July 10-15, 2018, volume 80 of Proceedings of Machine Learning Research, pages 1856–1865. PMLR, 2018.
217
+ [20] S. Hansen, W. Dabney, A. Barreto, D. Warde-Farley, T. V. de Wiele, and V. Mnih. Fast task inference with variational intrinsic successor features. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020.
218
+ [21] C. R. Harris, K. J. Millman, S. J. van der Walt, R. Gommers, P. Virtanen, D. Cournapeau, E. Wieser, J. Taylor, S. Berg, N. J. Smith, et al. Array programming with numpy. Nature, 585 (7825):357–362, 2020.
219
+ [22] E. Hazan, S. M. Kakade, K. Singh, and A. V. Soest. Provably efficient maximum entropy exploration. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pages 2681–2691. PMLR, 2019.
220
+ [23] K. He, H. Fan, Y. Wu, S. Xie, and R. B. Girshick. Momentum contrast for unsupervised visual representation learning. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pages 9726–9735. IEEE, 2020. doi: 10.1109/CVPR42600.2020.00975.
221
+ [24] O. J. Hénaff. Data-efficient image recognition with contrastive predictive coding. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 4182–4192. PMLR, 2020.
222
+ [25] M. Hessel, J. Modayil, H. van Hasselt, T. Schaul, G. Ostrovski, W. Dabney, D. Horgan, B. Piot, M. G. Azar, and D. Silver. Rainbow: Combining improvements in deep reinforcement learning. In Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, (AAAI-18), the 30th innovative Applications of Artificial Intelligence (IAAI-18), and the 8th AAAI Symposium on Educational Advances in Artificial Intelligence (EAAI-18), New Orleans, Louisiana, USA, February 2-7, 2018, pages 3215–3222. AAAI Press, 2018.
223
+ [26] R. Houthooft, X. Chen, Y. Duan, J. Schulman, F. D. Turck, and P. Abbeel. VIME: variational information maximizing exploration. In Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems 2016, December 5-10, 2016, Barcelona, Spain, pages 1109–1117, 2016.
224
+ [27] E. T. Jaynes. Information theory and statistical mechanics. Physical review, 106(4):620, 1957.
225
+ [28] J. Jiao, W. Gao, and Y. Han. The nearest neighbor information estimator is adaptively near minimax rate-optimal. In Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montréal, Canada, pages 3160–3171, 2018.
226
+ [29] R. Julian, B. Swanson, G. S. Sukhatme, S. Levine, C. Finn, and K. Hausman. Never stop learning: The effectiveness of fine-tuning in robotic reinforcement learning. arXiv e-prints, pages arXiv–2004, 2020.
227
+ [30] L. Kaiser, M. Babaeizadeh, P. Milos, B. Osinski, R. H. Campbell, K. Czechowski, D. Erhan, C. Finn, P. Kozakowski, S. Levine, A. Mohiuddin, R. Sepassi, G. Tucker, and H. Michalewski. Model based reinforcement learning for atari. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020.
228
+ [31] K. Kielak. Do recent advancements in model-based deep reinforcement learning really improve data efficiency? arXiv preprint arXiv:2003.10181, 2020.
229
+ [32] D. P. Kingma and M. Welling. Auto-encoding variational bayes. In 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Conference Track Proceedings, 2014.
230
+ [33] I. Kostrikov, D. Yarats, and R. Fergus. Image augmentation is all you need: Regularizing deep reinforcement learning from pixels. arXiv preprint arXiv:2004.13649, 2020.
231
+ [34] M. Laskin, K. Lee, A. Stooke, L. Pinto, P. Abbeel, and A. Srinivas. Reinforcement learming with augmented data. arXiv:2004.14990, 2020.
232
+ [35] M. Laskin, A. Srinivas, and P. Abbeel. CURL: contrastive unsupervised representations for reinforcement learning. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 5639–5650. PMLR, 2020.
233
+ [36] L. Lee, B. Eysenbach, E. Parisotto, E. Xing, S. Levine, and R. Salakhutdinov. Efficient exploration via state marginal matching. arXiv preprint arXiv:1906.05274, 2019.
234
+ [37] H. Liu and P. Abbeel. Aps: Active pretraining with successor features. In International Conference on Machine Learning, pages 6736–6747. PMLR, 2021.
235
+ [38] M. C. Machado, M. G. Bellemare, and M. Bowling. Count-based exploration with the successor representation. In The Thirty-Fourth AAAI Conference on Artificial Intelligence, AAAI 2020, The Thirty-Second Innovative Applications of Artificial Intelligence Conference, IAAI 2020, The Tenth AAAI Symposium on Educational Advances in Artificial Intelligence, EAAI 2020, New York, NY, USA, February 7-12, 2020, pages 5125–5133. AAAI Press, 2020.
236
+ [39] T. Miyato, T. Kataoka, M. Koyama, and Y. Yoshida. Spectral normalization for generative adversarial networks. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018.
237
+ [40] V. Mnih, K. Kavukcuoglu, D. Silver, A. A. Rusu, J. Veness, M. G. Bellemare, A. Graves, M. Riedmiller, A. K. Fidjeland, G. Ostrovski, et al. Human-level control through deep reinforcement learning. nature, 518(7540):529–533, 2015.
238
+ [41] S. Mohamed and D. J. Rezende. Variational information maximisation for intrinsically motivated reinforcement learning. In Advances in Neural Information Processing Systems 28: Annual Conference on Neural Information Processing Systems 2015, December 7-12, 2015, Montreal, Quebec, Canada, pages 2125–2133, 2015.
239
+ [42] M. Mutti, L. Pratissoli, and M. Restelli. A policy gradient method for task-agnostic exploration. arXiv preprint arXiv:2007.04640, 2020.
240
+ [43] A. v. d. Oord, Y. Li, and O. Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
241
+ [44] G. Ostrovski, M. G. Bellemare, A. van den Oord, and R. Munos. Count-based exploration with neural density models. In Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, 6-11 August 2017, volume 70 of Proceedings of Machine Learning Research, pages 2721–2730. PMLR, 2017.
242
+ [45] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin, N. Gimelshein, L. Antiga, A. Desmaison, A. Köpf, E. Yang, Z. DeVito, M. Raison, A. Tejani, S. Chilamkurthy, B. Steiner, L. Fang, J. Bai, and S. Chintala. Pytorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 8024–8035, 2019.
243
+ [46] D. Pathak, D. Gandhi, and A. Gupta. Self-supervised exploration via disagreement. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pages 5062–5071. PMLR, 2019.
244
+ [47] S. Pitis, H. Chan, S. Zhao, B. Stadie, and J. Ba. Maximum entropy gain exploration for long horizon multi-goal reinforcement learning. In International Conference on Machine Learning, pages 7750–7761. PMLR, 2020.
245
+ [48] M. L. Puterman. Markov decision processes: discrete stochastic dynamic programming. John Wiley &amp; Sons, 2014.
246
+ [49] K. Rawlik, M. Toussaint, and S. Vijayakumar. On stochastic optimal control and reinforcement learning by approximate inference. Proceedings of Robotics: Science and Systems VIII, 2012.
247
+ [50] E. Riba, D. Mishkin, D. Ponsa, E. Rublee, and G. Bradski. Kornia: an open source differentiable computer vision library for pytorch. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 3674–3683, 2020.
248
+ [51] J. Schrittwieser, I. Antonoglou, T. Hubert, K. Simonyan, L. Sifre, S. Schmitt, A. Guez, E. Lockhart, D. Hassabis, T. Graepel, et al. Mastering atari, go, chess and shogi by planning with a learned model. arXiv preprint arXiv:1911.08265, 2019.
249
+ [52] M. Schwarzer, A. Anand, R. Goel, R. D. Hjelm, A. Courville, and P. Bachman. Data-efficient reinforcement learning with self-predictive representations. In International Conference on Learning Representations, 2021.
250
+ [53] C. E. Shannon. A mathematical theory of communication. The Bell system technical journal, 27(3):379–423, 1948.
251
+ [54] A. Sharma, S. Gu, S. Levine, V. Kumar, and K. Hausman. Dynamics-aware unsupervised discovery of skills. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020.
252
+ [55] H. Singh, N. Misra, V. Hnizdo, A. Fedorowicz, and E. Demchuk. Nearest neighbor estimates of entropy. American journal of mathematical and management sciences, 23(3-4):301–321, 2003.
253
+ [56] A. Stooke, K. Lee, P. Abbeel, and M. Laskin. Decoupling representation learning from reinforcement learning. arXiv preprint arXiv:2009.08319, 2020.
254
+ [57] R. Y. Tao, V. François-Lavet, and J. Pineau. Novelty search in representational space for sample efficient exploration. arXiv preprint arXiv:2009.13579, 2020.
255
+ [58] Y. Tassa, S. Tunyasuvunakool, A. Muldal, Y. Doron, S. Liu, S. Bohez, J. Merel, T. Erez, T. Lillicrap, and N. Heess. dm_control: Software and tasks for continuous control. arXiv preprint arXiv:2006.12983, 2020.
256
+ [59] E. Todorov. General duality between optimal control and estimation. In 2008 47th IEEE Conference on Decision and Control, pages 4286–4292. IEEE, 2008.
257
+ [60] M. Toussaint. Robot trajectory optimization using approximate inference. In Proceedings of the 26th Annual International Conference on Machine Learning, ICML 2009, Montreal, Quebec, Canada, June 14-18, 2009, volume 382 of ACM International Conference Proceeding Series, pages 1049–1056. ACM, 2009. doi: 10.1145/1553374.1553508.
258
+ [61] H. van Hasselt, M. Hessel, and J. Aslanides. When to use parametric models in reinforcement learning? In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 14322–14333, 2019.
259
+ [62] H. P. van Hasselt, A. Guez, M. Hessel, V. Mnih, and D. Silver. Learning values across many orders of magnitude. Advances in Neural Information Processing Systems, 29:4287–4295, 2016.
260
+ [63] 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 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pages 5998–6008, 2017.
261
+ [64] O. Vinyals, I. Babuschkin, W. M. Czarnecki, M. Mathieu, A. Dudzik, J. Chung, D. H. Choi, R. Powell, T. Ewalds, P. Georgiev, et al. Grandmaster level in starcraft ii using multi-agent reinforcement learning. Nature, 575(7782):350–354, 2019.
262
+ [65] T. Wang and P. Isola. Understanding contrastive representation learning through alignment and uniformity on the hypersphere. In International Conference on Machine Learning, pages 9929–9939. PMLR, 2020.
263
+ [66] D. Warde-Farley, T. V. de Wiele, T. D. Kulkarni, C. Ionescu, S. Hansen, and V. Mnih. Unsupervised control through non-parametric discriminative rewards. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019.
264
+ [67] D. Yarats, R. Fergus, A. Lazaric, and L. Pinto. Reinforcement learning with prototypical representations. arXiv preprint arXiv:2102.11271, 2021.
265
+ [68] R. Zhao, Y. Gao, P. Abbeel, V. Tresp, and W. Xu. Mutual information state intrinsic control. arXiv preprint arXiv:2103.08107, 2021.
266
+ [69] B. D. Ziebart, A. L. Maas, J. A. Bagnell, and A. K. Dey. Maximum entropy inverse reinforcement learning. In Aaai, volume 8, pages 1433–1438. Chicago, IL, USA, 2008.
md/train/hm0i-cunzGW/hm0i-cunzGW.md ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Artistic Style Transfer with Internal-external Learning and Contrastive Learning
2
+
3
+ Haibo Chen Lei Zhao∗ Zhizhong Wang Huiming Zhang Zhiwen Zuo Ailin Li Wei Xing∗ Dongming Lu
4
+
5
+ College of Computer Science and Technology, Zhejiang University {cshbchen, cszhl, endywon, qinglanwuji, zzwcs, liailin, wxing, ldm}@zju.edu.cn
6
+
7
+ # Abstract
8
+
9
+ Although existing artistic style transfer methods have achieved significant improvement with deep neural networks, they still suffer from artifacts such as disharmonious colors and repetitive patterns. Motivated by this, we propose an internal-external style transfer method with two contrastive losses. Specifically, we utilize internal statistics of a single style image to determine the colors and texture patterns of the stylized image, and in the meantime, we leverage the external information of the large-scale style dataset to learn the human-aware style information, which makes the color distributions and texture patterns in the stylized image more reasonable and harmonious. In addition, we argue that existing style transfer methods only consider the content-to-stylization and style-to-stylization relations, neglecting the stylization-to-stylization relations. To address this issue, we introduce two contrastive losses, which pull the multiple stylization embeddings closer to each other when they share the same content or style, but push far away otherwise. We conduct extensive experiments, showing that our proposed method can not only produce visually more harmonious and satisfying artistic images, but also promote the stability and consistency of rendered video clips.
10
+
11
+ # 1 Introduction
12
+
13
+ Artistic style transfer is a long-standing research topic that seeks to render a photograph with a given artwork style. Ever since Gatys et al. [10] for the first time proposed a neural method, which leverages a pre-trained Deep Convolutional Neural Network (DCNN) to separate and recombine contents and styles of arbitrary images, an unprecedented booming [20, 26, 15, 30, 36, 51, 48] in style transfer has been witnessed.
14
+
15
+ Despite the recent progress, there still exists a large gap between real artworks and synthesized stylizations. As shown in Figure 1, the stylized images usually contain some disharmonious colors and repetitive patterns, which makes them easily distinguishable from real artworks. We argue that this is because existing style transfer methods often confine themselves to the internal style statistics of a single artistic image. In some other tasks (for example, image-to-image translation [17, 60, 16, 25, 8, 18]), the style is usually learned from a collection of images, which inspires us to leverage the external information reserved in the large-scale style dataset to improve the stylization results in style transfer. Why is the external information so important for style transfer? Our analyses are as follows:
16
+
17
+ Although different images in the style dataset vary greatly in fine details, they share a key commonality: they are all human-created artworks, whose brushstrokes, color distributions, texture patterns, tones, etc., are more consistent with human perception. Namely, they contain some human-aware style information that is lacked in synthesized stylizations. A natural idea is to utilize such human-aware style information to improve stylization results. To this end, we employ an internal-external learning scheme during training, which takes both internal learning and external learning into consideration. To be more specific, on the one hand, we follow previous methods [10, 20, 46, 54, 58], utilizing internal statistics of a single artwork to determine the colors and texture patterns of the stylized image. On the other hand, we employ Generative Adversarial Nets (GANs) [11, 39, 2, 56, 3] to externally learn the human-aware style information from the large-scale style dataset, which is then used to make the color distributions and texture patterns in the stylized image more reasonable and harmonious, significantly bridging the gap between human-created artworks and AI-created artworks.
18
+
19
+ ![](images/159c3e854ae7638a7fe8297a6d85476f89a3a0028e2f4f9a158dd16df68c96df.jpg)
20
+ Figure 1: Stylization examples. The first and second columns show the style and content images, respectively. The other seven columns show the stylized images produced by our method, Gatys et al. [10], AdaIN [15], WCT [30], Avatar-Net [41], LST [28], and SANet [36].
21
+
22
+ In addition, there is another problem with existing style transfer methods: they usually employ a content loss and a style loss to enforce the content-to-stylization relations and style-to-stylization relations, respectively, while neglect the stylization-to-stylization relations, which are also important for style transfer. What are stylization-to-stylization relations? Intuitively, stylized images rendered with the same style image should have closer relations in style than those rendered with different style images. Similarly, stylized images based on the same content image should have closer relations in content than those based on different content images. Inspired by this, in this paper we introduce two contrastive losses: content contrastive loss and style contrastive loss that can pull the multiple stylization embeddings closer to each other when they share the same content or style, but push far away otherwise. To the best of our knowledge, this is the first work that successfully leverages the power of contrastive learning [6, 12, 21, 38] in the style transfer scenario.
23
+
24
+ Our extensive experiments show that the proposed method can not only produce visually more harmonious and plausible artistic images, but also promote the stability and consistency of rendered video clips.
25
+
26
+ To summarize, the main contributions of this work are threefold:
27
+
28
+ • We propose a novel internal-external style transfer method which takes both internal learning and external learning into consideration, significantly bridging the gap between humancreated and AI-created artworks.
29
+ • We for the first time introduce contrastive learning to style transfer, yielding more satisfying stylization results with the learned stylization-to-stylization relations.
30
+ • We demonstrate the effectiveness and superiority of our approach by extensive comparisons with several state-of-the-art artistic style transfer methods.
31
+
32
+ # 2 Related Work
33
+
34
+ Artistic style transfer. Artistic style transfer is an image editing task that aims at transferring artistic styles onto everyday photographs to create new artworks. Earlier methods usually resort to traditional techniques such as stroke rendering [13], image analogy [14, 42, 9, 31], and image filtering [52] to perform artistic style transfer. These methods typically rely on low-level statistics and often fail to capture semantic information. Recently, Gatys et al. [10] discovered that the Gram matrix upon deep features extracted from a pre-trained DCNN can notably represent the characteristics of visual styles, which opens up the neural style transfer era. Since then, a suite of neural methods have been proposed, boosting the development of style transfer from different concerns. Specifically, [20, 27, 46] utilize feed-forward networks to improve efficiency. [26, 54, 36, 58, 35] refine various elements in the stylized images (including content preservation, textures, brushstrokes, etc.) to enhance visual quality. [7, 15, 30, 41, 28] propose universal style transfer methods to achieve generalization. [29, 47, 51] inject random noise to the generative network to encourage diversity. Despite the rapid progress, these style transfer methods still suffer from spurious artifacts such as disharmonious colors and repetitive patterns.
35
+
36
+ Notice that there is another line of work [40, 24, 23, 45, 4, 5] that aims to learn an artist’s style from all his/her artworks. In comparison, instead of learning an artist’s style, we focus on better leaning an artwork’s style (just like the style transfer methods mentioned in the previous paragraph) with the assist of the human-aware style information reserved in the external style dataset. Therefore, our method is orthogonal to these works.
37
+
38
+ Image-to-image translation. Image-to-image translation (I2I) [17, 60, 16, 25, 8, 18] aims at learning the mapping between different visual domains, which is closely related to style transfer. [60, 16] have distinguished these two tasks: (i) I2I can only translate between content-similar visual domains (such as horses zebras and summer winter), while style transfer does not have such limitation, whose content image and style image can be totally different (e.g., the former is a photo of a person and the latter is van Gogh’s The Starry Night). (ii) I2I aims to learn the mapping between two image collections, while style transfer aims to learn the mapping between two specific images. However, we argue that we can borrow some insights from I2I, and leverage the external information of the large-scale style image collections to improve the stylization quality in style transfer.
39
+
40
+ Internal-external learning. Internal-external learning has shown effectiveness in various image generation tasks, such as super-resolution, image inpainting, and so on. In detail, Soh et al. [44] presented a fast, flexible, and lightweight self-supervised super-resolution method by exploiting both external and internal samples. Park et al. [37] developed an internal-external super-resolution method that facilitates super-resolution networks to further enhance the quality of the restored images. Wang et al. [49] proposed a general external-internal learning inpainting scheme, which learns semantic knowledge externally by training on large datasets while fully utilizes internal statistics of the single test image. However, in the field of style transfer, existing methods only use a single artistic image to learn style, resulting in unsatisfying stylization results. Motivated by this, in this work we propose an internal-external style transfer method that takes both internal learning and external learning into consideration, significantly bridging the gap between human-created and AI-created artworks.
41
+
42
+ Contrastive learning. Generally, there are three key ingredients in a contrastive learning process: query, positive examples, and negative examples. The target of contrastive learning is to associate a “query” with its “positive” example while disassociate the “query” with other examples that are referred to as “negatives”. Recently, contrastive learning has demonstrated its effectiveness in the field of conditional image synthesis. To be more specific, ContraGAN [21] introduced a conditional contrastive loss (2C loss) to learn both data-to-class and data-to-data relations. Park et al. [38] maximized the mutual information between input and output with contrastive learning to encourage content preservation in unpaired image translation problems. Liu et al. [34] introduced a latentaugmented contrastive loss to encourage images generated from adjacent latent codes to be similar and those generated from distinct latent codes to be dissimilar, achieving diverse image synthesis. Yu et al. [55] proposed a dual contrastive loss in adversarial training that generalizes representation to more effectively distinguish between real and fake, and further incentivizes the image generation quality. Wu et al. [53] improved the image dehazing result by introducing contrastive learning, which ensures that the restored image is pulled closer to the clear image and pushed far away from the hazy image in representation space.
43
+
44
+ Note that all the above contrastive learning methods cannot be adopted for style transfer. In this work, we make the first attempt to adapt contrastive learning to artistic style transfer, and propose two novel contrastive losses: content contrastive loss and style contrastive loss to learn the stylization-tostylization relations that are ignored by existing style transfer methods.
45
+
46
+ ![](images/6361012454ddaa4e1ea56bf13c0a129d2082ac4d40cb77478222afa9f5aae711.jpg)
47
+ Figure 2: An overview of the proposed method. (a) illustrates our basic framework, which mainly contains a pre-trained encoder, a style-attentional transformation module, a decoder, and a discriminator. The style loss $\mathcal { L } _ { s }$ and the content loss $\mathcal { L } _ { c }$ are used to learn the style and content information, respectively. The adversarial loss $\mathcal { L } _ { a d v }$ is used to learn the human-aware style information. (b) and (c) depict the identity loss $\mathcal { L } _ { i d e n t i t y }$ and contrastive losses $\mathcal { L } _ { s - c o n t r a } \ \& \ \mathcal { L } _ { c - c o n t r a }$ , where $\mathcal { L } _ { i d e n t i t y }$ is used to preserve more content structures and style characteristics in the stylized image, and $\mathcal { L } _ { s - }$ contra $\& \mathcal { L } _ { c - c o n t r a }$ are used to learn the stylization-to-stylization relations.
48
+
49
+ # 3 Proposed Method
50
+
51
+ Existing style transfer methods usually produce unsatisfying stylization results with disharmonious colors and repetitive patterns, which makes them pretty easy to be distinguished from real artworks. As an attempt to bridge the large gap between human-created and AI-created artworks, we propose a novel internal-external style transfer method with two contrastive losses. The overview of our method is shown in Figure 2. It is worth noting that our framework is built on the SANet [36] (one of the state-of-the-art style transfer methods) backbone, which consists of an encoder $E$ , a transformation module $T$ , and a decoder $D$ . In detail, $E$ is a pre-trained VGG-19 network [43] used to extract image features, $T$ is a style-attentional network that can flexibly match the semantic nearest style features onto the content features, and $D$ is a generative network used to transform encoded semantic feature maps into stylized images. We extend SANet [36] with our proposed changes, and our full model is described below.
52
+
53
+ # 3.1 Internal-external Learning
54
+
55
+ Let $C$ and $S$ be the sets of photographs and artworks, respectively. We aim to learn both the internal style characteristics from a single artwork $I _ { s } \in S$ and the external human-aware style information
56
+
57
+ from the dataset $S$ , and then transfer them to an arbitrary content image $I _ { c } \in C$ to create new artistic images $I _ { s c }$ .
58
+
59
+ Internal style learning. Following previous style transfer methods [15, 36, 1], we use a pre-trained VGG-19 network $\phi$ to capture the internal style characteristics from a single artistic image, and the style loss can be generally computed as:
60
+
61
+ $$
62
+ \mathcal { L } _ { s } : = \sum _ { i = 1 } ^ { L } \parallel \mu ( \phi _ { i } ( I _ { s c } ) ) - \mu ( \phi _ { i } ( I _ { s } ) ) \parallel _ { 2 } + \parallel \sigma ( \phi _ { i } ( I _ { s c } ) ) - \sigma ( \phi _ { i } ( I _ { s } ) ) \parallel _ { 2 }
63
+ $$
64
+
65
+ where $\phi _ { i }$ denotes the $i _ { t h }$ layer (Relu1_1, Relu2_1, Relu3_1, Relu4_1, and Relu5_1 layers are used in our model) of the VGG-19 network. $\mu$ and $\sigma$ represent the mean and standard deviation of feature maps extracted by $\phi _ { i }$ , respectively.
66
+
67
+ External style learning. Here, we employ GAN [11, 39, 2, 56, 3] to learn the human-aware style information from the style dataset $S$ . GAN is a popular generative model consisting of two networks (i.e., a generator $\mathcal { G }$ and a discriminator $\mathcal { D }$ ) that compete against each other. Specifically, we input the stylized images produced by the generator and the artworks sampled from $S$ to the discriminator as fake data and real data, respectively. In the training process, the generator will try to fool the discriminator by generating a realistic artistic image, while the discriminator will try to distinguish generated fake artworks from real ones. Joint training of these two networks leads to a generator that is able to produce remarkable realistic fake images with the learned human-aware style information. The adversarial training process can be formulated as (note that our generator $\mathcal { G }$ contains an encoder $E$ , a transformation module $T$ , and a decoder $D$ , as shown in Figure 2 (a)):
68
+
69
+ $$
70
+ \mathcal { L } _ { a d v } : = \underset { I _ { s } \sim S } { \mathbb { E } } [ l o g ( \mathcal { D } ( I _ { s } ) ) ] + \underset { I _ { c } \sim C , I _ { s } \sim S } { \mathbb { E } } [ l o g ( 1 - \mathcal { D } ( D ( T ( E ( I _ { c } ) , E ( I _ { s } ) ) ) ) ) ]
71
+ $$
72
+
73
+ Content structure preservation. To preserve the content structure of $I _ { c }$ in the stylized image $I _ { s c }$ , we adopt the widely-used perceptual loss:
74
+
75
+ $$
76
+ \mathcal { L } _ { c } : = \parallel \phi _ { c o n v 4 \_ 2 } ( I _ { s c } ) - \phi _ { c o n v 4 \_ 2 } ( I _ { c } ) \parallel _ { 2 }
77
+ $$
78
+
79
+ Identity loss. Similar to [36, 32, 59], we utilize the identity loss to encourage the generator $\mathcal { G }$ to be an approximate identity mapping when the content image and style image are the same. In this manner, more content structures and style characteristics can be preserved in the stylization result. The identity loss is depicted in Figure 2 (b) and defined as:
80
+
81
+ $$
82
+ \begin{array} { r } { \mathcal { L } _ { i d e n t i t y } : = \lambda _ { i d e n t i t y 1 } ( \parallel I _ { c c } - I _ { c } \parallel _ { 2 } + \parallel I _ { s s } - I _ { s } \parallel _ { 2 } ) + } \\ { \lambda _ { i d e n t i t y 2 } \displaystyle \sum _ { i = 1 } ^ { L } ( \parallel \phi _ { i } ( I _ { c c } ) - \phi _ { i } ( I _ { c } ) \parallel _ { 2 } + \parallel \phi _ { i } ( I _ { s s } ) - \phi _ { i } ( I _ { s } ) \parallel _ { 2 } ) } \end{array}
83
+ $$
84
+
85
+ where $I _ { c c }$ is the output image generated when both the content image and style image are $I _ { c }$ . $I _ { s s }$ is analogous. $\lambda _ { i d e n t i t y 1 }$ and $\lambda _ { i d e n t i t y 2 }$ are the weights associated with different loss terms. For $\phi _ { i }$ , we choose Relu1_1, Relu2_1, Relu3_1, Relu4_1, and Relu5_1 layers in our experiments.
86
+
87
+ # 3.2 Contrastive Learning
88
+
89
+ Intuitively, stylized images rendered with the same style image should have closer relations in style than those rendered with different style images. Similarly, stylized images based on the same content image should have closer relations in content than those based on different content images. We refer to such relations as stylization-to-stylization relations. Generally, existing style transfer methods only consider the content-to-stylization and style-to-stylization relations by applying the content loss and style loss (like $\mathcal { L } _ { c }$ and $\mathcal { L } _ { s }$ introduced above), while neglect the stylization-to-stylization relations. To tackle this problem, we for the first time introduce contrastive learning to style transfer. The core idea of contrastive learning is to associate data points with their “positive” examples while disassociate them from the other points that are regarded as “negatives”.
90
+
91
+ Specifically, we propose two contrastive losses: a style contrastive loss and a content contrastive loss to learn the stylization-to-stylization relations. Note that for clearer expression, hereafter, we use $s _ { i }$ to represent the $i _ { t h }$ style image, $c _ { i }$ to represent the $i _ { t h }$ content image, and $s _ { i } c _ { i }$ to represent the stylized image generated with $s _ { i }$ and $c _ { i }$ . To perform contrastive learning in every training batch, we arrange a batch of style and content images in the following manner:
92
+
93
+ Assume the batch size $= b$ , which is an even number. Then we get a batch of style images $\{ s _ { 1 } , s _ { 2 }$ , $. . . , s _ { b / 2 } , s _ { 1 } , s _ { 2 } , . . . , s _ { b / 2 - 1 } , s _ { b / 2 } \big \}$ , and a batch of content images $\left\{ c _ { 1 } , c _ { 2 } , . . . , c _ { b / 2 } , c _ { 2 } , c _ { 3 } , . . . , c _ { b / 2 } , c _ { 1 } \right\}$ . Hence, the corresponding stylized images are $\{ s _ { 1 } c _ { 1 } , s _ { 2 } c _ { 2 } , . . . , s _ { b / 2 } c _ { b / 2 } , s _ { 1 } c _ { 2 } , s _ { 2 } c _ { 3 } , . . . , s _ { b / 2 - 1 } c _ { b / 2 }$ , $s _ { b / 2 } c _ { 1 } \}$ . In this way, we ensure that for every stylized image $s _ { i } c _ { j }$ , we can find a stylized image $s _ { i } c _ { x }$ $( x \neq j )$ ) that shares the same style with it, and a stylized image $s _ { y } c _ { j }$ $( y \ne i )$ ) that shares the same content with it in the same batch. Figure 2 (c) depicts this process by taking $b = 8$ as an example.
94
+
95
+ Style contrastive loss. To associate stylized images that share the same style, for a stylized image $s _ { i } c _ { j }$ , we select $s _ { i } c _ { x }$ $( x \neq j )$ ) as its positive example ( ${ } s _ { i } c _ { x }$ shares the same style with $s _ { i } c _ { j } .$ ), and $s _ { m } c _ { n }$ $m \neq i$ and $n \neq j$ ) as its negative examples. Notice that $s _ { m } c _ { n }$ represents a series of stylized images, not just one image. Then we can formulate our style contrastive loss as follows:
96
+
97
+ $$
98
+ \mathcal { L } _ { s - c o n t r a } : = - l o g ( \frac { e x p ( l _ { s } ( s _ { i } c _ { j } ) ^ { T } l _ { s } ( s _ { i } c _ { x } ) / \tau ) } { e x p ( l _ { s } ( s _ { i } c _ { j } ) ^ { T } l _ { s } ( s _ { i } c _ { x } ) / \tau ) + \sum e x p ( l _ { s } ( s _ { i } c _ { j } ) ^ { T } l _ { s } ( s _ { m } c _ { n } ) / \tau ) } )
99
+ $$
100
+
101
+ where $l _ { s } = h _ { s } ( \phi _ { r e l u 3 \_ 1 } ( \cdot ) )$ , in which $h _ { s }$ is a style projection network. $l _ { s }$ is used to obtain the style embeddings from stylized images. $\tau$ is a temperature hyper-parameter to control push and pull force.
102
+
103
+ Content contrastive loss. Similar to the style contrastive loss, to associate stylized images that share the same content, for a stylized image $s _ { i } c _ { j }$ , we select $s _ { y } c _ { j }$ $y \ne i )$ ) as its positive example $( s _ { y } c _ { j }$ shares the same content with $s _ { i } c _ { j }$ ), and $s _ { m } c _ { n }$ ( $m \neq i$ and $n \neq j$ ) as its negative examples. We express the content contrastive loss as:
104
+
105
+ $$
106
+ \mathcal { L } _ { c - c o n t r a : } = - l o g ( \frac { e x p ( l _ { c } ( s _ { i } c _ { j } ) ^ { T } l _ { c } ( s _ { y } c _ { j } ) / \tau ) } { e x p ( l _ { c } ( s _ { i } c _ { j } ) ^ { T } l _ { c } ( s _ { y } c _ { j } ) / \tau ) + \sum e x p ( l _ { c } ( s _ { i } c _ { j } ) ^ { T } l _ { c } ( s _ { m } c _ { n } ) / \tau ) } )
107
+ $$
108
+
109
+ where $l _ { c } = h _ { c } ( \phi _ { r e l u 4 \_ 1 } ( \cdot ) )$ , in which $h _ { c }$ is a content projection network. $l _ { c }$ is used to obtain the content embeddings from stylized images.
110
+
111
+ # 3.3 Final Objective
112
+
113
+ We summarize all aforementioned losses and obtain the final objective of our model,
114
+
115
+ $\begin{array} { r } { \mathcal { L } _ { f i n a l } : = \lambda _ { 1 } \mathcal { L } _ { s } + \lambda _ { 2 } \mathcal { L } _ { a d v } + \lambda _ { 3 } \mathcal { L } _ { c } + \lambda _ { 4 } \mathcal { L } _ { i d e n t i t y } + \lambda _ { 5 } \mathcal { L } _ { s - c o n t r a } + \lambda _ { 6 } \mathcal { L } _ { c - c o n t r a } } \end{array}$ where $\lambda _ { 1 } , \lambda _ { 2 } , \lambda _ { 3 } , \lambda _ { 4 } , \lambda _ { 5 }$ , and $\lambda _ { 6 }$ are hyper-parameters for striking proper balance among losse
116
+
117
+ # 4 Experimental Results
118
+
119
+ In this section, we first introduce the experimental settings. Then we present qualitative and quantitative comparisons between the proposed method and several baseline models. Finally, we discuss the effect of each component in our model by conducting ablation studies.
120
+
121
+ # 4.1 Experimental Settings
122
+
123
+ Implementation details. We build on the recent SANet [36] backbone and extend it with our proposed changes to further push the boundaries in automatic artwork generation. We refer to the original paper [36] for the detailed network architecture of the encoder $E$ , transformation module $T$ , and decoder $D$ . As for the discriminator $\mathcal { D }$ , we employ the multi-scale discriminator proposed by Wang et al. [50]. The style projection network $h _ { s }$ is a two-layer MLP (Multilayer Perceptron) with 256 units at the first layer and 128 units at the second layer. Similarly, the content projection network $h _ { c }$ is a two-layer MLP with 128 units at each layer. The hyper-parameter $\tau$ in Equation (5) and (6) is set to 0.2. The loss weights in Equation (4) and (7) are set to $\lambda _ { i d e n t i t y 1 } = 5 0$ , $\lambda _ { i d e n t i t y 2 } = 1$ , $\lambda _ { 1 } =$ 1, $\lambda _ { 2 } = 5$ , $\lambda _ { 3 } = 1$ , $\lambda _ { 4 } = 1$ , $\lambda _ { 5 } = 0 . 3$ , and $\lambda _ { 6 } = 0 . 3$ . We train our network using the Adam optimizer with a learning rate of 0.0001 and a batch size of 16 for 160000 iterations. Our code is available at: https://github.com/HalbertCH/IEContraAST.
124
+
125
+ ![](images/b7e68f689017b149d7f0a91cbce2e0b2acb50d715d735f4df07721cb1f616f29.jpg)
126
+ Figure 3: Qualitative comparisons on image style transfer. The first row shows the content and style images. The rest of the rows show the stylization results generated with different style transfer methods.
127
+
128
+ Datasets. Like [15, 58, 36, 19], we take MS-COCO [33] and WikiArt [22] as the content dataset and style dataset, respectively. During the training stage, we first resize the smallest dimension of training images to 512 while preserving the aspect ratio, and then randomly crop $2 5 6 \times 2 5 6$ patches from these images as input. Note that in the reference stage, our method is applicable for content images and style images with any size.
129
+
130
+ Baselines. We choose several state-of-the-art style transfer methods as our baselines, including Gatys et al. [10], AdaIN [15], WCT [30], Avatar-Net [41], LST [28], and SANet [36]. All these methods are conducted by using the public codes and default configurations.
131
+
132
+ # 4.2 Qualitative Comparisons
133
+
134
+ In Figure 3, we show the qualitative comparisons between our method and six baselines introduced above. We observe that Gatys et al. [10] is prone to fall in a bad local minimum (e.g., $1 ^ { s t } , 2 ^ { n d }$ , and $3 ^ { r d }$ columns). AdaIN [15] sometimes produces messy stylized images with unseen colors and unwanted halation around the edges (e.g., $\bar { \boldsymbol { 1 } } ^ { s t }$ , $3 ^ { r d }$ , and $6 ^ { \check { t } h }$ columns). WCT [30] often introduces distorted patterns, yielding less-structured and blunt stylized images (e.g., $2 ^ { n d }$ , $4 ^ { t h }$ , and $5 ^ { t h }$ columns). Avatar-Net [41] is hard to produce sharp details and fine brushstrokes (e.g., $1 ^ { s t }$ , $4 ^ { t h }$ , and $5 ^ { t h }$ columns). LST [28] usually produces less stylized images with very limited texture patterns (e.g., $2 ^ { n d }$ , $4 ^ { t h }$ , and $6 ^ { t h }$ columns). SANet [36] tends to apply similar repeated texture patterns among different styles (e.g., $1 ^ { s t }$ , $3 ^ { r d }$ , and $6 ^ { t h }$ columns). Despite the recent progress, the gap between synthesized artistic images and real artworks is still very large. To further narrow this gap, we introduce internal-external learning and contrastive learning to artistic style transfer, leading to visually more harmonious and plausible artistic images, as shown in the $2 ^ { n d }$ row of Figure 3.
135
+
136
+ ![](images/e620f850f57671f15f33b6b7eef6790b1d93ed8fe69602e1cf3e9952452847cf.jpg)
137
+ Figure 4: Qualitative comparisons on video style transfer. The first row shows several video frames and the style image. The rest of the rows show the stylization results generated with different style transfer methods. The last column shows the heat maps of differences between different frames.
138
+
139
+ Table 1: The user study scores for different methods. The higher the better.
140
+
141
+ <table><tr><td></td><td>WikiArt</td><td>Gatys et al.</td><td>AdaIN</td><td>WCT</td><td>Avatar-Net</td><td>LST</td><td>SANet</td><td>Ours</td></tr><tr><td>Preference Score</td><td>-</td><td>0.143</td><td>0.118</td><td>0.099</td><td>0.087</td><td>0.125</td><td>0.161</td><td>0.267</td></tr><tr><td>Deception Score</td><td>0.875</td><td>0.438</td><td>0.363</td><td>0.375</td><td>0.275</td><td>0.381</td><td>0.394</td><td>0.624</td></tr></table>
142
+
143
+ We also compare our method with 6 baselines on video style transfer, which is conducted between a content video and a style image in a frame-wise manner. The stylization results are shown in Figure 4. To visualize the stability and consistency of synthesized video clip, we also show the heat maps of differences between different frames in the last column of Figure 4. As we can see, our approach outperforms existing style transfer methods in terms of stability and consistency by a significant margin. This can be attributed to two points: (i) external learning smooths the stylization results by eliminating those distorted texture patterns; (ii) the proposed contrastive losses take the stylization-to-stylization relations into consideration, pulling adjacent stylized frames closer to each other since they share the same style and similar content.
144
+
145
+ # 4.3 Quantitative Comparisons
146
+
147
+ As the qualitative assessment presented above could be subjective, in this section, we resort to several evaluation metrics to better assess the performance of the proposed method in a quantitative manner.
148
+
149
+ User study [54, 36, 24, 23, 48] is the most widely adopted evaluation metric in style transfer, which investigates user preference over different stylization results for a more objective comparison.
150
+
151
+ Preference score. We use 10 content images and 15 style images to synthesize 150 stylized images for each method. Then 20 content-style pairs are randomly selected for each participant and show them the stylized images generated by our and competing methods side-by-side in a random order. Next, we ask each participant to choose his/her favorite stylization result for each content-style pair. We finally collect 1000 votes from 50 participants and present the percentage of votes for each method in the second row of Table 1. The results indicate that the stylized images generated by our method are more preferred by human participants compared to those generated by the competing methods.
152
+
153
+ Table 2: The average LPIPS distances for different methods. The lower the better.
154
+
155
+ <table><tr><td></td><td>Inputs|Gatys et al.A</td><td>AdaIN</td><td>WCT</td><td>Avatar-Net LST</td><td>SANet</td><td>Ours</td></tr><tr><td>LPIPS Distance</td><td>0.231</td><td>0.488 0.369</td><td>0.460</td><td>0.341 0.326</td><td>0.372</td><td>0.317</td></tr></table>
156
+
157
+ ![](images/962c0bf86010b1458796f6a6858f60e24750d2ce7072d6aac5c00f77cea856b5.jpg)
158
+ Figure 5: Ablation studies of external learning (abbr. EL) and contrastive learning (abbr. CL) on (a) image style transfer and (b) video style transfer. Please zoom in for a better view and details.
159
+
160
+ Deception score. To measure the gap between AI-created artistic images and human-created artworks, we conduct another user study: for each participant, we show them 80 artistic images which consist of 10 human-created artworks collected from WikiArt [22] and 70 stylized images generated by our and 6 baseline methods (note that each method provides 10 stylized images). Then for every image, we ask these participants to guess if it is a real artwork or not. The deception score is calculated as the fraction of times that the stylized images generated by this method are identified as “real”. For comparison, we also report the fraction of times that the human-created artworks are identified as “real”. The results are shown in the third row of Table 1, where we can see that the deception rate of our method is closest to that of human-created artworks, further demonstrating the effectiveness of our method.
161
+
162
+ To quantitatively evaluate the stability and consistency of the proposed method on video style transfer, we adopt LPIPS (Learned Perceptual Image Patch Similarity) [57] as the evaluation metric.
163
+
164
+ LPIPS. LPIPS is a widely used metric in the field of multimodal image-to-image translation (MI2I) [61, 16, 25, 8] to measure diversity. In this paper, we employ LPIPS to measure the stability and consistency of rendered clips by computing the average perceptual distances between adjacent frames. Note that contrary to MI2I methods that expect a higher LPIPS value to achieve better diversity, we expect a lower LPIPS value to achieve better stability and consistency. We synthesize 18 stylized video clips for each method and report the average LPIPS distances in Table 2, where we observe that our approach obtains the best score among all methods, consistent with the qualitative comparisons in Figure 4.
165
+
166
+ # 4.4 Ablation Studies
167
+
168
+ In this section, we conduct several ablation studies to highlight the effect of different components in our model.
169
+
170
+ We first explore the effect of external learning (abbr. EL) and contrastive learning (abbr. CL) on image style transfer. As for internal learning, since its effect has been fully validated in existing style transfer methods, we do not ablate it in this experiment. Figure 5 (a) shows the image stylization results of our method with and without EL/CL. It can be observed that, without EL, the stylized images become messier with abrupt colors and obvious distortions. The reason could be that the model without EL only focuses on increasing the style similarity between the stylized image and the style image, without considering whether the color distributions and texture patterns in the stylized image are natural and harmonious. In comparison, the model with EL can learn the human-aware style information from the large-scale style dataset, leading to more realistic and harmonious stylized images that cannot be distinguished from real artworks by the discriminator. In addition, we also find that our method can better match the target style to the content image with the proposed contrastive losses. This is because our contrastive losses can help the network to learn better style and content representations by taking the stylization-to-stylization relations into consideration, further refining the stylization results. The user preference results reported in the last column of Figure 5 (a) also demonstrate that our full model has the best performance.
171
+
172
+ Similar ablation studies are also conducted on video style transfer. As shown in Figure 5 (b), the stability degradation can be observed after we remove external learning or contrastive learning from our method (notice the color of hair and skin), which is in line with the reported LPIPS distance. The results indicate that both external learning and contrastive learning can improve the stability of video style transfer. As we analyzed in Section 4.2, external learning obtains stability gains by eliminating distorted texture patterns, and contrastive learning obtains stability gains by pulling adjacent stylized frames closer to each other.
173
+
174
+ # 5 Limitations
175
+
176
+ One limitation of this work is that the proposed internal-external learning scheme and two contrastive losses cannot be applied to learning-free style transfer methods, such as WCT [30], Avatar-Net [41], LST [28], etc. This is because the training process is necessary for our method. Therefore, our method can only be incorporated into learning-based methods, such as Johnson et al. [20], AdaIN [15], SANet [36] (in this work, we mainly take SANet as our backbone to show the effectiveness and superiority of our method), etc. Another limitation is that in the inference stage, the style images that are too different from the training styles may not benefit from the external learning scheme, since they are out of the learned style distributions.
177
+
178
+ # 6 Conclusion
179
+
180
+ In this paper, we propose an internal-external style transfer method with two novel contrastive losses. The internal-external learning scheme learns simultaneously both the internal statistics from a single artistic image and the human-aware style information from the large-scale style dataset. As for the contrastive losses, they are dedicated to learning the stylization-to-stylization relations by pulling the multiple stylization embeddings closer to each other when they share the same content or style, but pushing far away otherwise. Extensive experiments show that our method can not only produce visually more harmonious and satisfying artistic images, but also significantly promote the stability and consistency of rendered video clips. The proposed method is simple and effective, and may shed light on more future understandings of artistic style transfer from a new perspective. In the future, we would like to extend our method to other vision tasks, for example, texture synthesis.
181
+
182
+ # Acknowledgments
183
+
184
+ This work was supported in part by the projects No. 2020YFC1523202, 19ZDA197, LY21F020005, 2021009, 2019C03137, MOE Frontier Science Center for Brain Science & Brain-Machine Integration (Zhejiang University), National Natural Science Foundation of China (Research on Key Technologies of art image restoration based on decoupling learning), and Key Scientific Research Base for Digital Conservation of Cave Temples (Zhejiang University), State Administration for Cultural Heritage. We would also like to thank the reviewers and AC for their constructive and insightful comments on the early submission.
185
+
186
+ # Funding Transparency Statement
187
+
188
+ The projects mentioned in our Acknowledgments provided funding and support to this work. There are no additional revenues related to this work.
189
+
190
+ # References
191
+
192
+ g transfer via reversible neural flows. arXiv preprint arXiv:2103.16877, 2021. [2] Martin Arjovsky, Soumith Chintala, and Léon Bottou. Wasserstein gan. arXiv preprint arXiv:1701.07875, 2017. [3] Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. arXiv preprint arXiv:1809.11096, 2018. [4] Haibo Chen, Lei Zhao, Zhizhong Wang, Huiming Zhang, Zhiwen Zuo, Ailin Li, Wei Xing, and Dongming Lu. Dualast: Dual style-learning networks for artistic style transfer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 872–881, 2021. [5] Haibo Chen, Lei Zhao, Huiming Zhang, Zhizhong Wang, Zhiwen Zuo, Ailin Li, Wei Xing, and Dongming Lu. Diverse image style transfer via invertible cross-space mapping. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pages 14880–14889, October 2021. [6] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pages 1597–1607. PMLR, 2020. [7] Tian Qi Chen and Mark Schmidt. Fast patch-based style transfer of arbitrary style. arXiv preprint arXiv:1612.04337, 2016. [8] Yunjey Choi, Youngjung Uh, Jaejun Yoo, and Jung-Woo Ha. Stargan v2: Diverse image synthesis for multiple domains. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 8188–8197, 2020. [9] Oriel Frigo, Neus Sabater, Julie Delon, and Pierre Hellier. Split and match: Example-based adaptive patch sampling for unsupervised style transfer. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 553–561, 2016.
193
+ [10] Leon A Gatys, Alexander S Ecker, and Matthias Bethge. Image style transfer using convolutional neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2414–2423, 2016.
194
+ [11] 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, pages 2672–2680, 2014.
195
+ [12] Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9729–9738, 2020.
196
+ [13] Aaron Hertzmann. Painterly rendering with curved brush strokes of multiple sizes. In Proceedings of the 25th annual conference on Computer graphics and interactive techniques, pages 453–460, 1998.
197
+ [14] Aaron Hertzmann, Charles E Jacobs, Nuria Oliver, Brian Curless, and David H Salesin. Image analogies. In Proceedings of the 28th annual conference on Computer graphics and interactive techniques, pages 327–340, 2001.
198
+ [15] 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.
199
+ [16] Xun Huang, Ming-Yu Liu, Serge Belongie, and Jan Kautz. Multimodal unsupervised image-to-image translation. In Proceedings of the European Conference on Computer Vision (ECCV), pages 172–189, 2018.
200
+ [17] Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1125–1134, 2017.
201
+ [18] Somi Jeong, Youngjung Kim, Eungbean Lee, and Kwanghoon Sohn. Memory-guided unsupervised image-to-image translation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6558–6567, 2021.
202
+ [19] Yongcheng Jing, Xiao Liu, Yukang Ding, Xinchao Wang, Errui Ding, Mingli Song, and Shilei Wen. Dynamic instance normalization for arbitrary style transfer. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 4369–4376, 2020.
203
+ [20] Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In European conference on computer vision, pages 694–711. Springer, 2016.
204
+ [21] Minguk Kang and Jaesik Park. ContraGAN: Contrastive Learning for Conditional Image Generation. 2020.
205
+ [22] Sergey Karayev, Matthew Trentacoste, Helen Han, Aseem Agarwala, Trevor Darrell, Aaron Hertzmann, and Holger Winnemoeller. Recognizing image style. arXiv preprint arXiv:1311.3715, 2013.
206
+ [23] Dmytro Kotovenko, Artsiom Sanakoyeu, Sabine Lang, and Bjorn Ommer. Content and style disentanglement for artistic style transfer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 4422–4431, 2019. and Pattern Recognition, pages 10032–10041, 2019.
207
+ [25] Hsin-Ying Lee, Hung-Yu Tseng, Jia-Bin Huang, Maneesh Singh, and Ming-Hsuan Yang. Diverse imageto-image translation via disentangled representations. In Proceedings of the European conference on computer vision (ECCV), pages 35–51, 2018.
208
+ [26] Chuan Li and Michael Wand. Combining markov random fields and convolutional neural networks for image synthesis. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 2479–2486, 2016.
209
+ [27] Chuan Li and Michael Wand. Precomputed real-time texture synthesis with markovian generative adversarial networks. In European Conference on Computer Vision, pages 702–716. Springer, 2016.
210
+ [28] Xueting Li, Sifei Liu, Jan Kautz, and Ming-Hsuan Yang. Learning linear transformations for fast image and video style transfer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3809–3817, 2019.
211
+ [29] Yijun Li, Chen Fang, Jimei Yang, Zhaowen Wang, Xin Lu, and Ming-Hsuan Yang. Diversified texture synthesis with feed-forward networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 3920–3928, 2017.
212
+ [30] Yijun Li, Chen Fang, Jimei Yang, Zhaowen Wang, Xin Lu, and Ming-Hsuan Yang. Universal style transfer via feature transforms. In Advances in neural information processing systems, pages 386–396, 2017.
213
+ [31] Jing Liao, Yuan Yao, Lu Yuan, Gang Hua, and Sing Bing Kang. Visual attribute transfer through deep image analogy. arXiv preprint arXiv:1705.01088, 2017.
214
+ [32] Jianxin Lin, Yingxue Pang, Yingce Xia, Zhibo Chen, and Jiebo Luo. Tuigan: Learning versatile image-toimage translation with two unpaired images. In European Conference on Computer Vision, pages 18–35. Springer, 2020.
215
+ [33] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In European conference on computer vision, pages 740–755. Springer, 2014.
216
+ [34] Rui Liu, Yixiao Ge, Ching Lam Choi, Xiaogang Wang, and Hongsheng Li. Divco: Diverse conditional image synthesis via contrastive generative adversarial network. arXiv preprint arXiv:2103.07893, 2021.
217
+ [35] Ming Lu, Hao Zhao, Anbang Yao, Yurong Chen, Feng Xu, and Li Zhang. A closed-form solution to universal style transfer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 5952–5961, 2019.
218
+ [36] Dae Young Park and Kwang Hee Lee. Arbitrary style transfer with style-attentional networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 5880–5888, 2019.
219
+ [37] Seobin Park, Jinsu Yoo, Donghyeon Cho, Jiwon Kim, and Tae Hyun Kim. Fast adaptation to superresolution networks via meta-learning. arXiv preprint arXiv:2001.02905, 5, 2020.
220
+ [38] Taesung Park, Alexei A Efros, Richard Zhang, and Jun-Yan Zhu. Contrastive learning for unpaired image-to-image translation. In European Conference on Computer Vision, pages 319–345. Springer, 2020.
221
+ [39] Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv preprint arXiv:1511.06434, 2015.
222
+ [40] Artsiom Sanakoyeu, Dmytro Kotovenko, Sabine Lang, and Bjorn Ommer. A style-aware content loss for real-time hd style transfer. In Proceedings of the European Conference on Computer Vision (ECCV), pages 698–714, 2018.
223
+ [41] Lu Sheng, Ziyi Lin, Jing Shao, and Xiaogang Wang. Avatar-net: Multi-scale zero-shot style transfer by feature decoration. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 8242–8250, 2018.
224
+ [42] YiChang Shih, Sylvain Paris, Connelly Barnes, William T Freeman, and Frédo Durand. Style transfer for headshot portraits. 2014.
225
+ [43] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
226
+ [44] Jae Woong Soh, Sunwoo Cho, and Nam Ik Cho. Meta-transfer learning for zero-shot super-resolution. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3516–3525, 2020.
227
+ [45] Jan Svoboda, Asha Anoosheh, Christian Osendorfer, and Jonathan Masci. Two-stage peer-regularized feature recombination for arbitrary image style transfer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 13816–13825, 2020.
228
+ [46] Dmitry Ulyanov, Vadim Lebedev, Andrea Vedaldi, and Victor S Lempitsky. Texture networks: Feedforward synthesis of textures and stylized images. In ICML, volume 1, page 4, 2016.
229
+ [47] Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Improved texture networks: Maximizing quality and diversity in feed-forward stylization and texture synthesis. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 6924–6932, 2017.
230
+ [48] Huan Wang, Yijun Li, Yuehai Wang, Haoji Hu, and Ming-Hsuan Yang. Collaborative distillation for ultra-resolution universal style transfer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1860–1869, 2020.
231
+ [49] Tengfei Wang, Hao Ouyang, and Qifeng Chen. Image inpainting with external-internal learning and monochromic bottleneck. arXiv preprint arXiv:2104.09068, 2021.
232
+ [50] Ting-Chun Wang, Ming-Yu Liu, Jun-Yan Zhu, Andrew Tao, Jan Kautz, and Bryan Catanzaro. Highresolution image synthesis and semantic manipulation with conditional gans. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 8798–8807, 2018.
233
+ [51] Zhizhong Wang, Lei Zhao, Haibo Chen, Lihong Qiu, Qihang Mo, Sihuan Lin, Wei Xing, and Dongming Lu. Diversified arbitrary style transfer via deep feature perturbation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 7789–7798, 2020.
234
+ [52] Holger Winnemöller, Sven C Olsen, and Bruce Gooch. Real-time video abstraction. ACM Transactions On Graphics (TOG), 25(3):1221–1226, 2006.
235
+ [53] Haiyan Wu, Yanyun Qu, Shaohui Lin, Jian Zhou, Ruizhi Qiao, Zhizhong Zhang, Yuan Xie, and Lizhuang Ma. Contrastive learning for compact single image dehazing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10551–10560, 2021.
236
+ [54] Yuan Yao, Jianqiang Ren, Xuansong Xie, Weidong Liu, Yong-Jin Liu, and Jun Wang. Attention-aware multi-stroke style transfer. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 1467–1475, 2019.
237
+ [55] Ning Yu, Guilin Liu, Aysegul Dundar, Andrew Tao, Bryan Catanzaro, Larry Davis, and Mario Fritz. Dual contrastive loss and attention for gans. arXiv preprint arXiv:2103.16748, 2021.
238
+ [56] Han Zhang, Ian Goodfellow, Dimitris Metaxas, and Augustus Odena. Self-attention generative adversarial networks. In International conference on machine learning, pages 7354–7363. PMLR, 2019.
239
+ [57] Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 586–595, 2018.
240
+ [58] Yulun Zhang, Chen Fang, Yilin Wang, Zhaowen Wang, Zhe Lin, Yun Fu, and Jimei Yang. Multimodal style transfer via graph cuts. In Proceedings of the IEEE International Conference on Computer Vision, pages 5943–5951, 2019.
241
+ [59] Yihao Zhao, Ruihai Wu, and Hao Dong. Unpaired image-to-image translation using adversarial consistency loss. In European Conference on Computer Vision, pages 800–815. Springer, 2020.
242
+ [60] Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE international conference on computer vision, pages 2223–2232, 2017.
243
+ [61] Jun-Yan Zhu, Richard Zhang, Deepak Pathak, Trevor Darrell, Alexei A Efros, Oliver Wang, and Eli Shechtman. Toward multimodal image-to-image translation. In Advances in neural information processing systems, pages 465–476, 2017.
md/train/i_Q1yrOegLY/i_Q1yrOegLY.md ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Revisiting Deep Learning Models for Tabular Data
2
+
3
+ Yury Gorishniy∗†‡ Ivan Rubachev†♣
4
+
5
+ Valentin Khrulkov† Artem Babenko†♣
6
+
7
+ Yandex, Russia Moscow Institute of Physics and Technology, Russia National Research University Higher School of Economics, Russia
8
+
9
+ # Abstract
10
+
11
+ The existing literature on deep learning for tabular data proposes a wide range of novel architectures and reports competitive results on various datasets. However, the proposed models are usually not properly compared to each other and existing works often use different benchmarks and experiment protocols. As a result, it is unclear for both researchers and practitioners what models perform best. Additionally, the field still lacks effective baselines, that is, the easy-to-use models that provide competitive performance across different problems.
12
+
13
+ In this work, we perform an overview of the main families of DL architectures for tabular data and raise the bar of baselines in tabular DL by identifying two simple and powerful deep architectures. The first one is a ResNet-like architecture which turns out to be a strong baseline that is often missing in prior works. The second model is our simple adaptation of the Transformer architecture for tabular data, which outperforms other solutions on most tasks. Both models are compared to many existing architectures on a diverse set of tasks under the same training and tuning protocols. We also compare the best DL models with Gradient Boosted Decision Trees and conclude that there is still no universally superior solution. The source code is available at https://github.com/yandex-research/rtdl.
14
+
15
+ # 1 Introduction
16
+
17
+ Due to the tremendous success of deep learning on such data domains as images, audio and texts (Goodfellow et al., 2016), there has been a lot of research interest to extend this success to problems with data stored in tabular format. In these problems, data points are represented as vectors of heterogeneous features, which is typical for industrial applications and ML competitions, where neural networks have a strong non-deep competitor in the form of GBDT (Chen and Guestrin, 2016; Ke et al., 2017; Prokhorenkova et al., 2018). Along with potentially higher performance, using deep learning for tabular data is appealing as it would allow constructing multi-modal pipelines for problems, where only one part of the input is tabular, and other parts include images, audio and other DL-friendly data. Such pipelines can then be trained end-to-end by gradient optimization for all modalities. For these reasons, a large number of DL solutions were recently proposed, and new models continue to emerge (Arik and Pfister, 2020; Badirli et al., 2020; Hazimeh et al., 2020; Huang et al., 2020; Klambauer et al., 2017; Popov et al., 2020; Song et al., 2019; Wang et al., 2017, 2020).
18
+
19
+ Unfortunately, due to the lack of established benchmarks (such as ImageNet (Deng et al., 2009) for computer vision or GLUE (Wang et al., 2019a) for NLP), existing papers use different datasets for evaluation and proposed DL models are often not adequately compared to each other. Therefore, from the current literature, it is unclear what DL model generally performs better than others and whether GBDT is surpassed by DL models. Additionally, despite the large number of novel architectures, the field still lacks simple and reliable solutions that allow achieving competitive performance with moderate effort and provide stable performance across many tasks. In that regard, Multilayer
20
+
21
+ Perceptron (MLP) remains the main simple baseline for the field, however, it does not always represent a significant challenge for other competitors.
22
+
23
+ The described problems impede the research process and make the observations from the papers not conclusive enough. Therefore, we believe it is timely to review the recent developments from the field and raise the bar of baselines in tabular DL. We start with a hypothesis that well-studied DL architecture blocks may be underexplored in the context of tabular data and may be used to design better baselines. Thus, we take inspiration from well-known battle-tested architectures from other fields and obtain two simple models for tabular data. The first one is a ResNet-like architecture (He et al., 2015) and the second one is FT-Transformer — our simple adaptation of the Transformer architecture (Vaswani et al., 2017) for tabular data. Then, we compare these models with many existing solutions on a diverse set of tasks under the same protocols of training and hyperparameters tuning. First, we reveal that none of the considered DL models can consistently outperform the ResNet-like model. Given its simplicity, it can serve as a strong baseline for future work. Second, FT-Transformer demonstrates the best performance on most tasks and becomes a new powerful solution for the field. Interestingly, FT-Transformer turns out to be a more universal architecture for tabular data: it performs well on a wider range of tasks than the more “conventional” ResNet and other DL models. Finally, we compare the best DL models to GBDT and conclude that there is still no universally superior solution.
24
+
25
+ We summarize the contributions of our paper as follows:
26
+
27
+ 1. We thoroughly evaluate the main models for tabular DL on a diverse set of tasks to investigate their relative performance.
28
+ 2. We demonstrate that a simple ResNet-like architecture is an effective baseline for tabular DL, which was overlooked by existing literature. Given its simplicity, we recommend this baseline for comparison in future tabular DL works.
29
+ 3. We introduce FT-Transformer — a simple adaptation of the Transformer architecture for tabular data that becomes a new powerful solution for the field. We observe that it is a more universal architecture: it performs well on a wider range of tasks than other DL models.
30
+ 4. We reveal that there is still no universally superior solution among GBDT and deep models.
31
+
32
+ # 2 Related work
33
+
34
+ The “shallow” state-of-the-art for problems with tabular data is currently ensembles of decision trees, such as GBDT (Gradient Boosting Decision Tree) (Friedman, 2001), which are typically the top-choice in various ML competitions. At the moment, there are several established GBDT libraries, such as XGBoost (Chen and Guestrin, 2016), LightGBM (Ke et al., 2017), CatBoost (Prokhorenkova et al., 2018), which are widely used by both ML researchers and practitioners. While these implementations vary in detail, on most of the tasks, their performances do not differ much (Prokhorenkova et al., 2018).
35
+
36
+ During several recent years, a large number of deep learning models for tabular data have been developed (Arik and Pfister, 2020; Badirli et al., 2020; Hazimeh et al., 2020; Huang et al., 2020; Klambauer et al., 2017; Popov et al., 2020; Song et al., 2019; Wang et al., 2017). Most of these models can be roughly categorized into three groups, which we briefly describe below.
37
+
38
+ Differentiable trees. The first group of models is motivated by the strong performance of decision tree ensembles for tabular data. Since decision trees are not differentiable and do not allow gradient optimization, they cannot be used as a component for pipelines trained in the end-to-end fashion. To address this issue, several works (Hazimeh et al., 2020; Kontschieder et al., 2015; Popov et al., 2020; Yang et al., 2018) propose to “smooth” decision functions in the internal tree nodes to make the overall tree function and tree routing differentiable. While the methods of this family can outperform GBDT on some tasks (Popov et al., 2020), in our experiments, they do not consistently outperform ResNet.
39
+
40
+ Attention-based models. Due to the ubiquitous success of attention-based architectures for different domains (Dosovitskiy et al., 2021; Vaswani et al., 2017), several authors propose to employ attentionlike modules for tabular DL as well (Arik and Pfister, 2020; Huang et al., 2020; Song et al., 2019). In our experiments, we show that the properly tuned ResNet outperforms the existing attention-based models. Nevertheless, we identify an effective way to apply the Transformer architecture (Vaswani et al., 2017) to tabular data: the resulting architecture outperforms ResNet on most of the tasks.
41
+
42
+ Explicit modeling of multiplicative interactions. In the literature on recommender systems and click-through-rate prediction, several works criticize MLP since it is unsuitable for modeling multiplicative interactions between features (Beutel et al., 2018; Qin et al., 2021; Wang et al., 2017). Inspired by this motivation, some works (Beutel et al., 2018; Wang et al., 2017, 2020) have proposed different ways to incorporate feature products into MLP. In our experiments, however, we do not find such methods to be superior to properly tuned baselines.
43
+
44
+ The literature also proposes some other architectural designs (Badirli et al., 2020; Klambauer et al., 2017) that cannot be explicitly assigned to any of the groups above. Overall, the community has developed a variety of models that are evaluated on different benchmarks and are rarely compared to each other. Our work aims to establish a fair comparison of them and identify the solutions that consistently provide high performance.
45
+
46
+ # 3 Models for tabular data problems
47
+
48
+ In this section, we describe the main deep architectures that we highlight in our work, as well as the existing solutions included in the comparison. Since we argue that the field needs strong easy-to-use baselines, we try to reuse well-established DL building blocks as much as possible when designing ResNet (section 3.2) and FT-Transformer (section 3.3). We hope this approach will result in conceptually familiar models that require less effort to achieve good performance. Additional discussion and technical details for all the models are provided in supplementary.
49
+
50
+ Notation. In this work, we consider supervised learning problems. $D { = } \{ ( x _ { i } , ~ y _ { i } ) \} _ { i { = } 1 } ^ { n }$ denotes a dataset, where $x _ { i } = ( x _ { i } ^ { ( n u m ) } , x _ { i } ^ { ( c a t ) } ) \in \mathbb { X }$ )) ∈ X represents numerical x(nuij $x _ { i j } ^ { ( n u m ) }$ and categorical $x _ { i j } ^ { ( c a t ) }$ features of an object and $y _ { i } \in \mathbb { Y }$ denotes the corresponding object label. The total number of features is denoted as $k$ . The dataset is split into three disjoint subsets: $D = D _ { t r a i n } \cup D _ { v a l } \cup D _ { t e s t }$ , where $D _ { t r a i n }$ is used for training, $D _ { v a l }$ is used for early stopping and hyperparameter tuning, and $D _ { t e s t }$ is used for the final evaluation. We consider three types of tasks: binary classification $\mathbb { Y } = \{ 0 , 1 \}$ , multiclass classification $\mathbb { Y } = \{ 1 , \ . . . , C \}$ and regression $\mathbb { Y } = \mathbb { R }$ .
51
+
52
+ # 3.1 MLP
53
+
54
+ We formalize the “MLP” architecture in Equation 1.
55
+
56
+ $$
57
+ \begin{array} { c } { \mathtt { M L P } ( x ) = \mathtt { L i n e a r } \left( \mathtt { M L P B l o c k } \left( \dots \left( \mathtt { M L P B l o c k } ( x ) \right) \right) \right) } \\ { \mathtt { M L P B l o c k } ( x ) = \mathtt { D r o p o u t } \left( \mathtt { R e L U } \left( \mathtt { L i n e a r } ( x ) \right) \right) } \end{array}
58
+ $$
59
+
60
+ # 3.2 ResNet
61
+
62
+ We are aware of one attempt to design a ResNet-like baseline (Klambauer et al., 2017) where the reported results were not competitive. However, given ResNet’s success story in computer vision (He et al., 2015) and its recent achievements on NLP tasks (Sun and Iyyer, 2021), we give it a second try and construct a simple variation of ResNet as described in Equation 2. The main building block is simplified compared to the original architecture, and there is an almost clear path from the input to output which we find to be beneficial for the optimization. Overall, we expect this architecture to outperform MLP on tasks where deeper representations can be helpful.
63
+
64
+ ResNet $( x ) =$ Prediction (ResNetBlock (. . . (ResNetBlock (Linear(x))))) ResNetBlock(x) = x + Dropout(Linear(Dropout(ReLU(Linear(BatchNorm(x)))))) Prediction $( x ) =$ Linear (ReLU (BatchNorm (x)))
65
+
66
+ # 3.3 FT-Transformer
67
+
68
+ In this section, we introduce FT-Transformer (Feature Tokenizer $^ +$ Transformer) — a simple adaptation of the Transformer architecture (Vaswani et al., 2017) for the tabular domain. Figure 1 demonstrates the main parts of FT-Transformer. In a nutshell, our model transforms all features (categorical and numerical) to embeddings and applies a stack of Transformer layers to the embeddings. Thus, every Transformer layer operates on the feature level of one object. We compare FT-Transformer to conceptually similar AutoInt in section 5.2.
69
+
70
+ ![](images/df9999ef23ac55d1399747a5900f3eac717d0c6a4d8ac680caf051f5bf2bddda.jpg)
71
+ Figure 1: The FT-Transformer architecture. Firstly, Feature Tokenizer transforms features to embeddings. The embeddings are then processed by the Transformer module and the final representation of the [CLS] token is used for prediction.
72
+
73
+ ![](images/a59f8fc74fd228878c534e25ebbe4e2ef3f34dca0d1a9f7e4aafb3653f67b0ac.jpg)
74
+ Figure 2: (a) Feature Tokenizer; in the example, there are three numerical and two categorical features; (b) One Transformer layer.
75
+
76
+ Feature Tokenizer. The Feature Tokenizer module (see Figure 2) transforms the input features $x$ to embeddings $T \in \mathbb { R } ^ { k \times d }$ . The embedding for a given feature $x _ { j }$ is computed as follows:
77
+
78
+ $$
79
+ T _ { j } = b _ { j } + f _ { j } ( x _ { j } ) \in \mathbb { R } ^ { d } \qquad f _ { j } : \mathbb { X } _ { j } \to \mathbb { R } ^ { d } .
80
+ $$
81
+
82
+ where $b _ { j }$ is the $j$ -th feature bias, $f _ { j } ^ { ( n u m ) }$ is implemented as the element-wise multiplication with the vector $W _ { j _ { \lambda } } ^ { ( n u m ) } \in \mathbb { R } ^ { d }$ and $f _ { j } ^ { ( c a t ) }$ is implemented as the lookup table $W _ { j } ^ { ( c a t ) } \in \mathbb { R } ^ { S _ { j } \times d }$ for categorical features. Overall:
83
+
84
+ $$
85
+ \begin{array} { r l r } & { T _ { j } ^ { ( n u m ) } = b _ { j } ^ { ( n u m ) } + x _ { j } ^ { ( n u m ) } \cdot W _ { j } ^ { ( n u m ) } } & { \in \mathbb { R } ^ { d } , } \\ & { T _ { j } ^ { ( c a t ) } = b _ { j } ^ { ( c a t ) } + e _ { j } ^ { T } W _ { j } ^ { ( c a t ) } } & { \in \mathbb { R } ^ { d } , } \\ & { T = \mathsf { s t a c k } \left[ T _ { 1 } ^ { ( n u m ) } , \ldots , T _ { k ^ { ( n u m ) } } ^ { ( n u m ) } , T _ { 1 } ^ { ( c a t ) } , \ldots , T _ { k ^ { ( c a t ) } } ^ { ( c a t ) } \right] \in \mathbb { R } ^ { k \times d } . } \end{array}
86
+ $$
87
+
88
+ where $e _ { j } ^ { T }$ is a one-hot vector for the corresponding categorical feature.
89
+
90
+ Transformer. At this stage, the embedding of the [CLS] token (or “classification token”, or “output token”, see Devlin et al. (2019)) is appended to $T$ and $L$ Transformer layers $F _ { 1 }$ , . . . , $F _ { L }$ are applied:
91
+
92
+ $$
93
+ T _ { 0 } = { \tt s t a c k } \left[ \left[ { \tt C L S } \right] , T \right] \qquad T _ { i } = F _ { i } ( T _ { i - 1 } ) .
94
+ $$
95
+
96
+ We use the PreNorm variant for easier optimization (Wang et al., 2019b), see Figure 2. In the PreNorm setting, we also found it to be necessary to remove the first normalization from the first Transformer layer to achieve good performance. See the original paper (Vaswani et al., 2017) for the background on Multi-Head Self-Attention (MHSA) and the Feed Forward module. See supplementary for details such as activations, placement of normalizations and dropout modules (Srivastava et al., 2014).
97
+
98
+ Prediction. The final representation of the [CLS] token is used for prediction:
99
+
100
+ $$
101
+ \begin{array} { r } { \hat { y } = \mathtt { L i n e a r } \big ( \mathtt { R e L U } \big ( \mathtt { L a y e r N o r m } ( T _ { L } ^ { \mathtt { L C L S } } ) \big ) \big ) . } \end{array}
102
+ $$
103
+
104
+ Limitations. FT-Transformer requires more resources (both hardware and time) for training than simple models such as ResNet and may not be easily scaled to datasets when the number of features is “too large” (it is determined by the available hardware and time budget). Consequently, widespread usage of FT-Transformer for solving tabular data problems can lead to greater CO2 emissions produced by ML pipelines, since tabular data problems are ubiquitous. The main cause of the described problem lies in the quadratic complexity of the vanilla MHSA with respect to the number of features. However, the issue can be alleviated by using efficient approximations of MHSA (Tay et al., 2020). Additionally, it is still possible to distill FT-Transformer into simpler architectures for better inference performance. We report training times and the used hardware in supplementary.
105
+
106
+ # 3.4 Other models
107
+
108
+ In this section, we list the existing models designed specifically for tabular data that we include in the comparison.
109
+
110
+ • SNN (Klambauer et al., 2017). An MLP-like architecture with the SELU activation that enables training deeper models.
111
+ • NODE (Popov et al., 2020). A differentiable ensemble of oblivious decision trees.
112
+ • TabNet (Arik and Pfister, 2020). A recurrent architecture that alternates dynamical reweighing of features and conventional feed-forward modules. GrowNet (Badirli et al., 2020). Gradient boosted weak MLPs. The official implementation supports only classification and regression problems. DCN V2 (Wang et al., 2020). Consists of an MLP-like module and the feature crossing module (a combination of linear layers and multiplications).
113
+ • AutoInt (Song et al., 2019). Transforms features to embeddings and applies a series of attention-based transformations to the embeddings.
114
+ • XGBoost (Chen and Guestrin, 2016). One of the most popular GBDT implementations.
115
+ • CatBoost (Prokhorenkova et al., 2018). GBDT implementation that uses oblivious decision trees (Lou and Obukhov, 2017) as weak learners.
116
+
117
+ # 4 Experiments
118
+
119
+ In this section, we compare DL models to each other as well as to GBDT. Note that in the main text, we report only the key results. In supplementary, we provide: (1) the results for all models on all datasets; (2) information on hardware; (3) training times for ResNet and FT-Transformer.
120
+
121
+ # 4.1 Scope of the comparison
122
+
123
+ In our work, we focus on the relative performance of different architectures and do not employ various model-agnostic DL practices, such as pretraining, additional loss functions, data augmentation, distillation, learning rate warmup, learning rate decay and many others. While these practices can potentially improve the performance, our goal is to evaluate the impact of inductive biases imposed by the different model architectures.
124
+
125
+ # 4.2 Datasets
126
+
127
+ We use a diverse set of eleven public datasets (see supplementary for the detailed description). For each dataset, there is exactly one train-validation-test split, so all algorithms use the same splits. The datasets include: California Housing (CA, real estate data, Kelley Pace and Barry (1997)), Adult (AD, income estimation, Kohavi (1996)), Helena (HE, anonymized dataset, Guyon et al. (2019)),
128
+
129
+ Jannis (JA, anonymized dataset, Guyon et al. (2019)), Higgs (HI, simulated physical particles, Baldi et al. (2014); we use the version with 98K samples available at the OpenML repository (Vanschoren et al., 2014)), ALOI (AL, images, Geusebroek et al. (2005)), Epsilon (EP, simulated physics experiments), Year (YE, audio features, Bertin-Mahieux et al. (2011)), Covertype (CO, forest characteristics, Blackard and Dean. (2000)), Yahoo (YA, search queries, Chapelle and Chang (2011)), Microsoft (MI, search queries, Qin and Liu (2013)). We follow the pointwise approach to learning-to-rank and treat ranking problems (Microsoft, Yahoo) as regression problems. The dataset properties are summarized in Table 1.
130
+
131
+ Table 1: Dataset properties. Notation: “RMSE” $\sim$ root-mean-square error, “Acc.” $\sim$ accuracy.
132
+
133
+ <table><tr><td></td><td>CA</td><td>AD</td><td>HE</td><td>JA</td><td>HI</td><td>AL</td><td>EP</td><td>YE</td><td>Co</td><td>YA</td><td>MI</td></tr><tr><td>#objects</td><td>20640</td><td>48842</td><td>65196</td><td>83733</td><td>98050</td><td>108000</td><td>500000</td><td>515345</td><td>581012</td><td>709877</td><td>1200192</td></tr><tr><td>#num. features #cat. features</td><td>8</td><td>6</td><td>27</td><td>54</td><td>28</td><td>128</td><td>2000</td><td>90</td><td>54</td><td>699</td><td>136</td></tr><tr><td>metric</td><td>0</td><td>8</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td></td><td>RMSE</td><td>Acc.</td><td>Acc.</td><td>Acc.</td><td>Acc.</td><td>Acc.</td><td>Acc.</td><td>RMSE</td><td>Acc.</td><td>RMSE</td><td>RMSE</td></tr><tr><td>#classes</td><td>1</td><td>2</td><td>100</td><td>4</td><td>2</td><td>1000</td><td>2</td><td>1</td><td>7</td><td>1</td><td>1</td></tr></table>
134
+
135
+ # 4.3 Implementation details
136
+
137
+ Data preprocessing. Data preprocessing is known to be vital for DL models. For each dataset, the same preprocessing was used for all deep models for a fair comparison. By default, we used the quantile transformation from the Scikit-learn library (Pedregosa et al., 2011). We apply standardization (mean subtraction and scaling) to Helena and ALOI. The latter one represents image data, and standardization is a common practice in computer vision. On the Epsilon dataset, we observed preprocessing to be detrimental to deep models’ performance, so we use the raw features on this dataset. We apply standardization to regression targets for all algorithms.
138
+
139
+ Tuning. For every dataset, we carefully tune each model’s hyperparameters. The best hyperparameters are the ones that perform best on the validation set, so the test set is never used for tuning. For most algorithms, we use the Optuna library (Akiba et al., 2019) to run Bayesian optimization (the Tree-Structured Parzen Estimator algorithm), which is reported to be superior to random search (Turner et al., 2021). For the rest, we iterate over predefined sets of configurations recommended by corresponding papers. We provide parameter spaces and grids in supplementary. We set the budget for Optuna-based tuning in terms of iterations and provide additional analysis on setting the budget in terms of time in supplementary.
140
+
141
+ Evaluation. For each tuned configuration, we run 15 experiments with different random seeds and report the performance on the test set. For some algorithms, we also report the performance of default configurations without hyperparameter tuning.
142
+
143
+ Ensembles. For each model, on each dataset, we obtain three ensembles by splitting the 15 single models into three disjoint groups of equal size and averaging predictions of single models within each group.
144
+
145
+ Neural networks. We minimize cross-entropy for classification problems and mean squared error for regression problems. For TabNet and GrowNet, we follow the original implementations and use the Adam optimizer (Kingma and Ba, 2017). For all other algorithms, we use the AdamW optimizer (Loshchilov and Hutter, 2019). We do not apply learning rate schedules. For each dataset, we use a predefined batch size for all algorithms unless special instructions on batch sizes are given in the corresponding papers (see supplementary). We continue training until there are patience $+ 1$ consecutive epochs without improvements on the validation set; we set patience $= 1 6$ for all algorithms.
146
+
147
+ Categorical features. For XGBoost, we use one-hot encoding. For CatBoost, we employ the built-in support for categorical features. For Neural Networks, we use embeddings of the same dimensionality for all categorical features.
148
+
149
+ Table 2: Results for DL models. The metric values averaged over 15 random seeds are reported. See supplementary for standard deviations. For each dataset, top results are in bold. “Top” means “the gap between this result and the result with the best score is not statistically significant”. For each dataset, ranks are calculated by sorting the reported scores; the “rank” column reports the average rank across all datasets. Notation: FT-T \~ FT-Transformer, $\downarrow \sim \mathrm { R M S E }$ , $\uparrow$ \~ accuracy
150
+
151
+ <table><tr><td></td><td>CA↓</td><td>AD↑</td><td>HE↑</td><td>JA↑</td><td>HI↑</td><td>AL↑</td><td>EP↑</td><td>YE↓</td><td>CO↑</td><td>YA↓</td><td>MI↓</td><td>rank (std)</td></tr><tr><td>TabNet</td><td>0.510</td><td>0.850</td><td>0.378</td><td>0.723</td><td>0.719</td><td>0.954</td><td>0.8896</td><td>8.909</td><td>0.957</td><td>0.823</td><td>0.751</td><td>7.5 (2.0)</td></tr><tr><td>SNN</td><td>0.493</td><td>0.854</td><td>0.373</td><td>0.719</td><td>0.722</td><td>0.954</td><td>0.8975</td><td>8.895</td><td>0.961</td><td>0.761</td><td>0.751</td><td>6.4 (1.4)</td></tr><tr><td>AutoInt</td><td>0.474</td><td>0.859</td><td>0.372</td><td>0.721</td><td>0.725</td><td>0.945</td><td>0.8949</td><td>8.882</td><td>0.934</td><td>0.768</td><td>0.750</td><td>5.7 (2.3)</td></tr><tr><td>GrowNet</td><td>0.487</td><td>0.857</td><td></td><td></td><td>0.722</td><td>1</td><td>0.8970</td><td>8.827</td><td>1</td><td>0.765</td><td>0.751</td><td>5.7 (2.2)</td></tr><tr><td>MLP</td><td>0.499</td><td>0.852</td><td>0.383</td><td>0.719</td><td>0.723</td><td>0.954</td><td>0.8977</td><td>8.853</td><td>0.962</td><td>0.757</td><td>0.747</td><td>4.8 (1.9)</td></tr><tr><td>DCN2</td><td>0.484</td><td>0.853</td><td>0.385</td><td>0.716</td><td>0.723</td><td>0.955</td><td>0.8977</td><td>8.890</td><td>0.965</td><td>0.757</td><td>0.749</td><td>4.7 (2.0)</td></tr><tr><td>NODE</td><td>0.464</td><td>0.858</td><td>0.359</td><td>0.727</td><td>0.726</td><td>0.918</td><td>0.8958</td><td>8.784</td><td>0.958</td><td>0.753</td><td>0.745</td><td>3.9 (2.8)</td></tr><tr><td>ResNet</td><td>0.486</td><td>0.854</td><td>0.396</td><td>0.728</td><td>0.727</td><td>0.963</td><td>0.8969</td><td>8.846</td><td>0.964</td><td>0.757</td><td>0.748</td><td>3.3 (1.8)</td></tr><tr><td>FT-T</td><td></td><td>0.459 0.859</td><td>0.391</td><td>0.732</td><td>0.729</td><td>0.960</td><td>0.8982</td><td>8.855</td><td>0.970</td><td>0.756</td><td>0.746</td><td>1.8 (1.2)</td></tr></table>
152
+
153
+ # 4.4 Comparing DL models
154
+
155
+ Table 2 reports the results for deep architectures.
156
+
157
+ # The main takeaways:
158
+
159
+ • MLP is still a good sanity check
160
+ • ResNet turns out to be an effective baseline that none of the competitors can consistently outperform.
161
+ • FT-Transformer performs best on most tasks and becomes a new powerful solution for the field.
162
+ • Tuning makes simple models such as MLP and ResNet competitive, so we recommend tuning baselines when possible. Luckily, today, it is more approachable with libraries such as Optuna (Akiba et al., 2019).
163
+
164
+ Among other models, NODE (Popov et al., 2020) is the only one that demonstrates high performance on several tasks. However, it is still inferior to ResNet on six datasets (Helena, Jannis, Higgs, ALOI, Epsilon, Covertype), while being a more complex solution. Moreover, it is not a truly “single” model; in fact, it often contains significantly more parameters than ResNet and FT-Transformer and has an ensemble-like structure. We illustrate that by comparing ensembles in Table 3. The results indicate that FT-Transformer and ResNet benefit more from ensembling; in this regime, FT-Transformer outperforms NODE and the gap between ResNet and NODE is significantly reduced. Nevertheless, NODE remains a prominent solution among tree-based approaches.
165
+
166
+ Table 3: Results for ensembles of DL models with the highest ranks (see Table 2). For each model-dataset pair, the metric value averaged over three ensembles is reported. See supplementary for standard deviations. Depending on the dataset, the highest accuracy or the lowest RMSE is in bold. Due to the limited precision, some different values are represented with the same figures. Notation: $\downarrow \sim \mathrm { R M S E }$ , $\uparrow$ \~ accuracy.
167
+
168
+ <table><tr><td></td><td>CA↓</td><td>AD↑</td><td>HE↑</td><td>JA↑</td><td>HI↑</td><td>AL↑</td><td>EP↑</td><td>YE↓</td><td>CO→</td><td>YA↓</td><td>MI↓</td></tr><tr><td>NODE</td><td>0.461</td><td>0.860</td><td>0.361</td><td>0.730</td><td>0.727</td><td>0.921</td><td>0.8970</td><td>8.716</td><td>0.965</td><td>0.750</td><td>0.744</td></tr><tr><td>ResNet</td><td>0.478</td><td>0.857</td><td>0.398</td><td>0.734</td><td>0.731</td><td>0.966</td><td>0.8976</td><td>8.770</td><td>0.967</td><td>0.751</td><td>0.745</td></tr><tr><td>FT-Transformer</td><td>0.448</td><td>0.860</td><td>0.398</td><td>0.739</td><td>0.731</td><td>0.967</td><td>0.8984</td><td>8.751</td><td>0.973</td><td>0.747</td><td>0.743</td></tr></table>
169
+
170
+ # 4.5 Comparing DL models and GBDT
171
+
172
+ In this section, our goal is to check whether DL models are conceptually ready to outperform GBDT. To this end, we compare the best possible metric values that one can achieve using GBDT or DL models, without taking speed and hardware requirements into account (undoubtedly, GBDT is a more lightweight solution). We accomplish that by comparing ensembles instead of single models since
173
+
174
+ GBDT is essentially an ensembling technique and we expect that deep architectures will benefit more from ensembling (Fort et al., 2020). We report the results in Table 4.
175
+
176
+ Table 4: Results for ensembles of GBDT and the main DL models. For each model-dataset pair, the metric value averaged over three ensembles is reported. See supplementary for standard deviations. Notation follows Table 3.
177
+
178
+ <table><tr><td></td><td>CA←</td><td>AD个</td><td>HE↑</td><td>JA↑</td><td>HI↑</td><td>AL↑</td><td>EP个</td><td>YE↓</td><td>CO ↑</td><td>YA↓</td><td>MI↓</td></tr><tr><td colspan="10">Default hyperparameters</td></tr><tr><td>XGBoost</td><td>0.462 0.874 0.348</td><td></td><td></td><td>0.711</td><td>0.717</td><td>0.924</td><td>0.8799</td><td>9.192</td><td>0.964 0.761</td><td></td><td>0.751</td></tr><tr><td>CatBoost</td><td>0.428 0.873</td><td></td><td>0.386</td><td>0.724</td><td>0.728</td><td>0.948</td><td>0.8893</td><td>8.885</td><td>0.910</td><td>0.749</td><td>0.744</td></tr><tr><td>FT-Transformer 0.454</td><td></td><td>0.860</td><td>0.395</td><td>0.734</td><td>0.731</td><td></td><td>0.966 0.8969 8.727 0.973</td><td></td><td></td><td></td><td>0.747 0.742</td></tr><tr><td colspan="10">Tuned hyperparameters</td></tr><tr><td>XGBoost</td><td>0.431</td><td>0.872</td><td>0.377</td><td>0.724</td><td>0.728</td><td>一</td><td>0.8861</td><td>8.819</td><td>0.969</td><td>0.732</td><td>0.742</td></tr><tr><td>CatBoost</td><td>0.423 0.874</td><td></td><td>0.388</td><td>0.727</td><td>0.729</td><td></td><td>0.8898</td><td>8.837</td><td>0.968</td><td>0.740</td><td>0.741</td></tr><tr><td>ResNet</td><td>0.478</td><td>0.857</td><td>0.398</td><td>0.734</td><td>0.731</td><td>0.966</td><td>0.8976</td><td>8.770</td><td>0.967</td><td>0.751</td><td>0.745</td></tr><tr><td>FT-Transformer</td><td>0.448</td><td>0.860</td><td>0.398</td><td>0.739</td><td>0.731</td><td>0.967</td><td>0.8984</td><td>8.751</td><td>0.973</td><td>0.747</td><td>0.743</td></tr></table>
179
+
180
+ Default hyperparameters. We start with the default configurations to check the “out-of-the-box” performance, which is an important practical scenario. The default FT-Transformer implies a configuration with all hyperparameters set to some specific values that we provide in supplementary. Table 4 demonstrates that the ensemble of FT-Transformers mostly outperforms the ensembles of GBDT, which is not the case for only two datasets (California Housing, Adult). Interestingly, the ensemble of default FT-Transformers performs quite on par with the ensembles of tuned FT-Transformers.
181
+
182
+ The main takeaway: FT-Transformer allows building powerful ensembles out of the box.
183
+
184
+ Tuned hyperparameters. Once hyperparameters are properly tuned, GBDTs start dominating on some datasets (California Housing, Adult, Yahoo; see Table 4). In those cases, the gaps are significant enough to conclude that DL models do not universally outperform GBDT. Importantly, the fact that DL models outperform GBDT on most of the tasks does not mean that DL solutions are “better” in any sense. In fact, it only means that the constructed benchmark is slightly biased towards “DL-friendly” problems. Admittedly, GBDT remains an unsuitable solution to multiclass problems with a large number of classes. Depending on the number of classes, GBDT can demonstrate unsatisfactory performance (Helena) or even be untunable due to extremely slow training (ALOI).
185
+
186
+ # The main takeaways:
187
+
188
+ • there is still no universal solution among DL models and GBDT
189
+ • DL research efforts aimed at surpassing GBDT should focus on datasets where GBDT outperforms state-of-the-art DL solutions. Note that including “DL-friendly” problems is still important to avoid degradation on such problems.
190
+
191
+ # 4.6 An intriguing property of FT-Transformer
192
+
193
+ Table 4 tells one more important story. Namely, FT-Transformer delivers most of its advantage over the “conventional” DL model in the form of ResNet exactly on those problems where GBDT is superior to ResNet (California Housing, Adult, Covertype, Yahoo, Microsoft) while performing on par with ResNet on the remaining problems. In other words, FT-Transformer provides competitive performance on all tasks, while GBDT and ResNet perform well only on some subsets of the tasks. This observation may be the evidence that FT-Transformer is a more “universal” model for tabular data problems. We develop this intuition further in section 5.1. Note that the described phenomenon is not related to ensembling and is observed for single models too (see supplementary).
194
+
195
+ # 5 Analysis
196
+
197
+ # 5.1 When FT-Transformer is better than ResNet?
198
+
199
+ In this section, we make the first step towards understanding the difference in behavior between FT-Transformer and ResNet, which was first observed in section 4.6. To achieve that, we design a sequence of synthetic tasks where the difference in performance of the two models gradually changes from negligible to dramatic. Namely, we generate and $\mathit { \Omega } \mathcal { f } x$ objects $\{ x _ { i } \} _ { i = 1 } ^ { n }$ , perform the train-val-test split once and interpolate between two regression targets: $f _ { G B D T }$ , which is supposed to be easier for GBDT and $f _ { D L }$ , which is expected to be easier for ResNet. Formally, for one object:
200
+
201
+ $$
202
+ x \sim \mathcal { N } ( 0 , I _ { k } ) , \qquad y = \alpha \cdot f _ { G B D T } ( x ) + ( 1 - \alpha ) \cdot f _ { D L } ( x ) .
203
+ $$
204
+
205
+ where $f _ { G B D T } ( x )$ is an average prediction of 30 randomly constructed decision trees, and $f _ { D L } ( x )$ is an MLP with three randomly initialized hidden layers. Both $f _ { G B D T }$ and $f _ { D L }$ are generated once, i.e. the same functions are applied to all objects (see supplementary for details). The resulting targets are standardized before training. The results are visualized in Figure 3. ResNet and FT-Transformer perform similarly well on the ResNet-friendly tasks and outperform CatBoost on those tasks. However, the ResNet’s relative performance drops significantly when the target becomes more GBDT friendly. By contrast, FT-Transformer yields competitive performance across the whole range of tasks.
206
+
207
+ The conducted experiment reveals a type of functions that are better approximated by FT-Transformer than by ResNet. Additionally,
208
+
209
+ ![](images/5b076169d8fc7cd8436cac63dd25ffd01fe43409ea925556c824fbd55e8c9eba.jpg)
210
+ Figure 3: Test RMSE averaged over five seeds (shadows represent std. dev.). One $\alpha$ corresponds to one task; each task has the same set of train, validation and test features, but different targets.
211
+
212
+ the fact that these functions are based on decision trees correlates with the observations in section 4.6 and the results in Table 4, where FT-Transformer shows the most convincing improvements over ResNet exactly on those datasets where GBDT outperforms ResNet.
213
+
214
+ # 5.2 Ablation study
215
+
216
+ In this section, we test some design choices of FT-Transformer.
217
+
218
+ First, we compare FT-Transformer with AutoInt (Song et al., 2019), since it is the closest competitor in its spirit. AutoInt also converts all features to embeddings and applies self-attention on top of them. However, in its details, AutoInt significantly differs from FT-Transformer: its embedding layer does not include feature biases, its backbone significantly differs from the vanilla Transformer (Vaswani et al., 2017), and the inference mechanism does not use the [CLS] token.
219
+
220
+ Second, we check whether feature biases in Feature Tokenizer are essential for good performance.
221
+
222
+ We tune and evaluate FT-Transformer without feature biases following the same protocol as in section 4.3 and reuse the remaining numbers from Table 2. The results averaged over 15 runs are reported in Table 5 and demonstrate both the superiority of the Transformer’s backbone to that of AutoInt and the necessity of feature biases.
223
+
224
+ Table 5: The results of the comparison between FT-Transformer and two attention-based alternatives: AutoInt and FT-Transformer without feature biases. Notation follows Table 2.
225
+
226
+ <table><tr><td></td><td>CA↓</td><td>HE↑</td><td>JA↑</td><td>HI↑</td><td>AL↑</td><td>YE↓</td><td>Co↑</td><td>MI↓</td></tr><tr><td>AutoInt</td><td>0.474</td><td>0.372</td><td>0.721</td><td>0.725</td><td>0.945</td><td>8.882</td><td>0.934</td><td>0.750</td></tr><tr><td>FT-Transformer (w/o feature biases)</td><td>0.470</td><td>0.381</td><td>0.724</td><td>0.727</td><td>0.958</td><td>8.843</td><td>0.964</td><td>0.751</td></tr><tr><td>FT-Transformer</td><td>0.459</td><td>0.391</td><td>0.732</td><td>0.729</td><td>0.960</td><td>8.855</td><td>0.970</td><td>0.746</td></tr></table>
227
+
228
+ # 5.3 Obtaining feature importances from attention maps
229
+
230
+ In this section, we evaluate attention maps as a source of information on feature importances for FT-Transformer for a given set of samples. For the $i$ -th sample, we calculate the average attention map $p _ { i }$ for the [CLS] token from Transformer’s forward pass. Then, the obtained individual distributions are averaged into one distribution $p$ that represents the feature importances:
231
+
232
+ $$
233
+ p = \frac { 1 } { n _ { s a m p l e s } } \sum _ { i } p _ { i } \qquad p _ { i } = \frac { 1 } { n _ { h e a d s } \times L } \sum _ { h , l } p _ { i h l } .
234
+ $$
235
+
236
+ where $p _ { i h l }$ is the $h$ -th head’s attention map for the [CLS] token from the forward pass of the $l$ -th layer on the $i$ -th sample. The main advantage of the described heuristic technique is its efficiency: it requires a single forward for one sample.
237
+
238
+ In order to evaluate our approach, we compare it with Integrated Gradients (IG, Sundararajan et al. (2017)), a general technique applicable to any differentiable model. We use permutation test (PT, Breiman (2001)) as a reasonable interpretable method that allows us to establish a constructive metric, namely, rank correlation. We run all the methods on the train set and summarize results in Table 6. Interestingly, the proposed method yields reasonable feature importances and performs similarly to IG (note that this does not imply similarity to IG’s feature importances). Given that IG can be orders of magnitude slower and the “baseline” in the form of PT requires $( n _ { f e a t u r e s } + 1 )$ forward passes (versus one for the proposed method), we conclude that the simple averaging of attention maps can be a good choice in terms of cost-effectiveness.
239
+
240
+ Table 6: Rank correlation (takes values in $[ - 1 , \ 1 ] ,$ ) between permutation test’s feature importances ranking and two alternative rankings: Attention Maps (AM) and Integrated Gradients (IG). Means and standard deviations over five runs are reported.
241
+
242
+ <table><tr><td>CA</td><td></td><td>HE</td><td>JA</td><td>HI</td><td>AL</td><td>YE</td><td>Co</td><td>MI</td></tr><tr><td>AM 0.81 (0.05)</td><td></td><td>0.77 (0.03)</td><td>0.78 (0.05)</td><td>0.91 (0.03)</td><td>0.84 (0.01)</td><td>0.92 (0.01)</td><td>0.84 (0.04)</td><td>0.86 (0.02)</td></tr><tr><td>IG 0.84 (0.08)</td><td></td><td>0.74 (0.03)</td><td>0.75 (0.04)</td><td>0.72 (0.03)</td><td>0.89 (0.01)</td><td>0.50 (0.03)</td><td>0.90 (0.02)</td><td>0.56 (0.02)</td></tr></table>
243
+
244
+ # 6 Conclusion
245
+
246
+ In this work, we have investigated the status quo in the field of deep learning for tabular data and improved the state of baselines in tabular DL. First, we have demonstrated that a simple ResNet-like architecture can serve as an effective baseline. Second, we have proposed FT-Transformer — a simple adaptation of the Transformer architecture that outperforms other DL solutions on most of the tasks. We have also compared the new baselines with GBDT and demonstrated that GBDT still dominates on some tasks. The code and all the details of the study are open-sourced 1, and we hope that our evaluation and two simple models (ResNet and FT-Transformer) will serve as a basis for further developments on tabular DL.
247
+
248
+ # References
249
+
250
+ T. Akiba, S. Sano, T. Yanase, T. Ohta, and M. Koyama. Optuna: A next-generation hyperparameter optimization framework. In KDD, 2019.
251
+ S. O. Arik and T. Pfister. Tabnet: Attentive interpretable tabular learning. arXiv, 1908.07442v5, 2020.
252
+ S. Badirli, X. Liu, Z. Xing, A. Bhowmik, K. Doan, and S. S. Keerthi. Gradient boosting neural networks: Grownet. arXiv, 2002.07971v2, 2020.
253
+ P. Baldi, P. Sadowski, and D. Whiteson. Searching for exotic particles in high-energy physics with deep learning. Nature Communications, 5, 2014.
254
+ T. Bertin-Mahieux, D. P. Ellis, B. Whitman, and P. Lamere. The million song dataset. In Proceedings of the 12th International Conference on Music Information Retrieval (ISMIR 2011), 2011.
255
+ A. Beutel, P. Covington, S. Jain, C. Xu, J. Li, V. Gatto, and E. H. Chi. Latent cross: Making use of context in recurrent recommender systems. In WSDM 2018: The Eleventh ACM International Conference on Web Search and Data Mining, 2018.
256
+ J. A. Blackard and D. J. Dean. Comparative accuracies of artificial neural networks and discriminant analysis in predicting forest cover types from cartographic variables. Computers and Electronics in Agriculture, 24(3):131–151, 2000.
257
+ L. Breiman. Random forests. Machine Learning, 45(1):5–32, 2001.
258
+ O. Chapelle and Y. Chang. Yahoo! learning to rank challenge overview. In Proceedings of the Learning to Rank Challenge, volume 14, 2011.
259
+ T. Chen and C. Guestrin. Xgboost: A scalable tree boosting system. In SIGKDD, 2016.
260
+ J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, 2009.
261
+ J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv, 1810.04805v2, 2019.
262
+ 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 ICLR, 2021.
263
+ S. Fort, H. Hu, and B. Lakshminarayanan. Deep ensembles: A loss landscape perspective. arXiv, 1912.02757v2, 2020.
264
+ J. H. Friedman. Greedy function approximation: A gradient boosting machine. The Annals of Statistics, 29(5):1189–1232, 2001.
265
+ J. M. Geusebroek, G. J. Burghouts, , and A. W. M. Smeulders. The amsterdam library of object images. Int. J. Comput. Vision, 61(1):103–112, 2005.
266
+ I. Goodfellow, Y. Bengio, and A. Courville. Deep Learning. MIT Press, 2016. http://www. deeplearningbook.org.
267
+ I. Guyon, L. Sun-Hosoya, M. Boullé, H. J. Escalante, S. Escalera, Z. Liu, D. Jajetic, B. Ray, M. Saeed, M. Sebag, A. Statnikov, W. Tu, and E. Viegas. Analysis of the automl challenge series 2015-2018. In AutoML, Springer series on Challenges in Machine Learning, 2019.
268
+ H. Hazimeh, N. Ponomareva, P. Mol, Z. Tan, and R. Mazumder. The tree ensemble layer: Differentiability meets conditional computation. In ICML, 2020.
269
+ K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. arXiv, 1512.03385v1, 2015.
270
+ X. Huang, A. Khetan, M. Cvitkovic, and Z. Karnin. Tabtransformer: Tabular data modeling using contextual embeddings. arXiv, 2012.06678v1, 2020.
271
+ G. Ke, Q. Meng, T. Finley, T. Wang, W. Chen, W. Ma, Q. Ye, and T.-Y. Liu. Lightgbm: A highly efficient gradient boosting decision tree. Advances in neural information processing systems, 30: 3146–3154, 2017.
272
+ R. Kelley Pace and R. Barry. Sparse spatial autoregressions. Statistics & Probability Letters, 33(3): 291–297, 1997.
273
+ D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. arXiv, 1412.6980v9, 2017.
274
+ G. Klambauer, T. Unterthiner, A. Mayr, and S. Hochreiter. Self-normalizing neural networks. In NIPS, 2017.
275
+
276
+ R. Kohavi. Scaling up the accuracy of naive-bayes classifiers: a decision-tree hybrid. In KDD, 1996.
277
+
278
+ P. Kontschieder, M. Fiterau, A. Criminisi, and S. Rota Bulo. Deep neural decision forests. In Proceedings of the IEEE international conference on computer vision, 2015.
279
+
280
+ I. Loshchilov and F. Hutter. Decoupled weight decay regularization. In ICLR, 2019.
281
+
282
+ Y. Lou and M. Obukhov. Bdt: Gradient boosted decision tables for high accuracy and scoring efficiency. In Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2017.
283
+
284
+ F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12:2825–2830, 2011.
285
+
286
+ S. Popov, S. Morozov, and A. Babenko. Neural oblivious decision ensembles for deep learning on tabular data. In ICLR, 2020.
287
+
288
+ L. Prokhorenkova, G. Gusev, A. Vorobev, A. V. Dorogush, and A. Gulin. Catboost: unbiased boosting with categorical features. In NeurIPS, 2018.
289
+
290
+ T. Qin and T. Liu. Introducing LETOR 4.0 datasets. arXiv, 1306.2597v1, 2013.
291
+
292
+ Z. Qin, L. Yan, H. Zhuang, Y. Tay, R. K. Pasumarthi, X. Wang, M. Bendersky, and M. Najork. Are neural rankers still outperformed by gradient boosted decision trees? In ICLR, 2021.
293
+
294
+ W. Song, C. Shi, Z. Xiao, Z. Duan, Y. Xu, M. Zhang, and J. Tang. Autoint: Automatic feature interaction learning via self-attentive neural networks. In CIKM, 2019.
295
+
296
+ 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.
297
+
298
+ S. Sun and M. Iyyer. Revisiting simple neural probabilistic language models. In NAACL, 2021.
299
+
300
+ M. Sundararajan, A. Taly, and Q. Yan. Axiomatic attribution for deep networks. In ICML, 2017.
301
+
302
+ Y. Tay, M. Dehghani, D. Bahri, and D. Metzler. Efficient transformers: A survey. arXiv, 2009.06732v1, 2020.
303
+
304
+ R. Turner, D. Eriksson, M. McCourt, J. Kiili, E. Laaksonen, Z. Xu, and I. Guyon. Bayesian optimization is superior to random search for machine learning hyperparameter tuning: Analysis of the black-box optimization challenge 2020. arXiv, https://arxiv.org/abs/2104.10201v1, 2021.
305
+
306
+ J. Vanschoren, J. N. van Rijn, B. Bischl, and L. Torgo. Openml: networked science in machine learning. arXiv, 1407.7722v1, 2014.
307
+
308
+ A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin. Attention is all you need. In NIPS, 2017.
309
+
310
+ A. Wang, A. Singh, J. Michael, F. Hill, O. Levy, and S. R. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In ICLR, 2019a.
311
+
312
+ Q. Wang, B. Li, T. Xiao, J. Zhu, C. Li, D. F. Wong, and L. S. Chao. Learning deep transformer models for machine translation. In ACL, 2019b.
313
+
314
+ R. Wang, B. Fu, G. Fu, and M. Wang. Deep & cross network for ad click predictions. In ADKDD, 2017.
315
+
316
+ R. Wang, R. Shivanna, D. Z. Cheng, S. Jain, D. Lin, L. Hong, and E. H. Chi. Dcn v2: Improved deep & cross network and practical lessons for web-scale learning to rank systems. arXiv, 2008.13535v2, 2020.
317
+
318
+ Y. Yang, I. G. Morillo, and T. M. Hospedales. Deep neural decision trees. arXiv, 1806.06988v1, 2018.
md/train/iklDP-v1sgi/iklDP-v1sgi.md ADDED
@@ -0,0 +1,596 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Meta Reinforcement Learning for Fast Adaptation of Hierarchical Policies
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Hierarchical methods have the potential to allow reinforcement learning to scale to
11
+ 2 larger environments. Decomposing a task into transferable components, however,
12
+ 3 remains a challenging problem. In this paper, we propose a meta-learning approach
13
+ 4 for learning such a decomposition within the options framework. We formulate
14
+ 5 the objective as a bi-level optimization problem in which sub-policies and their
15
+ 6 terminations should facilitate fast learning on a family of tasks. Once such a set
16
+ 7 of options is obtained, it can then be used in new tasks where only the sequencing
17
+ 8 of options needs to be chosen. Our formalism tends to result in options where
18
+ 9 fewer decisions are needed to solve such new tasks. Experimentally, we show that
19
+ 10 our method is able to learn transferable components which accelerate learning and
20
+ 11 performs better than existing methods developed for this setting in the challenging
21
+ 12 ant maze locomotion task.
22
+
23
+ # 13 1 Introduction
24
+
25
+ 14 Current state of the art model-free reinforcement learning methods were successfully applied to
26
+ 15 many challenging tasks [33, 41]. However, one of the main drawbacks of these methods is their
27
+ 16 data-inefficiency and inability to generalize to other related tasks [12]. It is often impossible to use
28
+ 17 the agent trained on one task to solve another related task [53] or even to use it as a starting point for
29
+ 18 training because trained models become increasingly exploitative and thus are unable to explore in a
30
+ 19 new task. In such cases, we have to gather new data and train a new model which is time-consuming.
31
+ 20 One way to mitigate this problem is by learning a policy with reusable modules which can be used in
32
+ 21 multiple tasks. For example, if we assume that related tasks contain shared sub-tasks (i.e. tasks come
33
+ 22 from the same family or have hierarchical structure), we can speed up the adaptation to new tasks by
34
+ 23 learning sub-policies that solve these sub-tasks. This is because solutions to new tasks can be created
35
+ 24 by combining known solutions to sub-tasks during adaptation. The idea of learning reusable skills in
36
+ 25 multiple environments, which dates back to at least 1995 [48], was thoroughly explored within the
37
+ 26 options framework [17, 24, 25, 29, 36, 46].
38
+ 27 In this framework, a policy is composed of options (modules that encapsulate sub-policies), and
39
+ 28 a high-level policy that chooses among them. Options have their own termination function, and a
40
+ 29 new option is only initiated when the earlier option terminates. Therefore, options define temporally
41
+ 30 extended behaviors that can form solutions to sub-tasks. Despite extensive research in this area, there
42
+ 31 is not yet a consensus on answers to many important questions about options: What are good options?
43
+ 32 How can we find them? When should a termination occur? How many options should one use? In
44
+ 33 this work our aim will be to find options that allow for fast adaptation to tasks from the same family.
45
+ 34 We use this single principle to address all of these questions except for the number of options which
46
+ 35 we consider a hyperparameter.
47
+ 36 Learning high-level policy, sub-policies and terminations at the same time is a challenging task.
48
+ 37 Recent prior work on options proposed a way to learn both, including the terminations, in an end
49
+ 38 to end manner with policy gradient methods [4, 44]. However, despite achieving good performance
50
+ 39 in single-task settings, these methods often produce options which may not be useful for transfer
51
+ 40 [21, 22]. This is because such options are not explicitly trained for multi-task setting and can often
52
+ 41 terminate too often or not at all [21, 22].
53
+ 42 To overcome this issue, Frans et al. [17] proposed to use such method in a multi-task setting with
54
+ 43 options that have predefined length and are optimized for performance after adaptation of the high
55
+ 44 level policy. Although options that terminate after certain amount of steps simplify the problem
56
+ 45 and work well in some settings [17, 25], manually setting this important hyperparameter requires
57
+ 46 prior knowledge and might not work in cases where options need to have different lengths [23]. For
58
+ 47 example, task where this approach would not be preferable could be driving because some driving
59
+ 48 sub-tasks, such as driving on a highway, are much longer than others, such as driving out from one
60
+ 49 intersection to another in a city. Consequently, capturing the length of both sub-tasks with a single
61
+ 50 hyperparameter [17] or range of hyperparameters [25] can become difficult or even impossible. In
62
+ 51 such cases, learned terminations are preferable.
63
+ 52 In this paper, we propose a method for learning options that allows for fast adaptation to multiple tasks.
64
+ 53 We formalize this notion using recent ideas from gradient based meta-learning [14]. Rather than using
65
+ 54 options with fixed length [17], our algorithm learns both sub-policies and when to terminate options
66
+ 55 using a single meta-learning objective. We hypothesize that this objective implicitly encourages
67
+ 56 options to terminate in a way that yields reusable components. In our experiments, we demonstrate
68
+ 57 the benefits of our approach in a simple Taxi domain as well as in a complex Mujoco [49] Ant Maze
69
+ 58 domain [17].
70
+
71
+ # 2 Related Work
72
+
73
+ Since our work builds on insights from both hierarchical reinforcement learning and meta-learning, we present related work in both domains separately, in subsections 2.1 and 2.2 respectively.
74
+
75
+ # 2.1 Hierarchical Reinforcement Learning
76
+
77
+ 63 One of the aims of hierarchical reinforcement learning is to decompose a complex task or policy into
78
+ 64 simpler units. Popular approaches include learning a diverse set of skills [11] or utilizing the idea of
79
+ 65 Feudal Reinforcement Learning [7, 34, 50]. Another large collection of related work instead relies on
80
+ 66 the options framework [46].
81
+ 67 Some works on options rely on so-called bottleneck states that can be used as sub-goals [30, 31, 35]
82
+ 68 whereas others use spectral clustering to create options [28]. These approaches usually require prior
83
+ 69 knowledge about the environment which restricts their applicability. Different from aforementioned
84
+ 70 methods, end-to-end methods such as the ones which rely on the Option-Critic architecture [4, 39] are
85
+ 71 applicable in more general settings. However, these policy gradient methods can be less efficient than
86
+ 72 concurrently introduced inference based end-to-end methods [6, 16, 44] because they only update the
87
+ 73 option that generated the action whereas inference based methods update options according to their
88
+ 74 responsibilities for each action.
89
+ 75 A common problem with end-to-end methods that learn terminations in a single-task setting is
90
+ 76 option collapse [4]. This causes options to terminate after every action or to never terminate. In
91
+ 77 such cases the learning of terminations can be facilitated by augmenting the objective with entropy
92
+ 78 regularization [44] or deliberation cost [21], regularizing towards a termination prior [23], or by
93
+ 79 optimizing different objective that encourages appropriate terminations [22]. As an alternative, one
94
+ 80 can also use time-based terminations with fixed [17] or randomized length [25].
95
+
96
+ # 2.2 Meta-Reinforcement Learning
97
+
98
+ 82 Meta-reinforcement learning is concerned with producing models which are able to adapt to novel
99
+ 83 tasks quickly. This sub-field includes a broad range of work such as unsupervised methods [11, 19],
100
+ 84 methods that rely on latent variables [20, 38] or methods that learn the update rule of a policy
101
+ 85 [10, 32, 51].
102
+ 86 In contrast with the latter, the recent gradient-based method Model-Agnostic Meta-Learning
103
+ 87 (MAML) [14] assumes that policy parameters are updated with gradient descent and instead aims to
104
+ 88 learn initial parameter values. MAML was extended in followup works that only trained a part of the
105
+ 89 network [37, 54] or showed benefits of different architectural choices such as per-parameter learning
106
+ 90 rates [3, 26]. Several works also focused on MAML in a reinforcement learning setting [2, 27, 45].
107
+ 91 In particular, Al-Shedivat et al. [2] and Stadie et al. [45] pointed out a difference between theory and
108
+ 92 practical implementation of MAML in automatic differentiation frameworks. This issue was further
109
+ 93 discussed and resolved in followup works [13, 15, 40].
110
+ 94 Lastly, there exist methods which do not employ the techniques mentioned above and instead rely
111
+ 95 on the options framework [5, 17, 23–25, 29, 36, 52] or task-specific policies [47]. These approaches
112
+ 96 often make different assumptions about the tasks and settings in which they are applied. Some require
113
+ 97 policies that solve each environment [36] whereas others need environment ID [23, 29] or cumulants
114
+ 98 that properly represents task dynamics [5]. Closest to our work are Meta Learning Shared Hierarchies
115
+ 99 (MLSH) [17] and Adaptive Skills Adaptive Partitions (ASAP) [29]. ASAP uses a policy gradient
116
+ 100 method to optimize immediate performance on multiple tasks with known environment ID but does
117
+ 101 not use neural networks and does not learn terminations. On the other hand, MLSH uses a hierarchical
118
+ 102 structure with predefined options length and a problem setting with unknown environment ID. It
119
+ 103 optimizes for post-adaptation performance by using two alternating phases that either only update
120
+ 104 high-level policy or both high-level policy and sub-policies simultaneously. This approach does not
121
+ 105 use the information from the intermediate adaptation steps when calculating the gradient which can
122
+ 106 negatively affect its accuracy. Additionally, options with fixed length may be difficult to use in some
123
+ 107 settings as we’ve described in Section 1.
124
+
125
+ # 108 3 Background and Notation
126
+
127
+ In this section, we will first cover the fundamentals of reinforcement learning, and then focus on the options framework and gradient-based meta-learning.
128
+
129
+ # 111 3.1 Reinforcement Learning and the Options Framework
130
+
131
+ 112 We will consider environments which are episodic Markov decision processes (MDPs). An MDP
132
+ 113 $\mathcal { M }$ is a tuple $\langle S , A , p _ { 0 } , P , R , \gamma \rangle$ with $S$ being a set of states, $A$ a set of actions, $p _ { 0 } ( s _ { 0 } )$ a probability
133
+ 114 distribution of initial states, $P ( \pmb { s } ^ { \prime } | \pmb { s } , \pmb { a } )$ a transition probability function, $R ( s , a )$ a reward function
134
+ 115 and $\gamma$ a discount factor.
135
+ 116 An agent with a stochastic policy $\pi$ interacts with an environment $\mathcal { M }$ in the following way. At
136
+ 117 every timestep $t$ , the agent receives a state of the environment $\textbf { \textit { s } } _ { t } ~ \in ~ \textbf { \textit { S } }$ and selects an action
137
+ 118 $\mathbf { \Sigma } _ { \mathbf { \Phi } _ { t } } ~ \in ~ \mathbf { \Sigma } _ { A }$ according to conditional distribution $\pi ( \mathbf { \boldsymbol { a } } _ { t } | \mathbf { \boldsymbol { s } } _ { t } )$ . Depending on the current state and the
138
+ 119 action performed, the environment provides the agent with a new state $s _ { t + 1 } \sim P ( s _ { t + 1 } | s _ { t } , \mathbf { a } _ { t } )$ and
139
+ 120 a scalar reward $r _ { t } = R ( s _ { t } , { \pmb a } _ { t } )$ . This process is repeated until a so-called terminal state is reached.
140
+ 121 We define a trajectory $\tau$ as an ordered sequence of all states actions and rewards in a single episode
141
+ 122 $\tau = ( s _ { 0 } , { \pmb a } _ { 0 } , r _ { 0 } , . . . , s _ { T } ) .$ . Similarly, the history at timestep $t$ consists of all states and actions preceding
142
+ 123 $\mathbf { } \mathbf { a } _ { t }$ , $\pmb { h } _ { t } = ( \pmb { s } _ { 0 } , \pmb { a } _ { 0 } , . . . , \pmb { s } _ { t } )$ . The state value function is defined as $V _ { \pi } ( \pmb { s } ) = \mathbb { E } _ { \pi } \left[ G _ { t } | \pmb { s } _ { t } = \pmb { s } \right]$ where the
143
+ 124 discounted return at timestep $t$ is defined as $\begin{array} { r } { G _ { t } ( \tau ) = \sum _ { t ^ { \prime } = t } ^ { T } \gamma ^ { ( t - t ^ { \prime } ) } r _ { t ^ { \prime } } } \end{array}$ .
144
+ 125 The agent’s objective is to maximize the expected discounted return $J ~ = ~ \mathbb { E } _ { p ( \tau \mid \theta ) } \left[ G _ { 0 } ( \tau ) \right]$ .
145
+ 126 127 $\begin{array} { r } { \nabla _ { \theta } J \approx \mathbb { E } _ { p ( \tau | \theta ) } [ \sum _ { t = 0 } ^ { T } \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { t } | \mathbf { s } _ { t } ) \mathbf { } \mathbf { } \mathbf { } A _ { t } ] } \end{array}$ gradient descent by estimating thusing Monte Carlo sampling, where $A _ { t }$ policy gradientis an advantage
146
+ 128 estimator such as the generalized advantage estimator $A _ { t } ^ { G A E }$ [42].
147
+ 129 The options framework is a framework for temporal abstraction that consists of options
148
+ 130 $\omega = \langle \bar { \mathcal { T } } ^ { \omega } , \pi ^ { \omega } , \xi ^ { \omega } \rangle$ and a policy over options $\pi ^ { \Omega } ( \omega | s )$ . Each option $\omega$ consists of an initiation set, a
149
+ 131 sub-policy and a termination function. The initiation set ${ \mathcal { T } } ^ { \omega }$ is a set of states in which an option can
150
+ 132 be selected (initiated) and in our case it is the whole state space $( \mathbb { Z } ^ { \omega } = S$ ). A sub-policy $\bar { { \boldsymbol { \pi } } } ^ { \omega } ( a | s )$ ,
151
+ 133 also called low-level policy, is a regular policy that acts in the environment. Lastly, the termination
152
+ 134 condition $\xi ^ { \omega } ( s )$ is a function that outputs the probability of termination for the option in a given state.
153
+ 136 Model-Agnostic Meta-Learning (MAML) [14] is a meta-learning technique that trains a model for
154
+ 137 maximum post-adaptation performance on a distribution of tasks. The adaptation consists of one or
155
+ 138 several inner gradient updates. If we consider an estimator $f _ { \theta }$ with parameters $\theta$ and a task-specific
156
+ 139 loss $\mathcal { L } _ { \mathcal { M } _ { i } }$ , a supervised learning objective with a single inner update can be formalized as shown in
157
+ 140 Equation 1. In order to optimize this objective one only needs to take a gradient of this expression.
158
+ 141 This can be easily achieved with automatic differentiation frameworks by creating a backpropagation
159
+ 142 graph for the gradient.
160
+
161
+ $$
162
+ \operatorname* { m i n } _ { \theta } \mathbb { E } _ { \mathcal { M } } \left[ \mathcal { L } _ { \mathcal { M } _ { i } } ( f _ { \theta ^ { \prime } } ) \right] = \operatorname* { m i n } _ { \theta } \sum _ { \mathcal { M } _ { i } \sim p ( \mathcal { M } ) } \mathcal { L } _ { \mathcal { M } _ { i } } ( f _ { \theta - \alpha \nabla _ { \theta } \mathcal { L } _ { \mathcal { M } _ { i } } ( f _ { \theta } ) } )
163
+ $$
164
+
165
+ 143 One can similarly use this approach with a reinforcement learning objective. However, the implemen
166
+ 144 tation with an automatic differentiation framework differs because a simple backpropagation through
167
+ 145 the computation graph of the gradient produces biased gradients [2, 45]. This is due to an additional
168
+ 146 dependency of the sampling distribution on parameters that is not present in the supervised learning
169
+ 147 objective. To produce correct higher order gradients with automatic differentiation frameworks in
170
+ 148 a reinforcement learning setting, one can use the objective in Equation 3 as proposed by Farquhar
171
+ 149 et al. [13]. This objective utilizes the DiCE operator $\boxdot$ [15] which can be implemented according
172
+ 150 to Equation 2 where $\bot ( x )$ is a stop gradient operator that evaluates to $x$ but returns a zero gradient
173
+ 151 when differentiated.
174
+
175
+ $$
176
+ \begin{array} { r } { \Xi ( \mathbf { a } _ { t } ) = \exp \left[ \log \pi _ { \theta } ( \mathbf { a } _ { t } | s _ { t } ) - \perp ( \log \pi _ { \theta } ( \mathbf { a } _ { t } | s _ { t } ) ) \right] , \quad \nabla _ { \theta } \mathbb { E } _ { \tau \sim p ( \tau | \theta ) } \left[ G _ { 0 } ^ { M _ { i } } ( \tau ) \right] \approx \nabla _ { \theta } J _ { \bigstar } \pi _ { \star } ( \tau ) . } \end{array}
177
+ $$
178
+
179
+ 152
180
+
181
+ $$
182
+ \nabla _ { \theta } J _ { \bigstar \bigstar } = \mathbb { E } _ { \tau \sim p ( \tau | \theta ) } \left[ \sum _ { t = 0 } ^ { T } \nabla _ { \theta } \bigg ( \prod _ { t ^ { \prime } = 0 } ^ { t } \Xi ( a _ { t ^ { \prime } } ) \lambda ^ { t - t ^ { \prime } } A _ { t } ^ { G A E } - \prod _ { t ^ { \prime } = 0 } ^ { t - 1 } \Xi ( a _ { t ^ { \prime } } ) \lambda ^ { t - t ^ { \prime } } A _ { t } ^ { G A E } \bigg ) \right] .
183
+ $$
184
+
185
+ # 153 4 Fast Adaptation of Modular Policies
186
+
187
+ 154 Much of the extensive research in the options framework has focused on an intuition of options
188
+ 155 capturing useful sub-tasks [4, 17, 36, 46]. However, there is no consensus about capturing this
189
+ 156 intuition in an objective function or the best way to find such options. We propose a conceptually
190
+ 157 simple objective: a good set of options allows quick adaptation to many novel tasks. This can
191
+ 158 be formulated using the MAML framework [14], where we consider a setting in which there is a
192
+ 159 distribution of tasks $p ( \mathcal { M } )$ with similar (hierarchical) structure but different reward or transition
193
+ 160 functions. Our goal is then to maximize the expected performance after $L$ adaptation steps of the
194
+ 161 hierarchical policy parametrized by $\theta$ :
195
+
196
+ $$
197
+ \operatorname* { m a x } _ { \theta } \sum _ { M _ { i } \sim p ( \mathcal { M } ) } \mathbb { E } _ { \tau ^ { L } \sim p ( \tau ^ { L } \mid \theta ^ { L } ) } \left[ G _ { 0 } ^ { M _ { i } } ( \tau ^ { L } ) \right] , \quad \theta ^ { j + 1 } = \theta ^ { j } + \alpha _ { i n } \nabla _ { \theta ^ { j } } \mathbb { E } _ { \tau ^ { j } \sim p ( \tau ^ { j } \mid \theta ^ { j } ) } \left[ G _ { 0 } ^ { M _ { i } } ( \tau ^ { j } ) \right] .
198
+ $$
199
+
200
+ 162 Using conventional MAML means adapting a large number of parameters which can be disadvanta
201
+ 163 geous, as was demonstrated by Zintgraf et al. [54] and Antoniou et al. [3]. By reducing the number of
202
+ 164 parameters that are tuned during the adaptation phase, one can reduce the complexity of the problem
203
+ 165 during test time at the cost of a less expressive policy. We thus split the parameters into an inner group
204
+ 166 $\theta _ { \mathrm { i n } }$ and an outer group $\theta _ { \mathrm { o u t } }$ where inner parameters are updated during the adaptation step and outer
205
+ 167 parameters are optimized in the outer objective. Note that when using such split, the initialization
206
+ 168 values of inner parameters may also be meta-learned [54]. We experimented with both versions and
207
+ 169 observed that fixed initialization values performed better. Similarly, the per-parameter inner learning
208
+ 170 rate $\alpha _ { i n }$ [3, 26] can also be meta-learned to allow for more complex inner updates. We used this
209
+ 171 approach in a setting with more complex environment.
210
+ 172 Our option model has three sets of parameters: those of the high-level policy network $\theta _ { \Omega }$ , sub-policy
211
+ 173 networks $\theta _ { \omega }$ and termination networks $\theta _ { \xi }$ . We now divide these over the inner and outer parameter
212
+ 174 group. Since we assume that tasks with common sub-problems can be solved using identical options,
213
+ 175 we consider the sub-policy and termination function parameters as outer parameters. On the other
214
+ 176 hand, since in each task the decision of the high-level policy to choose options would be different,
215
+ 177 its parameters constitute the inner group. By keeping sub-policies fixed during the adaptation and
216
+
217
+ initialize θΩ, θξ , θω , αin , αout
218
+ set $\theta _ { i n } = \theta _ { \Omega }$
219
+ set $\theta _ { o u t } = \{ \theta _ { \xi } , \theta _ { \omega } \}$
220
+ repeat Set gradient of outer parameters $\mathbf { \nabla } _ { \mathbf { \theta } _ { \partial u t } } \mathbf { \Psi } = 0$ for $n = 1$ to $N$ do set $\theta _ { i n } ^ { \prime } = \theta _ { i n }$ sample a task $\mathcal { M } \sim p ( \mathcal { M } )$ for $l = 1$ to $L + 1$ do sample $k$ episodes $\tau _ { 1 : k }$ on $\mathcal { M }$ using $\pi _ { \{ \theta _ { i n } ^ { \prime } , \theta _ { o u t } \} }$ fit a baseline Vκ using data from τ1:k compute $A _ { t } ^ { G A \ddot { E } }$ for all $\tau _ { 1 : k }$ compute $\log \pi ( \boldsymbol { a } _ { t } | \boldsymbol { h } _ { t } ) = \mathbb { E } _ { \omega | \boldsymbol { h } _ { t } } [ \pi ^ { \omega } ( \boldsymbol { a } _ { t } | \boldsymbol { s } _ { t } ) ]$ compute $J _ { \bigodot }$ with $A _ { t } ^ { G A E } , \log \pi ( { \pmb a } _ { t } | { \pmb h } _ { t } )$ (Eqs. 2, 3) if $l < L + \overline { { 1 } }$ then $\theta _ { i n } ^ { \prime } = \theta _ { i n } ^ { \prime } + \alpha _ { i n } \nabla _ { \theta _ { i n } ^ { \prime } } J _ { \overline { { \mathbf { \bullet } } } }$ else $\begin{array} { c } { { { \pmb g } _ { \theta _ { o u t } } = { \pmb g } _ { \theta _ { o u t } } + \nabla _ { \theta _ { o u t } } J _ { \pmb { \left[ \pmb { \hat { \backprime } } \right] } } } } \\ { { \theta _ { o u t } = \theta _ { o u t } + \alpha _ { o u t } \frac { 1 } { N } { \pmb g } _ { \theta _ { o u t } } } } \end{array}$
221
+ until convergence
222
+
223
+ 178 restricting the update to the high-level policy, we optimize for options that can be used to solve
224
+ 179 multiple tasks, thereby allowing the overall policy to adapt quickly with the change of high-level
225
+ 180 policy. This also allows for an expressive policy which can capture different behaviors and reduces
226
+ 181 the number of parameters and decisions an agent needs to learn and make during test time.
227
+ 182 Formally, our final objective can be expressed as Equation 5 with the inner update given by Equation
228
+ 183 6. The objective is similar to the one used in MLSH [17] with some key differences. Firstly, by
229
+ 184 backpropagating through the update step we are able to capture additional information from the
230
+ 185 adaptation steps in the gradient and secondly, our objective includes the optimization of termination
231
+ 186 parameters and thus allows for options with different lengths.
232
+
233
+ $$
234
+ \begin{array} { r l } & { \displaystyle \operatorname* { m a x } _ { \theta _ { \omega } , \theta _ { \xi } } \sum _ { { \mathcal M } _ { i } \sim p ( { \mathcal M } ) } { \mathbb E } _ { \tau \sim p ( \tau \mid \{ \theta _ { \omega } , \theta _ { \xi } , \theta _ { \Omega } ^ { L } \} ) } \left[ G _ { 0 } ^ { { \mathcal M } _ { i } } ( \tau ) \right] } \\ & { \displaystyle \theta _ { \Omega } ^ { j + 1 } = \theta _ { \Omega } ^ { j } + \alpha _ { i n } \nabla _ { \theta _ { \Omega } ^ { j } } { \mathbb E } _ { \tau \sim p ( \tau \mid \{ \theta _ { \omega } , \theta _ { \xi } , \theta _ { \Omega } ^ { j } \} ) } \left[ G _ { 0 } ^ { { \mathcal M } _ { i } } ( \tau ) \right] . } \end{array}
235
+ $$
236
+
237
+ # 187 4.1 Algorithm
238
+
239
+ 188 Written in its general form the objective leaves some freedom with regard to which policy gradient
240
+ 189 algorithm is used for gradient calculation. In our work we use the Inferred Option Policy Gradient
241
+ 190 (IOPG) [44] because it updates all options at the same time based on their responsibilities, i.e., the
242
+ 191 probability that the option was active given the history $\pmb { h } _ { t }$ of states and actions so far. This can lead to
243
+ 192 better data-efficiency when compared to other methods that only update a single option at a time but
244
+ 193 comes at the cost of increased computation time. Another important design choice is the state value
245
+ 194 function estimator. In the MAML RL setting the policy constantly changes in every inner update. It is
246
+ 195 thus difficult to use past trajectories for fitting the value function. We therefore use a linear time-state
247
+ 196 dependent baseline [9] which works better than more complex baselines with little data and was also
248
+ 197 used in the original MAML implementation.
249
+ 198 The resulting algorithm for Fast Adaptation of Modular Policies (FAMP) is outlined in Algorithm 1.
250
+ 199 Note that in order to use IOPG with DiCE we replace $\pi ( \boldsymbol { a } _ { t } | \boldsymbol { s } _ { t } )$ with $\pi ( \mathbf { \boldsymbol { a } } _ { t } | \mathbf { \boldsymbol { h } } _ { t } )$ in Equation 2. An
251
+ 200 intuition about why this is possible comes from the fact that we can easily formulate a new MDP
252
+ 201 $\tilde { \mathcal { M } }$ in which states $\tilde { s } _ { t }$ are histories $\pmb { h } _ { t }$ of the original MDP without otherwise altering the dynamics.
253
+ 202 After $L$ inner updates, the gradient of the objective with respect to the outer parameters is calculated.
254
+ 203 In principle, we would like to optimize for performance after a moderate number of gradient updates
255
+ 204 $L$ such as 10 or 20. However, with more inner updates the resulting gradient of the objective becomes
256
+ 205 noisier due to the usage of Monte Carlo estimate in each inner update. Furthermore, the time
257
+ 206 complexity of gradient computation and sample complexity both scale linearly with the number of
258
+ 207 inner updates. In practice we found a range from 2 to 4 update steps to be acceptable. An important
259
+ 208 benefit of gradient-based meta-learning is that even though the model is optimized for performance
260
+ 209 after $L$ adaptation steps, it can still be improved after $L$ updates by performing more steps of gradient
261
+ 210 descent.
262
+
263
+ ![](images/11b10b77111fd2ba86e496f0980568cdb89d2062317dcefd5b981c41fe2f00f5.jpg)
264
+ Figure 1: Left: Map of a taxi environment with special states and an example task. Middle and Right: Visualization of the option usage in this task. Middle part shows states without passenger on board. Right part shows states with passenger. Arrows represent directional actions, pick-up/drop-off is shown as a square. Each action is colored according to the active option.
265
+
266
+ # 5 Experiments
267
+
268
+ In this section, we empirically evaluate our method and show its benefits when applied to randomly selected tasks within and outside of the training distribution.
269
+
270
+ # 214 5.1 Taxi
271
+
272
+ 215
273
+ 216
274
+ 217
275
+ 218
276
+ 219
277
+ 220
278
+ 221
279
+ 222
280
+ 223
281
+ 224
282
+ 225
283
+ 226
284
+ 227
285
+ 228
286
+
287
+ In the first set of experiments we use a modified Taxi environment1 [8] displayed in Figure 1. An agent acts as a taxi driver who starts in one of the special (colored) locations. The goal of the driver is then to drive a passenger from one of the special locations to his destination. The task family consists of 60 different tasks with different combination of start, goal and passenger positions. These are always initialized in special states. In 12 out of 60 easier configurations the passenger starts the episode in the car. The only restriction on start, goal and passenger positions in all cases is that passenger’s destination must not be the same as his initial position. Each task is an MDP in which the agent can use 4 directional actions and two special actions: pick-up/drop-off and no-op. The state space is represented as a one-hot vector with 72 entries for every combination of possible taxi location and passenger being on board. Thus the agent does not have any information about the location of the passenger or goal state. Therefore, in order to facilitate fast adaptation to the (unobservable) passenger and goal locations, the agent must acquire options that can serve as building blocks for exploration. The reward is 2 for reaching the goal and $- 0 . 1$ per step otherwise. To speed up training in the early phases, we terminate the episode if it takes longer than 1500 timesteps.
288
+
289
+ 229
290
+ 230
291
+ 231
292
+ 232
293
+ 233
294
+ 234
295
+ 235
296
+ 236
297
+ 237
298
+ 238
299
+ 23
300
+
301
+ In this experiment, we use tabular representations implemented as a combination of linear layer and non-linearity for the policy over options, terminations and sub-policies such that each one-hot state has its own set of parameters. We use 48 training tasks to train sub-policies and terminations with our algorithm. Learned terminations and sub-policies are then kept fixed during test time and only the policy over options is updated. Performance is then compared on the remaining 12 test tasks (selected to use combinations of special locations with similar frequency) to MLSH and two baselines. We chose MLSH because it is a closest hierarchical method designed for our setting in which there is no extra information about the environment available. This is in contrast with many other hierarchical [5, 23, 29] and non-hierarchical [38, 47] meta-reinforcement learning methods which utilize extra information such as the ID of a sampled environment.
302
+
303
+ 9 Similarly to our method, MLSH is trained on all training tasks and evaluated with fixed sub-policies.
304
+ 0 The multi-task baseline is an IOPG algorithm that learns a shared policy (including high-level policy)
305
+ 241 by optimizing average return over tasks rather than the meta-learning objective in Equations 5 and
306
+ 242 6. After the training, it only adapt its high-level policy on test tasks. We expect this baseline to
307
+ 243 perform poorly in the long run because it does not optimize for post-update performance. Lastly,
308
+ 244 the single-task baseline is an IOPG algorithm that learns the test tasks from scratch without any
309
+ 245 pre-training. Therefore, since it does not need to generalize to many tasks and has a policy with
310
+ 246 enough capacity, we expect that it should eventually outperform other methods after sufficiently
311
+ 247 long training. However, meta-learned policy with desirable options should find good solution much
312
+ 248 quicker. To make the single-task baseline as strong as possible, we set its learning rate to the highest
313
+ 249 value that was able to solve all tasks reliably.
314
+
315
+ ![](images/6cbe98a638d7064b46eaf89975adaf7d9fc316d9e522d9fb12da6bd7130c4124.jpg)
316
+ Figure 2: Left: Average performance of different algorithms on taxi environment test tasks. Plot shows mean and standard deviation over 5 seeds. Right: Average performance of our method with different hyperparameter values on taxi environments test tasks. Plot shows median and interquartile range over 5 seeds.
317
+
318
+ # 250 Results
319
+
320
+ 51 As shown in Figure 2, our method is able to outperform both MLSH and the multi-task baseline
321
+ 252 reaching the final performance of $- 0 . 3 1 5$ . Furthermore, it also outperforms all other algorithms
322
+ 253 in terms of adaptation speed. We additionally checked whether the single-task baseline eventually
323
+ 254 overtakes FAMP and found that after more than 200 episodes, its performance stabilizes at a final
324
+ 255 discounted return value of $- 0 . 2 8 4$ . This demonstrates that FAMP can learn sub-policies and termi
325
+ 256 nations that allow for fast adaptation in similar unseen environments at the cost of slightly lower
326
+ 257 asymptotic performance. An example trajectory that was produced by the agent in one of the hardest
327
+ 258 test tasks is displayed in Figure 1. In this task, the agent is able to combine three options to form an
328
+ 259 optimal solution. Plots with meta-training curves and learned options are included in Appendix C.
329
+ 260 In Figure 2 (right), we show how the performance varies with changes to important hyperparameters,
330
+ 261 namely, the number of options and adaptation steps. We observe that decreasing the number of
331
+ 262 adaptation steps during training to one leads to a clear drop in performance. This can be attributed to
332
+ 263 the policy not being able to switch from exploratory to exploitatory behavior in a single inner update
333
+ 264 as well as the smaller amount of data observed before each outer update.
334
+ 265 Unlike the number of adaptation steps, the number of options does not seem to affect the performance
335
+ 266 too much. The only noticeable exception is lower performance when using only 2 options. This
336
+ 267 exception can be explained by noticing that in some states one needs to perform 3 different actions
337
+ 268 to represent all optimal paths. As an example, consider the state two squares above the blue special
338
+ 269 state in Figure 1. To reach the blue state in the minimum number of steps the agent needs to use the
339
+ 270 down action. Similarly, to go from the blue state to the red or yellow one it needs to use up and right
340
+ 271 respectively. Thus the agent cannot represent the optimal policies with only 2 options. Interestingly,
341
+ 272 even in this case, the agent is still able to separate trajectories in such a way that it can reach all goals
342
+ 273 albeit with slightly worse performance.
343
+ 274 This outcome demonstrates another benefit of learned option lengths as the optimal option length
344
+ 275 does not only depend on tasks and their difficulty but also on the number of options that are available.
345
+ 276 To illustrate this, consider an extreme case where there are as many options as tasks. In this case, it
346
+ 277 would be sensible to have solution to a different task in each option and not terminate at all because
347
+ 278 each task would be solved with only one high-level action. However, as the number of available
348
+ 279 options decreases, sharing options between tasks becomes necessary and terminations should start to
349
+
350
+ Table 1: Percentage of terminations in trajectories obtained from adapted policies averaged over 5 seeds. Standard deviations are in $1 \%$ range.
351
+
352
+ <table><tr><td rowspan=1 colspan=1>Number of options</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>16</td></tr><tr><td rowspan=1 colspan=1>Avg. terminations in traj</td><td rowspan=1 colspan=1>70%</td><td rowspan=1 colspan=1>63%</td><td rowspan=1 colspan=1>57%</td><td rowspan=1 colspan=1>55%</td><td rowspan=1 colspan=1>44%</td><td rowspan=1 colspan=1>28%</td></tr></table>
353
+
354
+ ![](images/2be204a1d222a55fbe76bab216be6e5236945ba7b5f170a1f816e2c217132a2a.jpg)
355
+ Figure 3: Ant maze tasks. The agent needs to control a simulated 4-legged ant-like robot and move it towards the green square.
356
+
357
+ 280 occur to allow for all tasks to be solved. Moreover, if the number of options is decreased even further,
358
+ 281 there may not be enough to options to capture the optimal behavior for all tasks. Consequently, it
359
+ 282 becomes even more difficult to choose the appropriate option length a priori since it can depend on
360
+ 283 the number of available options. To confirm this intuition, we ran a followup experiment with longer
361
+ 284 time horizon in the taxi environment. While the trajectories produced by adapted policies had similar
362
+ 285 length, relative number of terminations decreased with the increase in the number of options as shown
363
+ 286 in Table 1.
364
+
365
+ # 287 5.2 Ant Maze
366
+
367
+ 288 In our second experiment, we demonstrate the applicability of our method to more complex environ
368
+ 289 ments. We use the family of ant maze tasks introduced by Frans et al. [17] shown in Figure 3. This
369
+ 290 allows us to reproduce the results of MLSH as closely as possible by mirroring the setting used in
370
+ 291 the original paper. In addition to MLSH, we also compare to $\mathtt { R L } ^ { 2 }$ , a non-hierarchical meta-learning
371
+ 292 algorithm designed for fast-adaptation and Proximal Policy Optimization (PPO) [43], which serves
372
+ 293 as a strong single-task baseline.
373
+ 294 In each task the agent needs to move a simulated 4-legged ant-like robot through a small maze towards
374
+ 295 the goal. Both state space and action space are continuous with 29 and 8 dimensions respectively
375
+ 296 and each episode lasts 1000 timesteps. States do not contain any information about the maze layout
376
+ 297 or the location of the goal. The original implementation also resets the orientation of the ant every
377
+ 298 200 steps. However, we removed these resets because they made the MDP partially observable,
378
+ 299 introduced discontinuities and were not realistic for the robotics scenario they are supposed to imitate.
379
+ 300 Results of experiments with the original implementation are similar to the ones we present. They can
380
+ 301 be found in Appendix C along with meta-training plots.
381
+ 302 Both FAMP and MLSH use the same architecture with two hidden layers of 64 nodes to represent the
382
+ 303 high-level policy, sub-policies and terminations (only applies to FAMP). We used existing repositories
383
+ 304 for the implementation of $\mathtt { R L } ^ { 2 }$ [18] and PPO [1]. Hyperparameter values can be found in Appendix
384
+ 305 B. During the training phase, sub-policies (and terminations) of both hierarchical algorithms were
385
+ 306 trained on all tasks until the return averaged over all environments stopped improving. In the test
386
+ 307 phase all parameters except for the policy over options were frozen. Similarly, $\hat { { \mathrm { R L } } ^ { 2 } }$ was pre-trained
387
+ 308 on all tasks and subsequently evaluated while PPO was trained from scratch.
388
+ 309 The comparison of the performance and speed of adaptation can be seen in Figure 4 (left). Our
389
+ 310 method achieves superior performance reaching an average return of 1330. We also observed a
390
+ 311 similar trend across individual environments. Plots of these comparisons are available in Appendix C.
391
+ 312 While the zero-shot performance of $\mathtt { R L } ^ { 2 }$ is slightly better than FAMP, it often struggles to further
392
+ 313 adapt to specific tasks and quickly gets outperformed by both hierarchical methods. This is likely be
393
+ 314 due to the objective that optimizes average return over all training episodes and not post-adaptation
394
+ 315 performance directly. Lastly, PPO continuously improves but its performance does not come close to
395
+ 316 the meta-learning algorithms. After about 1000 episodes it reaches the performance of MLSH and if
396
+ 317 ran sufficiently long , we would expect that it would eventually catch up to FAMP.
397
+ 318 We visualize the option usage of FAMP on two example tasks in Figure 4 (right). After the high-level
398
+ 319 policy is fine-tuned, we use the $x$ and $y$ positions of the ant in 3 sampled trajectories to highlight
399
+ 320 which option is active at each part of the state space. Although we only take 2 out of 29 dimensions
400
+ 321 into account, we are still able to get useful insight about the learned option structure. In the task that
401
+ 322 is depicted in the left part of the plot, the agent uses the blue option before switching to cyan in the
402
+ 323 middle and finishing with a combination of blue and purple. On the other hand, in the right task, the
403
+ 324 agent uses a combination of blue and purple to move down instead of to the right. This shows that the
404
+ 325 agent learned a useful abstraction that allows it to perform two different useful behaviors in similar
405
+ 326 parts of the state space by using terminations and different options.
406
+
407
+ ![](images/9bef7bf587ff121b72310db790213d994ef96fa9a115b07729a272de2bdff666.jpg)
408
+ Figure 4: Left: Average performance of algorithms on ant maze environments tasks. Plot shows mean and standard deviation over 3 seeds. Right: Option usage visualization on ant maze tasks. Both plots were created using positions of the ant during 3 trajectories. Each of the 3 options is represented by a different color.
409
+
410
+ # 327 6 Discussion and Future Work
411
+
412
+ 328 In this work, our aim was to learn both sub-policies and terminations of options by using a single
413
+ 329 simple principle: options should accelerate adaptation in many tasks. We proposed a method for
414
+ 330 learning hierarchical policies that combines the options framework with gradient-based meta-learning
415
+ 331 and explicitly optimizes for performance after several adaptation steps. In our experiments, we
416
+ 332 have demonstrated the benefits of our approach in quickly learning previously unseen test tasks.
417
+ 333 Furthermore, we have shown that the proposed method outperforms the closest hierarchical and
418
+ 334 non-hierarchical meta-reinforcement learning methods designed for similar setting in a challenging
419
+ 335 multi-task learning scenario.
420
+ 336 The computation limitations of our method are mostly connected to the calculation of responsibilities
421
+ 337 in IOPG. In this calculation, many sequential matrix multiplications are required both in the forward
422
+ 338 and backward pass. The compute time for each update is thus dependent on the trajectory length
423
+ 339 because these calculations cannot be done in parallel. One direction for future work could thus be
424
+ 340 alleviating this limitation.
425
+ 341 Our objective does not explicitly constrain the number of terminations as long as they lead to fast
426
+ 342 adaptation. Thus, there are many combinations of options with different lengths which can lead to
427
+ 343 good performance on all tasks, which do not always correspond to intuitive decompositions. One
428
+ 344 possible cause of spurious terminations lies in the continuous state space used in some tasks. When
429
+ 345 neural networks are used to represent termination functions, they learn to generalize to nearby states.
430
+ 346 In tasks such as the ant maze, the agent will visit many states in the same neighborhood and might
431
+ 347 thus terminate options several times in quick succession. A promising topic for future investigation is
432
+ 348 whether this problem could be alleviated by using terminations that also depend on the state in which
433
+ 349 the option was initiated.
434
+
435
+ # References
436
+
437
+ [1] Joshua Achiam. Spinning Up in Deep Reinforcement Learning. 2018. [2] Maruan Al-Shedivat, Trapit Bansal, Yura Burda, Ilya Sutskever, Igor Mordatch, and Pieter Abbeel. Continuous Adaptation via Meta-Learning in Nonstationary and Competitive Environments. In International Conference on Learning Representations, 2018. [3] Antreas Antoniou, Harrison Edwards, and Amos Storkey. How to train your MAML. In International Conference on Learning Representations, 2019.
438
+ [4] Pierre-Luc Bacon, Jean Harb, and Doina Precup. The Option-Critic Architecture. Proceedings of the AAAI Conference on Artificial Intelligence, 31(1), Feb. 2017. [5] Andre Barreto, Diana Borsa, Shaobo Hou, Gheorghe Comanici, Eser Aygün, Philippe Hamel, Daniel Toyama, Jonathan hunt, Shibl Mourad, David Silver, and Doina Precup. The option keyboard: Combining skills in reinforcement learning. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. [6] Christian Daniel, Herke Van Hoof, Jan Peters, and Gerhard Neumann. Probabilistic inference for determining options in reinforcement learning. Machine Learning, 104(2-3):337–357, 2016.
439
+ [7] Peter Dayan and Geoffrey E Hinton. Feudal Reinforcement Learning. In S. J. Hanson, J. D. Cowan, and C. L. Giles, editors, Advances in Neural Information Processing Systems 5, pages 271–278. Morgan-Kaufmann, 1993. [8] Thomas G. Dietterich. Hierarchical Reinforcement Learning with the MAXQ Value Function Decomposition. Journal of Artificial Intelligence Research, 13(1):227–303, 2000.
440
+ [9] Yan Duan, Xi Chen, Rein Houthooft, John Schulman, and Pieter Abbeel. Benchmarking Deep Reinforcement Learning for Continuous Control. In Proceedings of The 33rd International Conference on Machine Learning, volume 48 of Proceedings of Machine Learning Research, pages 1329–1338. PMLR, 2016.
441
+ [10] Yan Duan, John Schulman, Xi Chen, Peter L. Bartlett, Ilya Sutskever, and Pieter Abbeel. RL2 : Fast Reinforcement Learning via Slow Reinforcement Learning. CoRR, abs/1611.02779, 2016.
442
+ [11] Benjamin Eysenbach, Abhishek Gupta, Julian Ibarz, and Sergey Levine. Diversity is All You Need: Learning Skills without a Reward Function. In International Conference on Learning Representations, 2019.
443
+ [12] Jesse Farebrother, Marlos C. Machado, and Michael Bowling. Generalization and Regularization in DQN. CoRR, abs/1810.00123, 2018.
444
+ [13] Gregory Farquhar, Shimon Whiteson, and Jakob Foerster. Loaded DiCE: Trading off Bias and Variance in Any-Order Score Function Gradient Estimators for Reinforcement Learning. In Advances in Neural Information Processing Systems, volume 32, pages 8151–8162. Curran Associates, Inc., 2019.
445
+ [14] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks. In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 1126–1135. PMLR, 2017.
446
+ [15] Jakob Foerster, Gregory Farquhar, Maruan Al-Shedivat, Tim Rocktäschel, Eric Xing, and Shimon Whiteson. DiCE: The Infinitely Differentiable Monte Carlo Estimator. In Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 1529–1538. PMLR, 2018.
447
+ [16] Roy Fox, Sanjay Krishnan, Ion Stoica, and Ken Goldberg. Multi-Level Discovery of Deep Options. CoRR, abs/1703.08294, 2017.
448
+ [17] Kevin Frans, Jonathan Ho, Xi Chen, Pieter Abbeel, and John Schulman. Meta Learning Shared Hierarchies. In International Conference on Learning Representations, 2018.
449
+
450
+ 398 [18] The garage contributors. Garage: A toolkit for reproducible reinforcement learning research.
451
+ 399 https://github.com/rlworkgroup/garage, 2019.
452
+ 400 [19] Abhishek Gupta, Benjamin Eysenbach, Chelsea Finn, and Sergey Levine. Unsupervised
453
+ 401 Meta-Learning for Reinforcement Learning. CoRR, abs/1806.04640, 2018.
454
+ 402 [20] Abhishek Gupta, Russell Mendonca, YuXuan Liu, Pieter Abbeel, and Sergey Levine. Meta
455
+ 403 Reinforcement Learning of Structured Exploration Strategies. In Advances in Neural Informa
456
+ 404 tion Processing Systems, volume 31, pages 5302–5311. Curran Associates, Inc., 2018.
457
+ 405 [21] Jean Harb, Pierre-Luc Bacon, Martin Klissarov, and Doina Precup. When Waiting Is Not an
458
+ 406 Option: Learning Options with a Deliberation Cost. Proceedings of the AAAI Conference on
459
+ 407 Artificial Intelligence, 32(1), 2018.
460
+ 408 [22] Anna Harutyunyan, Will Dabney, Diana Borsa, Nicolas Heess, Remi Munos, and Doina
461
+ 409 Precup. The Termination Critic. In Proceedings of Machine Learning Research, volume 89 of
462
+ 410 Proceedings of Machine Learning Research, pages 2231–2240. PMLR, 2019.
463
+ 411 [23] Maximilian Igl, Andrew Gambardella, Jinke He, Nantas Nardelli, N Siddharth, Wendelin
464
+ 412 Boehmer, and Shimon Whiteson. Multitask Soft Option Learning. In Proceedings of the
465
+ 413 36th Conference on Uncertainty in Artificial Intelligence (UAI), volume 124 of Proceedings of
466
+ 414 Machine Learning Research, pages 969–978. PMLR, 2020.
467
+ 415 [24] George Konidaris and Andrew Barto. Building portable options: Skill transfer in reinforcement
468
+ 416 learning. In Proceedings of the 20th International Joint Conference on Artificial Intelligence,
469
+ 417 pages 895–900, 2007.
470
+ 418 [25] Alexander Li, Carlos Florensa, Ignasi Clavera, and Pieter Abbeel. Sub-policy Adaptation for
471
+ 419 Hierarchical Reinforcement Learning. In International Conference on Learning Representations,
472
+ 420 2020.
473
+ 421 [26] Zhenguo Li, Fengwei Zhou, Fei Chen, and Hang Li. Meta-SGD: Learning to Learn Quickly for
474
+ 422 Few Shot Learning. CoRR, abs/1707.09835, 2017.
475
+ 423 [27] Hao Liu, Richard Socher, and Caiming Xiong. Taming MAML: Efficient unbiased meta
476
+ 424 reinforcement learning. In Proceedings of the 36th International Conference on Machine
477
+ 425 Learning, volume 97 of Proceedings of Machine Learning Research, pages 4061–4071. PMLR,
478
+ 426 2019.
479
+ 427 [28] Marlos C. Machado, Marc G. Bellemare, and Michael Bowling. A Laplacian framework for
480
+ 428 option discovery in reinforcement learning. In Proceedings of the 34th International Conference
481
+ 429 on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 2295–
482
+ 430 2304. PMLR, 2017.
483
+ 431 [29] Daniel J Mankowitz, Timothy A Mann, and Shie Mannor. Adaptive skills adaptive partitions
484
+ 432 (asap). In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett, editors, Advances in
485
+ 433 Neural Information Processing Systems, volume 29. Curran Associates, Inc., 2016.
486
+ 434 [30] Amy McGovern and Andrew G. Barto. Automatic Discovery of Subgoals in Reinforcement
487
+ 435 Learning Using Diverse Density. In Proceedings of the 18th International Conference on
488
+ 436 Machine Learning, ICML ’01, page 361–368, 2001.
489
+ 437 [31] Ishai Menache, Shie Mannor, and Nahum Shimkin. Q-Cut — Dynamic Discovery of Sub-Goals
490
+ 438 in Reinforcement Learning. In Proceedings of the 13th European Conference on Machine
491
+ 439 Learning, ECML’02, page 295–306. Springer-Verlag, 2002.
492
+ 440 [32] Nikhil Mishra, Mostafa Rohaninejad, Xi Chen, and Pieter Abbeel. A Simple Neural Attentive
493
+ 441 Meta-Learner. In International Conference on Learning Representations, 2018.
494
+ 442 [33] Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan
495
+ 443 Wierstra, and Martin A. Riedmiller. Playing Atari with Deep Reinforcement Learning. CoRR,
496
+ 444 abs/1312.5602, 2013.
497
+ 445 [34] Ofir Nachum, Shixiang (Shane) Gu, Honglak Lee, and Sergey Levine. Data-Efficient Hierarchi
498
+ 446 cal Reinforcement Learning. In Advances in Neural Information Processing Systems 31, pages
499
+ 447 3303–3313. Curran Associates, Inc., 2018.
500
+ 448 [35] Scott Niekum and Andrew Barto. Clustering via Dirichlet Process Mixture Models for Portable
501
+ 449 Skill Discovery. In Advances in Neural Information Processing Systems, volume 24, pages
502
+ 450 1818–1826. Curran Associates, Inc., 2011.
503
+ 451 [36] Marc Pickett and Andrew G. Barto. Policyblocks: An algorithm for creating useful macro
504
+ 452 actions in reinforcement learning. In Proceedings of the Nineteenth International Conference
505
+ 453 on Machine Learning, pages 506–513. Morgan Kaufmann, 2002.
506
+ 454 [37] Aniruddh Raghu, Maithra Raghu, Samy Bengio, and Oriol Vinyals. Rapid Learning or Feature
507
+ 455 Reuse? Towards Understanding the Effectiveness of MAML. In International Conference on
508
+ 456 Learning Representations, 2020.
509
+ 457 [38] Kate Rakelly, Aurick Zhou, Chelsea Finn, Sergey Levine, and Deirdre Quillen. Efficient Off
510
+ 458 Policy Meta-Reinforcement Learning via Probabilistic Context Variables. In Proceedings of the
511
+ 459 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine
512
+ 460 Learning Research, pages 5331–5340. PMLR, 2019.
513
+ 461 [39] Matthew Riemer, Miao Liu, and Gerald Tesauro. Learning Abstract Options. In Advances in
514
+ 462 Neural Information Processing Systems 31, pages 10424–10434. Curran Associates, Inc., 2018.
515
+ 463 [40] Jonas Rothfuss, Dennis Lee, Ignasi Clavera, Tamim Asfour, and Pieter Abbeel. ProMP: Proximal
516
+ 464 Meta-Policy Search. In International Conference on Learning Representations, 2019.
517
+ 465 [41] John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust
518
+ 466 Region Policy Optimization. In Proceedings of the 32nd International Conference on Machine
519
+ 467 Learning, volume 37 of Proceedings of Machine Learning Research, pages 1889–1897. PMLR,
520
+ 468 2015.
521
+ 469 [42] John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel.
522
+ 470 High-Dimensional Continuous Control Using Generalized Advantage Estimation. CoRR,
523
+ 471 abs/1506.02438, 2015.
524
+ 472 [43] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal
525
+ 473 policy optimization algorithms. CoRR, abs/1707.06347, 2017.
526
+ 474 [44] Matthew Smith, Herke van Hoof, and Joelle Pineau. An Inference-Based Policy Gradient
527
+ 475 Method for Learning Options. In Proceedings of the 35th International Conference on Machine
528
+ 476 Learning, volume 80 of Proceedings of Machine Learning Research, pages 4703–4712. PMLR,
529
+ 477 2018.
530
+ 478 [45] Bradly Stadie, Ge Yang, Rein Houthooft, Peter Chen, Yan Duan, Yuhuai Wu, Pieter Abbeel,
531
+ 479 and Ilya Sutskever. The importance of sampling in meta-reinforcement learning. In Advances
532
+ 480 in Neural Information Processing Systems, volume 31, pages 9280–9290. Curran Associates,
533
+ 481 Inc., 2018.
534
+ 482 [46] Richard S Sutton, Doina Precup, and Satinder Singh. Between MDPs and semi-MDPs: A
535
+ 483 framework for temporal abstraction in reinforcement learning. Artificial intelligence, 112(1-2):
536
+ 484 181–211, 1999.
537
+ 485 [47] Yee Teh, Victor Bapst, Wojciech M. Czarnecki, John Quan, James Kirkpatrick, Raia Hadsell,
538
+ 486 Nicolas Heess, and Razvan Pascanu. Distral: Robust multitask reinforcement learning. In
539
+ 487 Advances in Neural Information Processing Systems, volume 30, pages 4496–4506. Curran
540
+ 488 Associates, Inc., 2017.
541
+ 489 [48] Sebastian Thrun and Anton Schwartz. Finding structure in reinforcement learning. In G. Tesauro,
542
+ 490 D. Touretzky, and T. Leen, editors, Advances in Neural Information Processing Systems,
543
+ 491 volume 7. MIT Press, 1995.
544
+ 492 [49] E. Todorov, T. Erez, and Y. Tassa. Mujoco: A physics engine for model-based control. In 2012
545
+ 493 IEEE/RSJ International Conference on Intelligent Robots and Systems, pages 5026–5033, 2012.
546
+ 494 [50] Alexander Sasha Vezhnevets, Simon Osindero, Tom Schaul, Nicolas Heess, Max Jaderberg,
547
+ 495 David Silver, and Koray Kavukcuoglu. FeUdal Networks for Hierarchical Reinforcement
548
+ 496 Learning. In Proceedings of the 34th International Conference on Machine Learning, volume 70
549
+ 497 of Proceedings of Machine Learning Research, pages 3540–3549. PMLR, 2017.
550
+ 498 [51] Jane X. Wang, Zeb Kurth-Nelson, Dhruva Tirumala, Hubert Soyer, Joel Z. Leibo, Rémi Munos,
551
+ 499 Charles Blundell, Dharshan Kumaran, and Matthew Botvinick. Learning to reinforcement learn.
552
+ 500 CoRR, abs/1611.05763, 2016.
553
+ 501 [52] Shangtong Zhang and Shimon Whiteson. DAC: The Double Actor-Critic Architecture for
554
+ 502 Learning Options. In Advances in Neural Information Processing Systems, volume 32, pages
555
+ 503 2012–2022. Curran Associates, Inc., 2019.
556
+ 504 [53] Chenyang Zhao, Olivier Sigaud, Freek Stulp, and Timothy M. Hospedales. Investigating
557
+ 505 Generalisation in Continuous Deep Reinforcement Learning. CoRR, abs/1902.07015, 2019.
558
+ 506 [54] Luisa Zintgraf, Kyriacos Shiarli, Vitaly Kurin, Katja Hofmann, and Shimon Whiteson. Fast
559
+ 507 Context Adaptation via Meta-Learning. In Proceedings of the 36th International Conference on
560
+ 508 Machine Learning, volume 97 of Proceedings of Machine Learning Research, pages 7693–7702.
561
+ 509 PMLR, 2019.
562
+
563
+ # 510 Checklist
564
+
565
+ 1. For all authors...
566
+
567
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
568
+ (b) Did you describe the limitations of your work? [Yes] See Section 6
569
+ (c) Did you discuss any potential negative societal impacts of your work? [No] We propose a general meta-reinforcement algorithm that does not have any foreseeable negative social impact
570
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
571
+
572
+ 2. If you are including theoretical results...
573
+
574
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
575
+
576
+ 3. If you ran experiments...
577
+
578
+ (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] In supplemental material
579
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Some training details are given in Section 5, the rest is provided in Appendix B
580
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
581
+ (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] Included in Appendix B
582
+
583
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
584
+
585
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We cite the codebases and works that introduced environments we use in Section 5
586
+ (b) Did you mention the license of the assets? [No] We used publicly available code
587
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We include our codebase in the supplemental material and will make a public github repository
588
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] We used publicly available code
589
+
590
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] We use data from virtual environments
591
+
592
+ 5. If you used crowdsourcing or conducted research with human subjects...
593
+
594
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
595
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
596
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/train/lM2971LAwV/lM2971LAwV.md ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Evolution Gym: A Large-Scale Benchmark for Evolving Soft Robots
2
+
3
+ Jagdeep Singh Bhatia MIT CSAIL jagdeep@mit.edu
4
+
5
+ Holly Jackson
6
+ MIT CSAIL
7
+ hjackson@mit.edu
8
+
9
+ Yunsheng Tian MIT CSAIL yunsheng@csail.mit.edu
10
+
11
+ Jie Xu MIT CSAIL jiex@csail.mit.edu
12
+
13
+ Wojciech Matusik MIT CSAIL wojciech@csail.mit.edu
14
+
15
+ # Abstract
16
+
17
+ Both the design and control of a robot play equally important roles in its task performance. However, while optimal control is well studied in the machine learning and robotics community, less attention is placed on finding the optimal robot design. This is mainly because co-optimizing design and control in robotics is characterized as a challenging problem, and more importantly, a comprehensive evaluation benchmark for co-optimization does not exist. In this paper, we propose Evolution Gym, the first large-scale benchmark for co-optimizing the design and control of soft robots. In our benchmark, each robot is composed of different types of voxels (e.g., soft, rigid, actuators), resulting in a modular and expressive robot design space. Our benchmark environments span a wide range of tasks, including locomotion on various types of terrains and manipulation. Furthermore, we develop several robot co-evolution algorithms by combining state-of-the-art design optimization methods and deep reinforcement learning techniques. Evaluating the algorithms on our benchmark platform, we observe robots exhibiting increasingly complex behaviors as evolution progresses, with the best evolved designs solving many of our proposed tasks. Additionally, even though robot designs are evolved autonomously from scratch without prior knowledge, they often grow to resemble existing natural creatures while outperforming hand-designed robots. Nevertheless, all tested algorithms fail to find robots that succeed in our hardest environments. This suggests that more advanced algorithms are required to explore the high-dimensional design space and evolve increasingly intelligent robots – an area of research in which we hope Evolution Gym will accelerate progress. Our website with code, environments, documentation, and tutorials is available at http://evogym.csail.mit.edu.
18
+
19
+ # 1 Introduction
20
+
21
+ One of the main goals of artificial intelligence is to develop effective approaches for the creation of embodied intelligent systems. Inspired from real organisms, where body structure and brain are two key factors for completing any task in a real environment, a successful intelligent robot typically requires concurrently optimizing its structure design and control mechanism. Such a co-design problem has been a long-standing key challenge in the robotics and machine learning communities. Surprisingly, despite its importance, most previous research works still either only develop complex control algorithms for existing robot structures [1, 2, 17, 30], or conduct co-optimization over robot morphology and control for only a few simple tasks (e.g., running, jumping) [7, 14, 31, 32], especially in the soft body domain. The primary reasons behind the under-exploration of co-design algorithms in sophisticated problems are: (1) the underlying complex bilevel optimization scheme of a co-design algorithm, where the inner control optimization loop leads to a long iteration cycle of the whole optimization process; (2) the lack of a well-established benchmark platform providing the researchers with a suite to evaluate and compare different algorithms.
22
+
23
+ Digital benchmark environments have proven to be successful at promoting the development of advanced learning techniques via providing a comprehensive evaluation suite to make fair comparisons among different algorithms [5, 11, 36]. However, to our best knowledge, all existing benchmark platforms constrain their domains within control optimization problems, and the space of co-optimization environment suites is still rarely explored.
24
+
25
+ To fill this gap, in this work we propose Evolution Gym, a large-scale benchmark for evolving both the shape structure and controller of soft robots. The body of each robot in Evolution Gym is composed of various types of primitive building blocks (e.g., soft voxels, rigid voxels, actuator voxels), and the control of the robot includes action signals applied on the actuator voxels. We choose to use this multi-material voxel-based structure as the representation of robot body since it provides a general and universal representation for various categories of robot designs, and at the same time results in a modular and expressive structure design space. We adopt a mass-spring dynamics system [26] with penalty-based frictional contact as the underlining physics engine. Such a light-weight simulator allows the co-design algorithms to significantly reduce the simulation cost and thus accelerate the develop-evaluate iteration cycle [3, 15, 23]. The back-end simulator is fully developed in $\mathrm { C } { + + }$ t o provide further computing efficiency. Another feature of Evolution Gym is its large variety of tasks categorized by varying difficulty levels, which offer an extensive evaluation benchmark for comparing approaches. The benchmark is currently comprised of more than 30 tasks, spanning locomotion on various types of terrains and manipulation. Moreover, Evolution Gym is easy to use. In order to have user-friendly interfaces, we build a Python wrapper outside the $\mathrm { C } { + + }$ simulator and carefully design our APIs off of the well-received APIs of OpenAI Gym with minimum modifications. Evolution Gym will be released fully open-source under the MIT license.
26
+
27
+ In addition, we develop several baseline algorithms by integrating state-of-the-art design optimization approaches and reinforcement learning techniques. Specifically, in our baseline algorithms, design optimization methods are served in the outer loop to evolve the physical structures of robots and reinforcement learning algorithms are applied in the inner loop to optimize a controller for a given proposed structure design. We conduct extensive experiments to evaluate all baseline algorithms on Evolution Gym. The experiment results demonstrate that intelligent robot designs can be evolved fully autonomously while outperforming hand-designed robots in easier tasks, which reaffirms the necessity of jointly optimizing for both robot structure and control. However, none of the baseline algorithms are capable enough to successfully find robots that complete the task in our hardest environments. Such insufficiency of the existing algorithms suggests the demand for more advanced robot co-design techniques, and we believe our proposed Evolution Gym provides a comprehensive evaluation testbed for robot co-design and unlocks future research in this direction.
28
+
29
+ In summary, our work has the following key contributions: (i) We propose Evolution Gym, the first large-scale benchmark for soft robot co-design algorithms. (ii) We develop several co-design algorithms by combining state-of-the-art design optimization methods and deep reinforcement learning techniques for control optimization. (iii) The developed algorithms are evaluated and analyzed on our proposed benchmark suite, and the results validate the efficacy of robot co-design while pointing out the failure and limitations of existing algorithms.
30
+
31
+ # 2 Related work
32
+
33
+ Robot co-design Co-designing the structure (i.e., body) and control (i.e., brain) of robots is a long-standing key challenge in the robotics community. As the earliest work in this space, Sims [31] represents the structure of a rigid robot as a directed graph and proposes an evolutionary algorithm defined on graphs to optimize the robot design. Subsequently, the co-design of rigid robots is formulated as a graph search problem where more efficient search algorithms are applied [13, 27, 39, 41] to achieve increasingly interesting results. However, with the restriction of having rigid components only, these algorithms are unable to produce optimal or even feasible designs for many challenging tasks where a compliant joint or robot component is required to achieve the goal.
34
+
35
+ On the contrary, soft components offer much more flexibility to represent arbitrary shapes, making the design of more complex, agile, and high-performing robots possible. Inspired by this, some work has been conducted to co-design robots composed of soft cells. Cheney et al. [7, 8]; Van Diepen and Shea [37]; Corucci et al. [10] propose evolutionary algorithms to co-optimize the structure and control of voxel-based robots. However those algorithms typically parameterize the control as an open-loop periodic sequence of actuation, which prevents robots from learning complex non-periodic tasks such as walking on uneven or varying terrains. Spielberg et al. [32] and Medvet et al. [23] jointly optimize the spatial-varying material parameters and the neural network policy for soft robots but leave the shape of the robot fixed. Our proposed benchmark shares a similar expressive structure design space as Cheney et al. [7], but allows the control to be parameterized by a sophisticated neural network feedback policy. To handle such sophisticated joint optimization of the robot structure and high-dimensional neural network control policy, we develop several baseline co-design algorithms by combining state-of-the-art design optimization strategies and reinforcement learning techniques for control optmization.
36
+
37
+ Benchmark environments for robotics learning Present research in robotics learning is largely facilitated by emerging benchmark environments. For instance, OpenAI Gym [5], DeepMind Control Suite [36], rllab [11], and Gibson [40] have been developed to benchmark RL algorithms for controlling rigid robots. At the same time, PlasticineLab [16] is specifically designed for soft robot learning. However, the existing benchmark environments are all constructed for learning the control only. To enable the possibility of evolving the structure of a robot, the existing co-design work has to either implement their own testing environment [32, 7, 8, 10, 37], or make substantial changes on the underlying code of the existing control-only environments [29]. The independent development of testing beds requires non-trivial workload, and as a result, existing co-design works mainly focus on evaluating the robot on a few simple tasks such as walking on a flat terrain [7, 6, 8, 37, 32, 23], or swimming along a single direction [9, 39]. An unintended consequence of such independency is an indirect comparison among different algorithms. Evolution Gym fills this gap by presenting a large variety of tasks with different difficulty levels that span from locomotion to manipulation. The proposed benchmark suite can be effectively used to test the generalizability of the algorithms on different tasks, potentially accelerating research in robot co-design.
38
+
39
+ # 3 Evolution Gym
40
+
41
+ ![](images/f540f0a25bd3a4ab567d628bc5020febbc9d55526a09cf77187a1637e5342b14.jpg)
42
+ Figure 1: Overview of Evolution Gym and its integration with the co-design algorithms. Evolution Gym is comprised of a back-end soft body simulator (A, B) and task-specific environments (C). A user-customized co-design algorithm can be plugged in to optimize for both robot structure and control through interacting with Evolution Gym on a certain task.
43
+
44
+ # 3.1 Overview
45
+
46
+ In this section, we present Evolution Gym, a large-scale benchmark for the co-design of voxel-based soft robots. Evolution Gym is featured by its versatile and expressive multi-material voxel-based structure design space, flexibility of the controller parameterization, wide spectrum of tasks of various difficulty levels, fast back-end soft-body simulation support, and user-friendly Python interfaces.
47
+
48
+ As shown in the overview in Figure 1, Evolution Gym is comprised of a task-specific environment and a back-end soft-body simulator. The gym suite provides seamless interfaces with a user-defined co-design algorithm. The co-design algorithm typically consists of a design optimizer and a control optimizer. The design optimizer can propose a new robot structure to the control optimizer, then the control optimizer will compute an optimized controller for the given structure through interactions with Evolution Gym and finally return the maximum reward that this robot structure can achieve. In this way, Evolution Gym provides an easy-to-use platform for co-design algorithms to evolve both robot structure and control to optimize for robots’ task performances. Evolution Gym is designed to be the first comprehensive testbed for benchmarking and comparing different co-design algorithms with the hope to facilitate the development of more novel and powerful algorithms in the co-design field.
49
+
50
+ # 3.2 Multi-material voxel-based representation
51
+
52
+ Evolution Gym employs a unified multi-material voxel-based representation for all the components in the environment (e.g., robot, terrain, object) as shown in Figure 1A. Specifically, each robot in our gym is composed of rigid voxels, soft voxels, horizontal/vertical actuator voxels, and empty voxels. For terrain and objects, we use the same voxel-based structure but with passive voxel types (i.e., soft/rigid voxels).
53
+
54
+ We chose a voxel-based representation for three main reasons. First, such a multi-material structure of robots provides a general and universal representation for various categories of robot designs and results in a modular structure design space. Additionally, with just the few voxel types described above, and less than 100 voxels per robot, we are able to construct a wide diversity of morphologies due to the resulting combinatorial robot design space. Even with this simple representation, our designed robots are capable of performing complex motions and completing difficult tasks. Finally, voxel-based robots can be simulated by a fast mass-spring simulation (see section 3.4) which allows our framework to be efficient enough to train robots in a matter of minutes and provides a computationally tractable benchmark for iterating co-design algorithms.
55
+
56
+ # 3.3 Task representation
57
+
58
+ Each task in Evolution Gym contains a robot structure proposed by the co-design algorithm, environment specifications (e.g., terrain, object), and a task-related goal (e.g., locomotion or manipulation). The tasks interface with the co-design algorithm through a few key elements including robot structure specification, observation, action, and reward. We introduce each element in detail below.
59
+
60
+ Robot structure specification As described in Section 3.2, we construct each robot from primitive building blocks arranged on a grid layout. In code, each robot is specified as a material matrix of voxels $\mathcal { M }$ and a connection link list $\mathcal { C }$ . The value of entry $m \in \mathcal { M }$ is a label corresponding to a voxel type from the set {Empty, Rigid, Soft, Horizontal Actuator, Vertical Actuator}. The connection link list $\mathcal { C }$ stores a list of connection pairs of adjacent voxels. The co-design algorithm can update the robot structure in the environment through initialization function with $\mathcal { M }$ and $\mathcal { C }$ as arguments.
61
+
62
+ Observation The observation is composed in each step to inform the controller of state information of the robot, terrain information of the environment, and goal-relevant information. More specifically, let $N$ be the total number of voxel corner points of the robot. Then the state information of the robot in our tasks is a $( 2 N + 3 )$ -D vector including the relative position of each voxel corner with respect to the center of mass of the robot (2N -D), and the velocity and orientation of center of mass (3-D). To handle complex tasks, specifically those with varying terrain types, an additional observation vector including terrain information is provided. We compile terrain information within a local window of size $2 W$ around the robot into a length- $2 W$ vector observation that describes the terrain’s elevation. Furthermore, goal-related information is offered to inform the controller of the execution status of the current task. This goal-related observation is task-specific and is defined on each task separately. For instance, in manipulation tasks where the robot interacts with some object $O$ , we provide orientation and velocity as well as the position of $O$ ’s center of mass relative to the robot.
63
+
64
+ Action At each time step, an action vector from the robot’s controller is provided to step Evolution Gym’s simulator. In Evolution Gym, each component of the action vector is associated with an actuator voxel (either horizontal or vertical) of the robot, and instructs a deformation target of that voxel. Specifically, the action value $u$ is within the range [0.6, 1.6], and corresponds to a gradual expansion/contraction of that actuator to $u$ times its rest length.
65
+
66
+ ![](images/053eb8c429dde48e5939018f6c3c0ddcb5a5e3b0be8c8177374baf33de67a0c2.jpg)
67
+ Figure 2: A visual overview of selected 10 environments from Evolution Gym. A verbal description of tasks is provided in Section 3.5.
68
+
69
+ Reward Each task is equipped with a reward function measuring the performance of the current robot and the control action. The value of the reward is defined step-wise and is fed back to the agent through step function. The reward function is highly task-specific and should be defined to precisely characterize the robot’s completeness of the task. Please refer to Section 3.5 and Appendix for detailed descriptions of the reward functions on each task.
70
+
71
+ # 3.4 Simulation engine
72
+
73
+ We model the dynamics of the underlying simulator as a 2D mass-spring system [26]. This simple, flexible formulation allows us to efficiently model soft robots with a wide range of capabilities in a wide range of environments. The simulation engine is written entirely in $\mathrm { C } { + + }$ . We create Python bindings of our simulator so it seamlessly interfaces with standard learning frameworks.
74
+
75
+ The simulation represents objects and their environment as a mass-spring system in a grid-like layout (Figure 1B). Objects and their environments are initialized as a set of non-overlapping, connected voxels. On initialization, each voxel is a cross-braced square, but may undergo deformation as the simulation progresses. Each edge acts as an ideal spring obeying Hooke’s law, with a spring constant defined by one of five possible material types. We employ symplectic RK-4 integration to step forward the simulation.
76
+
77
+ Collision detection is performed using a bounding-box tree structure [12]. Penalty-based contact forces and frictional forces are computed proportionally to the depth of penetration of the corresponding voxels in contact, and are applied on the voxel vertices in the normal and tangential directions of the contact respectively. Please refer to Appendix A for more details of simulation.
78
+
79
+ # 3.5 Benchmark environment suite
80
+
81
+ We have developed over 30 unique tasks with Evolution Gym and select 10 tasks here to illustrate the diversity and comprehensiveness of our benchmark task set. All tasks are organized into two categories – locomotion and manipulation – though some tasks are a mix of both. We further classify the tasks into different difficulty levels (i.e., easy, medium, hard) based on the performance of the baseline algorithms (see Section 4) on them. We briefly introduce the selected tasks in this section. For more detailed descriptions and visualizations of the tasks, please refer to our website or Appendix B. It is also worth mentioning that our gym is designed to be extendable and the user can easily create new tasks for their needs.
82
+
83
+ # 3.5.1 Locomotion tasks
84
+
85
+ Walker (Easy) This is a common standard task typically considered by previous works where the robot needs to walk on a flat terrain as fast as possible.
86
+
87
+ Bridge Walker (Easy) In this task, the robot traverses a series of soft “rope” bridges separated by fixed pillars, and similarly as before it needs to maximize its forward speed.
88
+
89
+ Up Stepper (Medium) The agent walks up a fixed staircase with steps of varying length.
90
+
91
+ Climber (Medium) The robot must climb two tall fixed walls on each side. The robot is rewarded by its upward climbing speed.
92
+
93
+ Traverser (Hard) In this hard task, the robot needs to traverse a pit of rigid blocks to get to the other side without sinking into the pit.
94
+
95
+ # 3.5.2 Object manipulation tasks
96
+
97
+ Carrier (Easy) The robot needs to catch a small, soft rectangular object initially dropped from above and then carry it along the forward direction. The robot is rewarded by the distance both it and the object have traveled.
98
+
99
+ Thrower (Medium) The robot throws a soft rectangular box as far as possible without moving itself significantly from its original position.
100
+
101
+ Beam Slider (Hard) In this task, a beam sits on top of a set of spaced-out floating platforms. The robot is rewarded for moving to the beam and sliding it in the forward direction.
102
+
103
+ Catcher (Hard) The agent needs to catch a spinning object randomly falling from a high location.
104
+
105
+ Lifter (Hard) The robot has to manipulate an object and lift it out of a hole.
106
+
107
+ # 4 Evolving soft robots
108
+
109
+ Robot evolution/co-design algorithms are formulated as a two-level optimization problem, which involves a design optimization method that evolves physical structures of the robots in the outer loop and a control optimization algorithm that computes an optimized controller for a given robot structure in the inner loop, as illustrated in Algorithm 1. We briefly introduce several instantiations of design optimization methods and control optimization methods in Section 4.1 and 4.2 that we use for evaluation on our benchmark, and more details can be found in Appendix C.
110
+
111
+ Inputs: Task specification $T$ , number of generations $n$ , population size $p$ .
112
+ Outputs: The best robot design $D ^ { * }$ and controller $C ^ { * }$ .
113
+ $S \emptyset$ // Dataset of robot designs, controllers and reward
114
+ $D _ { 1 } , . . . , D _ { p } \gets \mathrm { S A M P L E D E S I G N S } ( p )$ // Sample an initial population of robot designs
115
+ for $i \gets 1$ to $n$ do for $j 1$ to $p$ do $C _ { j } \gets 0 \mathrm { P T I M I Z E C O N T R O L } ( T , D _ { j } )$ // Optimize the controller of given robot design $r _ { j } \gets 1$ EVALUATEREWARD $( T , D _ { j } , C _ { j } )$ // Evaluate the reward of given design and controller $\bar { S } S \cup \{ ( D _ { j } , C _ { j } , r _ { j } ) \}$ // Update the evaluation result to the dataset $D _ { 1 } , . . . , D _ { p } \gets \mathrm { O P T I M I Z E D E S I G N S } ( S , p ) .$ // Optimize a population of robot designs to evaluate
116
+ Find the best design $D ^ { * }$ and controller $C ^ { * }$ in dataset $S$ with the maximum reward $r ^ { * }$ .
117
+
118
+ # 4.1 Design optimization
119
+
120
+ Design optimization aims at evolving robot structures to maximize the reward under two physical constraints: the body has to be connected, and actuators must exist. In this section, we introduce three instantiations of the design optimization algorithm (OPTIMIZEDESIGN in Algorithm 1).
121
+
122
+ Genetic algorithm (GA) GAs [24] are widely used in optimizing black-box functions by relying on biologically inspired operators such as mutation, crossover and selection, as demonstrated in previous works on evolving rigid robots [31, 39]. We implement a simple GA using elitism selection and a simple mutation strategy to evolve the population of robot designs. Specifically, in each generation, our elitism selection works by keeping the top $x \%$ of the robots from the current population as survivors and discarding the rest, where $x$ decreases gradually from 60 to 0 over generations. Next, we iteratively sample and mutate one of those survivors with $1 \dot { 0 } \%$ probability of changing each voxel of the robot to create more offsprings. Note that by mutating a voxel type from/to empty voxel, we are able to change the topology of the robot. The crossover operator is not implemented in our genetic algorithm.
123
+
124
+ Bayesian optimization (BO) BO [20, 25] is a commonly used global optimization method for black-box functions by learning and utilizing a surrogate model, which is usually employed to optimize expensive-to-evaluate functions, including evolving rigid robots in previous works [29, 21]. Specifically, we choose a batch BO algorithm as described in Kandasamy et al. [18] and implemented in the GPyOpt package [4] that supports categorical input data. We use Gaussian processes as the surrogate model, batch Thompson sampling for extracting the acquisition function, and L-BFGS algorithm to optimize the acquisition function. To ensure a fair comparison with other populationbased evolutionary baseline algorithms, the batch size of this algorithm is set equal to the population size of other algorithms.
125
+
126
+ CPPN-NEAT CPPN-NEAT is the predominant method for evolving soft robot design in previous literature [6, 7, 8]. In this method, the robot design is parameterized by a Compositional Pattern Producing Network (CPPN) [33]. The input to a CPPN is the spatial coordinate of a robot voxel and the output is the type of that voxel. Therefore, by querying the CPPN at all the spatial locations of a robot, we can obtain the type for each voxel to construct a robot. At the same time the NeuroEvolution of Augmenting Topologies (NEAT) algorithm [34] is used to evolve the structure of CPPNs by working as a genetic algorithm with specific mutation, crossover, and selection operators defined on network structures. Our implementation of CPPN-NEAT is based on the PyTorch-NEAT library [28] and the neat-python library [22].
127
+
128
+ # 4.2 Control optimization
129
+
130
+ In this section, we introduce the specific control optimization algorithm (OPTIMIZECONTROL in Algorithm 1) that we use in the robot evolution algorithms. In previous works on evolving soft robots, the controller is either encoded as a fixed periodic sequence of actuation [7] or is parameterized as a CPPN that outputs the frequency and phase offset of the periodic actuation for each voxel [8]. However, the periodic pattern of the control prevents robots from learning complex non-periodic tasks such as walking on uneven or varying terrains. Therefore, we use reinforcement learning (RL) [35] to train the controller, making it possible for the soft robots to perform arbitrarily complex tasks in our benchmark. Specifically, we apply a state-of-the-art RL algorithm named Proximal Policy Optimization (PPO) [30] for control optimization of robots, with code implementation given by [19].
131
+
132
+ # 5 Experiments and results
133
+
134
+ In this section we present the evaluation results of baseline robot co-design algorithms on 10 selected benchmark tasks described in Section 3.5. The complete evaluation results on all our benchmark tasks can be found in Appendix E.
135
+
136
+ We develop three baseline algorithms for robot evolution by combing the three design optimization methods in Section 4.1 and PPO for control optimization in Section 4.2. Since the control optimization method is the same for all baseline algorithms, we simply use GA, BO, CPPN-NEAT to denote these three baseline algorithms with different design optimization methods. The evaluations of our baseline algorithms are performed on machines with Intel Xeon CPU $\textcircled { \omega } 2 . 8 0 \mathrm { G H z } ^ { \ast } 8 0$ processors on Google Cloud Platform; GPU is not required. Evaluating one algorithm on a single task usually takes several hours to twenty hours, depending on the number of evaluations, size of population, etc. See Appendix D for more details on hyperparameters of all the experiments.
137
+
138
+ # 5.1 Comparisons among baseline algorithms
139
+
140
+ We plot the reward curves of the three baseline algorithms on 10 selected benchmark tasks in Figure 3. There is no single optimal algorithm that performs the best on all tasks, but overall, GA outperforms the other two baseline algorithms. This is surprising because our genetic algorithm is implemented with simple and intuitive operators for mutation and selection without sophisticated mechanisms. Therefore, we believe that with more carefully designed operators, GA has the potential to evolve much more intelligent robots. CPPN-NEAT generally performs well on locomotion tasks, as tested by previous works, but performs poorly on more complex manipulation tasks. This is possibly because
141
+
142
+ NEAT favors CPPNs with simpler structures, which encourages CPPNs to generate robots with more regular patterns. However, to succeed in complex manipulation tasks, some agile substructures of the robot must evolve, which might only exist in robots with irregular patterns. Finally, it is not surprising that BO performs poorly on most of the tasks because the high-dimensional categorical input parameter space and the noisy evaluation done by RL together pose a challenge to fitting an accurate surrogate model in BO.
143
+
144
+ ![](images/28e51489c7a7245067ab9847f4db9c6e44c41dc3361b5bced78ec9e49378767c.jpg)
145
+ Figure 3: Performance comparison among baseline algorithms. We plot the best performance of robots that each algorithm has evolved w.r.t. the number of evaluations on each task. All the curves are averaged over 6 different random seeds, and the variance is shown as a shaded region.
146
+
147
+ ![](images/d519dc86079772f8349aceead1bdea35217b757992471ed111590a2dd19d2cf5.jpg)
148
+ Figure 4: Evolution of robot designs. For each of the three selected tasks, we visualize the population in three different generations. Each column corresponds to one generation for which we show the four top performing robots along with their average reward.
149
+
150
+ # 5.2 Evolution analysis
151
+
152
+ In Figure 4 we visualize the top four robots in three different generations on training the genetic algorithm for the Carrier, Lifter, and Bridge Walker task. We also show the average reward these designs achieve.
153
+
154
+ In the carrier task, the robot must catch an object that falls from above and then carry that object as far as possible. Therefore, a successful design for this task achieves two main goals 1) allowing the robot to catch and hold the object securely 2) allowing the robot to move fast. We observe that robots with a block-holding mechanism and with legs are selected for in the top survivors of generation 1 (randomly initialized). As evolution progresses, these structures become increasingly optimized. Specifically, in later generations, the robots’ structures allow them to walk faster while still preventing the block from falling.
155
+
156
+ ![](images/8ffffcf3f893ce0f4598ad550be5790e071afbff144f94f4526036d0285a0e16.jpg)
157
+ Figure 5: Comparison between algorithm-optimized robots and hand designed robots on three tasks. In each task, we visualize one robot optimized by the algorithm and several hand-designed robots.
158
+
159
+ A similar comparison pattern can be seen in the Lifter task, where the algorithm learns a parallel gripper-like shape underneath the robot in order to manipulate an object. Unlike in the carrier task, the design structures that the algorithm generates are not prominently found in the initial generation. Finally, these patterns are echoed in the Bridge Walker task. Here the robot learns to evolve a large front foot to maximize its surface area and friction force to best walk across the soft rope bridge.
160
+
161
+ # 5.3 Comparison against hand-designed robots
162
+
163
+ We compare the performances of robots optimized by algorithm and the hand designed robots on several tasks to show the necessity of a co-design algorithm (Figure 5). The structure of the hand designed robots are bio-inspired and manually constructed according to our best intuition, and their control are optimized by PPO.
164
+
165
+ For every task, the hand designed robots are outperformed by at least one algorithm (usually more). For instance, for the Climber task we tested numerous natural robot designs. However, none of them successfully climbed very far. The issue with our designs is that we could not find the right trade off between getting traction on the wall, and accelerating upwards. The genetic algorithm, however, is able to find this balance. It develops leg-like structures that help the robot make forward progress, as well as a long flat back that maximizes contact/frictional forces with the wall. Additionally, the genetic algorithm selects for having a hole in the center of its body, which helps it achieve a certain optimized walking motion.
166
+
167
+ For other tasks, the performance between the hand designed robots and the robots produced by the algorithms is quite comparable. This is the case with the Carrier robots, as a very natural hand-designed Carrier robot performs almost as well as the best optimized robots produced by the design-optimization algorithms.
168
+
169
+ In the final case, there are tasks where neither a hand designed nor robot produced by the algorithm could achieve satisfying performance. One such environment is the Beam Slider environment. For this task, many of the hand design robots fail to even achieve the first part of the goal and position themselves underneath the beam. While there is one robot produced by the genetic algorithm that does slide the beam across several pegs, from visual observation we believe it comes nowhere close to exhibiting the optimal behavior in this environment. This suggests that further work is needed in designing co-optimization algorithms that can complete these hard tasks.
170
+
171
+ # 6 Conclusion and future work
172
+
173
+ In this paper we proposed Evolution Gym, the first large-scale benchmark for evolving the structure and control of soft robots. Through the wide spectrum of tasks in Evolution Gym, we systematically studied the performance of current state-of-the-art co-design algorithms. As a result, we observed how intelligent robots could be evolved autonomously from scratch yet still be capable of accomplishing some surprisingly complex tasks. We also discovered the limitations of existing techniques for evolving more intelligent embodied systems.
174
+
175
+ There are several potential directions to be explored in the future. First, with the help of our proposed benchmark, it is desirable to develop more advanced co-design algorithms to solve the difficult tasks which existing methods cannot address. Our currently implemented baseline algorithms share a bi-level optimization routine where the design optimization is in the outer loop while the control optimization is in the inner loop. However, Evolution Gym is agnostic to the specific training procedure used. As a result, some ideas for future work using our framework could include concurrently co-optimizing the design and control, neuroevolution algorithms, morphogenetic development, gradient-based methods for design optimization, or algorithms with decentralized controllers.
176
+
177
+ Second, a robot will be considered more successful if it can perform multiple tasks. Our benchmark suite naturally provides a comprehensive set of tasks and can potentially promote more exciting research work about multi-task or multi-objective robot co-design algorithms.
178
+
179
+ Another consideration is the specific morphological encodings used by the codesign algorithms as more intelligent encodings could lead to better performance. For instance, [38] analyzes the strengths and weaknesses of different morphological encodings. Our baseline algorithms use a direct encoding and CPPN but exploring other encoding representations remains interesting future work.
180
+
181
+ Finally, since tasks in Evolution Gym are currently limited to either locomotion or manipulation, we plan to further extend Evolution Gym to additional task categories such as flying or swimming by incorporating new simulation capabilities.
182
+
183
+ Overall, we believe our carefully-designed benchmarking tool fills an important missing piece in research in soft robotics and robotic evolution algorithms. Armed with the flexible and expressive framework Evolution Gym provides, we are optimistic that future researchers will use Evolution Gym as a standard test bed to improve co-design methods and evolve more intelligent robots.
184
+
185
+ # Societal Impact
186
+
187
+ We regard this work as a very preliminary piece of research in the field of soft robot co-design, and therefore think that we are still far away from causing harm to society. However, we can definitely foresee some problems if this technology were to be applied in the real world on a large scale. For instance, this work may inspire the automatic design of real biological creatures in which serious ethical issues exist. Additionally, since the users have full control over the reward design when customizing the benchmark environments, they could specify pernicious goals and encourage the co-design algorithm to produce more biased results.
188
+
189
+ # Acknowledgments and Disclosure of Funding
190
+
191
+ We thank Tao Du and the anonymous reviewers for their helpful comments in revising the paper. This work is supported by the Defense Advanced Research Projects Agency (FA8750-20-C-0075).
192
+
193
+ # References
194
+
195
+ [1] Ilge Akkaya, Marcin Andrychowicz, Maciek Chociej, Mateusz Litwin, Bob McGrew, Arthur Petron, Alex Paino, Matthias Plappert, Glenn Powell, Raphael Ribas, et al. Solving rubik’s cube with a robot hand. arXiv preprint arXiv:1910.07113, 2019.
196
+
197
+ [2] OpenAI: Marcin Andrychowicz, Bowen Baker, Maciek Chociej, Rafal Jozefowicz, Bob McGrew, Jakub Pachocki, Arthur Petron, Matthias Plappert, Glenn Powell, Alex Ray, et al. Learning dexterous in-hand manipulation. The International Journal of Robotics Research, 39(1):3–20, 2020.
198
+ [3] Jacob Austin, Rafael Corrales-Fatou, Sofia Wyetzner, and Hod Lipson. Titan: A parallel asynchronous library for multi-agent and soft-body robotics using nvidia cuda. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 7754–7760, 2020.
199
+ [4] The GPyOpt authors. GPyOpt: A bayesian optimization framework in python. http:// github.com/SheffieldML/GPyOpt, 2016.
200
+ [5] Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym, 2016.
201
+ [6] Nicholas Cheney, Jeff Clune, and Hod Lipson. Evolved electrophysiological soft robots. In Artificial Life Conference Proceedings 14, pages 222–229. MIT Press, 2014.
202
+ [7] Nick Cheney, Robert MacCurdy, Jeff Clune, and Hod Lipson. Unshackling evolution: Evolving soft robots with multiple materials and a powerful generative encoding. SIGEVOlution, 7(1):11–23, August 2014.
203
+ [8] Francesco Corucci, Nick Cheney, Francesco Giorgio-Serchi, Josh Bongard, and Cecilia Laschi. Evolving soft locomotion in aquatic and terrestrial environments: effects of material properties and environmental transitions, 2017.
204
+ [9] Francesco Corucci, Nick Cheney, Francesco Giorgio-Serchi, Josh Bongard, and Cecilia Laschi. Evolving soft locomotion in aquatic and terrestrial environments: effects of material properties and environmental transitions. Soft robotics, 5(4):475–495, 2018.
205
+ [10] Francesco Corucci, Nick Cheney, Hod Lipson, Cecilia Laschi, and Josh Bongard. Evolving swimming soft-bodied creatures. In ALIFE XV, The Fifteenth International Conference on the Synthesis and Simulation of Living Systems, Late Breaking Proceedings, volume 6, 2016.
206
+ [11] Yan Duan, Xi Chen, Rein Houthooft, John Schulman, and Pieter Abbeel. Benchmarking deep reinforcement learning for continuous control. In International conference on machine learning, pages 1329–1338. PMLR, 2016.
207
+ [12] Christer Ericson. Real-time collision detection. CRC Press, 2004.
208
+ [13] David Ha. Reinforcement learning for improving agent design. Artificial life, 25(4):352–365, 2019.
209
+ [14] Donald J Hejna III, Pieter Abbeel, and Lerrel Pinto. Task-agnostic morphology evolution. arXiv preprint arXiv:2102.13100, 2021.
210
+ [15] Jonathan Hiller and Hod Lipson. Dynamic simulation of soft multimaterial 3d-printed objects. Soft robotics, 1(1):88–101, 2014.
211
+ [16] Zhiao Huang, Yuanming Hu, Tao Du, Siyuan Zhou, Hao Su, Joshua B. Tenenbaum, and Chuang Gan. Plasticinelab: A soft-body manipulation benchmark with differentiable physics, 2021.
212
+ [17] Jemin Hwangbo, Joonho Lee, Alexey Dosovitskiy, Dario Bellicoso, Vassilios Tsounis, Vladlen Koltun, and Marco Hutter. Learning agile and dynamic motor skills for legged robots. Science Robotics, 4(26), 2019.
213
+ [18] Kirthevasan Kandasamy, Akshay Krishnamurthy, Jeff Schneider, and Barnabás Póczos. Parallelised bayesian optimisation via thompson sampling. In International Conference on Artificial Intelligence and Statistics, pages 133–142. PMLR, 2018.
214
+ [19] Ilya Kostrikov. Pytorch implementations of reinforcement learning algorithms. https:// github.com/ikostrikov/pytorch-a2c-ppo-acktr-gail, 2018.
215
+ [20] Harold J Kushner. A new method of locating the maximum point of an arbitrary multipeak curve in the presence of noise. 1964.
216
+ [21] Thomas Liao, Grant Wang, Brian Yang, Rene Lee, Kristofer Pister, Sergey Levine, and Roberto Calandra. Data-efficient learning of morphology and controller for a microrobot. In 2019 International Conference on Robotics and Automation (ICRA), pages 2488–2494. IEEE, 2019.
217
+ [22] Alan McIntyre, Matt Kallada, Cesar G. Miguel, and Carolina Feher da Silva. neat-python. https://github.com/CodeReclaimers/neat-python.
218
+ [23] Eric Medvet, Alberto Bartoli, Andrea De Lorenzo, and Stefano Seriani. 2d-vsr-sim: A simulation tool for the optimization of 2-d voxel-based soft robots. SoftwareX, 12:100573, 2020.
219
+ [24] Zbigniew Michalewicz. Genetic algorithms $^ +$ data structures $=$ evolution programs. Springer Science & Business Media, 2013.
220
+ [25] J. Mockus. On bayesian methods for seeking the extremum. In G. I. Marchuk, editor, ˇ Optimization Techniques IFIP Technical Conference Novosibirsk, July 1–7, 1974, pages 400–404, Berlin, Heidelberg, 1975. Springer Berlin Heidelberg.
221
+ [26] Andrew Nealen, Matthias Müller, Richard Keiser, Eddy Boxerman, and Mark Carlson. Physically based deformable models in computer graphics. In Computer graphics forum, volume 25, pages 809–836. Wiley Online Library, 2006.
222
+ [27] Deepak Pathak, Chris Lu, Trevor Darrell, Phillip Isola, and Alexei A Efros. Learning to control self-assembling morphologies: a study of generalization via modularity. arXiv preprint arXiv:1902.05546, 2019.
223
+ [28] Uber Research. pytorch-neat. https://github.com/uber-research/PyTorch-NEAT.
224
+ [29] Charles Schaff, David Yunis, Ayan Chakrabarti, and Matthew R Walter. Jointly learning to construct and control agents using deep reinforcement learning. In 2019 International Conference on Robotics and Automation (ICRA), pages 9798–9805. IEEE, 2019.
225
+ [30] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms, 2017.
226
+ [31] Karl Sims. Evolving virtual creatures. In Proceedings of the 21st annual conference on Computer graphics and interactive techniques, pages 15–22, 1994.
227
+ [32] Andrew Spielberg, Allan Zhao, Yuanming Hu, Tao Du, Wojciech Matusik, and Daniela Rus. Learning-in-the-loop optimization: End-to-end control and co-design of soft robots through learned deep latent representations. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché- Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019.
228
+ [33] Kenneth O Stanley. Compositional pattern producing networks: A novel abstraction of development. Genetic programming and evolvable machines, 8(2):131–162, 2007.
229
+ [34] Kenneth O Stanley and Risto Miikkulainen. Evolving neural networks through augmenting topologies. Evolutionary computation, 10(2):99–127, 2002.
230
+ [35] Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018.
231
+ [36] Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdolmaleki, Josh Merel, Andrew Lefrancq, Timothy Lillicrap, and Martin Riedmiller. Deepmind control suite, 2018.
232
+ [37] Merel Van Diepen and Kristina Shea. A spatial grammar method for the computational design synthesis of virtual soft locomotion robots. Journal of Mechanical Design, 141(10), 2019.
233
+ [38] Frank Veenstra and Kyrre Glette. How different encodings affect performance and diversification when evolving the morphology and control of 2d virtual creatures. In Artificial Life Conference Proceedings, pages 592–601. MIT Press, 2020.
234
+ [39] Tingwu Wang, Yuhao Zhou, Sanja Fidler, and Jimmy Ba. Neural graph evolution: Towards efficient automatic robot design, 2019.
235
+ [40] Fei Xia, Amir R Zamir, Zhiyang He, Alexander Sax, Jitendra Malik, and Silvio Savarese. Gibson env: Real-world perception for embodied agents. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 9068–9079, 2018.
236
+ [41] Allan Zhao, Jie Xu, Mina Konakovic-Lukovi ´ c, Josephine Hughes, Andrew Spielberg, Daniela ´ Rus, and Wojciech Matusik. Robogrammar: Graph grammar for terrain-optimized robot design. ACM Trans. Graph., 39(6), November 2020.
237
+
238
+ # Checklist
239
+
240
+ 1. For all authors...
241
+
242
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
243
+ (b) Did you describe the limitations of your work? [Yes] See Section 6.
244
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 6.
245
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
246
+
247
+ 2. If you are including theoretical results...
248
+
249
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
250
+
251
+ 3. If you ran experiments...
252
+
253
+ (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] The URL is presented in the abstract.
254
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix D.
255
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We ran experiments with multiple random seeds and reported error bars. See Section 5.
256
+ (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 5.
257
+
258
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
259
+
260
+ (a) If your work uses existing assets, did you cite the creators? [Yes] The existing code implementation for our baseline algorithms are cited in Section 4.
261
+ (b) Did you mention the license of the assets? [Yes] This benchmark platform will be released under the MIT license. See Section 1.
262
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] The URL is presented in the abstract.
263
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
264
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
265
+
266
+ 5. If you used crowdsourcing or conducted research with human subjects...
267
+
268
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
269
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
270
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/train/q8qLAbQBupm/q8qLAbQBupm.md ADDED
The diff for this file is too large to render. See raw diff
 
md/train/r1lZgyBYwS/r1lZgyBYwS.md ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HILLOC: LOSSLESS IMAGE COMPRESSION WITH HIERARCHICAL LATENT VARIABLE MODELS
2
+
3
+ James Townsend∗, Thomas Bird∗, Julius Kunze & David Barber
4
+
5
+ Department of Computer Science University College London <firstname>.<surname>@cs.ucl.ac.uk
6
+
7
+ # ABSTRACT
8
+
9
+ We make the following striking observation: fully convolutional VAE models trained on $3 2 \times 3 2$ ImageNet can generalize well, not just to $6 4 \times 6 4$ but also to far larger photographs, with no changes to the model. We use this property, applying fully convolutional models to lossless compression, demonstrating a method to scale the VAE-based ‘Bits-Back with ANS’ algorithm for lossless compression (Townsend et al., 2019) to large color photographs, and achieving state of the art for compression of full size ImageNet images. We release Craystack, an open source library for convenient prototyping of lossless compression using probabilistic models, along with full implementations of all of our compression results1.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Bits back coding (Wallace, 1990; Hinton & van Camp, 1993) is a method for performing lossless compression using a latent variable model. In an ideal implementation, the method can achieve an expected message length equal to the variational free energy, often referred to as the negative evidence lower bound (ELBO) of the model. Bits back was first introduced to form a theoretical argument for using the ELBO as an objective function for machine learning (Hinton & van Camp, 1993).
14
+
15
+ The first implementation of bits back coding (Frey, 1997; Frey & Hinton, 1996) made use of first-infirst-out (FIFO) arithmetic coding (AC) (Witten et al., 1987). However, the implementation did not achieve optimal compression, due to an incompatibility between a FIFO coder and bits back coding, and its use was only demonstrated on a small dataset of $8 \times 8$ binary images.
16
+
17
+ Recently, zero-overhead bits back compression with a significantly simpler implementation has been developed by Townsend et al. (2019). This implementation makes use of asymmetric numeral systems (ANS), a last-in-first-out (LIFO) entropy coding scheme (Duda, 2009). The method, known as ‘Bits Back with Asymmetric Numeral Systems’ (BB-ANS) was demonstrated by compressing the MNIST test set using a variational auto-encoder (VAE) model (Kingma & Welling, 2013; Rezende et al., 2014), achieving a compression rate within $1 \%$ of the model ELBO.
18
+
19
+ More recently, Hoogeboom et al. (2019) and Ho et al. (2019) have proposed flow-based methods for lossless compression, and Kingma et al. (2019) have presented ‘Bit-Swap’, extending BB-ANS to hierarchical models. In this work we present an alternative method for extending to hierarchical VAEs. This entails the following novel techniques:
20
+
21
+ 1. Direct coding of arbitrary sized images using a fully convolutional model.
22
+ 2. A vectorized ANS implementation supporting dynamic shape.
23
+ 3. Dynamic discretization to avoid having to calibrate a static discretization.
24
+ 4. Initializing the bits back chain using a different codec.
25
+
26
+ We discuss each of these contributions in detail in Section 3. We call the combination of BB-ANS using a hierarchical latent variable model and the above techniques: ‘Hierarchical Latent Lossless
27
+
28
+ ![](images/53a3ea46390b1219edc9189a33bf7eff0f9e303b75a6636748c5f743d57cfeff.jpg)
29
+ Figure 1: A selection of images from the ImageNet dataset and the compression rates achieved on the dataset by PNG, WebP, FLIF, Bit-Swap and the HiLLoC codec (with ResNet VAE) presented in this work.
30
+
31
+ Compression’ (HiLLoC). In our experiments (Section 4), we demonstrate that HiLLoC can be used to compress color images from the ImageNet test set at rates close to the ELBO, outperforming all of the other codecs which we benchmark. We also demonstrate the speedup, of nearly three orders of magnitude, resulting from vectorization. We release an open source implementation based on ‘Craystack’, a Python package which we have written for general prototyping of lossless compression with ANS.
32
+
33
+ # 2 BACKGROUND
34
+
35
+ In this section we briefly describe the BB-ANS algorithm first introduced by Townsend et al. (2019). We begin by giving a high-level description of the ANS LIFO entropy coder (Duda, 2009), along with a new notation for describing the basic ANS operations. Throughout the rest of the paper we use log to mean the base two logarithm, usually denoted $\log _ { 2 }$ , and we measure message lengths in bits.
36
+
37
+ # 2.1 ASYMMETRIC NUMERAL SYSTEMS
38
+
39
+ As an entropy coder, ANS was designed for compressing sequences of discretely distributed symbols. It achieves a compressed message length equal to the negative log-probability (information content) of the sequence plus an implementation dependent constant, which is usually less than 32 bits. For long sequences, the constant overhead has a negligible contribution to the overall compression rate. Thus, by Shannon’s source coding theorem (Shannon, 1948), ANS coding is guaranteed to be near-optimal for long sequences.
40
+
41
+ There are two basic operations defined by ANS, which we will refer to as ‘push’ and ‘pop’. Push encodes a symbol by adding it to an existing message. It has the signature
42
+
43
+ $$
44
+ \mathrm { p u s h } : \left( \mathrm { m e s s a g e } , \mathrm { s y m b o l } \right) \mapsto \mathrm { m e s s a g e } ^ { \prime } .
45
+ $$
46
+
47
+ Pop is the inverse of push, and may be used to decode a symbol and recover a message identical to that before pushing.
48
+
49
+ $$
50
+ \mathrm { p o p : m e s s a g e ^ { \prime } \mapsto ( m e s s a g e , s y m b o l ) . }
51
+ $$
52
+
53
+ When multiple symbols are pushed in sequence, they must be popped using the precise inverse procedure, which means popping the symbols in the opposite order. Hence why ANS is referred to as a last-in-first-out coder, or a stack.
54
+
55
+ The push and pop operations require access to a probabilistic model of symbols, summarized by a probability mass function $p$ over the alphabet of possible symbols. The way that symbols are encoded depends on the model, and pushing a symbol $s$ according to $p$ results in an increase in message length of log $\displaystyle \frac { 1 } { p ( s ) }$ . Popping $s$ results in an equal reduction in message length. For details on how the ANS operations are implemented, see Duda (2009).
56
+
57
+ Note that any model/mass function can be used for the pop operation, i.e. there’s no hard restriction to use the distribution that was used to encode the message. In this way, rather than decoding the same data that was encoded, pop can actually be used to sample a symbol from a different distribution. The pop method itself is deterministic, so the source of randomness for the sample comes from the data contained within the message. This sampling operation, which can be inverted by pushing the sample back onto the stack, is essential for bits back coding.
58
+
59
+ For convenience, we introduce the shorthand notation $s \to p ( \cdot )$ for encoding (pushing) a symbol $s$ according to $p$ , and $s \gets p ( \cdot )$ for decoding (popping).
60
+
61
+ # 2.2 BITS BACK WITH ANS
62
+
63
+ Suppose we have a model for data $x$ which involves a latent variable $z$ . A sender and receiver wish to communicate a sample $x$ . They have access to a prior on $z$ , denoted $p ( z )$ , a likelihood $p ( x \mid z )$ and a (possibly approximate) posterior $q ( \boldsymbol { z } \mid \boldsymbol { x } )$ , but not the marginal distribution $p ( x )$ . Without access to $p ( x )$ , sender and receiver cannot directly code $x$ using ANS. However, BB-ANS specifies an indirect way to push and pop $x$ . It does not require access to the marginal $p ( x )$ , but rather uses the prior, conditional, and posterior from the latent variable model.
64
+
65
+ Table 1(a) shows, in order from the top, the three steps of the BB-ANS pushing procedure which the sender can perform to encode $x$ . The ‘Variables’ column shows the variables known to the sender before each step. 1(b) shows the inverse steps which the receiver can use to pop $x$ , with the ‘Variables’ column showing what is known to the receiver after each step. After decoding $x$ , the third step of popping, $z \to q ( \cdot | x )$ , is necessary to ensure that BB-ANS pop is a precise inverse of push.
66
+
67
+ Table 1: Indirectly pushing and popping $x$ using BB-ANS. and denote pushing and popping respectively. $\Delta L$ denotes the change in message length resulting from each operation. The three steps to push/pop are ordered, starting at the top of the table and descending.
68
+
69
+ <table><tr><td colspan="3">(a) Pushing x</td><td colspan="3">(b) Popping x</td></tr><tr><td>Variables</td><td>Operation</td><td>△L</td><td>Operation</td><td>Variables</td><td>△L</td></tr><tr><td>x</td><td>z←q(-|x)</td><td>-log 1 q(x)</td><td>2←p(-)</td><td>2</td><td>-log 1 p(</td></tr><tr><td>x,z</td><td>x→p(-|z)</td><td>+l0gp(x12) 1</td><td>x ←p(-|z)</td><td>x,z</td><td>-logp(x12) 1</td></tr><tr><td>2</td><td>z→p()</td><td>+l0gp( 1</td><td>→q(-|x)x</td><td></td><td>+log 1 q(21x)</td></tr></table>
70
+
71
+ The change in message length from BB-ANS can easily be derived by adding up the quantities in the $\Delta L$ column of Table 1. For encoding we get
72
+
73
+ $$
74
+ \begin{array} { l } { \Delta L _ { \mathrm { B B - A N S } } = - \log \displaystyle \frac { 1 } { q ( { \boldsymbol z } \mid { \boldsymbol x } ) } + \log \displaystyle \frac { 1 } { p ( { \boldsymbol x } \mid { \boldsymbol z } ) } + \log \displaystyle \frac { 1 } { p ( { \boldsymbol z } ) } } \\ { = - \log \displaystyle \frac { p ( { \boldsymbol x } , { \boldsymbol z } ) } { q ( { \boldsymbol z } \mid { \boldsymbol x } ) } . } \end{array}
75
+ $$
76
+
77
+ Taking the expectation over $z$ gives the expected message length for a datum $x$
78
+
79
+ $$
80
+ { \mathcal { L } } ( x ) = - \mathbb { E } _ { q ( z \mid x ) } \left[ \log { \frac { p ( x , z ) } { q ( z \mid x ) } } \right]
81
+ $$
82
+
83
+ which is the negative evidence lower bound (ELBO), also known as the free energy. This is a commonly used training objective for latent variable models. The above equation implies that latent variable models trained using the ELBO are implicitly being trained to minimize the expected message length of lossless compression using BB-ANS.
84
+
85
+ Note that, as Table 1 shows, the first step of encoding a data point, $x$ , using BB-ANS is to, counterintuitively, decode (and thereby sample) a latent $z \bar { } q ( \cdot | x )$ . This requires that there is already a buffer of random data pushed to the ANS coder, which can be popped. This data used to start the encoding process is recovered after the final stage of decoding, hence the name ‘bits back’.
86
+
87
+ If we have multiple samples to compress, then we can use ‘chaining’, which is essentially repeated application of the procedure in Table 1 (Townsend et al., 2019). In Section 3.4 we describe how we build up an initial buffer of compressed data by using a different codec to code the first images in a sequence.
88
+
89
+ ![](images/5995fcbe35b1f559fb566f5c563d6ca684a64eeb31a37c66cc444cf4b91ef3d3.jpg)
90
+ Figure 2: Visualizing the process of pushing images and latents from a VAE to the vectorized ANS stack with Craystack. The ANS stack head is shaped such that images and latents can be pushed and popped in parallel, without reshaping. Beneath the shaped top of the stack is the flat message stream output by ANS.
91
+
92
+ # 3 SCALING UP BITS BACK WITH ANS
93
+
94
+ We now discuss the techniques we introduce to scale up BB-ANS.
95
+
96
+ # 3.1 FULLY CONVOLUTIONAL MODELS
97
+
98
+ When all of the layers in the generative and recognition networks of a VAE are either convolutional or elementwise functions (i.e. the VAE has no densely connected layers), then it is possible to evaluate the recognition network on images of any height and width, and similarly to pass latents of any height and width through the generative network to generate an image. Thus, such a VAE can be used as a (probabilistic) model for images of any size.
99
+
100
+ We exploit this fact, and show empirically in Section 4 that, surprisingly, a fully convolutional VAE trained on $3 2 \times 3 2$ images can perform well (in the sense of having a high ELBO) as a model for 64 $\times 6 4$ images as well as far larger images. This in turn corresponds to a good compression rate, and we implement lossless compression of arbitrary sized images by using a VAE in this way.
101
+
102
+ # 3.2 VECTORIZED LOSSLESS COMPRESSION
103
+
104
+ The primary computational bottlenecks in the original BB-ANS implementation (Townsend et al., 2019) were loops over data and latent variables occurring in the Python interpreter. We have been able to vectorize these, achieving an implementation which can scale to large ImageNet images. The effect of vectorization on runtime is shown in Figure 4.
105
+
106
+ A vectorized implementation of ANS was described in Giesen (2014) using SIMD instructions. This works by expanding the size of the ANS stack head, from a scalar to a vector, and interleaving the output/input bit stream. We implement this in our lossless compression library, Craystack, using Numpy. Please refer to the Craystack code and to Giesen (2014) for more detail. We ensure that the compression rate overhead to vectorization is low by using the BitKnit technique described in Giesen (2015), see Appendix D for more detail. Having vectorized, we found that most of the compute time for our compression was spent in neural net inference, whether running on CPU or GPU, which we know to already be reasonably well optimized.
107
+
108
+ In Craystack, we further generalize the ANS coder using Numpy’s n-dimensional array view interface, allowing the stack head to be ‘shaped’ like an n-dimensional array, or a nested Python data-structure containing arrays. We can then use a shape which fits that of the data that we wish to encode or decode. When coding data according to a VAE we use an ANS stack head shaped into a pair of arrays, matching the shapes of the observation $x$ and the latent $z$ . This allows for a straightforward implementation and clarifies the lack of data dependence between certain operations, such as the $x \to p ( \cdot | z )$ and $z p ( \cdot )$ during encoding, which can theoretically be performed concurrently. This vectorized encoding process is visualized in Figure 2.
109
+
110
+ # 3.3 DISCRETIZATION
111
+
112
+ It is standard for state of the art latent variable models to use continuous latent variables. Since ANS operates over discrete probability distributions, if we wish to use BB-ANS with such models it is necessary to discretize the latent space so that latent samples can be communicated. Townsend et al. (2019) described a static discretization scheme for the latents in a simple VAE with a single layer of continuous latent variables, and showed that this discretization has a negligible impact on compression rate. The addition of multiple layers of stochastic variables to a VAE has been shown to improve performance (Kingma et al., 2019; Kingma et al., 2016; Maaløe et al., 2019; Sønderby et al., 2016). Motivated by this, we propose a discretization scheme for hierarchical VAEs with multiple layers of latent variables.
113
+
114
+ The discretization described in Townsend et al. (2019) is formed by dividing the latent space into intervals of equal mass under the prior $p ( z )$ . For a hierarchical model, the prior on each layer depends on the previous layers:
115
+
116
+ $$
117
+ p ( z _ { 1 : L } ) = p ( z _ { L } ) \prod _ { l = 1 } ^ { L - 1 } p ( z _ { l } \mid z _ { l + 1 : L } ) .
118
+ $$
119
+
120
+ It isn’t immediately possible to use the simple static scheme from Townsend et al. (2019), since the marginals $p ( z _ { 1 } ) , \dots , p ( z _ { L - 1 } )$ are not known. Kingma et al. (2019) estimate these marginals by sampling, and create static bins based on the estimates. They demonstrate that this approach can work well. We propose an alternative approach, allowing the discretization to vary with the context of the latents we are trying to code. We refer to our approach as dynamic discretization.
121
+
122
+ In dynamic discretization, instead of discretizing with respect to the marginals of the prior, we discretize according to the conditionals in the prior, $p \big ( \boldsymbol { z } _ { l } \mid \boldsymbol { z } _ { l + 1 : L } \big )$ . Specifically, for each latent layer $l$ we partition each dimension into intervals which have equal probability mass under the conditional $p \big ( z _ { l } \big | z _ { l + 1 : L } \big )$ . This directly generalizes the scheme used in BB-ANS (Townsend et al., 2019).
123
+
124
+ Dynamic discretization is more straightforward to implement because it doesn’t require callibrating the discretization to samples. However it imposes a restriction on model structure, in particular it requires that posterior inference is done top-down. This precludes the use of Bit-Swap. In Section 3.3.1 we contrast the model restriction from dynamic discretization with the bottom-up, Markov restriction imposed by Bit-Swap itself.
125
+
126
+ We give further details about the dynamic discretization implementation we use in Appendix A.
127
+
128
+ # 3.3.1 MODEL RESTRICTIONS
129
+
130
+ ![](images/5cd683ca8e3e562acc905b2b6e32b4270672593d0e1630e8b6ad4f7b468c065f.jpg)
131
+ Figure 3: Graphical models representing the generative and inference models with HiLLoC and Bit-Swap, both using a 3 layer latent hierarchy. The dashed lines indicate dependence on the fixed observation.
132
+
133
+ The first stage of BB-ANS encoding is to pop from the posterior, $z _ { 1 : L } \gets q ( \cdot | x )$ . When using dynamic discretization, popping the layer $z _ { l }$ requires knowledge of the discretization used for $z _ { l }$ and
134
+
135
+ thus of the conditional distribution $p \big ( z _ { l } \mid z _ { l + 1 : L } \big )$ . This requires the latents $z _ { l + 1 : L }$ to have already been popped. Because of this, latents in general must be popped (sampled) in ‘top-down’ order, i.e. $z _ { L }$ first, then $z _ { L - 1 }$ and so on down to $z _ { 1 }$ .
136
+
137
+ The most general form of posterior for which top-down sampling is possible is
138
+
139
+ $$
140
+ q ( z _ { 1 : L } \mid x ) = q ( z _ { L } \mid x ) \prod _ { l = 1 } ^ { L - 1 } q ( z _ { l } \mid z _ { l + 1 : L } , x ) .
141
+ $$
142
+
143
+ This is illustrated, for a hierarchy of depth 3, in Figure 3b. The Bit-Swap technique (Kingma et al., 2019) requires that inference be done bottom up, and that generative and inference models must both be a Markov chain on $z _ { 1 } , \dots , z _ { L }$ , and thus cannot use skip connections. These constraints are illustrated in Figure 3c,d. Skip connections have been shown to improve model ELBO in very deep models (Sønderby et al., 2016; Maaløe et al., 2019). HiLLoC does not have this constraint, and we do utilize skip connections in our experiments.
144
+
145
+ # 3.4 STARTING THE BITS BACK CHAIN
146
+
147
+ As discussed in Section 3.3, our dynamic discretization method precludes the use of Bit-Swap for reducing the one-time cost of starting a BB-ANS chain. We propose instead to use a significantly simpler method to address the high cost of coding a small number of samples with BB-ANS, namely we code the first samples using a different codec. The purpose of this is to build up a sufficiently large buffer of compressed data to permit the first stage of the BB-ANS algorithm - to pop a latent sample from the posterior. In our experiments we use the ‘Free Lossless Image Format’ (FLIF) (Sneyers & Wuille, 2016) to build up the buffer. We chose this codec because it performed better than other widely used codecs, but in principal any lossless codec could be used.
148
+
149
+ The amount of previously compressed data required to pop a posterior sample from the ANS stack (and therefore start the BB-ANS chain) is roughly proportional to the size of the image we wish to compress, since in a fully convolutional model the size of the latent space is determined by the image size.
150
+
151
+ We can exploit this to allow us to obtain a better compression rate than FLIF as quickly as possible. We do so by partitioning the first images we wish to compress with HiLLoC into smaller patches. These patches require a smaller data buffer, and thus we can use the superior HiLLoC coding sooner than if we attempted to compress full images. We find experimentally that, generally, larger patches have a better coding rate than smaller patches. Therefore we increase the size of the image patches being compressed with HiLLoC as more images are compressed and the size of the data buffer grows, until we finally compress full images once the buffer is sufficiently large. For our experiments on compressing full ImageNet images, we compress $3 2 \times 3 2$ patches, then $6 4 \times 6 4$ , then $1 2 8 \times 1 2 8$ before switching to coding the full size images directly. Note that since our model can compress any shape image, we can compress the edge patches which will have different shape if the patch size does not divide the image dimensions exactly. Using this technique means that our coding rate improves gradually from the FLIF coding rate towards the coding rate achieved by HiLLoC on full images. We compress only 5 ImageNet images using FLIF before we start compressing $3 2 \times 3 2$ patches using HiLLoC.
152
+
153
+ # 4 EXPERIMENTAL RESULTS
154
+
155
+ Using Craystack, we implement HiLLoC with a ResNet VAE (RVAE) (Kingma et al., 2016). This powerful hierarchical latent variable model achieves ELBOs comparable to state of the art autoregressive models2. In all experiments we used an RVAE with 24 stochastic hidden layers. The RVAE utilizes skip connections, which are important to be able to effectively train models with such a deep latent hierarchy. See Appendix E for more details.
156
+
157
+ We trained the RVAE on the ImageNet 32 training set, then evaluated the RVAE ELBO and HiLLoC compression rate on the ImageNet 32 test set. To test generalization, we also evaluated the ELBO and compression rate on the tests sets of ImageNet64, CIFAR10 and full size ImageNet. For full size ImageNet, we used the partitioning method described in 3.4. The results are shown in Table 2.
158
+
159
+ For HiLLoC the compression rates are for the entire test set, except for full ImageNet, where we use 2000 random images from the test set.
160
+
161
+ Table 2: Compression performance of HiLLoC with RVAE compared to other codecs. Rates measured in bits/dimension (raw data is 8 bits/dimension). For HiLLoC we display compression rate and theoretical performance (ELBO). All HiLLoC results are obtained from the same model, trained on ImageNet 32.
162
+
163
+ <table><tr><td colspan="2"></td><td>ImageNet 32</td><td>ImageNet 64</td><td>Cifar-10</td><td>ImageNet</td></tr><tr><td rowspan="3">Generic</td><td>PNG</td><td>6.39</td><td>5.71</td><td>5.87</td><td>4.71</td></tr><tr><td>WebP</td><td>5.29</td><td>4.64</td><td>4.61</td><td>3.66</td></tr><tr><td>FLIF</td><td>4.52</td><td>4.19</td><td>4.19</td><td>3.37</td></tr><tr><td rowspan="3">Flow-based</td><td>IDF3</td><td>4.18</td><td>3.90</td><td>3.34</td><td>1</td></tr><tr><td> IDF generalized4</td><td>4.18</td><td>3.94</td><td>3.60</td><td></td></tr><tr><td>LBB</td><td>3.88</td><td>3.70</td><td>3.12</td><td>=</td></tr><tr><td rowspan="3">VAE-based</td><td>Bit-Swap</td><td>4.50</td><td>1</td><td>3.82</td><td>3.516</td></tr><tr><td>HiLLoC</td><td>4.20</td><td>3.90</td><td>3.56</td><td>3.15</td></tr><tr><td>HiLLoC (ELBO)</td><td>(4.18)</td><td>(3.89)</td><td>(3.55)</td><td>(3.14)</td></tr></table>
164
+
165
+ Table 2 shows that HiLLoC achieves competitive compression rates on all benchmarks, and state of the art on full size ImageNet images. The fact that HiLLoC can achieve state of the art compression on ImageNet relative to the baselines, even under a change of distribution, is striking. This provides strong evidence of its efficacy as a general method for lossless compression of natural images. Naively, one might expect a degradation of performance relative to the original test set when changing the test distribution—even more so when the resolution changes. However, in the settings we studied, the opposite was true, in that the average per-pixel ELBO (and thus the compressed message length) was lower on all other datasets compared to the ImageNet 32 validation set.
166
+
167
+ In the case of CIFAR, we conjecture that the reason for this is that its images are simpler and contain more redundancy than ImageNet. This theory is backed up by the performance of standard compression algorithms which, as shown in Table 2, also perform better on CIFAR images than they do on ImageNet 32. We find the compression rate improvement on larger images more surprising. We hypothesize that this is because pixels at the edge of an image are harder to model because they have less context to reduce uncertainty. The ratio of edge pixels to interior pixels is lower for larger images, thus we might expect less uncertainty per pixel in a larger image.
168
+
169
+ To demonstrate the effect of vectorization we timed ANS of single images at different, fixed, sizes, using a fully vectorized and a fully serial implementation. The results are shown in Figure 4, which clearly shows a speedup of nearly three orders of magnitude for all image sizes. We find that the run times for encoding and decoding are roughly linear in the number of pixels, and the time to compress an average sized ImageNet image of $5 0 0 \times 3 7 4$ pixels (with vectorized ANS) is around 29s on a desktop computer with 6 CPU cores and a GTX 1060 GPU.
170
+
171
+ # 5 DISCUSSION
172
+
173
+ Our experiments demonstrate HiLLoC as a bridge between large scale latent variable models and compression. To do this we use simple variants of pre-existing VAE models. Having shown that bits back coding is flexible enough to compress well with large, complex models, we see plenty of work still to be done in searching model structures (i.e. architecture search), optimizing with a trade-off between compression rate, encode/decode time and memory usage. Particularly pertinent for HiLLoC is latent dimensionality, since compute time and memory usage both scale with this. Since the model must be stored/transmitted to use HiLLoC, weight compression is also highly relevant. This is a well-established research area in machine learning (Han et al., 2016; Ullrich et al., 2017).
174
+
175
+ ![](images/0aaca877eccf26d2edd08745b3eabab37ccddddb8c673f0d8034be6cdb262052.jpg)
176
+ Figure 4: Runtime of vectorized vs. serial ANS implementations. Times were computed on a desktop with 6 CPU cores and a GTX 1060 GPU.
177
+
178
+ Our experiments also demonstrated that one can achieve good performance on a dataset of large images by training on smaller images. This result is promising, but future work should be done to discover what the best training datasets are for coding generic images. One question in particular is whether results could be improved by training on larger images and/or images of varying size. We leave this to future work. Another related direction for improvement is batch compression of images of different sizes using masking, analogous to how samples of different length may be processed in batches by recurrent neural nets.
179
+
180
+ Whilst this work has focused on latent variable models, there is also promise in applying state of the art fully observed auto-regressive models to lossless compression. We look forward to future work investigating the performance of models such as WaveNet (van den Oord et al., 2016) for lossless audio compression as well as $\mathrm { P i x e l C N N + + }$ (Salimans et al., 2017) and the state of the art models in Menick & Kalchbrenner (2019) for images. Sampling speed for these models, and thus decompression, scales with autoregressive sequence length, and can be very slow. This could be a serious limitation, particularly in common applications where encoding is performed once but decoding is performed many times. This effect can be mitigated by using dynamic programming (Le Paine et al., 2016; Ramachandran et al., 2017), and altering model architecture (Reed et al., 2017), but on parallel architectures sampling/decompression is still significantly slower than with VAE models.
181
+
182
+ On the other hand, fully observed models, as well as the flow based models of Hoogeboom et al. (2019) and Ho et al. (2019), do not require bits back coding, and therefore do not have to pay the one-off cost of starting a chain. Therefore they may be well suited to situations where one or a few i.i.d. samples are to be communicated. Similar to the way that we use FLIF to code the first images for our experiments, one could initially code images using a fully observed model then switch to a faster latent variable model once a stack of bits has been built up.
183
+
184
+ # 6 CONCLUSION
185
+
186
+ We presented HiLLoC, an extension of BB-ANS to hierarchical latent variable models, and show that HiLLoC can perform well with large models. We open-sourced our implementation, along with the Craystack package for prototyping lossless compression.
187
+
188
+ We have also explored generalization of large VAE models, and established that fully convolutional VAEs can generalize well to other datasets, including images of very different size to those they were trained on. We have described how to compress images of arbitrary size with HiLLoC, achieving a compression rate superior to the best available codecs on ImageNet images. We look forward to future work reuniting machine learning and lossless compression.
189
+
190
+ # ACKNOWLEDGMENTS
191
+
192
+ We thank Paul Rubenstein for the substantial constructive feedback and advice which he gave us. We also thank the anonymous reviewers for their feedback. This work was supported by the Alan Turing Institute under the EPSRC grant EP/N510129/1.
193
+
194
+ REFERENCES
195
+ C. Bloom. Understanding ans - 9. http://cbloomrants.blogspot.com/2014/02/ 02-10-14-understanding-ans-9.html, 2014. Accessed: 2019-05-22.
196
+ J. Duda. Asymmetric numeral systems. ArXiv e-prints, 2009.
197
+ B. Frey. Bayesian networks for pattern classification, data compression, and channel coding. PhD thesis, University of Toronto, 1997.
198
+ B. Frey and G. Hinton. Free energy coding. In Proceedings of the Data Compression Conference, 1996.
199
+ F. Giesen. Interleaved entropy coders. ArXiv e-prints, 2014.
200
+ F. Giesen. rANS in practice. https://fgiesen.wordpress.com/2015/12/21/ rans-in-practice/, 2015. Accessed: 2019-05-22.
201
+ S. Han, H. Mao, and W. Dally. Deep compression: compressing deep neural networks with pruning, trained quantization and huffman coding. In Proceedings of the International Conference on Learning Representations (ICLR), 2016.
202
+ G. Hinton and D. van Camp. Keeping neural networks simple by minimizing the description length of the weights. In Proceedings of the Sixth Annual Conference on Computational Learning Theory (COLT), 1993.
203
+ J. Ho, E. Lohn, and P. Abbeel. Compression with Flows via Local Bits-Back Coding. In Advances in Neural Information Processing Systems (NIPS), 2019.
204
+ E. Hoogeboom, J. W. T. Peters, R. van den Berg, and M. Welling. Integer Discrete Flows and Lossless Compression. In Advances in Neural Information Processing Systems (NIPS), 2019.
205
+ D. P. Kingma and M. Welling. Auto-encoding variational Bayes. In Proceedings of the International Conference on Learning Representations (ICLR), 2013.
206
+ D. P. Kingma, T. Salimans, R. Jozefowicz, X. Chen, I. Sutskever, and M. Welling. Improved variational inference with inverse autoregressive flow. In Advances in Neural Information Processing Systems (NIPS), 2016.
207
+ F. H. Kingma, P. Abbeel, and J. Ho. Bit-Swap: recursive bits-back coding for lossless compression with hierarchical latent variables. In International Conference on Machine Learning (ICML), 2019.
208
+ T. Le Paine, P. Khorrami, S. Chang, Y. Zhang, P. Ramachandran, M. A. Hasegawa-Johnson, and T. S. Huang. Fast Wavenet generation algorithm. ArXiv e-prints, 2016.
209
+ L. Maaløe, M. Fraccaro, V. Liévin, and O. Winther. BIVA: a very deep hierarchy of latent variables for generative modeling. ArXiv e-prints, 2019.
210
+ J. Menick and N. Kalchbrenner. Generating high fidelity images with subscale pixel networks and multidimensional upscaling. In Proceedings of the International Conference on Learning Representations (ICLR), 2019.
211
+ P. Ramachandran, T. Le Paine, P. Khorrami, M. Babaeizadeh, S. Chang, Y. Zhang, M. A. HasegawaJohnson, R. H. Campbell, and T. S. Huang. Fast generation for convolutional autoregressive models. ArXiv e-prints, 2017.
212
+ S. Reed, A. van den Oord, N. Kalchbrenner, S. Gómez Colmenarejo, Z. Wang, D. Belov, and N. de Freitas. Parallel multiscale autoregressive density estimation. In International Conference on Machine Learning (ICML), 2017.
213
+ D. J. Rezende, S. Mohamed, and D. Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In International Conference on Machine Learning (ICML), 2014.
214
+ T. Salimans, A. Karpathy, X. Chen, and D. P. Kingma. Pixelcnn $^ { + + }$ : improving the pixelcnn with discretized logistic mixture likelihood and other modifications. In Proceedings of the International Conference on Learning Representations (ICLR), 2017.
215
+ C. Shannon. A mathematical theory of communication. Bell System Technical Journal, 27, 1948.
216
+ J. Sneyers and P. Wuille. FLIF: Free lossless image format based on maniac compression. In IEEE International Conference on Image Processing (ICIP), 2016.
217
+ C. K. Sønderby, T. Raiko, L. Maaløe, S. K. Sønderby, and O. Winther. Ladder variational autoencoders. In Advances in Neural Information Processing Systems (NIPS), 2016.
218
+ J. Townsend, T. Bird, and D. Barber. Practical lossless compression with latent variables using bits back coding. In Proceedings of the International Conference on Learning Representations (ICLR), 2019.
219
+ K. Ullrich, E. Meeds, and M. Welling. Soft weight-sharing for neural network compression. In Proceedings of the International Conference on Learning Representations (ICLR), 2017.
220
+ A. van den Oord, S. Dieleman, H. Zen, K. Simonyan, O. Vinyals, A. Graves, N. Kalchbrenner, A. Senior, and K. Kavukcuoglu. WaveNet: a generative model for raw audio. ArXiv e-prints, 2016.
221
+ C. S. Wallace. Classification by minimum-message-length inference. In Proceedings of the International Conference on Advances in Computing and Information (ICCI), 1990.
222
+ I. Witten, R. Neal, and J. Cleary. Arithmetic coding for data compression. Communications of the ACM, 30(6), 1987.
223
+
224
+ # A REPARAMETERIZING DISCRETIZED LATENTS
225
+
226
+ After discretizing the latent space, the latent variable at layer $l$ can be treated as simply an index $i _ { l }$ into one of the intervals created by the discretization. As such, we introduce the following notation for pushing and popping according to a discretized version of the posterior.
227
+
228
+ $$
229
+ i _ { l } Q _ { l } ( \cdot | i _ { l + 1 : L } , x )
230
+ $$
231
+
232
+ Where $Q _ { l } \big ( \cdot \mid i _ { l + 1 : L } , x \big )$ is the distribution over the intervals of the discretized latent space for $z _ { l }$ with interval masses equal to their probability under $q \big ( z _ { l } \big | \tilde { z } _ { l + 1 : L } , x \big )$ . The discretization is created from splitting the latent space into equal mass intervals under $p \big ( \boldsymbol { z } _ { l } \mid \tilde { \boldsymbol { z } } _ { l + 1 : L } \big )$ . The mass of a given interval under some distribution is the CDF at the upper bound of the interval minus the CDF at the lower end of the interval. We have used $\tilde { z }$ to indicate that these will be discrete $z _ { l }$ values that are reconstructed from the indices $i _ { l }$ . In practise we take $\tilde { z } _ { l } ( i _ { l } )$ to be the centre of the interval indexed by $i _ { l }$ . It is important to note that the $Q _ { l }$ has an implicit dependence on the previous prior distributions $p ( \boldsymbol { z } _ { k } | \boldsymbol { z } _ { k + 1 : L } )$ for $k \geq l$ , as these prior distributions are required to calculate $\tilde { z } _ { l + 1 : L }$ and the discretization of the latent space.
233
+
234
+ Since we discretize each latent layer to be intervals of equal mass under the prior, the prior distribution over the indices $i _ { l }$ becomes a uniform distribution over the interval indices, $U ( i _ { l } )$ , which is not dependent on $i _ { \neq l }$ . Note that this allows us to push/pop the $i _ { l }$ according to the prior in parallel. The full encoding and decoding procedures with a hierarchical latent model and the dynamic discretization we have described are shown in Table 3. Note that the operations in the two tables are ordered top to bottom.
235
+
236
+ <table><tr><td>Variables</td><td colspan="3"> Operation</td><td colspan="2">Operation</td><td></td><td>Variables</td></tr><tr><td>x</td><td>iL</td><td></td><td>←Qr(-|x)</td><td>i1:L</td><td>↑</td><td>U()</td><td>i1:L</td><td></td></tr><tr><td>x,iL</td><td></td><td></td><td>iL-1 ← QL-1(·liL,x)</td><td>x</td><td>↑</td><td>p(.|1:L(i1:L))</td><td>x,i1:L</td><td></td></tr><tr><td>:</td><td></td><td>:</td><td></td><td>i1</td><td>→</td><td>Qi(-|i2:L,x)</td><td></td><td>x,i2:L</td></tr><tr><td>x,i2:L</td><td>i1</td><td>↑</td><td>Q1(-|i2:L,x)</td><td>i2</td><td>→</td><td>Q2(:|i3:L,x)</td><td></td><td>x,i3:L</td></tr><tr><td>x,i1:L</td><td>X</td><td></td><td>→p(|1:L(i1:L))</td><td></td><td>:</td><td></td><td>:</td><td></td></tr><tr><td>i1:L</td><td>i1:L</td><td></td><td>→U(·)</td><td>iL</td><td></td><td>→QL(-|x)</td><td></td><td>X</td></tr></table>
237
+
238
+ Table 3: The BB-ANS encoding and decoding operations, in order from the top, for a hierarchical latent model with $l$ layers. The $Q _ { l }$ are posterior distributions over the indices $i _ { l }$ of the discretized latent space for the lth latent, $z _ { l }$ . The discretization for the $l$ th latent is created such that the intervals have equal mass under the prior.
239
+
240
+ # B CODEC FOR VARIABLE IMAGE SIZES
241
+
242
+ Here we describe a codec to compress a set of images of arbitrary size. The encoder now adds the dimensions of the image being coded to the stream of compressed data, such that the decoder knows what shape the image will be before decoding it. Since we are using a vectorized ANS coder, as described in Section 3.2, we resize the top of the coder in between each coding/decoding step such that the size of the top of the coder matches the sizes of the image and latents being coded. The codec is detailed in Table 4.
243
+
244
+ To make the resizing procedure efficient, we resize via ‘folding’ the top of the vectorized ANS coder such that we are roughly halving/doubling the number of individual ANS coders each time we fold. This makes the cost of the resize logarithmic with the size difference between the vectorized coder and the targeted size.
245
+
246
+ Table 4: Codec for an image, $x$ , with shape $s$ . We code the image via the HiLLoC codec, and the dimensions of the image with the uniform codec, $U$ . Since the coder has the same size, init_size, before and after encoding/decoding, we can use this codec repeatedly to code any number of arbitrary sized images.
247
+
248
+ <table><tr><td>Variables</td><td>Operation</td><td>Operation</td><td>Variables</td></tr><tr><td>x,s</td><td>resize_coder(s)</td><td>s ←U(.)</td><td>S</td></tr><tr><td>x,s</td><td>x → HiLLoC(·)</td><td>resize_coder(s)</td><td>S</td></tr><tr><td>S</td><td>resize_coder(init_size)</td><td>x ← HiLLoC(·)</td><td>x,s</td></tr><tr><td>S</td><td>s→U(·)</td><td>resize_coder(init_size)</td><td>x,s</td></tr><tr><td></td><td>(a) Encoding</td><td>(b) Decoding</td><td></td></tr></table>
249
+
250
+ # C COMPRESSION WITH PIXELVAE
251
+
252
+ To further demonstrate HiLLoC, we implement it with a PixelVAE model. We use a model with two latent layers, although the posterior is fully factorized. The implementation requires nesting an autoregressive codec inside the BB-ANS codec, since the observations and one of the latent layers in PixelVAE have autoregressive generative distributions. Handling this complexity showcases Craystack, which was designed to support this kind of composition. It would also have been prohibitively slow to run on the datasets we compress without the vectorized ANS scheme discussed in Section 3.2.
253
+
254
+ The achieved compression rate on the entire ImageNet validation set is displayed in Table 5.
255
+
256
+ The autoregressive component of the PixelVAE generative model leads to an asymmetry between the times required for compression and decompression. Compression with the PixelVAE model is readily parallelizable across pixels, since we already have access to the pixel values we wish to compress and thus also the conditional distributions on each pixel. However, decompression (equivalently, sampling) is not parallelizable across pixels, since we must decompress a pixel value in order to give us access to the conditional distribution on the next pixel. This means the time complexity of decompression is linear in the number of pixels, making it prohibitively slow for most image sizes.
257
+
258
+ Table 5: The ELBO and compression rate of HiLLoC with PixelVAE, trained to convergence on ImageNet 64, compared to other schemes. All schemes are evaluated on the ImageNet 64 validation set, and measured in bits per pixel-channel.
259
+ PixelVAE
260
+
261
+ <table><tr><td>Raw data</td><td>PNG</td><td>WebP</td><td>FLIF</td><td>HiLLoC</td><td>ELBO</td></tr><tr><td>8</td><td>5.71</td><td>4.64</td><td>4.19</td><td>3.94</td><td>(3.67)</td></tr></table>
262
+
263
+ # D VECTORIZATION WITHOUT OVERHEADS
264
+
265
+ To ensure that the compression rate overhead from using vectorization is low, we use a technique from the BitKnit codec (Giesen, 2015). When we reach the end of encoding, we could simply concatenate the integers in the (vector) stack head to form the final output message. However, this is inefficient because the stack head is not uniformly distributed. As discussed in Giesen (2015), elements of the top of the stack have a probability mass roughly
266
+
267
+ $$
268
+ p ( h ) \propto 1 / h .
269
+ $$
270
+
271
+ Equivalently, the length of $h$ is approximately uniformly distributed. More detailed discussion and an empirical demonstration of this is given by Bloom (2014). An efficient way to form the final output message at the end of decoding, is to fold the stack head vector by repeatedly encoding half of it onto the other half, until only a scalar remains, using the above distribution for the encoding. We implement this technique in Craystack and use it for our experiments. The number of (vectorized) encode steps required is logarithmic in the size (i.e. the number of elements) of the stack head.
272
+
273
+ Some of the overhead from vectorization also comes at the start of encoding, when, in existing implementations, the elements of the stack head vector are initialized to copies of a fixed constant. Information from these copies ends up in the message and introduces redundancy which scales with the size of the head. This overhead can be removed by initializing the stack head to a vector of length 1 and then growing the length of the stack head vector gradually as more random data is added to the stack, by decoding new stack head vector elements according to the distribution (9).
274
+
275
+ # E RESNET VAE ARCHITECTURE
276
+
277
+ A full description of the RVAE architecture is given in Kingma et al. (2016), and a full implementation can be found in our repository https://github.com/hilloc-submission/hilloc, but we give a short description below.
278
+
279
+ The RVAE is a hierarchical latent model, trained by maximization of the usual evidence lower bound (ELBO) on the log-likelihood:
280
+
281
+ $$
282
+ \log p ( x ) \geq \mathbb { E } _ { q ( z \mid x ) } \left[ \log { \frac { p ( x , z ) } { q ( z \mid x ) } } \right]
283
+ $$
284
+
285
+ Take the latent hierarchy to be depth $L$ , such that the latents are $z _ { 1 : L }$ . There are skip connections in both the generative model, $p ( x , z _ { 1 : L } )$ , and the inference model, $q ( \boldsymbol { z } _ { 1 : L } \mid x )$ . Due to our requirement of using dynamic discretization, we use a top-down inference model 7. This means that we can write
286
+
287
+ $$
288
+ \begin{array} { l } { { \displaystyle p ( x , z _ { 1 : L } ) = p ( x \mid z _ { 1 : L } ) p ( z _ { L } ) \prod _ { l = 1 } ^ { L - 1 } p ( z _ { l } \mid z _ { l + 1 : L } ) } } \\ { { \displaystyle q ( z _ { 1 : L } \mid x ) = q ( z _ { L } \mid x ) \prod _ { l = 1 } ^ { L - 1 } q ( z _ { l } \mid z _ { l + 1 : L } , x ) } } \end{array}
289
+ $$
290
+
291
+ And the ELBO as
292
+
293
+ $$
294
+ \begin{array} { l } { \log p ( x ) \ge \mathbb { E } _ { q ( z _ { 1 : L } \mid x ) } \left[ \log p ( x \mid z _ { 1 : L } ) \right] - D _ { \mathrm { K L } } ( q ( z _ { L } \mid x ) \parallel p ( z _ { L } ) ) \ ~ } \\ { \displaystyle ~ - \sum _ { l = 1 } ^ { L - 1 } \mathbb { E } _ { q ( z _ { l + 1 : L } \mid x ) } \left[ D _ { \mathrm { K L } } ( q ( z _ { l } \mid z _ { l + 1 : L } , x ) \parallel p ( z _ { l } \mid z _ { l + 1 : L } ) ) \right] } \end{array}
295
+ $$
296
+
297
+ Where $D _ { \mathrm { K L } }$ is the $\mathrm { K L }$ divergence. As in Kingma et al. (2016), the $\mathrm { K L }$ terms are individually clamped as $\mathrm { m a x } ( D _ { \mathrm { K L } } , \lambda )$ , where $\lambda$ is some constant. This is an optimization technique known as free bits, and aims to prevent latent layers in the hierarchy collapsing such that the posterior is equal to the prior.
298
+
299
+ Each layer in the hierarchy consists of a ResNet block with two sets of activations. One set of activations are calculated bottom-up (in the direction of $x$ to $z _ { L }$ ), and the other are calculated top-down. The bottom-up activations are used only within $q ( z _ { 1 : L } \mid x )$ , whereas the top-down activations are used by both $q ( z _ { 1 : L } \mid x )$ and $p ( x , z _ { 1 : L } )$ . Every conditional distribution on a latent $z _ { l }$ is parameterized as a diagonal Gaussian distribution, with mean and covariance a function of the activations within the ResNet block, and the conditional distribution on $x$ is parameterized by a discretized logistic distribution. Given activations for previous ResNet blocks, the activations at the following ResNet block are a combination of stochastic and deterministic features of the previous latent layer, as well as from skip connections directly passing the previous activations. The features are calculated by convolutions.
300
+
301
+ Note also that all latent layers are the same shape. Since we retained the default hyperparameters from the original implementation, each latent layer has 32 feature maps and spatial dimensions half those of the input (e.g. ${ \frac { h } { 2 } } \times { \frac { w } { 2 } }$ for input of shape $h \times w$ ).
md/train/rJe4_xSFDB/rJe4_xSFDB.md ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LIPSCHITZ CONSTANT ESTIMATION OF NEURAL NETWORKS VIA SPARSE POLYNOMIAL OPTIMIZATION
2
+
3
+ Fabian Latorre, Paul Rolland and Volkan Cevher EPFL, Switzerland firstname.lastname@epfl.ch
4
+
5
+ # ABSTRACT
6
+
7
+ We introduce LiPopt, a polynomial optimization framework for computing increasingly tighter upper bounds on the Lipschitz constant of neural networks. The underlying optimization problems boil down to either linear (LP) or semidefinite (SDP) programming. We show how to use the sparse connectivity of a network, to significantly reduce the complexity of computation. This is specially useful for convolutional as well as pruned neural networks. We conduct experiments on networks with random weights as well as networks trained on MNIST, showing that in the particular case of the $\ell _ { \infty }$ -Lipschitz constant, our approach yields superior estimates, compared to baselines available in the literature.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ We consider a neural network $f _ { d }$ defined by the recursion:
12
+
13
+ $$
14
+ f _ { 1 } ( x ) : = W _ { 1 } x \qquad f _ { i } ( x ) : = W _ { i } \sigma ( f _ { i - 1 } ( x ) ) , \quad i = 2 , \ldots , d
15
+ $$
16
+
17
+ for an integer $d$ larger than 1, matrices $\{ W _ { i } \} _ { i = 1 } ^ { d }$ of appropriate dimensions and an activation function $\sigma$ , understood to be applied element-wise. We refer to $d$ as the depth, and we focus on the case where $f _ { d }$ has a single real value as output.
18
+
19
+ In this work, we address the problem of estimating the Lipschitz constant of the network $f _ { d }$ . A function $f$ is Lipschitz continuous with respect to a norm $\left\| \cdot \right\|$ if there exists a constant $L$ such that for all $x , y$ we have $| f ( x ) - f ( y ) | \leq L \| x - y \|$ . The minimum over all such values satisfying this condition is called the Lipschitz constant of $f$ and is denoted by $L ( f )$ .
20
+
21
+ The Lipschitz constant of a neural network is of major importance in many successful applications of deep learning. In the context of supervised learning, Bartlett et al. (2017) show how it directly correlates with the generalization ability of neural network classifiers, suggesting it as model complexity measure. It also provides a measure of robustness against adversarial perturbations (Szegedy et al., 2014) and can be used to improve such metric (Cisse et al., 2017). Moreover, an upper bound on $L ( f _ { d } )$ provides a certificate of robust classification around data points (Weng et al., 2018).
22
+
23
+ Another example is the discriminator network of the Wasserstein GAN (Arjovsky et al., 2017), whose Lipschitz constant is constrained to be at most 1. To handle this constraint, researchers have proposed different methods like heuristic penalties (Gulrajani et al., 2017), upper bounds (Miyato et al., 2018), choice of activation function (Anil et al., 2019), among many others. This line of work has shown that accurate estimation of such constant is key to generating high quality images.
24
+
25
+ Lower bounds or heuristic estimates of $L ( f _ { d } )$ can be used to provide a general sense of how robust a network is, but fail to provide true certificates of robustness to input perturbations. Such certificates require true upper bounds, and are paramount when deploying safety-critical deep reinforcement learning applications (Berkenkamp et al., 2017; Jin & Lavaei, 2018). The trivial upper bound given by the product of layer-wise Lipschitz constants is easy to compute but rather loose and overly pessimistic, providing poor insight into the true robustness of a network (Huster et al., 2018).
26
+
27
+ Indeed, there is a growing need for methods that provide tighter upper bounds on $L ( f _ { d } )$ , even at the expense of increased complexity. For example Raghunathan et al. (2018a); Jin & Lavaei (2018); Fazlyab et al. (2019) derive upper bounds based on semidefinite programming $( S D P )$ . While expensive to compute, these type of certificates are in practice surprisingly tight. Our work belongs in this vein of research, and aims to overcome some limitations in the current state-of-the-art.
28
+
29
+ # Our Contributions.
30
+
31
+ . We present LiPopt, a general approach for upper bounding the Lipschitz constant of a neural network based on a relaxation to a polynomial optimization problem (POP) (Lasserre, 2015). This approach requires only that the unit ball be described with polynomial inequalities, which covers the common $\ell _ { 2 ^ { - } }$ and $\ell _ { \infty }$ -norms. . Based on a theorem due to Weisser et al. (2018), we exploit the sparse connectivity of neural network architectures to derive a sequence of linear programs (LPs) of considerably smaller size than their vanilla counterparts. We provide an asymptotic analysis of the size of such programs, in terms of the number of neurons, depth and sparsity of the network. . Focusing on the $\ell _ { \infty }$ -norm, we experiment on networks with random weights and networks trained on MNIST (Lecun et al., 1998). We evaluate different configurations of depth, width and sparsity and we show that the proposed sequence of LPs can provide tighter upper bounds on $\dot { L } ( f _ { d } )$ compared to other baselines available in the literature.
32
+
33
+ Notation. We denote by $n _ { i }$ the number of columns of the matrix $W _ { i }$ in the definition (1) of the network. This corresponds to the size of the $i$ -th layer, where we identify the input as the first layer. We let $n = n _ { 1 } + . . . + n _ { d }$ be the total number of neurons in the network. For a vector $x$ , $\operatorname { D i a g } ( x )$ denotes the square matrix with $x$ in its diagonal and zeros everywhere else. For an array $X$ , $\operatorname { v e c } ( X )$ is the flattened array. The support of a sequence $\operatorname { s u p p } ( \alpha )$ is defined as the set of indices $j$ such that $\alpha _ { j }$ is nonnote by o. For the m $x = [ x _ { 1 } , \ldots , x _ { n } ]$ a sequence of nonnegative integers . The set of nonnegative integers is $\gamma = [ \gamma _ { 1 } , \dotsc , \gamma _ { n } ]$ we $x ^ { \gamma }$ $x _ { 1 } ^ { \gamma _ { 1 } } x _ { 2 } ^ { \gamma _ { 2 } } \ldots x _ { n } ^ { \gamma _ { n } }$ $\mathbb { N }$
34
+
35
+ Remark. The definition of network (1) covers typical architectures composed of dense and convolutional layers. In general, our proposed approach can be readily extended with minor modifications to any directed acyclic computation graph e.g., residual network architectures (He et al., 2016).
36
+
37
+ # 2 POLYNOMIAL OPTIMIZATION FORMULATION
38
+
39
+ In this section we derive an upper bound on $L ( f _ { d } )$ given by the value of a POP, i.e. the minimum value of a polynomial subject to polynomial inequalities. Our starting point is the following theorem, which casts $\dot { L } ( f )$ as an optimization problem:
40
+
41
+ Theorem 1. Let $f$ be a differentiable and Lipschitz continuous function on an open, convex subset $\mathcal { X }$ of an euclidean space. Let $\left\| \cdot \right\| _ { * }$ be the dual norm. The Lipschitz constant of $f$ is given by
42
+
43
+ $$
44
+ L ( f ) = \operatorname* { s u p } _ { x \in \mathcal { X } } \| \nabla f ( x ) \| _ { * }
45
+ $$
46
+
47
+ For completeness, we provide a proof in appendix A. In our setting, we assume that the activation function $\sigma$ is Lipschitz continuous and differentiable. In this case, the assumptions of Theorem 1 are fulfilled because $f _ { d }$ is a composition of activations and linear transformations. The differentiability assumption rules out the common ReLU activation $\sigma ( x ) = \operatorname* { m a x } \{ 0 , x \}$ , but allows many others such as the exponential linear unit (ELU) (Clevert et al., 2015) or the softplus.
48
+
49
+ Using the chain rule, the compositional structure of $f _ { d }$ yields the following formula for its gradient:
50
+
51
+ $$
52
+ \nabla f _ { d } ( x ) = W _ { 1 } ^ { T } \prod _ { i = 1 } ^ { d - 1 } \operatorname { D i a g } ( \sigma ^ { \prime } ( f _ { i } ( x ) ) ) W _ { i + 1 } ^ { T }
53
+ $$
54
+
55
+ For every $i = 1 , \ldots , d - 1$ we introduce a variable $s _ { i } = \sigma ^ { \prime } ( f _ { i } ( x ) )$ corresponding to the derivative of $\sigma$ at the $i$ -th hidden layer of the network. For activation functions like ELU or softplus, their derivative is bounded between 0 and 1, which implies that $0 \leq s _ { i } \leq 1$ . This bound together with the definition of the dual norm $\| x \| _ { * } : = \operatorname* { s u p } _ { \| t \| \leq 1 } t ^ { T } \bar { x }$ implies the following upper bound of $L ( f _ { d } )$ :
56
+
57
+ $$
58
+ L ( f _ { d } ) \leq \operatorname* { m a x } \left\{ t ^ { T } W _ { 1 } ^ { T } \prod _ { i = 1 } ^ { d - 1 } \operatorname { D i a g } ( s _ { i } ) W _ { i + 1 } ^ { T } : 0 \leq s _ { i } \leq 1 , \| t \| \leq 1 \right\}
59
+ $$
60
+
61
+ We will refer to the polynomial objective of this problem as the norm-gradient polynomial of the network $f _ { d }$ , a central object of study in this work.
62
+
63
+ For some frequently used $\ell _ { p }$ -norms, the constraint $\| t \| _ { p } \leq 1$ can be written with polynomial inequalities. In the rest of this work, we use exclusively the $\ell _ { \infty }$ -norm for which $\| t \| _ { \infty } \dot { \leq } 1$ is equivalent to the polynomial inequalities $- 1 \leq t _ { i } \leq 1$ , for $i = 1 , \ldots , n _ { 1 }$ . However, note that when $p \geq 2$ is a positive even integer, $\| t \| _ { p } \leq 1$ is equivalent to a single polynomial inequality $\| t \| _ { p } ^ { p } \leq 1$ , and our proposed approach can be adapted with minimal modifications.
64
+
65
+ In such cases, the optimization problem in the right-hand side of (4) is a POP. Optimization of polynomials is a NP-hard problem and we do not expect to have efficient algorithms for solving (4) in this general form. In the next sections we describe LiPopt: a systematic way of obtaining an upper bound on $L ( f _ { d } )$ via tractable approximation methods of the POP (4).
66
+
67
+ Local estimation. In many practical escenarios, we have additional bounds on the input of the network. For example, in the case of image classification tasks, valid input is constrained in a hypercube. In the robustness certification task, we are interested in all possible input in a $\epsilon$ -ball around some data point. In those cases, it is interesting to compute a local Lipschitz constant, that is, the Lipschitz constant of a function restricted to a subset.
68
+
69
+ We can achieve this by deriving tighter bounds $0 \leq l _ { i } \leq s _ { i } \leq u _ { i } \leq 1$ , as a consequence of the restricted input (see for example, Algorithm 1 in Wong & Kolter (2018)). By incorporating this knowledge in the optimization problem (4) we obtain bounds on local Lipschitz constants of $f _ { d }$ . We study this setting and provide numerical experiments in section 7.3.
70
+
71
+ Choice of norm. We highlight the importance of computing good upper bounds on $L ( f _ { d } )$ with respect to the $\ell _ { \infty }$ -norm. It is one of the most commonly used norms to assess robustness in the adversarial examples literature. Moreover, it has been shown that, in practice, $\ell _ { \infty }$ -norm robust networks are also robust in other more plausible measures of perceptibility, like the Wasserstein distance (Wong et al., 2019). This motivates our focus on this choice.
72
+
73
+ # 3 HIERARCHICAL SOLUTION BASED ON A POLYNOMIAL POSITIVITY CERTIFICATE
74
+
75
+ For ease of exposition, we rewrite (4) as a POP constrained in $[ 0 , 1 ] ^ { n }$ using the substitution $s _ { 0 } : = ( t +$ $1 ) / 2$ . Denote by $p$ the norm-gradient polynomial, and let $x = [ s _ { 0 } , \ldots , s _ { d - 1 } ]$ be the concatenation of all variables. Polynomial optimization methods (Lasserre, 2015) start from the observation that a value $\lambda$ is an upper bound for $p$ over a set $K$ if and only if the polynomial $\lambda - p$ is positive over $K$ .
76
+
77
+ In LiPopt, we will employ a well-known classical result in algebraic geometry, the so-called Krivine’s positivity certificate1, but in theory we can use any positivity certificate like sum-of-squares (SOS). The following is a straightforward adaptation of Krivine’s certificate to our setting:
78
+
79
+ Theorem 2. (Adapted from Krivine (1964); Stengle (1974); Handelman (1988)) If the polynomial $\lambda - p$ is strictly positive on $[ 0 , 1 ] ^ { n }$ , then there exist finitely many positive weights $c _ { \alpha \beta }$ such that
80
+
81
+ $$
82
+ \lambda - p = \sum _ { ( \alpha , \beta ) \in \mathbb { N } ^ { 2 n } } c _ { \alpha \beta } h _ { \alpha \beta } , \qquad h _ { \alpha \beta } ( x ) : = \prod _ { j = 1 } ^ { n } x _ { j } ^ { \alpha _ { j } } ( 1 - x _ { j } ) ^ { \beta _ { j } }
83
+ $$
84
+
85
+ By truncating the degree of Krivine’s positivity certificate (Theorem 2) and minimizing over all possible upper bounds $\lambda$ we obtain a hierarchy of LP problems (Lasserre, 2015, Section 9):
86
+
87
+ $$
88
+ \theta _ { k } : = \operatorname* { m i n } _ { c \geq 0 , \lambda } \left\{ \lambda : \lambda - p = \sum _ { ( \alpha , \beta ) \in \mathbb { N } _ { k } ^ { 2 n } } c _ { \alpha \beta } h _ { \alpha \beta } \right\}
89
+ $$
90
+
91
+ where $\mathbb { N } _ { k } ^ { 2 n }$ is the set of nonnegative integer sequences of length $2 n$ adding up to at most $k$ . This is indeed a sequence of LPs as the polynomial equality constraint can be implemented by equating coefficients in the canonical monomial basis. For this polynomial equality to be feasible, the degree of the certificate has to be at least that of the norm-gradient polynomial $p$ , which is equal to the depth $d$ . This implies that the first nontrivial bound $( \theta _ { k } < \infty )$ ) corresponds to $k = d$ .
92
+
93
+ The sequence $\{ \theta _ { k } \} _ { k = 1 } ^ { \infty }$ is non-incresing and converges to the maximum of the upper bound (4). Note that for any level of the hierarchy, the solution of the LP (6) provides a valid upper bound on $L ( f _ { d } )$ .
94
+
95
+ An advantage of using Krivine’s positivity certificate over SOS is that one obtains an LP hierarchy (rather than SDP), for which commercial solvers can reliably handle a large instances. Other positivity certificates offering a similar advantage are the DSOS and SDSOS hierarchies (Ahmadi & Majumdar, 2019), which boil down to LP or second order cone programming (SOCP), respectively.
96
+
97
+ Drawback. The size of the LPs given by Krivine’s positivity certificate can become quite large. The dimension of the variable $c$ is $| \mathbb { N } _ { k } ^ { 2 n } | = { \dot { \mathcal { O } } } ( n ^ { k } )$ . For reference, if we consider the MNIST dataset and a one-hidden-layer network with 100 neurons we have $\left| \mathbb { N } _ { 2 } ^ { 2 n } \right| \approx 1 . 5 \times 1 0 ^ { 6 }$ while $\left| \mathbb { N } _ { 3 } ^ { 2 n } \right| \approx 9 . 3 \times 1 0 ^ { 8 }$ . To make this approach more scalable, in the next section we exploit the sparsity of the polynomial $p$ to find LPs of drastically smaller size than (6), but with similar approximation properties.
98
+
99
+ Remark. In order to compute upper bounds for local Lipschitz constants, first obtain tighter bounds $0 \leq l _ { i } \leq s _ { i } \leq u _ { i }$ and then perform the change of variables $\widetilde { s } _ { i } = ( s _ { i } - l _ { i } ) / ( u _ { i } - l _ { i } )$ to rewrite the problem (4) as a POP constrained on $[ 0 , 1 ] ^ { n }$ .
100
+
101
+ # 4 REDUCING THE NUMBER OF VARIABLES
102
+
103
+ Many neural network architectures, like those composed of convolutional layers, have a highly sparse connectivity between neurons. Moreover, it has been empirically observed that up to $90 \%$ of network weights can be pruned (set to zero) without harming accuracy (Frankle & Carbin, 2019). In such cases their norm-gradient polynomial has a special structure that allows polynomial positivity certificates of smaller size than the one given by Krivine’s positivity certificate (Theorem 2).
104
+
105
+ In this section, we describe an implementation of LiPopt (Algorithm 1) that exploits the sparsity of the network to decrease the complexity of the LPs (6) given by the Krivine’s positivity certificate. In this way, we obtain upper bounds on $L ( f _ { d } )$ that require less computation and memory. Let us start with the definition of a valid sparsity pattern:
106
+
107
+ Definition 1. Let $I = \{ 1 , \ldots , n \}$ and $p$ be a polynomial with variable $x \in \mathbb { R } ^ { n }$ . A valid sparsity pattern of $p$ is a sequence $\{ I _ { i } \} _ { i = 1 } ^ { m }$ of subsets of $I$ , called cliques, such that $\textstyle \bigcup _ { i = 1 } ^ { m } I _ { i } = I$ and:
108
+
109
+ . $\textstyle p = \sum _ { i = 1 } ^ { m } p _ { i }$ where $p _ { i }$ is a polynomial that depends only on the variables $\{ x _ { j } : j \in I _ { i } \}$ . for all $i = 1 , \ldots , m - 1$ there is an $l \leq i$ such that $\begin{array} { r } { ( I _ { i + 1 } \cap \bigcup _ { r = 1 } ^ { i } I _ { r } ) \subseteq I _ { l } } \end{array}$
110
+
111
+ When the polynomial objective $p$ in a POP has a valid sparsity pattern, there is an extension of Theorem 2 due to Weisser et al. (2018), providing a smaller positivity certificate for $\lambda - p$ over $[ 0 , 1 ] ^ { n }$ . We refer to it as the sparse Krivine’s certificate and we include it here for completeness:
112
+
113
+ Theorem 3 (Adapted from Weisser et al. (2018)). Let a polynomial $p$ have a valid sparsity pattern $\{ I _ { i } \} _ { i = 1 } ^ { m }$ . Define $N _ { i }$ as the set of sequences $( \alpha , \beta ) \in \bar { \mathbb { N } } ^ { 2 n }$ where the support of both $\alpha$ and $\beta$ is contained in $I _ { i }$ . If $\lambda - p$ is strictly positive over $K = [ 0 , 1 ] ^ { n }$ , there exist finitely many positive weights $c _ { \alpha \beta }$ such that
114
+
115
+ $$
116
+ \lambda - p = \sum _ { i = 1 } ^ { m } h _ { i } , \qquad h _ { i } = \sum _ { ( \alpha , \beta ) \in N _ { i } } c _ { \alpha \beta } h _ { \alpha \beta }
117
+ $$
118
+
119
+ where the polynomials $h _ { \alpha \beta }$ are defined as in (5).
120
+
121
+ The sparse Krivine’s certificate can be used like the general version (Theorem 2) to derive a sequence of LPs approximating the upper bound on $L ( f _ { d } )$ stated in (4). However, the number of different polynomials $h _ { \alpha \beta }$ of degree at most $k$ appearing in the sparse certificate can be drastically smaller, the amount of which determines how good the sparsity pattern is.
122
+
123
+ We introduce a graph that depends on the network $f _ { d }$ , from which we will extract a sparsity pattern for the norm-gradient polynomial of a network.
124
+
125
+ ![](images/214b4ec10db794f93e318582922104545dac5f8d93ae013d25d849c225637e9d.jpg)
126
+ Figure 1: Sparsity pattern of Proposition 1 for a network of depth three.
127
+
128
+ ![](images/c840ffb3080a0f590ddc61c0b1ed0992fd23d3fa33726a52fedf988a09c2b4b8.jpg)
129
+ Figure 2: Structure of one set in the sparsity pattern from Proposition 1 for a network with 2D convolutional layers with $3 \times 3$ filters.
130
+
131
+ Definition 2. Let $f _ { d }$ be a network with weights $\{ W _ { i } \} _ { i = 1 } ^ { d }$ . Define a directed graph $G _ { d } = ( V , E )$ as:
132
+
133
+ $$
134
+ \begin{array} { c } { { V = \{ s _ { i , j } : 0 \leq i \leq d - 1 , 1 \leq j \leq n _ { i } \} } } \\ { { E = \{ ( s _ { i , j } , s _ { i + 1 , k } ) : 0 \leq i \leq d - 2 , [ W _ { i } ] _ { k , j } \neq 0 \} } } \end{array}
135
+ $$
136
+
137
+ which we call the computational graph of the network $f _ { d }$
138
+
139
+ In the graph $G _ { d }$ the vertex $s _ { ( i , j ) }$ represents the $j$ -th neuron in the $i$ -th layer. There is a directed edge between two neurons in consecutive layers if they are joined by a nonzero weight in the network. The following result shows that for fully connected networks we can extract a valid sparsity pattern from this graph. We relegate the proof to appendix B.
140
+
141
+ Proposition 1. Let $f _ { d }$ be a dense network (all weights are nonzero). The following sets, indexed by $i = 1 , \ldots , n _ { d } ,$ form a valid sparsity pattern for the norm-gradient polynomial of the network $f _ { d }$ :
142
+
143
+ $$
144
+ I _ { i } : = \left\{ s _ { ( d - 1 , i ) } \right\} \cup \left\{ s _ { ( j , k ) } : t h e r e \ e x i s t s a \ d i r e c t e d p a t h f r o m \ s _ { ( j , k ) } \ t o \ s _ { ( d - 1 , i ) } \ i n \ G _ { d } \right\}
145
+ $$
146
+
147
+ We refer to this as the sparsity pattern induced by $G _ { d }$ . An example is depicted in in Figure 1.
148
+
149
+ Remark. When the network is not dense, the the second condition (Definition 1) for the sparsity pattern (9) to be valid might not hold. In that case we lose the guarantee that the values of the corresponding LPs converge to the maximum of the POP (4). Nevertheless, it still provides a valid positivity certificate that we use to upper bound $L ( f _ { d } )$ . In Section 7 we show that in practice it provides upper bounds of good enough quality. If needed, a valid sparsity pattern can be obtained via a chordal completion of the correlative sparsity graph of the POP (Waki et al., 2006).
150
+
151
+ We now quantify how good this sparsity pattern is. Let $s$ be the size of the largest clique in a sparsity pattern, and let $N _ { i , k }$ be the subset of $N _ { i }$ (defined in Theorem 3) composed of sequences summing up to $k$ . The number of different polynomials for the $k$ -th LP in the hierarchy given by the sparse Krivine’s certificate can be bounded as follows:
152
+
153
+ $$
154
+ \left| \bigcup _ { i = 1 } ^ { m } N _ { i , k } \right| \leq \sum _ { i = 1 } ^ { m } { \binom { 2 | I _ { i } | + k } { k } } = \mathcal { O } \left( m s ^ { k } \right)
155
+ $$
156
+
157
+ We immediately see that the dependence on the number of cliques $m$ is really mild (linear) but the size of the cliques as well as the degree of the hierarchy can really impact the size of the optimization problem. Nevertheless, this upper bound can be quite loose; polynomials $h _ { \alpha \beta }$ that depend only on variables in the intersection of two or more cliques are counted more than once.
158
+
159
+ The number of cliques given in the sparsity pattern induced by $G _ { d }$ is equal to the size of the last layer $m = n _ { d }$ and the size of each clique depends on the particular implementation of the network. We now study different architectures that could arise in practice, and determine the amount of polynomials in their sparse Krivine’s certificate.
160
+
161
+ Fully connected networks. Even in the case of a network with all nonzero connections, the sparsity pattern induced by $G _ { d }$ decreases the size of the LPs when compared to Krivine’s certificate. In this case the cliques have size $n _ { 1 } + . . . + n _ { d - 1 } + 1$ but they all have the same common intersection equal to all neurons up to the second-to-last hidden layer. A straightforward counting argument shows that the total number of polynomials is $\mathcal { O } ( n ( n _ { 1 } + . . . + n _ { d - 1 } + \bar { 1 } ) ^ { k - 1 } )$ ), improving the upper bound (10).
162
+
163
+ Unstructured sparsity. In the case of networks obtained by pruning (Hanson & Pratt, 1989) or generated randomly from a distribution over graphs (Xie et al., 2019), the sparsity pattern can be arbitrary. In this case the size of the resulting LPs varies at runtime. Under the layer-wise assumption that any neuron is connected to at most $r$ neurons in the previous layer, the size of the cliques in (9) is bounded as $s = \mathcal { O } ( r ^ { d } )$ . This estimate has an exponential dependency on the depth but ignores that many neurons might share connections to the same inputs in the previous layer, thus being potentially loose. The bound (10) implies that the number of different polynomials is $\mathcal { O } ( n _ { d } r ^ { d k } )$ .
164
+
165
+ 2D Convolutional networks. The sparsity in the weight matrices of convolutional layers has a certain local structure; neurons are connected to contiguous inputs in the previous layer. Adjacent neurons also have many input pixels in common (see Figure 2). Assuming a constant number of channels per layer, the size of the cliques in (9) is $\mathcal { O } ( d ^ { 3 } )$ . Intuitively, such number is proportional to the volume of the pyramid depicted in Figure 2 where each dimension depends linearly on $d$ . Using (10) we get that there are $\mathcal { O } ( \dot { n } _ { d } d ^ { 3 k } )$ different polynomials in the sparse Krivine’s certificate. This is a drastic decrease in complexity when compared to the unstructured sparsity case.
166
+
167
+ The use of sparsity in polynomial optimization preceeds Theorem 3 (Weisser et al., 2018). First studied in the context of sum-of-squares by Kojima et al. (2005) and further refined in Waki et al. (2006); Lasserre (2006) (and references therein), it has found applications in safety verification (Yang et al., 2016; Zhang et al., 2018), sensor localization Wang et al. (2006), optimal power flow (Ghaddar et al., 2015) and many others. Our work fits precisely into this set of important applications.
168
+
169
+ # Algorithm 1 LiPopt for ELU activations and sparsity pattern
170
+
171
+ Input: matrices $\{ W _ { i } \} _ { i = 1 } ^ { d }$ , sparsity pattern $\{ I _ { i } \} _ { i = 1 } ^ { m }$ , hierarchy degree $k$ .
172
+ 1: p ← (2s0 − 1)T W T1 Qd−1i=1 $\triangleright$ compute norm-gradient polynomial
173
+ 2: $x \gets [ s _ { 0 } , \ldots , s _ { d - 1 } ]$
174
+ 3: $b [ b _ { \gamma } : \gamma \in \mathbb { N } _ { k } ^ { n } ]$ where $\begin{array} { r } { p ( x ) = \sum _ { \gamma \in \mathbb { N } _ { k } ^ { n } } b _ { \gamma } x ^ { \gamma } } \end{array}$ $\triangleright$ compute coefficients of $p$ in basis
175
+ 4: for $i = 1 , \ldots , m$ do
176
+ 5: $N _ { i , k } \gets \{ ( \alpha , \beta ) \in \mathbb { N } _ { k } ^ { 2 n } : \operatorname { s u p p } ( \alpha ) \cap \operatorname { s u p p } ( \beta ) \subseteq I _ { i } \}$
177
+ 6: $\widetilde { N } _ { k } \gets \cup _ { i = 1 } ^ { m } N _ { i , k }$
178
+ 7: $\begin{array} { r } { h \sum _ { ( \alpha , \beta ) \in \widetilde { N } } c _ { \alpha \beta } h _ { \alpha \beta } } \end{array}$ . compute positivity certificate
179
+ 8: $c [ c _ { \alpha \beta } : ( \alpha , \beta ) \in \widetilde { N } _ { k } ] ; \ y [ \lambda , c ]$ $\triangleright$ linear program variables
180
+ 9: $Z \gets [ z _ { \gamma } ] _ { \gamma \in \mathbb { N } _ { k } ^ { n } }$ where $\begin{array} { r } { \lambda - h ( x ) = \sum _ { \gamma \in \mathbb { N } _ { k } ^ { n } } ( z _ { \gamma } ^ { T } y ) x ^ { \gamma } } \end{array}$ $\triangleright$ compute coefficients of $\lambda - h$ in basis
181
+ return $\operatorname* { m i n } \{ \lambda : b = Z y$ , $y = [ \lambda , c ]$ , $c \geq 0 \}$ $\triangleright$ solve LP
182
+
183
+ # 5 QCQP REFORMULATION AND SHOR’S SDP RELAXATION
184
+
185
+ Another way of upper bounding $L ( f _ { d } )$ comes from a further relaxation of (4) to an SDP. We consider the following equivalent formulation where the variables $s _ { i }$ are normalized to lie in the interval $[ - 1 , 1 ]$ , and we rename $t = s _ { 0 }$ :
186
+
187
+ $$
188
+ L ( f _ { d } ) \leq \operatorname* { m a x } \left\{ \frac { 1 } { 2 ^ { d - 1 } } s _ { 0 } ^ { T } W _ { 1 } ^ { T } \prod _ { i = 1 } ^ { d - 1 } \mathrm { D i a g } ( s _ { i } + 1 ) W _ { i + 1 } ^ { T } : - 1 \leq s _ { i } \leq 1 \right\}
189
+ $$
190
+
191
+ Any polynomial optimization problem like (11) can be cast as a (possibly non-convex) quadratically constrained quadratic program (QCQP) by introducing new variables and quadratic constraints. This is a well-known procedure described in Park & Boyd (2017, Section 2.1). When $d = 2$ problem (11) is already a QCQP (for the $\ell _ { \infty }$ and $\ell _ { 2 }$ -norm cases) and no modification is necessary.
192
+
193
+ QCQP reformulation. We illustrate the case $d = 3$ where we have the variables $s _ { 1 } , s _ { 2 }$ corresponding to the first and second hidden layer and a variable $s _ { 0 }$ corresponding to the input. The norm-gradient polynomial in this case is cubic, and it can be rewritten as a quadratic polynomial by introducing new variables corresponding to the product of the first and second hidden layer variables.
194
+
195
+ More precisely the introduction of a variable $s _ { 1 , 2 }$ with quadratic constraint $s _ { 1 , 2 } = \mathrm { v e c } ( s _ { 1 } s _ { 2 } ^ { T } )$ allows us to write the objective (11) as a quadratic polynomial. The problem then becomes a QCQP with variable $y = [ 1 , s _ { 0 } , s _ { 1 } , s _ { 2 } , s _ { 1 , 2 } ]$ of dimension $1 + n + n _ { 1 } n _ { 2 }$ .
196
+
197
+ SDP relaxation. Any quadratic objective and constraints can then be relaxed to linear constraints on the positive semidefinite variable $y y ^ { T } = X \succcurlyeq 0$ yielding the so-called Shor’s relaxation of (11) (Park & Boyd, 2017, Section 3.3). When $d = 2$ the resulting SDP corresponds precisely to the one studied in Raghunathan et al. (2018a). This resolves a common misconception (Raghunathan et al., 2018b) that this approach is only limited to networks with one hidden layer.
198
+
199
+ Note that in our setting we are only interested in the optimal value rather than the optimizers, so there is no need to extract a solution for (11) from that of the SDP relaxation.
200
+
201
+ Drawback. This approach includes a further relaxation step from (11), thus being fundamentally limited in how tightly it can upper bound the value of $L ( f _ { d } )$ . Moreover when compared to LP solvers, off-the-shelf semidefinite programming solvers are, in general, much more limited in the number of variables they can efficiently handle.
202
+
203
+ In the case $d = 2$ this relaxation provides a constant factor approximation to the original QCQP (Ye, 1999). Further approximation quality results for such hierarchical optimization approaches to NP-hard problems are out of the scope of this work.
204
+
205
+ Relation to sum-of-squares. The QCQP approach might appear fundamentaly different to the hierarchical optimization approaches to POPs, like the one described in Section 3. However, it is known that Shor’s SDP relaxation corresponds exactly to the first degree of the SOS hierarchical SDP solution to the QCQP relaxation (Lasserre, 2000). Thus, the approach in section 3 and the one in this section are, in essence, the same; they only differ in the choice of polynomial positivity certificate.
206
+
207
+ # 6 RELATED WORK
208
+
209
+ Estimation of $L ( f _ { d } )$ with $\ell _ { 2 }$ -norm is studied by Virmaux & Scaman (2018); Combettes & Pesquet (2019); Fazlyab et al. (2019); Jin & Lavaei (2018). The method SeqLip proposed in Virmaux & Scaman (2018) has the drawback of not providing true upper bounds. It is in fact a heuristic method for solving (4) but which provides no guarantees and thus can not be used for robustness certification. In contrast the LipSDP method of Fazlyab et al. (2019) provides true upper bounds on $L ( f _ { d } )$ and in practice shows superior performance over both SeqLip and CPLip (Combettes & Pesquet, 2019).
210
+
211
+ Despite the accurate estimation of LipSDP, its formulation is limited to the $\ell _ { 2 }$ -norm. The only estimate available for other $\ell _ { p }$ -norms comes from the equivalence of norms in euclidean spaces. For instance, we can obtain an upper bound for the $\ell _ { \infty }$ -norm after multiplying the $\ell _ { 2 }$ Lipschitz constant upper bound by the square root of the input dimension. The resulting bound can be rather loose and our experiments in section 7 confirm the issue. In contrast, our proposed approach LiPopt can acommodate any norm whose unit ball can be described via polynomial inequalities.
212
+
213
+ Let us point to one key advantage of LiPopt, compared to LipSDP (Jin & Lavaei, 2018; Fazlyab et al., 2019). In the context of robustness certification we are given a sample $x ^ { \sharp }$ and a ball of radius $\epsilon$ around it. Computing an upper bound on the local Lipschitz constant in this subset, rather than a global one, can provide a larger region of certified robustness. Taking into account the restricted domain we can refine the bounds in our POP (see remark in section 1). This potentially yields a tighter estimate of the local Lipschitz constant. On the other hand, it is not clear how to include such additional information in LipSDP, which only computes one global bound on the Lipschitz constant for the unconstrained network.
214
+
215
+ Raghunathan et al. (2018a) find an upper bound for $L ( f _ { d } )$ with $\ell _ { \infty }$ metric starting from problem (4) but only in the context of one-hidden-layer networks $\ Q = 2 ,$ ). To compute such bound they use its corresponding Shor’s relaxation and obtain as a byproduct a differentiable regularizer for training networks. They claim such approach is limited to the setting $d = 2$ but, as we remark in section 5, it is just a particular instance of the SDP relaxation method for QCQPs arising from a polynomial optimization problem. We find that this method fits into the LiPopt framework, using SOS certificates instead of Krivine’s. We expect that the SDP-based bounds described in 5 can also be used as regularizers promoting robustness.
216
+
217
+ Weng et al. (2018) provide an upper bound on the local Lipschitz constant for networks based on a sequence of ad-hoc bounding arguments, which are particular to the choice of ReLU activation function. In contrast, our approach applies in general to activations whose derivative is bounded.
218
+
219
+ # 7 EXPERIMENTS
220
+
221
+ We consider the following estimators of $L ( f _ { d } )$ with respect to the $\ell _ { \infty }$ norm:
222
+
223
+ <table><tr><td rowspan=1 colspan=1>Name</td><td rowspan=1 colspan=1>Description</td></tr><tr><td rowspan=1 colspan=1>SDP</td><td rowspan=1 colspan=1>Upper bound arising from the solution of the SDP relaxation described in Sec-tion 5</td></tr><tr><td rowspan=1 colspan=1>LipOpt-k</td><td rowspan=1 colspan=1>Upper bound arising from the k-th degree of the LP hierarchy (6) based on thesparse Krivine Positivstellenstatz.</td></tr><tr><td rowspan=1 colspan=1>Lip-SDP</td><td rowspan=1 colspan=1>Upper bound from Fazlyab et al. (2019) multiplied √d where d is the inputdimension of the network.</td></tr><tr><td rowspan=1 colspan=1>UBP</td><td rowspan=1 colspan=1>Upper bound determined by the product of the layer-wise Lipschitz constantswith loometric</td></tr><tr><td rowspan=1 colspan=1>LBS</td><td rowspan=1 colspan=1>Lower bound obtained by sampling 5oooO random points around zero, andevaluating the dual norm of the gradient</td></tr></table>
224
+
225
+ # 7.1 EXPERIMENTS ON RANDOM NETWORKS
226
+
227
+ We compare the bounds obtained by the algorithms described above on networks with random weights and either one or two hidden layers. We define the sparsity level of a network as the maximum number of neurons any neuron in one layer is connected to in the next layer. For example, the network represented on Figure 1 has sparsity 2. The non-zero weights of network’s $i$ -th layer are sampled uniformly in $[ - \frac { \breve { 1 } } { \sqrt { n _ { i } } } , \frac { 1 } { \sqrt { n _ { i } } } ]$ where $n _ { i }$ is the number of neurons in layer $i$ .
228
+
229
+ For different configurations of width and sparsity, we generate 10 random networks and average the obtained Lipschitz bounds. For better comparison, we plot the relative error. Since we do not know the true Lipschitz constant, we cannot compute the true relative error. Instead, we take as reference the lower bound given by LBS. Figures 3 and 5 show the relative error, i.e., $( \hat { L } - L _ { L B S } ) / L _ { L B S }$ where $L _ { L B S }$ is the lower bound computed by LBS and $\hat { L }$ is the estimated upper bound. Figures 9 and 10 in Appendix C we show the values of the computed Lipschitz bounds for 1 and 2 hidden layers respectively.
230
+
231
+ When the chosen degree for LiPopt-k is the smallest as possible, i.e., equal to the depth of the network, we observe that the method is already competitive with the SDP method, especially in the case of 2 hidden layers. When we increment the degree by 1, LiPopt-k becomes uniformly better than SDP over all tested configurations. We remark that the upper bounds given by UBP are too large to be shown in the plots. Similarly, for the 1-hidden layer networks, the bounds from LipSDP are too large to be plotted.
232
+
233
+ Finally, we measured the computation time of the different methods on each tested network (Figures 4 and 6). We observe that the computation time for LiPopt-k heavily depends on the network sparsity, which reflects the fact that such structure is exploited in the algorithm. In contrast, the time required for SDP does not depend on the sparsity, but only on the size of the network. Therefore as the network size grows (with fixed sparsity level), LipOpt-k obtains a better upper bound and runs faster. Also, with our method, we see that it is possible to increase the computation power in order to compute tighter bounds when required, making it more flexible than SDP in terms of computation/accuracy tradeoff. LiPopt uses the Gurobi LP solver, while SDP uses Mosek. All methods run on a single machine with Core i7 2.8Ghz quad-core processor and 16Gb of RAM.
234
+
235
+ ![](images/36715696c6d13101074bebdd53e4699329e7143885a21b2eaae6a91eea796e9d.jpg)
236
+ Figure 3: Lipschitz approximated relative error for 1-hidden layer networks
237
+
238
+ ![](images/16f4460aa96107ed8b842356f329b5f9c62f18f106042c719ca032bde18b336b.jpg)
239
+ Figure 4: Computation times for 1-hidden layer networks (seconds)
240
+
241
+ ![](images/688cbbb935006042a5b738de27979cf8fb8ddd23c626da768e5bb13bf7dbf66b.jpg)
242
+ Figure 5: Lipschitz approximated relative error for 2-hidden layer networks
243
+
244
+ ![](images/2913548161f337fdbd03d9ad1bbad83e6f237e8215410cc7e959db088133e3f3.jpg)
245
+ Figure 6: Computation times for 2-hidden layer networks (seconds)
246
+
247
+ # 7.2 EXPERIMENTS ON TRAINED NETWORKS
248
+
249
+ Similarly, we compare these methods on networks trained on MNIST. The architecture we use is a fully connected network with two hidden layers with 300 and 100 neurons respectively, and with one-hot output of size 10. Since the output is multi-dimensional, we restrict the network to a single output, and estimate the Lipschitz constant with respect to label 8.
250
+
251
+ Moreover, in order to improve the scalability of our method, we train the network using the pruning strategy described in Han et al. $( 2 0 1 5 ) ^ { 2 }$ . After training the full network using a standard technique, the weights of smallest magnitude are set to zero. Then, the network is trained for additional iterations, only updating the nonzero parameters. Doing so, we were able to remove $9 5 \%$ of the weights, while preserving the same test accuracy. We recorded the Lipschitz bounds for various methods in Table 7.2. We observe clear improvement of the Lipschitz bound obtained from LiPopt-k compared to SDP method, even when using $k = 3$ . Also note that the input dimension is too large for the method Lip-SDP to provide competitive bound, so we do not provide the obtained bound for this method.
252
+
253
+ <table><tr><td rowspan=1 colspan=1>Algorithm</td><td rowspan=1 colspan=1>LBS</td><td rowspan=1 colspan=1>LiPopt-4</td><td rowspan=1 colspan=1>LiPopt-3</td><td rowspan=1 colspan=1>SDP</td><td rowspan=1 colspan=1>UBP</td></tr><tr><td rowspan=1 colspan=1>Lipschitz bound</td><td rowspan=1 colspan=1>84.2</td><td rowspan=1 colspan=1>88.3</td><td rowspan=1 colspan=1>94.6</td><td rowspan=1 colspan=1>98.8</td><td rowspan=1 colspan=1>691.5</td></tr></table>
254
+
255
+ # 7.3 ESTIMATING LOCAL LIPSCHITZ CONSTANTS WITH LIPOPT
256
+
257
+ In the of section 7.1, we study the improvement on the upper bound obtained by LiPopt, when we incorporate tighter upper and lower bounds on the variables $s _ { i }$ of the polynomial optimization problem (4). Such bounds arise from the limited range that the pre-activation values of the network can take, when the input is limited to an $\ell _ { \infty }$ -norm ball of radius $\epsilon$ centered at an arbitrary point $x _ { 0 }$ .
258
+
259
+ The algorithm that computes upper and lower bounds on the pre-activation values is fast (it has the same complexity as a forward pass) and is described, for example, in Wong & Kolter (2018). The variables $s _ { i }$ correspond to the value of the derivative of the activation function. For activations like ELU or ReLU, their derivative is monotonically increasing, so we need only evaluate it at the upper and lower bounds of the pre-activation values to obtain corresponding bounds for the variables $s _ { i }$ .
260
+
261
+ We plot the local upper bounds obtained by LiPopt-3 for increasing values of the radius $\epsilon$ , the bound for the global constant (given by LiPopt-3) and the lower bound on the local Lipschitz constant obtained by sampling in the $\epsilon$ -neighborhood (LBS). We sample 15 random networks and plot the average values obtained. We observe clear gap between both estimates, which shows that larger certified balls could be obtained with such method in the robustness certification applications.
262
+
263
+ ![](images/caca3de17318ea9710940bfd4d6d9c624bdb96ef7815b200478040db061a5551.jpg)
264
+ Figure 7: Global vs local Lipschitz constant bounds for 1-hidden layer networks
265
+
266
+ ![](images/adac380da60ee5e5deb213f94cacd68bbe4c0a5ffac2336cfd61a636727ca433.jpg)
267
+ Figure 8: Global vs local Lipschitz constant bounds for 2-hidden layer networks
268
+
269
+ # 8 CONCLUSION AND FUTURE WORK
270
+
271
+ In this work, we have introduced a general approach for computing an upper bound on the Lipschitz constant of neural networks. This approach is based on polynomial positivity certificates and generalizes some existing methods available in the literature. We have empirically demonstrated that it can tightly upper bound such constant. The resulting optimization problems are computationally expensive but the sparsity of the network can reduce this burden.
272
+
273
+ In order to further scale such methods to larger and deeper networks, we are interested in several possible directions: $( i )$ divide-and-conquer approaches splitting the computation on sub-networks in the same spirit of Fazlyab et al. (2019), $( i i )$ exploiting parallel optimization algorithms leveraging the structure of the polynomials, $( i i i )$ custom optimization algorithms with low-memory costs such as Frank-wolfe-type methods for SDP (Yurtsever et al., 2019) as well as stochastic handling of constraints (Fercoq et al., 2019) and $( i v )$ , exploting the symmetries in the polynomial that arise from weight sharing in typical network architectures to further reduce the size of the problems.
274
+
275
+ # ACKNOWLEDGMENTS
276
+
277
+ This project has received funding from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement 725594 - time-data) and from the Swiss National Science Foundation (SNSF) under grant number 200021 178865. FL is supported through a PhD fellowship of the Swiss Data Science Center, a joint venture between EPFL and ETH Zurich. VC acknowledges the 2019 Google Faculty Research Award.
278
+
279
+ REFERENCES
280
+ A. Ahmadi and A. Majumdar. Dsos and sdsos optimization: More tractable alternatives to sum of squares and semidefinite optimization. SIAM Journal on Applied Algebra and Geometry, 3(2):193–230, 2019. doi: 10.1137/18M118935X. URL https://doi.org/10.1137/ 18M118935X.
281
+ Cem Anil, James Lucas, and Roger Grosse. Sorting out Lipschitz function approximation. In Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 291–301, Long Beach, California, USA, 09–15 Jun 2019. PMLR.
282
+ Martin Arjovsky, Soumith Chintala, and Leon Bottou. Wasserstein generative adversarial networks. ´ In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 214–223, International Convention Centre, Sydney, Australia, 06–11 Aug 2017. PMLR.
283
+ Peter L Bartlett, Dylan J Foster, and Matus J Telgarsky. Spectrally-normalized margin bounds for neural networks. In Advances in Neural Information Processing Systems 30, pp. 6240–6249. Curran Associates, Inc., 2017.
284
+ Felix Berkenkamp, Matteo Turchetta, Angela Schoellig, and Andreas Krause. Safe model-based reinforcement learning with stability guarantees. In Advances in Neural Information Processing Systems 30, pp. 908–918. Curran Associates, Inc., 2017.
285
+ Moustapha Cisse, Piotr Bojanowski, Edouard Grave, Yann Dauphin, and Nicolas Usunier. Parseval networks: Improving robustness to adversarial examples. In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 854–863, International Convention Centre, Sydney, Australia, 06–11 Aug 2017. PMLR.
286
+ Djork-Arne Clevert, Thomas Unterthiner, and Sepp Hochreiter. Fast and Accurate Deep Network ´ Learning by Exponential Linear Units (ELUs). arXiv e-prints, art. arXiv:1511.07289, Nov 2015.
287
+ Patrick L. Combettes and Jean-Christophe Pesquet. Lipschitz Certificates for Neural Network Structures Driven by Averaged Activation Operators. arXiv e-prints, art. arXiv:1903.01014, Mar 2019.
288
+ Mahyar Fazlyab, Alexander Robey, Hamed Hassani, Manfred Morari, and George J. Pappas. Efficient and Accurate Estimation of Lipschitz Constants for Deep Neural Networks. arXiv e-prints, art. arXiv:1906.04893, Jun 2019.
289
+ Olivier Fercoq, Ahmet Alacaoglu, Ion Necoara, and Volkan Cevher. Almost surely constrained convex optimization. In Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 1910–1919, Long Beach, California, USA, 09–15 Jun 2019. PMLR.
290
+ Jonathan Frankle and Michael Carbin. The lottery ticket hypothesis: Finding sparse, trainable neural networks. In International Conference on Learning Representations, 2019.
291
+ Bissan Ghaddar, Jakub Marecek, and Martin Mevissen. Optimal power flow as a polynomial optimization problem. IEEE Transactions on Power Systems, 31(1):539–546, 2015.
292
+ Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron C Courville. Improved training of wasserstein gans. In Advances in Neural Information Processing Systems 30, pp. 5767–5777. Curran Associates, Inc., 2017.
293
+ Song Han, Huizi Mao, and William J Dally. Deep compression: Compressing deep neural networks with pruning, trained quantization and huffman coding. arXiv preprint arXiv:1510.00149, 2015.
294
+ David Handelman. Representing polynomials by positive linear functions on compact convex polyhedra. Pacific J. Math., 132(1):35–62, 1988. URL https://projecteuclid.org: 443/euclid.pjm/1102689794.
295
+ Stephen Jose Hanson and Lorien Y. Pratt. Comparing biases for minimal network construction with back-propagation. In Advances in Neural Information Processing Systems 1, pp. 177–185. Morgan-Kaufmann, 1989.
296
+
297
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Conference on Computer Vision and Pattern Recognition, pp. 770–778, 06 2016. doi: 10.1109/CVPR.2016.90.
298
+
299
+ Todd Huster, Cho-Yu Jason Chiang, and Ritu Chadha. Limitations of the Lipschitz constant as a defense against adversarial examples. arXiv e-prints, art. arXiv:1807.09705, Jul 2018.
300
+
301
+ Ming Jin and Javad Lavaei. Stability-certified reinforcement learning: A control-theoretic perspective. arXiv e-prints, art. arXiv:1810.11505, Oct 2018.
302
+
303
+ Masakazu Kojima, Sunyoung Kim, and Hayato Waki. Sparsity in sums of squares of polynomials. Mathematical Programming, 103(1):45–62, May 2005. ISSN 1436-4646. doi: 10.1007/s10107-004-0554-3.
304
+
305
+ Jean-Louis Krivine. Anneaux preordonn ´ es. ´ Journal d’analyse mathematique ´ , 12:p. 307–326, 1964.
306
+
307
+ J. B. Lasserre. Convergent lmi relaxations for nonconvex quadratic programs. In Proceedings of the 39th IEEE Conference on Decision and Control (Cat. No.00CH37187), volume 5, pp. 5041–5046 vol.5, Dec 2000. doi: 10.1109/CDC.2001.914738.
308
+
309
+ Jean B Lasserre. Convergent sdp-relaxations in polynomial optimization with sparsity. SIAM Journal on Optimization, 17(3):822–843, 2006.
310
+
311
+ Jean Bernard Lasserre. An Introduction to Polynomial and Semi-Algebraic Optimization. Cambridge Texts in Applied Mathematics. Cambridge University Press, 2015. doi: 10.1017/ CBO9781107447226.
312
+
313
+ 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. doi: 10.1109/5.726791.
314
+
315
+ Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. In International Conference on Learning Representations, 2018.
316
+
317
+ Jaehyun Park and Stephen Boyd. General heuristics for nonconvex quadratically constrained quadratic programming. arXiv preprint arXiv:1703.07870, 2017.
318
+
319
+ Aditi Raghunathan, Jacob Steinhardt, and Percy Liang. Certified defenses against adversarial examples. In International Conference on Learning Representations, 2018a.
320
+
321
+ Aditi Raghunathan, Jacob Steinhardt, and Percy S Liang. Semidefinite relaxations for certifying robustness to adversarial examples. In Advances in Neural Information Processing Systems, pp. 10877–10887, 2018b.
322
+
323
+ Gilbert Stengle. A nullstellensatz and a positivstellensatz in semialgebraic geometry. Mathematische Annalen, 207(2):87–97, Jun 1974. ISSN 1432-1807. doi: 10.1007/BF01362149.
324
+
325
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian J. Goodfellow, and Rob Fergus. Intriguing properties of neural networks. In 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Conference Track Proceedings, 2014.
326
+
327
+ Aladin Virmaux and Kevin Scaman. Lipschitz regularity of deep neural networks: analysis and efficient estimation. In Advances in Neural Information Processing Systems 31, pp. 3835–3844. Curran Associates, Inc., 2018.
328
+
329
+ H. Waki, S. Kim, M. Kojima, and M. Muramatsu. Sums of squares and semidefinite program relaxations for polynomial optimization problems with structured sparsity. SIAM Journal on Optimization, 17(1):218–242, 2006. doi: 10.1137/050623802.
330
+
331
+ Zizhuo Wang, Song Zheng, Stephen Boyd, and Yinyu Ye. Further relaxations of the sdp approach to sensor network localization. Tech. Rep., 2006.
332
+
333
+ Tillmann Weisser, Jean B Lasserre, and Kim-Chuan Toh. Sparse-bsos: a bounded degree sos hierarchy for large scale polynomial optimization with sparsity. Mathematical Programming Computation, 10(1):1–32, 2018.
334
+
335
+ Lily Weng, Huan Zhang, Hongge Chen, Zhao Song, Cho-Jui Hsieh, Luca Daniel, Duane Boning, and Inderjit Dhillon. Towards fast computation of certified robustness for ReLU networks. In Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 5276–5285, Stockholmsmassan, Stockholm Sweden, 10–15 ¨ Jul 2018. PMLR.
336
+
337
+ Eric Wong and Zico Kolter. Provable defenses against adversarial examples via the convex outer adversarial polytope. In Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 5286–5295, Stockholmsmassan, ¨ Stockholm Sweden, 10–15 Jul 2018. PMLR.
338
+
339
+ Eric Wong, Frank Schmidt, and Zico Kolter. Wasserstein adversarial examples via projected Sinkhorn iterations. In Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 6808–6817, Long Beach, California, USA, 09–15 Jun 2019. PMLR.
340
+
341
+ Saining Xie, Alexander Kirillov, Ross Girshick, and Kaiming He. Exploring Randomly Wired Neural Networks for Image Recognition. International Conference on Computer Vision, Apr 2019.
342
+
343
+ Zhengfeng Yang, Chao Huang, Xin Chen, Wang Lin, and Zhiming Liu. A linear programming relaxation based approach for generating barrier certificates of hybrid systems. In John Fitzgerald, Constance Heitmeyer, Stefania Gnesi, and Anna Philippou (eds.), FM 2016: Formal Methods, pp. 721–738, Cham, 2016. Springer International Publishing. ISBN 978-3-319-48989-6.
344
+
345
+ Yinyu Ye. Approximating quadratic programming with bound and quadratic constraints. Mathematical Programming, 84(2):219–226, Feb 1999. ISSN 1436-4646. doi: 10.1007/s10107980012a.
346
+
347
+ Alp Yurtsever, Olivier Fercoq, and Volkan Cevher. A conditional-gradient-based augmented lagrangian framework. In Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 7272–7281, Long Beach, California, USA, 09–15 Jun 2019. PMLR.
348
+
349
+ Y. Zhang, Z. Yang, W. Lin, H. Zhu, X. Chen, and X. Li. Safety verification of nonlinear hybrid systems based on bilinear programming. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 37(11):2768–2778, Nov 2018. doi: 10.1109/TCAD.2018.2858383.
350
+
351
+ # A PROOF OF THEOREM 1
352
+
353
+ Theorem. Let $f$ be a differentiable and Lipschitz continuous function on an open, convex subset $\mathcal { X }$ of a euclidean space. Let $\| \cdot \|$ be the dual norm. The Lipschitz constant of $f$ is given by
354
+
355
+ $$
356
+ L ( f ) = \operatorname* { s u p } _ { x \in \mathcal { X } } \| \nabla f ( x ) \| _ { * }
357
+ $$
358
+
359
+ Proof. First we show that $L ( f ) \leq \operatorname* { s u p } _ { x \in \mathcal { X } } \left\| \nabla f ( x ) \right\| _ { * }$ .
360
+
361
+ $$
362
+ \begin{array} { r l } { | f ( y ) - f ( x ) | = \displaystyle \left. \int _ { 0 } ^ { 1 } \nabla f ( ( 1 - t ) x + t y ) ^ { T } ( y - x ) d t \right. } & { } \\ { \displaystyle } & { \le \displaystyle \int _ { 0 } ^ { 1 } \left. \nabla f ( ( 1 - t ) x + t y ) ^ { T } ( y - x ) \right. d t } \\ { \displaystyle } & { \le \displaystyle \int _ { 0 } ^ { 1 } \| \nabla f ( ( 1 - t ) x + t y ) \| _ { * } d t \| y - x \| } \\ { \displaystyle } & { \le \operatorname* { s u p } _ { x \in \mathcal { X } } \| \nabla f ( x ) \| _ { * } \| y - x \| } \end{array}
363
+ $$
364
+
365
+ were we have used the convexity of $\mathcal { X }$ .
366
+
367
+ Now we show the reverse inequality $L ( f ) \geq \operatorname* { s u p } _ { x \in \mathcal { X } } \| \nabla f ( x ) \| _ { * }$ . To this end, we show that for any positive $\epsilon$ , we have that $L ( f ) \geq \operatorname* { s u p } _ { x \in \mathcal { X } } \| \nabla f ( x ) \| _ { * } ^ { - } - \epsilon$ .
368
+
369
+ Let $z \in \mathcal { X }$ be such that $\begin{array} { r } { \| \nabla f ( z ) \| _ { * } \geq \operatorname* { s u p } _ { x \in \mathcal { X } } \| \nabla f ( x ) \| _ { * } - \epsilon } \end{array}$ . Because $\mathcal { X }$ is open, there exists a sequence $\{ h _ { k } \} _ { k = 1 } ^ { \infty }$ with the following properties:
370
+
371
+ 1. $\langle h _ { k } , \nabla f ( z ) \rangle = \| h _ { k } \| \| \nabla f ( z ) \| _ { * }$
372
+ 2. $z + h _ { k } \in \mathcal { X }$
373
+ 3. $\scriptstyle \operatorname* { l i m } _ { k \to \infty } h _ { k } = 0$ .
374
+
375
+ By definition of the gradient, there exists a function $\delta$ such that $\begin{array} { r } { \operatorname* { l i m } _ { h 0 } \delta ( h ) = 0 } \end{array}$ and the following holds:
376
+
377
+ $$
378
+ f ( z + h ) = f ( z ) + \langle h , \nabla f ( z ) \rangle + \delta ( h ) \| h \|
379
+ $$
380
+
381
+ For our previously defined iterates $h _ { k }$ we then have
382
+
383
+ $$
384
+ \Rightarrow | f ( z + h _ { k } ) - f ( z ) | = | \| h _ { k } \| \| \nabla f ( z ) \| _ { * } + \delta ( h _ { k } ) \| h _ { k } \| |
385
+ $$
386
+
387
+ Dividing both sides by $\| h _ { k } \|$ and using the definition of $L ( f )$ we finally get
388
+
389
+ $$
390
+ \begin{array} { r l } & { \Rightarrow L ( f ) \geq \left| \frac { f ( z + h _ { k } ) - f ( z ) } { \| h _ { k } \| } \right| = \| \| \nabla f ( z ) \| _ { * } + \delta ( h _ { k } ) \| } \\ & { \Rightarrow L ( f ) \geq \underset { k \to \infty } { \operatorname* { l i m } } \left| \| f ( z ) \| _ { * } + \delta ( h _ { k } ) \right| = \| \nabla f ( z ) \| _ { * } } \\ & { \Rightarrow L ( f ) \geq \underset { x \in \mathcal { X } } { \operatorname* { s u p } } \| \nabla f ( x ) \| _ { * } - \epsilon } \end{array}
391
+ $$
392
+
393
+ # B PROOF OF PROPOSITION 1
394
+
395
+ Proposition. Let $f _ { d }$ be a dense network (all weights are nonzero). The following sets, indexed by $i = 1 , \ldots , n _ { d } ,$ form a valid sparsity pattern for the norm-gradient polynomial of the network $f _ { d }$ :
396
+
397
+ $$
398
+ I _ { i } : = \left\{ s _ { ( d - 1 , i ) } \right\} \cup \left\{ s _ { ( j , k ) } : t h e r e \ e x i s t s a \ d i r e c t e d p a t h f r o m \ s _ { ( j , k ) } \ t o \ s _ { ( d - 1 , i ) } \ i n \ G _ { d } \right\}
399
+ $$
400
+
401
+ Proof. First we show that $\cup _ { i = 1 } ^ { m } I _ { i } = I$ . This comes from the fact that any neuron in the network is connected to at least one neuron in the last layer. Otherwise such neuron could be removed from the network altogether.
402
+
403
+ Now we show the second property of a valid sparsity pattern. Note that the norm-gradient polynomial is composed of monomials corresponding to the product of variables in a path from input to a final neuron. This imples that if we let $p _ { i }$ be the sum of all the terms that involve the neuron $s _ { ( d - 1 , i ) }$ we have that $p = \sum _ { i } p _ { i }$ , and $p _ { i }$ only depends on the variables in $I _ { i }$ .
404
+
405
+ We now show the last property of the valid sparsity pattern. This is the only part where we use that the network is dense. For any network architecture the first two conditions hold. We will use the fact that the maximal cliques of a chordal graph form a valid sparsity pattern (see for example Lasserre (2006)).
406
+
407
+ Because the network is dense, we see that the clique $I _ { i }$ is composed of the neuron in the last layer $s _ { ( d - 1 , i ) }$ and all neurons in the previous layers. Now consider the extension of the computational graph $\hat { G } _ { d } = ( V , \hat { E } )$ where
408
+
409
+ $$
410
+ \hat { E } = E \cup \{ ( s _ { j , k } , s _ { l , m } ) : j , l \leq d - 2 ) \}
411
+ $$
412
+
413
+ which consists of adding all the edges between the neurons that are not in the last layer. We show that this graph is chordal. Let $( a _ { 1 } , \ldots , a _ { r } , a _ { 1 } )$ be a cycle of length at least 4 $( r \geq 4 )$ ). notice that because neurons in the last layer are not connected between them in $\hat { G }$ , no two consecutive neurons in this cycle belong to the last layer. This implies that in the subsequence $( a _ { 1 } , a _ { 2 } , a _ { 3 } , a _ { 4 } , a _ { 5 } )$ at most three belong to the last layer. A simple analysis of all cases implies that it contains at least two nonconsecutive neurons not in the last layer. Neurons not in the last layer are always connected in $\hat { G }$ . This constitutes a chord. This shows that $\hat { G } _ { d }$ is a chordal graph. Its maximal cliques correspond exactly to the sets in proposition.
414
+
415
+ ![](images/c4d3bde944b1201dbb14a1b15dbe0955ab341b628a0782d8b01936caadfeaf19.jpg)
416
+ Figure 9: Lipschitz bound comparison for 1-hidden layer networks
417
+
418
+ ![](images/5b9afc5939934f50f5c505c382a417332da65ece6fd0ac90a05e2e208e5c12a0.jpg)
419
+ Figure 10: Lipschitz bound comparison for 2-hidden layer networks
md/train/rJqFGTslg/rJqFGTslg.md ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PRUNING FILTERS FOR EFFICIENT CONVNETS
2
+
3
+ Hao Li∗ University of Maryland haoli@cs.umd.edu
4
+
5
+ Asim Kadav NEC Labs America asim@nec-labs.com
6
+
7
+ Igor Durdanovic NEC Labs America igord@nec-labs.com
8
+
9
+ Hanan Samet† University of Maryland hjs@cs.umd.edu
10
+
11
+ Hans Peter Graf NEC Labs America hpg@nec-labs.com
12
+
13
+ # ABSTRACT
14
+
15
+ The success of CNNs in various applications is accompanied by a significant increase in the computation and parameter storage costs. Recent efforts toward reducing these overheads involve pruning and compressing the weights of various layers without hurting original accuracy. However, magnitude-based pruning of weights reduces a significant number of parameters from the fully connected layers and may not adequately reduce the computation costs in the convolutional layers due to irregular sparsity in the pruned networks. We present an acceleration method for CNNs, where we prune filters from CNNs that are identified as having a small effect on the output accuracy. By removing whole filters in the network together with their connecting feature maps, the computation costs are reduced significantly. In contrast to pruning weights, this approach does not result in sparse connectivity patterns. Hence, it does not need the support of sparse convolution libraries and can work with existing efficient BLAS libraries for dense matrix multiplications. We show that even simple filter pruning techniques can reduce inference costs for VGG-16 by up to $34 \%$ and ResNet-110 by up to $38 \%$ on CIFAR10 while regaining close to the original accuracy by retraining the networks.
16
+
17
+ # 1 INTRODUCTION
18
+
19
+ The ImageNet challenge has led to significant advancements in exploring various architectural choices in CNNs (Russakovsky et al. (2015); Krizhevsky et al. (2012); Simonyan & Zisserman (2015); Szegedy et al. (2015a); He et al. (2016)). The general trend since the past few years has been that the networks have grown deeper, with an overall increase in the number of parameters and convolution operations. These high capacity networks have significant inference costs especially when used with embedded sensors or mobile devices where computational and power resources may be limited. For these applications, in addition to accuracy, computational efficiency and small network sizes are crucial enabling factors (Szegedy et al. (2015b)). In addition, for web services that provide image search and image classification APIs that operate on a time budget often serving hundreds of thousands of images per second, benefit significantly from lower inference times.
20
+
21
+ There has been a significant amount of work on reducing the storage and computation costs by model compression (Le Cun et al. (1989); Hassibi & Stork (1993); Srinivas & Babu (2015); Han et al. (2015); Mariet & Sra (2016)). Recently Han et al. (2015; 2016b) report impressive compression rates on AlexNet (Krizhevsky et al. (2012)) and VGGNet (Simonyan & Zisserman (2015)) by pruning weights with small magnitudes and then retraining without hurting the overall accuracy. However, pruning parameters does not necessarily reduce the computation time since the majority of the parameters removed are from the fully connected layers where the computation cost is low, e.g., the fully connected layers of VGG-16 occupy $90 \%$ of the total parameters but only contribute less than $1 \%$ of the overall floating point operations (FLOP). They also demonstrate that the convolutional layers can be compressed and accelerated (Iandola et al. (2016)), but additionally require sparse
22
+
23
+ BLAS libraries or even specialized hardware (Han et al. (2016a)). Modern libraries that provide speedup using sparse operations over CNNs are often limited (Szegedy et al. (2015a); Liu et al. (2015)) and maintaining sparse data structures also creates an additional storage overhead which can be significant for low-precision weights.
24
+
25
+ Recent work on CNNs have yielded deep architectures with more efficient design (Szegedy et al. (2015a;b); He & Sun (2015); He et al. (2016)), in which the fully connected layers are replaced with average pooling layers (Lin et al. (2013); He et al. (2016)), which reduces the number of parameters significantly. The computation cost is also reduced by downsampling the image at an early stage to reduce the size of feature maps (He & Sun (2015)). Nevertheless, as the networks continue to become deeper, the computation costs of convolutional layers continue to dominate.
26
+
27
+ CNNs with large capacity usually have significant redundancy among different filters and feature channels. In this work, we focus on reducing the computation cost of well-trained CNNs by pruning filters. Compared to pruning weights across the network, filter pruning is a naturally structured way of pruning without introducing sparsity and therefore does not require using sparse libraries or any specialized hardware. The number of pruned filters correlates directly with acceleration by reducing the number of matrix multiplications, which is easy to tune for a target speedup. In addition, instead of layer-wise iterative fine-tuning (retraining), we adopt a one-shot pruning and retraining strategy to save retraining time for pruning filters across multiple layers, which is critical for pruning very deep networks. Finally, we observe that even for ResNets, which have significantly fewer parameters and inference costs than AlexNet or VGGNet, still have about $30 \%$ of FLOP reduction without sacrificing too much accuracy. We conduct sensitivity analysis for convolutional layers in ResNets that improves the understanding of ResNets.
28
+
29
+ # 2 RELATED WORK
30
+
31
+ The early work by Le Cun et al. (1989) introduces Optimal Brain Damage, which prunes weights with a theoretically justified saliency measure. Later, Hassibi & Stork (1993) propose Optimal Brain Surgeon to remove unimportant weights determined by the second-order derivative information. Mariet & Sra (2016) reduce the network redundancy by identifying a subset of diverse neurons that does not require retraining. However, this method only operates on the fully-connected layers and introduce sparse connections.
32
+
33
+ To reduce the computation costs of the convolutional layers, past work have proposed to approximate convolutional operations by representing the weight matrix as a low rank product of two smaller matrices without changing the original number of filters (Denil et al. (2013); Jaderberg et al. (2014); Zhang et al. (2015b;a); Tai et al. (2016); Ioannou et al. (2016)). Other approaches to reduce the convolutional overheads include using FFT based convolutions (Mathieu et al. (2013)) and fast convolution using the Winograd algorithm (Lavin & Gray (2016)). Additionally, quantization (Han et al. (2016b)) and binarization (Rastegari et al. (2016); Courbariaux & Bengio (2016)) can be used to reduce the model size and lower the computation overheads. Our method can be used in addition to these techniques to reduce computation costs without incurring additional overheads.
34
+
35
+ Several work have studied removing redundant feature maps from a well trained network (Anwar et al. (2015); Polyak & Wolf (2015)). Anwar et al. (2015) introduce a three-level pruning of the weights and locate the pruning candidates using particle filtering, which selects the best combination from a number of random generated masks. Polyak & Wolf (2015) detect the less frequently activated feature maps with sample input data for face detection applications. We choose to analyze the filter weights and prune filters with their corresponding feature maps using a simple magnitude based measure, without examining possible combinations. We also introduce network-wide holistic approaches to prune filters for simple and complex convolutional network architectures.
36
+
37
+ Concurrently with our work, there is a growing interest in training compact CNNs with sparse constraints (Lebedev & Lempitsky (2016); Zhou et al. (2016); Wen et al. (2016)). Lebedev & Lempitsky (2016) leverage group-sparsity on the convolutional filters to achieve structured brain damage, i.e., prune the entries of the convolution kernel in a group-wise fashion. Zhou et al. (2016) add group-sparse regularization on neurons during training to learn compact CNNs with reduced filters. Wen et al. (2016) add structured sparsity regularizer on each layer to reduce trivial filters, channels or even layers. In the filter-level pruning, all above work use $\ell _ { 2 , 1 }$ -norm as a regularizer.
38
+
39
+ Similar to the above work, we use $\ell _ { 1 }$ -norm to select unimportant filters and physically prune them. Our fine-tuning process is the same as the conventional training procedure, without introducing additional regularization. Our approach does not introduce extra layer-wise meta-parameters for the regularizer except for the percentage of filters to be pruned, which is directly related to the desired speedup. By employing stage-wise pruning, we can set a single pruning rate for all layers in one stage.
40
+
41
+ # 3 PRUNING FILTERS AND FEATURE MAPS
42
+
43
+ Let $n _ { i }$ denote the number of input channels for the $i$ th convolutional layer and $h _ { i } / w _ { i }$ be the height/width of the input feature maps. The convolutional layer transforms the input feature maps $\mathbf { x } _ { i } \ \in \ \mathbb { R } ^ { n _ { i } \times h _ { i } \times w _ { i } }$ into the output feature maps $\mathbf { x } _ { i + 1 } \in \mathbb { R } ^ { n _ { i + 1 } \times h _ { i + 1 } \times w _ { i + 1 } }$ , which are used as input feature maps for the next convolutional layer. This is achieved by applying $n _ { i + 1 }$ 3D filters $\dot { \mathcal { F } } _ { i , j } \in \mathbb { R } ^ { n _ { i } \times k \times k }$ on the $n _ { i }$ input channels, in which one filter generates one feature map. Each filter is composed by $n _ { i }$ 2D kernels $\mathcal { K } \in \mathbb { R } ^ { k \times k }$ (e.g., $3 \times 3 ,$ ). All the filters, together, constitute the kernel matrix $\bar { \mathcal { F } _ { i } } \in \mathbb { R } ^ { n _ { i } \times n _ { i + 1 } \times k \times k }$ . The number of operations of the convolutional layer is $n _ { i + 1 } n _ { i } k ^ { 2 } h _ { i + 1 } w _ { i + 1 }$ . As shown in Figure 1, when a filter $\mathcal { F } _ { i , j }$ is pruned, its corresponding feature map $\mathbf { x } _ { i + 1 , j }$ is removed, which reduces $n _ { i } k ^ { 2 } h _ { i + 1 } w _ { i + 1 }$ operations. The kernels that apply on the removed feature maps from the filters of the next convolutional layer are also removed, which saves an additional $n _ { i + 2 } k ^ { 2 } h _ { i + 2 } w _ { i + 2 }$ operations. Pruning $m$ filters of layer $i$ will reduce $m / n _ { i + 1 }$ of the computation cost for both layers $i$ and $i + 1$ .
44
+
45
+ ![](images/619352a13ffe559234e5f9fabf6d64df485dbd1a171e3c7e4032d1a96fa87aef.jpg)
46
+ Figure 1: Pruning a filter results in removal of its corresponding feature map and related kernels in the next layer.
47
+
48
+ # 3.1 DETERMINING WHICH FILTERS TO PRUNE WITHIN A SINGLE LAYER
49
+
50
+ Our method prunes the less useful filters from a well-trained model for computational efficiency while minimizing the accuracy drop. We measure the relative importance of a filter in each layer by calculating the sum of its absolute weights $\sum | \mathcal { F } _ { i , j } |$ , i.e., its $\ell _ { 1 }$ -norm $\| \mathcal { F } _ { i , j } \| _ { 1 }$ . Since the number of input channels, $n _ { i }$ , is the same across filters, $\sum \lvert \mathcal { F } _ { i , j } \rvert$ also represents the average magnitude of its kernel weights. This value gives an expectation of the magnitude of the output feature map. Filters with smaller kernel weights tend to produce feature maps with weak activations as compared to the other filters in that layer. Figure 2(a) illustrates the distribution of filters’ absolute weights sum for each convolutional layer in a VGG-16 network trained on the CIFAR-10 dataset, where the distribution varies significantly across layers. We find that pruning the smallest filters works better in comparison with pruning the same number of random or largest filters (Section 4.4). Compared to other criteria for activation-based feature map pruning (Section 4.5), we find $\ell _ { 1 }$ -norm is a good criterion for data-free filter selection.
51
+
52
+ The procedure of pruning $m$ filters from the ith convolutional layer is as follows:
53
+
54
+ 1. For each filter $\mathcal { F } _ { i , j }$ , calculate the sum of its absolute kernel weights $\begin{array} { r } { s _ { j } = \sum _ { l = 1 } ^ { n _ { i } } \sum | \mathcal { K } _ { l } | } \end{array}$ .
55
+ 2. Sort the filters by $s _ { j }$ .
56
+ 3. Prune $m$ filters with the smallest sum values and their corresponding feature maps. The kernels in the next convolutional layer corresponding to the pruned feature maps are also removed.
57
+ 4. A new kernel matrix is created for both the $i$ th and $i + 1$ th layers, and the remaining kernel weights are copied to the new model.
58
+
59
+ ![](images/ce53c95f05812b506661a08f7bdfa02de648dd1c7b323bdd24083968e33e810e.jpg)
60
+ Figure 2: (a) Sorting filters by absolute weights sum for each layer of VGG-16 on CIFAR-10. The $\mathbf { X }$ -axis is the filter index divided by the total number of filters. The y-axis is the filter weight sum divided by the max sum value among filters in that layer. (b) Pruning filters with the lowest absolute weights sum and their corresponding test accuracies on CIFAR-10. (c) Prune and retrain for each single layer of VGG-16 on CIFAR-10. Some layers are sensitive and it can be harder to recover accuracy after pruning them.
61
+
62
+ Relationship to pruning weights Pruning filters with low absolute weights sum is similar to pruning low magnitude weights (Han et al. (2015)). Magnitude-based weight pruning may prune away whole filters when all the kernel weights of a filter are lower than a given threshold. However, it requires a careful tuning of the threshold and it is difficult to predict the exact number of filters that will eventually be pruned. Furthermore, it generates sparse convolutional kernels which can be hard to accelerate given the lack of efficient sparse libraries, especially for the case of low-sparsity.
63
+
64
+ Relationship to group-sparse regularization on filters Recent work (Zhou et al. (2016); Wen et al. (2016)) apply group-sparse regularization $( \sum _ { j = 1 } ^ { n _ { i } } \| \mathcal { F } _ { i , j } \| _ { 2 }$ or $\ell _ { 2 , 1 }$ -norm) on convolutional filters, which also favor to zero-out filters with small $l _ { 2 }$ -norms, i.e. $\mathcal { F } _ { i , j } = \mathbf { 0 }$ . In practice, we do not observe noticeable difference between the $\ell _ { 2 }$ -norm and the $\ell _ { 1 }$ -norm for filter selection, as the important filters tend to have large values for both measures (Appendix 6.1). Zeroing out weights of multiple filters during training has a similar effect to pruning filters with the strategy of iterative pruning and retraining as introduced in Section 3.4.
65
+
66
+ # 3.2 DETERMINING SINGLE LAYER’S SENSITIVITY TO PRUNING
67
+
68
+ To understand the sensitivity of each layer, we prune each layer independently and evaluate the resulting pruned network’s accuracy on the validation set. Figure 2(b) shows that layers that maintain their accuracy as filters are pruned away correspond to layers with larger slopes in Figure 2(a). On the contrary, layers with relatively flat slopes are more sensitive to pruning. We empirically determine the number of filters to prune for each layer based on their sensitivity to pruning. For deep networks such as VGG-16 or ResNets, we observe that layers in the same stage (with the same feature map size) have a similar sensitivity to pruning. To avoid introducing layer-wise meta-parameters, we use the same pruning ratio for all layers in the same stage. For layers that are sensitive to pruning, we prune a smaller percentage of these layers or completely skip pruning them.
69
+
70
+ # 3.3 PRUNING FILTERS ACROSS MULTIPLE LAYERS
71
+
72
+ We now discuss how to prune filters across the network. Previous work prunes the weights on a layer by layer basis, followed by iteratively retraining and compensating for any loss of accuracy (Han et al. (2015)). However, understanding how to prune filters of multiple layers at once can be useful: 1) For deep networks, pruning and retraining on a layer by layer basis can be extremely time-consuming 2) Pruning layers across the network gives a holistic view of the robustness of the network resulting in a smaller network 3) For complex networks, a holistic approach may be necessary. For example, for the ResNet, pruning the identity feature maps or the second layer of each residual block results in additional pruning of other layers.
73
+
74
+ To prune filters across multiple layers, we consider two strategies for layer-wise filter selection:
75
+
76
+ • Independent pruning determines which filters should be pruned at each layer independent of other layers.
77
+
78
+ • Greedy pruning accounts for the filters that have been removed in the previous layers. This strategy does not consider the kernels for the previously pruned feature maps while calculating the sum of absolute weights.
79
+
80
+ Figure 3 illustrates the difference between two approaches in calculating the sum of absolute weights. The greedy approach, though not globally optimal, is holistic and results in pruned networks with higher accuracy especially when many filters are pruned.
81
+
82
+ ![](images/9ae252ba29e79b34067305970cd8873607231fa869f3c8846bab1134d42119e8.jpg)
83
+ Figure 3: Pruning filters across consecutive layers. The independent pruning strategy calculates the filter sum (columns marked in green) without considering feature maps removed in previous layer (shown in blue), so the kernel weights marked in yellow are still included. The greedy pruning strategy does not count kernels for the already pruned feature maps. Both approaches result in a $( n _ { i + 1 } - 1 ) \times ( n _ { i + 2 } - 1 )$ kernel matrix.
84
+
85
+ ![](images/fc4073cfc9ee90662e1f6addd6326c8c3a456ccc6af00f2f1d2fce366232de18.jpg)
86
+ Figure 4: Pruning residual blocks with the projection shortcut. The filters to be pruned for the second layer of the residual block (marked as green) are determined by the pruning result of the shortcut projection. The first layer of the residual block can be pruned without restrictions.
87
+
88
+ For simpler CNNs like VGGNet or AlexNet, we can easily prune any of the filters in any convolutional layer. However, for complex network architectures such as Residual networks (He et al. (2016)), pruning filters may not be straightforward. The architecture of ResNet imposes restrictions and the filters need to be pruned carefully. We show the filter pruning for residual blocks with projection mapping in Figure 4. Here, the filters of the first layer in the residual block can be arbitrarily pruned, as it does not change the number of output feature maps of the block. However, the correspondence between the output feature maps of the second convolutional layer and the identity feature maps makes it difficult to prune. Hence, to prune the second convolutional layer of the residual block, the corresponding projected feature maps must also be pruned. Since the identical feature maps are more important than the added residual maps, the feature maps to be pruned should be determined by the pruning results of the shortcut layer. To determine which identity feature maps are to be pruned, we use the same selection criterion based on the filters of the shortcut convolutional layers (with $1 \times 1$ kernels). The second layer of the residual block is pruned with the same filter index as selected by the pruning of the shortcut layer.
89
+
90
+ # 3.4 RETRAINING PRUNED NETWORKS TO REGAIN ACCURACY
91
+
92
+ After pruning the filters, the performance degradation should be compensated by retraining the network. There are two strategies to prune the filters across multiple layers:
93
+
94
+ 1. Prune once and retrain: Prune filters of multiple layers at once and retrain them until the original accuracy is restored.
95
+
96
+ 2. Prune and retrain iteratively: Prune filters layer by layer or filter by filter and then retrain iteratively. The model is retrained before pruning the next layer for the weights to adapt to the changes from the pruning process.
97
+
98
+ We find that for the layers that are resilient to pruning, the prune and retrain once strategy can be used to prune away significant portions of the network and any loss in accuracy can be regained by retraining for a short period of time (less than the original training time). However, when some filters from the sensitive layers are pruned away or large portions of the networks are pruned away, it may not be possible to recover the original accuracy. Iterative pruning and retraining may yield better results, but the iterative process requires many more epochs especially for very deep networks.
99
+
100
+ # 4 EXPERIMENTS
101
+
102
+ We prune two types of networks: simple CNNs (VGG-16 on CIFAR-10) and Residual networks (ResNet-56/110 on CIFAR-10 and ResNet-34 on ImageNet). Unlike AlexNet or VGG (on ImageNet) that are often used to demonstrate model compression, both VGG (on CIFAR-10) and Residual networks have fewer parameters in the fully connected layers. Hence, pruning a large percentage of parameters from these networks is challenging. We implement our filter pruning method in Torch7 (Collobert et al. (2011)). When filters are pruned, a new model with fewer filters is created and the remaining parameters of the modified layers as well as the unaffected layers are copied into the new model. Furthermore, if a convolutional layer is pruned, the weights of the subsequent batch normalization layer are also removed. To get the baseline accuracies for each network, we train each model from scratch and follow the same pre-processing and hyper-parameters as ResNet (He et al. (2016)). For retraining, we use a constant learning rate 0.001 and retrain 40 epochs for CIFAR-10 and 20 epochs for ImageNet, which represents one-fourth of the original training epochs. Past work has reported up to $3 \times$ original training times to retrain pruned networks (Han et al. (2015)).
103
+
104
+ Table 1: Overall results. The best test/validation accuracy during the retraining process is reported. Training a pruned model from scratch performs worse than retraining a pruned model, which may indicate the difficulty of training a network with a small capacity.
105
+
106
+ <table><tr><td>Model</td><td>Error(%)</td><td>FLOP</td><td>Pruned %</td><td>Parameters</td><td>Pruned %</td></tr><tr><td>VGG-16</td><td>6.75</td><td>3.13×108</td><td></td><td>1.5 ×107</td><td></td></tr><tr><td>VGG-16-pruned-A</td><td>6.60</td><td>2.06×108</td><td>34.2%</td><td>5.4×106</td><td>64.0%</td></tr><tr><td>VGG-16-pruned-A scratch-train</td><td>6.88</td><td></td><td></td><td></td><td></td></tr><tr><td>ResNet-56</td><td>6.96</td><td>1.25×108</td><td></td><td>8.5×105</td><td></td></tr><tr><td>ResNet-56-pruned-A</td><td>6.90</td><td>1.12 ×108</td><td>10.4%</td><td>7.7×105</td><td>9.4%</td></tr><tr><td>ResNet-56-pruned-B</td><td>6.94</td><td>9.09×107</td><td>27.6%</td><td>7.3 ×105</td><td>13.7%</td></tr><tr><td>ResNet-56-pruned-B scratch-train</td><td>8.69</td><td></td><td></td><td></td><td></td></tr><tr><td>ResNet-110</td><td>6.47</td><td>2.53×108</td><td></td><td>1.72 × 106</td><td></td></tr><tr><td>ResNet-110-pruned-A</td><td>6.45</td><td>2.13×108</td><td>15.9%</td><td>1.68 × 106</td><td>2.3%</td></tr><tr><td>ResNet-110-pruned-B</td><td>6.70</td><td>1.55×108</td><td>38.6%</td><td>1.16 × 106</td><td>32.4%</td></tr><tr><td>ResNet-11O-pruned-B scratch-train</td><td>7.06</td><td></td><td></td><td></td><td></td></tr><tr><td>ResNet-34</td><td>26.77</td><td>3.64×109</td><td></td><td>2.16×107</td><td></td></tr><tr><td>ResNet-34-pruned-A</td><td>27.44</td><td>3.08×109</td><td>15.5%</td><td>1.99×107</td><td>7.6%</td></tr><tr><td>ResNet-34-pruned-B</td><td>27.83</td><td>2.76×109</td><td>24.2%</td><td>1.93×107</td><td>10.8%</td></tr><tr><td>ResNet-34-pruned-C</td><td>27.52</td><td>3.37×109</td><td>7.5%</td><td>2.01×107</td><td>7.2%</td></tr></table>
107
+
108
+ # 4.1 VGG-16 ON CIFAR-10
109
+
110
+ VGG-16 is a high-capacity network originally designed for the ImageNet dataset (Simonyan & Zisserman (2015)). Recently, Zagoruyko (2015) applies a slightly modified version of the model on CIFAR-10 and achieves state of the art results. As shown in Table 2, VGG-16 on CIFAR-10 consists of 13 convolutional layers and 2 fully connected layers, in which the fully connected layers do not occupy large portions of parameters due to the small input size and less hidden units. We use the model described in Zagoruyko (2015) but add Batch Normalization (Ioffe & Szegedy (2015))
111
+
112
+ Table 2: VGG-16 on CIFAR-10 and the pruned model. The last two columns show the number of feature maps and the reduced percentage of FLOP from the pruned model.
113
+
114
+ <table><tr><td>layer type</td><td>WiXhi</td><td>#Maps</td><td>FLOP</td><td>#Params</td><td>#Maps</td><td>FLOP%</td></tr><tr><td>Conv_1</td><td>32×32</td><td>64</td><td>1.8E+06</td><td>1.7E+03</td><td>32</td><td>50%</td></tr><tr><td>Conv_2</td><td>32×32</td><td>64</td><td>3.8E+07</td><td>3.7E+04</td><td>64</td><td>50%</td></tr><tr><td>Conv_3</td><td>16 ×16</td><td>128</td><td>1.9E+07</td><td>7.4E+04</td><td>128</td><td>0%</td></tr><tr><td>Conv_4</td><td>16 ×16</td><td>128</td><td>3.8E+07</td><td>1.5E+05</td><td>128</td><td>0%</td></tr><tr><td>Conv_5</td><td>8×8</td><td>256</td><td>1.9E+07</td><td>2.9E+05</td><td>256</td><td>0%</td></tr><tr><td>Conv_6</td><td>8×8</td><td>256</td><td>3.8E+07</td><td>5.9E+05</td><td>256</td><td>0%</td></tr><tr><td>Conv_7</td><td>8×8</td><td>256</td><td>3.8E+07</td><td>5.9E+05</td><td>256</td><td>0%</td></tr><tr><td>Conv_8</td><td>4×4</td><td>512</td><td>1.9E+07</td><td>1.2E+06</td><td>256</td><td>50%</td></tr><tr><td>Conv_9</td><td>4×4</td><td>512</td><td>3.8E+07</td><td>2.4E+06</td><td>256</td><td>75%</td></tr><tr><td>Conv_10</td><td>4×4</td><td>512</td><td>3.8E+07</td><td>2.4E+06</td><td>256</td><td>75%</td></tr><tr><td>Conv_11</td><td>2×2</td><td>512</td><td>9.4E+06</td><td>2.4E+06</td><td>256</td><td>75%</td></tr><tr><td>Conv_12</td><td>2×2</td><td>512</td><td>9.4E+06</td><td>2.4E+06</td><td>256</td><td>75%</td></tr><tr><td>Conv_13</td><td>2×2</td><td>512</td><td>9.4E+06</td><td>2.4E+06</td><td>256</td><td>75%</td></tr><tr><td>Linear</td><td>1</td><td>512</td><td>2.6E+05</td><td>2.6E+05</td><td>512</td><td>50%</td></tr><tr><td>Linear</td><td>1</td><td>10</td><td>5.1E+03</td><td>5.1E+03</td><td>10</td><td>0%</td></tr><tr><td>Total</td><td></td><td></td><td>3.1E+08</td><td>1.5E+07</td><td></td><td>34%</td></tr></table>
115
+
116
+ layer after each convolutional layer and the first linear layer, without using Dropout (Srivastava et al. (2014)). Note that when the last convolutional layer is pruned, the input to the linear layer is changed and the connections are also removed.
117
+
118
+ As shown in Figure 2(b), each of the convolutional layers with 512 feature maps can drop at least $60 \%$ of filters without affecting the accuracy. Figure 2(c) shows that with retraining, almost $90 \%$ of the filters of these layers can be safely removed. One possible explanation is that these filters operate on $4 \times 4$ or $2 \times 2$ feature maps, which may have no meaningful spatial connections in such small dimensions. For instance, ResNets for CIFAR-10 do not perform any convolutions for feature maps below $8 \times 8$ dimensions. Unlike previous work (Zeiler & Fergus (2014); Han et al. (2015)), we observe that the first layer is robust to pruning as compared to the next few layers. This is possible for a simple dataset like CIFAR-10, on which the model does not learn as much useful filters as on ImageNet (as shown in Figure. 5). Even when $80 \%$ of the filters from the first layer are pruned, the number of remaining filters (12) is still larger than the number of raw input channels. However, when removing $80 \%$ filters from the second layer, the layer corresponds to a 64 to 12 mapping, which may lose significant information from previous layers, thereby hurting the accuracy. With $50 \%$ of the filters being pruned in layer 1 and from 8 to 13, we achieve $34 \%$ FLOP reduction for the same accuracy.
119
+
120
+ ![](images/23352f419b41f8e139001d11b41b305f079257025f13118ff68de90d67b8db68.jpg)
121
+ Figure 5: Visualization of filters in the first convolutional layer of VGG-16 trained on CIFAR-10. Filters are ranked by $\ell _ { 1 }$ -norm.
122
+
123
+ # 4.2 RESNET-56/110 ON CIFAR-10
124
+
125
+ ResNets for CIFAR-10 have three stages of residual blocks for feature maps with sizes of $3 2 \times 3 2$ , $1 6 \times 1 6$ and $8 \times 8$ . Each stage has the same number of residual blocks. When the number of feature maps increases, the shortcut layer provides an identity mapping with an additional zero padding for the increased dimensions. Since there is no projection mapping for choosing the identity feature maps, we only consider pruning the first layer of the residual block. As shown in Figure 6, most of the layers are robust to pruning. For ResNet-110, pruning some single layers without retraining even improves the performance. In addition, we find that layers that are sensitive to pruning (layers 20, 38 and 54 for ResNet-56, layer 36, 38 and 74 for ResNet-110) lie at the residual blocks close to the layers where the number of feature maps changes, e.g., the first and the last residual blocks for each stage. We believe this happens because the precise residual errors are necessary for the newly added empty feature maps.
126
+
127
+ ![](images/518d5649c7670f16528b1371c32ea03d282ec91caa3c460e5259dbe367688d1c.jpg)
128
+ Figure 6: Sensitivity to pruning for the first layer of each residual block of ResNet-56/110.
129
+
130
+ The retraining performance can be improved by skipping these sensitive layers. As shown in Table 1, ResNet-56-pruned-A improves the performance by pruning $10 \%$ filters while skipping the sensitive layers 16, 20, 38 and 54. In addition, we find that deeper layers are more sensitive to pruning than layers in the earlier stages of the network. Hence, we use a different pruning rate for each stage. We use $p _ { i }$ to denote the pruning rate for layers in the ith stage. ResNet-56-pruned-B skips more layers (16, 18, 20, 34, 38, 54) and prunes layers with $p _ { 1 } { = } 6 0 \%$ , $p _ { 2 } { = } 3 0 \%$ and $p _ { 3 } { = } 1 0 \%$ . For ResNet-110, the first pruned model gets a slightly better result with $p _ { 1 } { = } 5 0 \%$ and layer 36 skipped. ResNet-110-pruned-B skips layers 36, 38, 74 and prunes with $p _ { 1 } { = } 5 0 \%$ , $p _ { 2 } { = } 4 0 \%$ and $p _ { 3 } { = } 3 0 \%$ . When there are more than two residual blocks at each stage, the middle residual blocks may be redundant and can be easily pruned. This might explain why ResNet-110 is easier to prune than ResNet-56.
131
+
132
+ # 4.3 RESNET-34 ON ILSVRC2012
133
+
134
+ ResNets for ImageNet have four stages of residual blocks for feature maps with sizes of $5 6 \times 5 6$ , $2 8 \times 2 8$ , $1 4 \times 1 4$ and $7 \times 7$ . ResNet-34 uses the projection shortcut when the feature maps are down-sampled. We first prune the first layer of each residual block. Figure 7 shows the sensitivity of the first layer of each residual block. Similar to ResNet-56/110, the first and the last residual blocks of each stage are more sensitive to pruning than the intermediate blocks (i.e., layers 2, 8, 14, 16, 26, 28, 30, 32). We skip those layers and prune the remaining layers at each stage equally. In Table 1 we compare two configurations of pruning percentages for the first three stages: (A) $p _ { 1 } { = } 3 0 \%$ , $p _ { 2 } { = } 3 0 \%$ , $p _ { 3 } { = } 3 0 \%$ ; (B) $p _ { 1 } { = } 5 0 \%$ , $p _ { 2 } { = } 6 0 \%$ , $p _ { 3 } { = } 4 0 \%$ . Option-B provides $24 \%$ FLOP reduction with about $1 \%$ loss in accuracy. As seen in the pruning results for ResNet-50/110, we can predict that ResNet-34 is relatively more difficult to prune as compared to deeper ResNets.
135
+
136
+ We also prune the identity shortcuts and the second convolutional layer of the residual blocks. As these layers have the same number of filters, they are pruned equally. As shown in Figure 7(b), these layers are more sensitive to pruning than the first layers. With retraining, ResNet-34-pruned-C prunes the third stage with $p _ { 3 } { = } 2 0 \%$ and results in $7 . 5 \%$ FLOP reduction with $0 . 7 5 \%$ loss in accuracy. Therefore, pruning the first layer of the residual block is more effective at reducing the overall FLOP than pruning the second layer. This finding also correlates with the bottleneck block design for deeper ResNets, which first reduces the dimension of input feature maps for the residual layer and then increases the dimension to match the identity mapping.
137
+
138
+ ![](images/041fa18e6af678dd399d55b5a64d77da9e68736c9689848439255c4fcb3ad40b.jpg)
139
+ Figure 7: Sensitivity to pruning for the residual blocks of ResNet-34.
140
+
141
+ # 4.4 COMPARISON WITH PRUNING RANDOM FILTERS AND LARGEST FILTERS
142
+
143
+ We compare our approach with pruning random filters and largest filters. As shown in Figure 8, pruning the smallest filters outperforms pruning random filters for most of the layers at different pruning ratios. For example, smallest filter pruning has better accuracy than random filter pruning for all layers with the pruning ratio of $90 \%$ . The accuracy of pruning filters with the largest $\ell _ { 1 }$ -norms drops quickly as the pruning ratio increases, which indicates the importance of filters with larger $\ell _ { 1 }$ -norms.
144
+
145
+ ![](images/c7b364a8ebb1bb575cf84dad08332b77306c45d971300a3a63deeccf745c0a27.jpg)
146
+ Figure 8: Comparison of three pruning methods for VGG-16 on CIFAR-10: pruning the smallest filters, pruning random filters and pruning the largest filters. In random filter pruning, the order of filters to be pruned is randomly permuted.
147
+
148
+ # 4.5 COMPARISON WITH ACTIVATION-BASED FEATURE MAP PRUNING
149
+
150
+ The activation-based feature map pruning method removes the feature maps with weak activation patterns and their corresponding filters and kernels (Polyak & Wolf (2015)), which needs sample data as input to determine which feature maps to prune. A feature map $\mathbf { x } _ { i + 1 , j } \in \mathbb { R } ^ { w _ { i + 1 } \times h _ { i + 1 } }$ is generated by applying filter $\mathcal { F } _ { i , j } \in \mathbb { R } ^ { n _ { i } \times k \times k }$ to feature maps of previous layer $\mathbf { x } _ { i } \in \mathbb { R } ^ { n _ { i } \times w _ { i } \times h _ { i } }$ , i.e., $\mathbf { x } _ { i + 1 , j } = \mathcal { F } _ { i , j } * \mathbf { x } _ { i }$ . Given $N$ randomly selected images $\{ \mathbf { x } _ { 1 } ^ { n } \} _ { n = 1 } ^ { N }$ from the training set, the statistics of each feature map can be estimated with one epoch forward pass of the $N$ sampled data. Note that we calculate statistics on the feature maps generated from the convolution operations before batch normalization or non-linear activation. We compare our $\ell _ { 1 }$ -norm based filter pruning with feature map pruning using the following criteria: $\begin{array} { r } { \sigma _ { \mathfrak { m e a n - m e a n } } ( \mathbf { x } _ { i , j } ) = \frac { 1 } { N } \sum _ { n = 1 } ^ { N } \mathfrak { m e a n } ( \mathbf { x } _ { i , j } ^ { n } ) . } \end{array}$ , $\sigma _ { \mathrm { m e a n - s t d } } ( \mathbf { x } _ { i , j } ) =$ $\begin{array} { r } { \frac { 1 } { N } \sum _ { n = 1 } ^ { N } \mathsf { s t d } ( \mathbf { x } _ { i , j } ^ { n } ) } \end{array}$ , $\begin{array} { r } { \sigma _ { \mathrm { m e a n } - \ell _ { 1 } } ( \mathbf { x } _ { i , j } ) = \frac { 1 } { N } \sum _ { n = 1 } ^ { N } \vert \vert \mathbf { x } _ { i , j } ^ { n } \vert \vert _ { 1 } } \end{array}$ , $\begin{array} { r } { \sigma _ { \mathrm { m e a n } - \ell _ { 2 } } ( \mathbf { x } _ { i , j } ) = \frac { 1 } { N } \sum _ { n = 1 } ^ { N } \vert \vert \mathbf { x } _ { i , j } ^ { n } \vert \vert _ { 2 } } \end{array}$ and $\sigma _ { \mathrm { v a r - } \ell _ { 2 } } ( \mathbf { x } _ { i , j } ) = \mathrm { v a r } ( \{ \| \mathbf { x } _ { i , j } ^ { n } \| _ { 2 } \} _ { n = 1 } ^ { N } )$ , where mean, std and var are standard statistics (average, standard deviation and variance) of the input. Here, $\sigma _ { \tt V a r - \ell _ { 2 } }$ is the contribution variance of channel criterion proposed in Polyak & Wolf (2015), which is motivated by the intuition that an unimportant feature map has almost similar outputs for the whole training data and acts like an additional bias.
151
+
152
+ ![](images/7d798fe84aa3510a694c1faa2b1b37ea5c43b9698e0e5def97a3874b09d58360.jpg)
153
+ Figure 9: Comparison of activation-based feature map pruning for VGG-16 on CIFAR-10.
154
+
155
+ The estimation of the criteria becomes more accurate when more sample data is used. Here we use the whole training set $N = 5 0$ , 000 for CIFAR-10) to compute the statistics. The performance of feature map pruning with above criteria for each layer is shown in Figure 9. Smallest filter pruning outperforms feature map pruning with the criteria $\sigma _ { \mathrm { m e a n - m e a n } }$ , $\sigma _ { \mathrm { m e a n } - \ell _ { 1 } }$ , $\sigma _ { \mathrm { m e a n } - \ell _ { 2 } }$ and $\sigma _ { \tt V a r - \ell _ { 2 } }$ . The $\sigma _ { \mathrm { m e a n - s t d } }$ criterion has better or similar performance to $\ell _ { 1 }$ -norm up to pruning ratio of $60 \%$ . However, its performance drops quickly after that especially for layers of conv 1, conv 2 and conv 3. We find $\ell _ { 1 }$ -norm is a good heuristic for filter selection considering that it is data free.
156
+
157
+ # 5 CONCLUSIONS
158
+
159
+ Modern CNNs often have high capacity with large training and inference costs. In this paper we present a method to prune filters with relatively low weight magnitudes to produce CNNs with reduced computation costs without introducing irregular sparsity. It achieves about $30 \%$ reduction in FLOP for VGGNet (on CIFAR-10) and deep ResNets without significant loss in the original accuracy. Instead of pruning with specific layer-wise hayperparameters and time-consuming iterative retraining, we use the one-shot pruning and retraining strategy for simplicity and ease of implementation. By performing lesion studies on very deep CNNs, we identify layers that are robust or sensitive to pruning, which can be useful for further understanding and improving the architectures.
160
+
161
+ # ACKNOWLEDGMENTS
162
+
163
+ The authors would like to thank the anonymous reviewers for their valuable feedback.
164
+
165
+ # REFERENCES
166
+
167
+ Sajid Anwar, Kyuyeon Hwang, and Wonyong Sung. Structured Pruning of Deep Convolutional Neural Networks. arXiv preprint arXiv:1512.08571, 2015.
168
+
169
+ Ronan Collobert, Koray Kavukcuoglu, and Clement Farabet. Torch7: A matlab-like environment for ´ machine learning. In BigLearn, NIPS Workshop, 2011.
170
+ Matthieu Courbariaux and Yoshua Bengio. Binarynet: Training deep neural networks with weights and activations constrained to+ 1 or-1. arXiv preprint arXiv:1602.02830, 2016.
171
+ Misha Denil, Babak Shakibi, Laurent Dinh, Nando de Freitas, et al. Predicting parameters in deep learning. In NIPS, 2013.
172
+ Song Han, Jeff Pool, John Tran, and William Dally. Learning both Weights and Connections for Efficient Neural Network. In NIPS, 2015.
173
+ Song Han, Xingyu Liu, Huizi Mao, Jing Pu, Ardavan Pedram, Mark A Horowitz, and William J Dally. EIE: Efficient Inference Engine on Compressed Deep Neural Network. In ISCA, 2016a.
174
+ Song Han, Huizi Mao, and William J Dally. Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding. In ICLR, 2016b.
175
+ Babak Hassibi and David G Stork. Second Order Derivatives for Network Pruning: Optimal Brain Surgeon. In NIPS, 1993.
176
+ Kaiming He and Jian Sun. Convolutional Neural Networks at Constrained Time Cost. In CVPR, 2015.
177
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep Residual Learning for Image Recognition. In CVPR, 2016.
178
+ Forrest Iandola, Matthew Moskewicz, Khalidand Ashraf, Song Han, William Dally, and Keutzer Kurt. SqueezeNet: AlexNet-level accuracy with $5 0 \mathrm { x }$ fewer parameters and ¡ 1MB model size. arXiv preprint arXiv:1602.07360, 2016.
179
+ Yani Ioannou, Duncan Robertson, Jamie Shotton, Roberto Cipolla, and Antonio Criminisi. Training CNNs with Low-Rank Filters for Efficient Image Classification. In ICLR, 2016.
180
+ Sergey Ioffe and Christian Szegedy. Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift. 2015.
181
+ Max Jaderberg, Andrea Vedaldi, and Andrew Zisserman. Speeding up convolutional neural networks with low rank expansions. In BMVC, 2014.
182
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet Classification with Deep Convolutional Neural Networks. In NIPS, 2012.
183
+ Andrew Lavin and Scott Gray. Fast Algorithms for Convolutional Neural Networks. In CVPR, 2016.
184
+ Yann Le Cun, John S Denker, and Sara A Solla. Optimal Brain Damage. In NIPS, 1989.
185
+ Vadim Lebedev and Victor Lempitsky. Fast Convnets Using Group-wise Brain Damage. In CVPR, 2016.
186
+ Min Lin, Qiang Chen, and Shuicheng Yan. Network in Network. arXiv preprint arXiv:1312.4400, 2013.
187
+ Baoyuan Liu, Min Wang, Hassan Foroosh, Marshall Tappen, and Marianna Pensky. Sparse Convolutional Neural Networks. In CVPR, 2015.
188
+ Zelda Mariet and Suvrit Sra. Diversity Networks. In ICLR, 2016.
189
+ Michael Mathieu, Mikael Henaff, and Yann LeCun. Fast Training of Convolutional Networks through FFTs. arXiv preprint arXiv:1312.5851, 2013.
190
+ Adam Polyak and Lior Wolf. Channel-Level Acceleration of Deep Face Representations. IEEE Access, 2015.
191
+ Mohammad Rastegari, Vicente Ordonez, Joseph Redmon, and Ali Farhadi. XNOR-Net: ImageNet Classification Using Binary Convolutional Neural Networks. In ECCV, 2016.
192
+
193
+ Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. IJCV, 2015.
194
+
195
+ Karen Simonyan and Andrew Zisserman. Very Deep Convolutional Networks for Large-Scale Image Recognition. In ICLR, 2015.
196
+
197
+ Suraj Srinivas and R Venkatesh Babu. Data-free Parameter Pruning for Deep Neural Networks. In BMVC, 2015.
198
+
199
+ Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: A Simple Way to Prevent Neural Networks from Overfitting. JMLR, 2014.
200
+
201
+ Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going Deeper with Convolutions. In CVPR, 2015a.
202
+
203
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the Inception Architecture for Computer Vision. arXiv preprint arXiv:1512.00567, 2015b.
204
+
205
+ Cheng Tai, Tong Xiao, Xiaogang Wang, and Weinan E. Convolutional neural networks with low-rank regularization. In ICLR, 2016.
206
+
207
+ Wei Wen, Chunpeng Wu, Yandan Wang, Yiran Chen, and Hai Li. Learning Structured Sparsity in Deep Learning. In NIPS, 2016.
208
+
209
+ Sergey Zagoruyko. $9 2 . 4 5 \%$ on CIFAR-10 in Torch. http://torch.ch/blog/2015/07/30/ cifar.html, 2015.
210
+
211
+ Matthew D Zeiler and Rob Fergus. Visualizing and Understanding Convolutional Networks. In ECCV, 2014.
212
+
213
+ Xiangyu Zhang, Jianhua Zou, Kaiming He, and Jian Sun. Accelerating Very Deep Convolutional Networks for Classification and Detection. IEEE T-PAMI, 2015a.
214
+
215
+ Xiangyu Zhang, Jianhua Zou, Xiang Ming, Kaiming He, and Jian Sun. Efficient and accurate approximations of nonlinear convolutional networks. In CVPR, 2015b.
216
+
217
+ Hao Zhou, Jose Alvarez, and Fatih Porikli. Less Is More: Towards Compact CNNs. In ECCV, 2016.
218
+
219
+ # 6 APPENDIX
220
+
221
+ # 6.1 COMPARISON WITH $\ell _ { 2 }$ -NORM BASED FILTER PRUNING
222
+
223
+ We compare $\ell _ { 1 }$ -norm with $\ell _ { 2 }$ -norm for filter pruning. As shown in Figure 10, $\ell _ { 1 }$ -norm works slightly better than $\ell _ { 2 }$ -norm for layer conv 2. There is no significant difference between the two norms for other layers.
224
+
225
+ ![](images/cfc4c3de2cb86b8ab6d7da33c8fd76397640b6a559607e78225adaf2931657b8.jpg)
226
+ Figure 10: Comparison of $\ell _ { 1 }$ -norm and $\ell _ { 2 }$ -norm based filter pruning for VGG-16 on CIFAR-10.
227
+
228
+ # 6.2 FLOP AND WALL-CLOCK TIME
229
+
230
+ FLOP is a commonly used measure to compare the computation complexities of CNNs. It is easy to compute and can be done statically, which is independent of the underlying hardware and software implementations. Since we physically prune the filters by creating a smaller model and then copy the weights, there are no masks or sparsity introduced to the original dense BLAS operations. Therefore the FLOP and wall-clock time of the pruned model is the same as creating a model with smaller number of filters from scratch.
231
+
232
+ We report the inference time of the original model and the pruned model on the test set of CIFAR-10 and the validation set of ILSVRC 2012, which contains $1 0 , 0 0 0 3 2 \times 3 2$ images and $5 0 , 0 0 0 2 2 4 \times 2 2 4$ images respectively. The ILSVRC 2012 dataset is used only for ResNet-34. The evaluation is conducted in Torch7 with Titan X (Pascal) GPU and cuDNN v5.1, using a mini-batch size 128. As shown in Table 3, the saved inference time is close to the FLOP reduction. Note that the FLOP number only considers the operations in the Conv and FC layers, while some calculations such as Batch Normalization and other overheads are not accounted.
233
+
234
+ Table 3: The reduction of FLOP and wall-clock time for inference.
235
+
236
+ <table><tr><td>Model</td><td>FLOP</td><td>Pruned %</td><td>Time (s)</td><td>Saved %</td></tr><tr><td>VGG-16</td><td>3.13×108</td><td></td><td>1.23</td><td></td></tr><tr><td>VGG-16-pruned-A</td><td>2.06×108</td><td>34.2%</td><td>0.73</td><td>40.7%</td></tr><tr><td>ResNet-56</td><td>1.25×108</td><td></td><td>1.31</td><td></td></tr><tr><td>ResNet-56-pruned-B</td><td>9.09×107</td><td>27.6%</td><td>0.99</td><td>24.4%</td></tr><tr><td>ResNet-110</td><td>2.53×108</td><td></td><td>2.38</td><td></td></tr><tr><td>ResNet-110-pruned-B</td><td>1.55 ×108</td><td>38.6%</td><td>1.86</td><td>21.8%</td></tr><tr><td>ResNet-34</td><td>3.64×109</td><td></td><td>36.02</td><td></td></tr><tr><td>ResNet-34-pruned-B</td><td>2.76 ×109</td><td>24.2%</td><td>22.93</td><td>28.0%</td></tr></table>
md/train/rJxt0JHKvS/rJxt0JHKvS.md ADDED
@@ -0,0 +1,475 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # COLORING GRAPH NEURAL NETWORKS FOR NODE DISAMBIGUATION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ In this paper, we show that a simple coloring scheme can improve, both theoretically and empirically, the expressive power of Message Passing Neural Networks (MPNNs). More specifically, we introduce a graph neural network called Colored Local Iterative Procedure (CLIP) that uses colors to disambiguate identical node attributes, and show that this representation is a universal approximator of continuous functions on graphs with node attributes. Our method relies on separability, a key topological characteristic that allows to extend well-chosen neural networks into universal representations. Finally, we show experimentally that CLIP is capable of capturing structural characteristics that traditional MPNNs fail to distinguish, while being state-of-the-art on benchmark graph classification datasets.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Learning good representations is seen by many machine learning researchers as the main reason behind the tremendous successes of the field in recent years (Bengio et al., 2013). In image analysis (Krizhevsky et al., 2012), natural language processing (Vaswani et al., 2017) or reinforcement learning (Mnih et al., 2015), groundbreaking results rely on efficient and flexible deep learning architectures that are capable of transforming a complex input into a simple vector while retaining most of its valuable features. The universal approximation theorem (Cybenko, 1989; Hornik et al., 1989; Hornik, 1991; Pinkus, 1999) provides a theoretical framework to analyze the expressive power of such architectures by proving that, under mild hypotheses, multi-layer perceptrons (MLPs) can uniformly approximate any continuous function on a compact set. This result provided a first theoretical justification of the strong approximation capabilities of neural networks, and was the starting point of more refined analyses providing valuable insights into the generalization capabilities of these architectures (Baum and Haussler, 1989; Geman et al., 1992; Saxe et al., 2014; Bartlett et al., 2018).
12
+
13
+ Despite a large literature and state-of-the-art performance on benchmark graph classification datasets, graph neural networks yet lack a similar theoretical foundation (Xu et al., 2019). Universality for these architectures is either hinted at via equivalence with approximate graph isomorphism tests $k$ -WL tests in Xu et al. 2019; Maron et al. 2019a), or proved under restrictive assumptions (finite node attribute space in Murphy et al. 2019). In this paper, we introduce Colored Local Iterative Procedure1 (CLIP), which tackles the limitations of current Message Passing Neural Networks (MPNNs) by showing, both theoretically and experimentally, that adding a simple coloring scheme can improve the flexibility and power of these graph representations. More specifically, our contributions are: 1) we provide a precise mathematical definition for universal graph representations, 2) we present a general mechanism to design universal neural networks using separability, 3) we propose a novel node coloring scheme leading to CLIP, the first provably universal extension of MPNNs, 4) we show that CLIP achieves state of the art results on benchmark datasets while significantly outperforming traditional MPNNs as well as recent methods on graph property testing.
14
+
15
+ The rest of the paper is organized as follows: Section 2 gives an overview of the graph representation literature and related works. Section 3 provides a precise definition for universal representations, as well as a generic method to design them using separable neural networks. In Section 4, we show that most state-of-the-art representations are not sufficiently expressive to be universal. Then, using the analysis of Section 3, Section 5 provides CLIP, a provably universal extension of MPNNs. Finally,
16
+
17
+ Section 6 shows that CLIP achieves state-of-the-art accuracies on benchmark graph classification taks, as well as outperforming its competitors on graph property testing problems.
18
+
19
+ # 2 RELATED WORKS
20
+
21
+ The first works investigating the use of neural networks for graphs used recurrent neural networks to represent directed acyclic graphs (Sperduti and Starita, 1997; Frasconi et al., 1998). More generic graph neural networks were later introduced by Gori et al. (2005); Scarselli et al. (2009), and may be divided into two categories. 1) Spectral methods (Bruna et al., 2014; Henaff et al., 2015; Defferrard et al., 2016; Kipf and Welling, 2017) that perform convolution on the Fourier domain of the graph through the spectral decomposition of the graph Laplacian. 2) Message passing neural networks (Gilmer et al., 2017), sometimes simply referred to as graph neural networks, that are based on the aggregation of neighborhood information through a local iterative process. This category contains most state-of-the-art graph representation methods such as (Duvenaud et al., 2015; Grover and Leskovec, 2016; Lei et al., 2017; Ying et al., 2018; Verma and Zhang, 2019), DeepWalk (Perozzi et al., 2014), graph attention networks (Velickovic et al., 2018), graphSAGE (Hamilton et al., 2017) or GIN (Xu et al., 2019).
22
+
23
+ Recently, (Xu et al., 2019) showed that MPNNs were, at most, as expressive as the WeisfeilerLehman (WL) test for graph isomorphism (Weisfeiler and Lehman, 1968). This suprising result led to several works proposing MPNN extensions to improve their expressivity, and ultimately tend towards universality (Maron et al., 2019a;b;c; Murphy et al., 2019; Chen et al., 2019). However, these graph representations are either as powerful as the $k$ -WL test (Maron et al., 2019a), or provide universal graph representations under the restrictive assumption of finite node attribute space (Murphy et al., 2019). Other recent approaches (Maron et al., 2019c) implies quadratic order of tensors in the size of the considered graphs. Some more powerfull GNNs are studied and benchmarked on real classical datasets and on graph property testing (Kriege et al., 2018; Murphy et al., 2019; Chen et al., 2019): a set of problems that classical MPNNs cannot handle. Our work thus provides a more general and powerful result of universality, matching the original definition of (Cybenko, 1989) for MLPs.
24
+
25
+ # 3 UNIVERSAL REPRESENTATIONS VIA SEPARABILITY
26
+
27
+ In this section we present the theoretical tools used to design our universal graph representation. More specifically, we show that separable representations are sufficiently flexible to capture all relevant information about a given object, and may be extended into universal representations.
28
+
29
+ # 3.1 NOTATIONS AND BASIC ASSUMPTIONS
30
+
31
+ Let $\mathcal { X } , \mathcal { y }$ be two topological spaces, then $\mathcal { F } ( \mathcal { X } , \mathcal { Y } )$ (resp. $\mathcal { C } ( \mathcal { X } , \mathcal { Y } ) )$ denotes the space of all functions (resp. continuous functions) from $\mathcal { X }$ to $\mathcal { V }$ . Moreover, for any group $G$ acting on a set $\mathcal { X }$ , $\mathcal { X } / G$ denotes the set of orbits of $\mathcal { X }$ under the action of $G$ (see Appendix B for more details). Finally, $\| \cdot \|$ is a norm on $\mathbb { R } ^ { d }$ , and $\mathcal { P } _ { n }$ is the set of all permutation matrices of size $n$ . In what follows, we assume that all the considered topological spaces are Hausdorff (see e.g. (Bourbaki, 1998) for an in-depth review): each pair of distinct points can be separated by two disjoint open sets. This assumption is rather weak (e.g. all metric spaces are Hausdorff) and is verified by most topological spaces commonly encountered in the field of machine learning.
32
+
33
+ # 3.2 UNIVERSAL REPRESENTATIONS
34
+
35
+ Let $\mathcal { X }$ be a set of objects (e.g. vectors, images, graphs, or temporal data) to be used as input information for a machine learning task (e.g. classification, regression or clustering). In what follows, we denote as vector representation of $\mathcal { X }$ a function $f : \mathcal { X } \overset { } { \to } \mathbb { R } ^ { d }$ that maps each element $x \in \mathcal { X }$ to a $d$ -dimensional vector $f ( x ) \in \mathbb { R } ^ { d }$ . A standard setting for supervised representation learning is to define a class of vector representations $\mathfrak { F } _ { d } \subset \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$ (e.g. convolutional neural networks for images) and use the target values (e.g. image classes) to learn a good vector representation in light of the supervised learning task (i.e. one vector representation $f \in \mathfrak { F } _ { d }$ that leads to a good accuracy on the learning task). In order to present more general results, we will consider neural network architectures that can output vectors of any size, i.e. $\mathfrak { F } \subset \cup _ { d \in \mathbb { N } ^ { * } } \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$ , and will denote $\mathfrak { F } _ { d } = \mathfrak { F } \cap \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$
36
+
37
+ ![](images/394812434f9c98041d41a217983e4bbe8d4a7a89a342c14b7b6592754ed72c84.jpg)
38
+ Figure 1: Concatenation of two MLPs $f$ and $g$
39
+
40
+ ![](images/d0258eb8d1cdb42aeeef0b3b9c0aefb37cc6747df3aee46e9be36d9ba71066b0.jpg)
41
+ Figure 2: Universal representations can easily be created by combining a separable representation with an MLP.
42
+
43
+ the set of $d$ -dimensional vector representations of $\mathfrak { F }$ . A natural characteristic to ask from the class $\mathfrak { F }$ is to be generic enough to approximate any vector representation, a notion that we will denote as universal representation (Hornik et al., 1989).
44
+
45
+ Definition 1. A class of vector representations $\mathfrak { F } \subset \cup _ { d \in \mathbb { N } ^ { * } } \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$ is called a universal representation of $\mathcal { X }$ if for any compact subset $K \subset { \mathcal { X } }$ and $d \in \mathbb { N } ^ { * }$ , $\mathcal { F }$ is uniformly dense in $\mathcal { C } ( K , \mathbb { R } ^ { d } )$ .
46
+
47
+ In other words, $\mathfrak { F }$ is a universal representation of a normed space $\mathcal { X }$ if and only if, for any continuous function $\phi : \mathcal { X } \mathbb { R } ^ { d }$ , any compact $K \subset { \mathcal { X } }$ and any $\varepsilon > 0$ , there exists $f \in \mathfrak { F }$ such that
48
+
49
+ $$
50
+ \forall x \in K , \ \| \phi ( x ) - f ( x ) \| \leq \varepsilon .
51
+ $$
52
+
53
+ One of the most fundamental theorems of neural network theory states that one hidden layer MLPs are universal representations of the $m$ -dimensional vector space $\mathbb { R } ^ { m }$ .
54
+
55
+ Theorem 1 (Pinkus, 1999, Theorem 3.1). Let $\varphi : \mathbb { R } \mathbb { R }$ be a continuous non polynomial activation function. For any compact $K \subset \mathbb { R } ^ { m }$ and $d \in \mathbb { N } ^ { * }$ , two layers neural networks with activation $\varphi$ are uniformly dense in the set $\mathcal { C } ( K , \mathbb { R } ^ { d } )$ .
56
+
57
+ However, for graphs and structured objects, universal representations are hard to obtain due to their complex structure and invariance to a group of transformations (e.g. permutations of the node labels). We show in this paper that a key topological property, separability, may lead to universal representations of those structures.
58
+
59
+ # 3.3 SEPARABILITY IS (ALMOST) ALL YOU NEED
60
+
61
+ Loosely speaking, universal representations can approximate any vector-valued function. It is thus natural to require that these representations are expressive enough to separate each pair of dissimilar elements of $\mathcal { X }$ .
62
+
63
+ Definition 2 (Separability). A set of functions $\mathfrak { F } \subset \mathcal { F } ( \mathcal { X } , \mathcal { Y } )$ is said to separate points of $\mathcal { X }$ if for every pair of distinct points $x$ and $y$ , there exists $f \in \mathfrak { F }$ such that $f ( x ) \neq { \bar { f } } ( y )$ .
64
+
65
+ For a class of vector representations $\mathfrak { F } \subset \cup _ { d \in \mathbb { N } ^ { * } } \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$ , we will say that $\mathfrak { F }$ is separable if its 1-dimensional representations $\mathfrak { F } _ { 1 }$ separates points of $\mathcal { X }$ . Separability is rather weak, as we only require the existence of different outputs for every pair of inputs. Unsurprisingly, we now show that it is a necessary condition for universality (see Appendix A for all the detailed proofs).
66
+
67
+ Proposition 1. Let $\mathfrak { F }$ be a universal representation of $\mathcal { X }$ , then $\mathfrak { F } _ { 1 }$ separates points of $\mathcal { X }$
68
+
69
+ While separability is necessary for universal representations, it is also key to designing neural network architectures that can be extended into universal representations. More specifically, under technical assumptions, separable representations can be composed with a universal representation of $\mathbb { R } ^ { d }$ (such as MLPs) to become universal.
70
+
71
+ Theorem 2. For all $d \geq 0 ,$ , let $\mathcal { M } _ { d }$ be a universal approximation of $\mathbb { R } ^ { d }$ . Let $\mathfrak { F }$ be a class of vector representations of $\mathcal { X }$ such that:
72
+
73
+ (i) Continuity: every $f \in \mathfrak { F }$ is continuous, (ii) Stability by concatenation: for all $f , g \in { \mathfrak { F } }$ , $x \mapsto ( f ( x ) , g ( x ) ) \in \mathfrak { F } ,$ ,
74
+
75
+ # (iii) Separability: $\mathfrak { F } _ { 1 }$ separates points of $\mathcal { X }$
76
+
77
+ Then $\{ \psi \circ f : \exists d \geq 1$ s.t. $\psi \in \mathcal { M } _ { d } , f \in \mathfrak { F } \}$ is a universal representation of $\mathcal { X }$ .
78
+
79
+ Stability by concatenation is verified by most neural networks architectures, as illustrated for MLPs in Figure 1. The proof of Theorem 2 relies on the Stone-Weierstrass theorem (see e.g. Rudin, 1987, Theorem 7.32) whose assumptions are continuity, separability, and the fact that the class of functions is an algebra. Fortunately, composing a separable and concatenable representation with a universal representation automatically leads to an algebra, and thus the applicability of the StoneWeierstrass theorem and the desired result. A complete derivation is available in Appendix A. Since MLPs are universal representations of $\mathbb { R } ^ { d }$ , Theorem 2 implies a convenient way to design universal representations of more complex object spaces: create a separable representation and compose it with a simple MLP (see Figure 2).
80
+
81
+ Corollary 1. A continuous, concatenable and separable representation of $\mathcal { X }$ composed with an MLP is universal.
82
+
83
+ Note that many neural networks of the deep learning literature have this two steps structure, including classical image CNNs such as AlexNet (Krizhevsky et al., 2012) or Inception (Szegedy et al., 2016). In this paper, we use Corollary 1 to design universal graph and neighborhood representations, although the method is much more generic and may be applied to other objects.
84
+
85
+ # 4 LIMITATIONS OF EXISTING REPRESENTATIONS
86
+
87
+ In this section, we first provide a proper definition for graphs with node attributes, and then show that message passing neural networks are not sufficiently expressive to be universal.
88
+
89
+ # 4.1 GRAPHS WITH NODE ATTRIBUTES
90
+
91
+ Consider a dataset of $n$ interacting objects (e.g. users of a social network) in which each object $i \in [ [ 1 , n ] ]$ has a vector attribute $v _ { i } \in \mathbb { R } ^ { m }$ and is a node in an undirected graph $G$ with adjacency J Kmatrix A ∈ Rn×n.
92
+
93
+ Definition 3. The space of graphs of size $n$ with $m$ -dimensional node attributes is the quotient space
94
+
95
+ $$
96
+ \mathbf { G r a p h } _ { m , n } = \left\{ ( v , A ) \in \mathbb { R } ^ { n \times m } \times \mathbb { R } ^ { n \times n } \right\} / \mathcal { P } _ { n } ,
97
+ $$
98
+
99
+ where $A$ is the adjacency matrix of the graph, $v$ contains the $m$ -dimensional representation of each node in the graph and the set of permutations matrices $\mathcal { P } _ { n }$ is acting on $( v , A )$ by
100
+
101
+ $$
102
+ \forall P \in \mathcal { P } _ { n } , \quad P \cdot ( v , A ) = ( P v , P A P ^ { \top } ) .
103
+ $$
104
+
105
+ Moreover, we limit ourselves to graphs of maximum size $n _ { \mathrm { m a x } }$ , where $n _ { \mathrm { m a x } }$ is a large integer. This allows us to consider functions on graphs of different sizes without obtaining infinite dimensional spaces and infinitely complex functions that would be impossible to learn via a finite number of samples. We thus define Graphm = Sn≤nmax . More details on the technical topological aspects of the definition are available in Appendix B, as well as a proof that $\mathbf { G r a p h } _ { m }$ is Hausdorff.
106
+
107
+ # 4.2 MESSAGE PASSING NEURAL NETWORKS
108
+
109
+ A common method for designing graph representations is to rely on local iterative procedures. Following the notations of $\mathrm { X u }$ et al. (2019), a message passing neural network (MPNN) (Gilmer et al., 2017) is made of three consecutive phases that will create intermediate node representations $x _ { i , t }$ for each node $i \in [ [ 1 , n ] ]$ and a final graph representation $x _ { G }$ as described by the following J Kprocedure: 1) Initialization: All node representations are initialized with their node attributes $x _ { i , 0 } = v _ { i }$ . 2) Aggregation and combination: $T$ local iterative steps are performed in order to capture larger and larger structural characteristics of the graph. 3) Readout: This step combines all final node representations into a single graph representation: $x _ { G } = \mathtt { R E A D O U T } \big ( \{ x _ { i , T } \} _ { i \in [ [ 1 , n ] ] } \big )$ , where READOUT is permutation invariant.
110
+
111
+ ![](images/6ef7e1ab55de1fc20833eaadbcc4e37286ad76e8e78b542a89afd48d15eba060.jpg)
112
+ Figure 3: Example of two valid colorings of the same attributed graph. Note that each $V _ { k }$ contains nodes with identical attributes.
113
+
114
+ Unfortunately, while MPNNs are very efficient in practice and proven to be as expressive as the Weisfeiler-Lehman algorithm (Weisfeiler and Lehman, 1968; Xu et al., 2019), they are not sufficiently expressive to construct isomorphism tests or separate all graphs (for example, consider $k$ -regular graphs without node attributes, for which a small calculation shows that any MPNN representation will only depend on the number of nodes and degree $k$ (Xu et al., 2019)). As a direct application of Proposition 1, MPNNs are thus not expressive enough to create universal representations.
115
+
116
+ # 5 EXTENDING MPNNS USING A SIMPLE COLORING SCHEME
117
+
118
+ In this section, we present Colored Local Iterative Procedure (CLIP), an extension of MPNNs using colors to differentiate identical node attributes, that is able to capture more complex structural graph characteristics than traditional MPNNs. This is proved theoretically through a universal approximation theorem in Section 5.3 and experimentally in Section 6. CLIP is based on three consecutive steps: 1) graphs are colored with several different colorings, 2) a neighborhood aggregation scheme provides a vector representation for each colored graph, 3) all vector representations are combined to provide a final output vector. We now provide more information on the coloring scheme.
119
+
120
+ # 5.1 COLORS TO DIFFERENTIATE NODES
121
+
122
+ In order to distinguish non-isomorphic graphs, our approach consists in coloring nodes of the graph with identical attributes. This idea is inspired by classical graph isomorphism algorithms that use colors to distinguish nodes (McKay, 1981), and may be viewed as an extension of one-hot encodings used for graphs without node attributes $\mathrm { { X u } }$ et al., 2019).
123
+
124
+ For any $k \in \mathbb N$ , let $C _ { k }$ be a finite set of $k$ colors. These colors may be represented as one-hot encodings ( $C _ { k }$ is the natural basis of $\mathbb { R } ^ { k }$ ) or more generally any finite set of $k$ elements. At initialization, we first partition the nodes into groups of identical attributes $V _ { 1 } , . . . , V _ { K } \subset [ [ 1 , n ] ]$ . Then, for a subset $V _ { k }$ of size $| V _ { k } |$ , we give to each of its nodes a distinct color from $C _ { k }$ J K(hence a subset of size $| V _ { k } | )$ . For example, Figure 3 shows two colorings of the same graph, which is decomposed in three groups $V _ { 1 }$ , $V _ { 2 }$ and $V _ { 3 }$ containing nodes with attributes $a , b$ and $c$ respectively. Since $V _ { 1 }$ contains only two nodes, a coloring of the graph will attribute two colors $( ( 1 , 0 )$ and $( 0 , 1 )$ , depicted as blue and red) to these nodes. More precisely, the set of colorings $ { \mathcal { C } } ( v , A )$ of a graph ${ \cal { G } } = ( v , A )$ are defined as
125
+
126
+ $$
127
+ \mathcal { C } ( v , A ) = \Big \{ ( c _ { 1 } , . . . , c _ { n } ) : \forall k \in [ [ 1 , K ] ] , ( c _ { i } ) _ { i \in V _ { k } } \mathrm { { i s } a p e r m u t a t i o n { o f } } C _ { | V _ { k } | } \Big \} .
128
+ $$
129
+
130
+ # 5.2 THE CLIP ALGORITHM
131
+
132
+ In the CLIP algorithm, we add a coloring scheme to an MPNN in order to distinguish identical node attributes. This is achieved by modifying the initialization and readout phases of MPNNs as follows.
133
+
134
+ 1. Colored initialization: We first select a set ${ \mathcal { C } } _ { k } \subseteq { \mathcal { C } } ( v , A )$ of $k$ distinct colorings uniformly at random (see Eq. (4)). Then, for each coloring $c \in { \mathcal { C } } _ { k }$ , node representations are initialized with their node attributes concatenated with their color: $\boldsymbol { x } _ { i , 0 } ^ { c } = \left( \boldsymbol { v } _ { i } , \boldsymbol { c } _ { i } \right)$ .
135
+
136
+ 2. Aggregation and combination: This step is performed for all colorings $c \in { \mathcal { C } } _ { k }$ using a universal set representation as the aggregation function: $\begin{array} { r } { \boldsymbol { x } _ { i , t + 1 } ^ { c } = \psi ^ { ( t ) } \big ( \boldsymbol { x } _ { i , t } ^ { c } , \sum _ { j \in \mathcal { N } _ { i } } \varphi ^ { ( t ) } \bar { ( } \boldsymbol { x } _ { j , t } ^ { c } ) \big ) } \end{array}$ , where $\psi$ and $\varphi$ are MLPs with continuous non-polynomial activation functions and $\psi ( x , y )$ denotes the result of $\psi$ applied to the concatenation of $x$ and $y$ . The aggregation scheme we propose is closely related to DeepSet (Zaheer et al., 2017), and a direct application of Corollary 1 proves the universality of our architecture. More details, as well as the proof of universality, are available in Appendix C.
137
+
138
+ 3. Colored readout: This step performs a maximum over all possible colorings in order to obtain a final coloring-independent graph representation. In order to keep the stability by concatenation, the maximum is taken coefficient-wise
139
+
140
+ $$
141
+ x _ { G } = \psi \left( \operatorname* { m a x } _ { c \in \mathcal { C } _ { k } } \sum _ { i = 1 } ^ { n } x _ { i , T } ^ { c } \right) ,
142
+ $$
143
+
144
+ where $\psi$ is an MLP with continuous non polynomial activation functions.
145
+
146
+ We treat $k$ as a hyper-parameter of the algorithm and call $k$ -CLIP (resp. $\infty$ -CLIP) the algorithm using $k$ colorings (resp. all colorings, i.e. $\boldsymbol { \bar { k } } = | \mathcal { C } ( \boldsymbol { v } , \boldsymbol { A } ) | )$ . Note that, while our focus is graphs with node attributes, the approach used for CLIP is easily extendable to similar data structures such as directed or weighted graphs with node attributes, graphs with node labels, graphs with edge attributes or graphs with additional attributes at the graph level.
147
+
148
+ # 5.3 UNIVERSAL REPRESENTATION THEOREM
149
+
150
+ As the colorings are chosen at random, the CLIP representation is itself random as soon as $k <$ $| \mathcal { C } ( v , A ) |$ , and the number of colorings $k$ will impact the variance of the representation. However, $\infty$ -CLIP is deterministic and permutation invariant, as MPNNs are permutation invariant. The separability is less trivial and is ensured by the coloring scheme.
151
+
152
+ Theorem 3. The $\infty$ -CLIP algorithm with one local iteration $T = 1 .$ ) is a universal representation of the space $\mathbf { G r a p h } _ { m }$ of graphs with node attributes.
153
+
154
+ The proof of Theorem 3 relies on showing that $\infty$ -CLIP is separable and applying Corollary 1. This is achieved by fixing a coloring on one graph and identifying all nodes and edges of the second graph using the fact that all pairs $( v _ { i } , c _ { i } )$ are dissimilar (see Appendix D). Similarly to the case of MLPs, only one local iteration is necessary to ensure universality of the representation. This rather counter-intuitive result is due to the fact that all nodes can be identified by their color, and the readout function can aggregate all the structural information in a complex and non-trivial way. However, as for MLPs, one may expect poor generalization capabilities for CLIP with only one local iteration, and deeper networks may allow for more complex representations and better generalization. This point is addressed in the experiments of Section 6. Moreover, $\infty$ -CLIP may be slow in practice due to a large number of colorings, and reducing $k$ will speed-up the computation. Fortunately, while $k$ -CLIP is random, a similar universality theorem still holds even for $k = 1$ .
155
+
156
+ Theorem 4. The 1-CLIP algorithm with one local iteration $T = 1 .$ ) is a random representation whose expectation is a universal representation of the space $\mathbf { G r a p h } _ { m }$ of graphs with node attributes.
157
+
158
+ The proof of Theorem 4 relies on using $\infty$ -CLIP on the augmented node attributes $\boldsymbol { v } _ { i } ^ { \prime } = \left( v _ { i } , c _ { i } \right)$ . As all node attributes are, by design, different, the max over all colorings in Eq. (5) disappears and, for any coloring, 1-CLIP returns an $\varepsilon$ -approximation of the target function (see Appendix D).
159
+
160
+ Remark 1. Note that the variance of the representation may be reduced by averaging over multiple samples. Moreover, the proof of Theorem 4 shows that the variance can be reduced to an arbitrary precision given enough training epochs, although this may lead to very large training times in practice.
161
+
162
+ # 5.4 COMPUTATIONAL COMPLEXITY
163
+
164
+ As the local iterative steps are performed $T$ times on each node and the complexity of the aggregation depends on the number of neighbors of the considered node, the complexity is proportional to the number of edges of the graph $E$ and the number of steps $T$ . Moreover, CLIP performs this iterative aggregation for each coloring, and its complexity is also proportional to the number of chosen colorings $k = | \mathcal { C } _ { k } |$ . Hence the complexity of the algorithm is in $O ( k E T )$ .
165
+
166
+ Note that the number of all possible colorings for a given graph depends exponentially in the size of the groups $V _ { 1 } , . . . , V _ { K }$ ,
167
+
168
+ $$
169
+ | { \mathcal C } ( v , A ) | = \prod _ { k = 1 } ^ { K } | V _ { k } | ! ,
170
+ $$
171
+
172
+ and thus $\infty$ -CLIP is practical only when most node attributes are dissimilar. This worst case exponential dependency in the number of nodes can hardly be avoided for universal representations. Indeed, a universal graph representation should also be able to solve the graph isomorphism problem. Despite the existence of polynomial time algorithms for a broad class of graphs (Luks, 1982; Bodlaender, 1990), graph isomorphism is still quasi-polynomial in general (Babai, 2016). As a result, creating a universal graph representation with polynomial complexity for all possible graphs and functions to approximate is highly unlikely, as it would also induce a graph isomorphism test of polynomial complexity and thus solve a very hard and long standing open problem of theoretical computer science.
173
+
174
+ # 6 EXPERIMENTS
175
+
176
+ In this section we show empirically the practical efficiency of CLIP and its relaxation. We run two sets of experiments to compare CLIP w.r.t. state-of-the-art methods in supervised learning settings: i) on 5 real-world graph classification datasets and ii) on 4 synthetic datasets to distinguish structural graph properties and isomorphism. Both experiments follow the same experimental protocol as described in $\mathrm { X u }$ et al. (2019): 10-fold cross validation with grid search hyper-parameter optimization. More details on the experimental setup are provided in Appendix E.
177
+
178
+ # 6.1 CLASSICAL BENCHMARK DATASETS
179
+
180
+ We performed experiments on five benchmark datasets extracted from standard social networks (IMDBb and IMDBm) and bio-informatics databases (MUTAG, PROTEINS and PTC). All dataset characteristics (e.g. size, classes), as well as the experimental setup, are available in Appendix E. Following standard practices for graph classification on these datasets, we use one-hot encodings of node degrees as node attributes for IMDBb and IMDBm (Xu et al., 2019), and perform singlelabel multi-class classification on all datasets. We compared CLIP with six state-of-the-art baseline algorithms: 1) WL: Weisfeiler-Lehman subtree kernel (Shervashidze et al., 2011), 2) AWL: Anonymous Walk Embeddings (Ivanov and Burnaev, 2018), 3) DCNN: Diffusion-convolutional neural networks (Atwood and Towsley, 2016), 4) PS: PATCHY-SAN (Niepert et al., 2016), 5) DGCNN: Deep Graph CNN (Zhang et al., 2018) and 6) GIN: Graph Isomorphism Network (Xu et al., 2019). WL and AWL are representative of unsupervised methods coupled with an SVM classifier, while DCNN, PS, DGCNN and GIN are four deep learning architectures. As the same experimental protocol as that of Xu et al. (2019) was used, we present their reported results on Table 1.
181
+
182
+ Table 1: Classification accuracies of the compared methods on benchmark datasets. The best performer w.r.t. the mean is highlighted with an asterisk. We perform an unpaired t-test with asymptotic significance of 0.1 w.r.t. the best performer and highlight with boldface the ones for which the difference is not statistically significant. 0-CLIP is the CLIP architecture without any colorings.
183
+
184
+ <table><tr><td>Dataset</td><td>PTC</td><td>IMDBb</td><td>IMDBm</td><td>PROTEINS</td><td>MUTAG</td></tr><tr><td>WL DCNN</td><td>59.9±4.3</td><td>73.8±3.9</td><td>50.9±3.8</td><td>75.0±3.1</td><td>90.4±5.7</td></tr><tr><td>PS</td><td>56.6 60.0±4.8</td><td>49.1</td><td>33.5</td><td>61.3</td><td>67.0</td></tr><tr><td></td><td></td><td>71.0±2.2</td><td>45.2±2.8</td><td>75.9±2.8</td><td>92.6±4.2</td></tr><tr><td>DGCNN</td><td>58.6</td><td>70.0</td><td>47.8</td><td>75.5</td><td>85.8</td></tr><tr><td>AWL</td><td>=</td><td>74.5±5.9</td><td>51.5±3.6</td><td>/</td><td>87.9±9.8</td></tr><tr><td>GIN</td><td>64.6±7.0</td><td>75.1±5.1</td><td>52.3±2.8</td><td>76.2±2.8</td><td>89.4±5.6</td></tr><tr><td>0-CLIP</td><td>65.9±4.0</td><td>75.4±2.0</td><td>52.5±2.6*</td><td>77.0±3.2</td><td>90.0±5.1</td></tr><tr><td>CLIP</td><td>67.9±7.1*</td><td>76.0±2.7*</td><td>52.5±3.0*</td><td>77.1±4.4*</td><td>93.9±4.0*</td></tr></table>
185
+
186
+ As Table 1 shows, CLIP can achieve state-of-the-art performance on the five benchmark datasets. Moreover, CLIP is consistent across all datasets, while all other competitors have at least one weak performance. This is a good indicator of the robustness of the method to multiple classification tasks and dataset types. Finally, the addition of colors does not improve the accuracy for these graph classification tasks, except on the MUTAG dataset. This may come from the small dataset sizes (leading to high variances) or an inherent difficulty of these classification tasks, and contrasts with the clear improvements of the method for property testing (see Section 6.2). More details on the performance of CLIP w.r.t. the number of colors $k$ are available in Appendix E.
187
+
188
+ Remark 2. In three out of five datasets, none of the recent state-of-the-art algorithms have statistically significantly better results than older methods (e.g. WL). We argue that, considering the high variances of all classification algorithms on classical graph datasets, graph property testing may be better suited to measure the expressiveness of graph representation learning algorithms in practice.
189
+
190
+ # 6.2 GRAPH PROPERTY TESTING
191
+
192
+ We now investigate the ability of CLIP to identify structural graph properties, a task which was previously used to evaluate the expressivity of graph kernels and on which the Weisfeiler-Lehman subtree kernel has been shown to fail for bounded-degree graphs (Kriege et al., 2018). The performance of our algorithm is evaluated for the binary classification of four different structural properties: 1) connectivity, 2) bipartiteness, 3) triangle-freeness, 4) circular skip links (Murphy et al., 2019) (see Appendix E for precise definitions of these properties) against three competitors: a) GIN, arguably the most efficient MPNN variant yet published (Xu et al., 2019), b) Ring-GNN, a permutation invariant network that uses the ring of matrix addition and multiplication (Chen et al., 2019), c) RP-GIN, the Graph Isomorphism Network combined with Relational Pooling, as described by Murphy et al. (2019), which is able to distinguish certain cases of non-isomorphic regular graphs. We provide all experimental details in Appendix E.
193
+
194
+ Table 2: Classification accuracies of the synthetic datasets. $k$ -RP-GIN refers to a relational pooling averaged over $k$ random permutations. We report Ring-GNN results from Chen et al. (2019).
195
+
196
+ <table><tr><td>Property</td><td>Connectivity</td><td>Bipartiteness</td><td>Triangle-freeness</td><td colspan="3">Circular skip links</td></tr><tr><td></td><td>mean ± std</td><td>mean ± std</td><td>mean ± std</td><td>mean ± std</td><td>max</td><td>min</td></tr><tr><td>GIN</td><td>55.2 ± 4.4</td><td>53.1 ±4.7</td><td>50.7±6.1</td><td>10.0 ± 0.0</td><td>10.0</td><td>10.0</td></tr><tr><td>Ring-GNN</td><td>=</td><td>=</td><td>1</td><td>(?) ± 15.7</td><td>80.0</td><td>10.0</td></tr><tr><td>1-RP-GIN</td><td>66.1±5.2</td><td>66.0±5.1</td><td>63.0±3.6</td><td>20.0 ± 7.0</td><td>28.6</td><td>10.0</td></tr><tr><td>16-RP-GIN</td><td>83.3±7.9</td><td>64.9±4.1</td><td>65.7±3.3</td><td>37.6 ± 12.9</td><td>53.3</td><td>10.0</td></tr><tr><td>0-CLIP</td><td>56.5 ± 4.0</td><td>55.4 ± 5.7</td><td>59.6 ± 3.8</td><td>10.0 ± 0.0</td><td>10.0</td><td>10.0</td></tr><tr><td>1-CLIP</td><td>73.3 ± 2.2</td><td>63.3 ±1.9</td><td>63.5 ±7.3</td><td>61.9 ±11.9</td><td>80.7</td><td>36.7</td></tr><tr><td>16-CLIP</td><td>99.7 ± 0.5</td><td>99.2 ± 0.9</td><td>94.2±3.4</td><td>90.8 ± 6.8</td><td>98.7</td><td>76.0</td></tr></table>
197
+
198
+ Table 2 shows that CLIP is able to capture the structural information of connectivity, bipartiteness, triangle-freeness and circular skip links, while MPNN variants fail to identify these graph properties. Furthermore, we observe that CLIP outperforms RP-GIN, that was shown to provide very expressive representations for regular graphs (Murphy et al., 2019), even with a high number of permutations (the equivalent of colors in their method is set to $k = 1 6$ ). Moreover, both for $k$ -RP-GIN and $k$ -CLIP, the increase of permutations and colorings respectively lead to higher accuracies. In particular, CLIP can capture almost perfectly the different graph properties with as little as $k = 1 6$ colorings.
199
+
200
+ # 7 CONCLUSION
201
+
202
+ In this paper, we showed that a simple coloring scheme can improve the expressive power of MPNNs. Using such a coloring scheme, we extended MPNNs to create CLIP, the first universal graph representation. Universality was proven using the novel concept of separable neural networks, and our experiments showed that CLIP is state-of-the-art on both graph classification datasets and property testing tasks. The coloring scheme is especially well suited to hard classification tasks that require complex structural information to learn. The framework is general and simple enough to extend to other data structures such as directed, weighted or labeled graphs. Future work includes more detailed and quantitative approximation results depending on the parameters of the architecture such as the number of colors $k$ , or number of hops of the iterative neighborhood aggregation.
203
+
204
+ # REFERENCES
205
+
206
+ Atwood, J. and Towsley, D. (2016). Diffusion-convolutional neural networks. In Advances in Neural Information Processing Systems.
207
+
208
+ Babai, L. (2016). Graph isomorphism in quasipolynomial time. In Proceedings of the forty-eighth annual ACM symposium on Theory of Computing, pages 684–697. ACM.
209
+
210
+ Bartlett, P., Helmbold, D., and Long, P. (2018). Gradient descent with identity initialization efficiently learns positive definite linear transformations. In International Conference on Machine Learning, pages 520–529.
211
+
212
+ Baum, E. B. and Haussler, D. (1989). What size net gives valid generalization? In Advances in neural information processing systems, pages 81–90.
213
+
214
+ Bengio, Y., Courville, A., and Vincent, P. (2013). Representation learning: A review and new perspectives. IEEE transactions on pattern analysis and machine intelligence, 35(8):1798–1828.
215
+
216
+ Bodlaender, H. L. (1990). Polynomial algorithms for graph isomorphism and chromatic index on partial k-trees. Journal of Algorithms, 11(4):631–643.
217
+
218
+ Bourbaki, N. (1998). General Topology: Chapters 1-4. Number vol. 4 in Addison-Wesley series in mathematics. Springer.
219
+
220
+ Bruna, J., Zaremba, W., Szlam, A., and Lecun, Y. (2014). Spectral networks and locally connected networks on graphs. ICLR.
221
+
222
+ Chen, Z., Villar, S., Chen, L., and Bruna, J. (2019). On the equivalence between graph isomorphism testing and function approximation with gnns. NeurIPS 2019, abs/1905.12560.
223
+
224
+ Cybenko, G. (1989). Approximation by superpositions of a sigmoidal function. Mathematics of control, signals and systems, 2(4):303–314.
225
+
226
+ Defferrard, M., Bresson, X., and Vandergheynst, P. (2016). Convolutional neural networks on graphs with fast localized spectral filtering. In Advances in Neural Information Processing Systems, pages 3844–3852.
227
+
228
+ Duvenaud, D. K., Maclaurin, D., Iparraguirre, J., Bombarell, R., Hirzel, T., Aspuru-Guzik, A., and Adams, R. P. (2015). Convolutional networks on graphs for learning molecular fingerprints. In Advances in neural information processing systems, pages 2224–2232.
229
+
230
+ Erdös, P. and Rényi, A. (1959). On random graphs i. Publicationes Mathematicae Debrecen, 6:290.
231
+
232
+ Frasconi, P., Gori, M., and Sperduti, A. (1998). A general framework for adaptive processing of data structures. IEEE transactions on Neural Networks, 9(5):768–786.
233
+
234
+ Geman, S., Bienenstock, E., and Doursat, R. (1992). Neural networks and the bias/variance dilemma. Neural computation, 4(1):1–58.
235
+
236
+ Gilmer, J., Schoenholz, S. S., Riley, P. F., Vinyals, O., and Dahl, G. E. (2017). Neural message passing for quantum chemistry. ICML.
237
+
238
+ Gori, M., Monfardini, G., and Scarselli, F. (2005). A new model for learning in graph domains. In Neural Networks, 2005. IJCNN’05. Proceedings. 2005 IEEE International Joint Conference on, volume 2, pages 729–734. IEEE.
239
+
240
+ Grover, A. and Leskovec, J. (2016). node2vec: Scalable feature learning for networks. In Proceedings of the 22nd ACM SIGKDD international conference on Knowledge discovery and data mining, pages 855–864. ACM.
241
+
242
+ Guttenberg, N., Virgo, N., Witkowski, O., Aoki, H., and Kanai, R. (2016). Permutation-equivariant neural networks applied to dynamics prediction. arXiv preprint arXiv:1612.04530.
243
+
244
+ Hamilton, W., Ying, Z., and Leskovec, J. (2017). Inductive representation learning on large graphs. In Advances in Neural Information Processing Systems, pages 1024–1034.
245
+
246
+ Henaff, M., Bruna, J., and LeCun, Y. (2015). Deep convolutional networks on graph-structured data. arXiv preprint arXiv:1506.05163.
247
+
248
+ Hornik, K. (1991). Approximation capabilities of multilayer feedforward networks. Neural networks, 4(2):251–257.
249
+
250
+ Hornik, K., Stinchcombe, M., and White, H. (1989). Multilayer feedforward networks are universal approximators. Neural networks, 2(5):359–366.
251
+
252
+ Ivanov, S. and Burnaev, E. (2018). Anonymous walk embeddings. ICML.
253
+
254
+ Kipf, T. N. and Welling, M. (2017). Semi-supervised classification with graph convolutional networks. ICLR.
255
+
256
+ Kriege, N. M., Morris, C., Rey, A., and Sohler, C. (2018). A property testing framework for the theoretical expressivity of graph kernels. In Proceedings of the Twenty-Seventh International Joint Conference on Artificial Intelligence, IJCAI-18, pages 2348–2354. International Joint Conferences on Artificial Intelligence Organization.
257
+
258
+ Krizhevsky, A., Sutskever, I., and Hinton, G. E. (2012). Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems, pages 1097–1105.
259
+
260
+ Lei, T., Jin, W., Barzilay, R., and Jaakkola, T. (2017). Deriving neural architectures from sequence and graph kernels. ICML.
261
+
262
+ Luks, E. M. (1982). Isomorphism of graphs of bounded valence can be tested in polynomial time. Journal of Computer and System Sciences, 25(1):42 – 65.
263
+
264
+ Maron, H., Ben-Hamu, H., Serviansky, H., and Lipman, Y. (2019a). Provably powerful graph networks. NeurIPS.
265
+
266
+ Maron, H., Ben-Hamu, H., Shamir, N., and Lipman, Y. (2019b). Invariant and equivariant graph networks. In International Conference on Learning Representations.
267
+
268
+ Maron, H., Fetaya, E., Segol, N., and Lipman, Y. (2019c). On the universality of invariant networks. ICML 2019.
269
+
270
+ McKay, B. D. (1981). Practical graph isomorphism. Congressus Numerantium, 30:45–87.
271
+
272
+ Mnih, V., Kavukcuoglu, K., Silver, D., Rusu, A. A., Veness, J., Bellemare, M. G., Graves, A., Riedmiller, M., Fidjeland, A. K., Ostrovski, G., Petersen, S., Beattie, C., Sadik, A., Antonoglou, I., King, H., Kumaran, D., Wierstra, D., Legg, S., and Hassabis, D. (2015). Human-level control through deep reinforcement learning. Nature, 518(7540):529–533.
273
+
274
+ Murphy, R., Srinivasan, B., Rao, V., and Ribeiro, B. (2019). Relational pooling for graph representations. In Chaudhuri, K. and Salakhutdinov, R., editors, Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pages 4663–4673, Long Beach, California, USA. PMLR.
275
+
276
+ Niepert, M., Ahmed, M., and Kutzkov, K. (2016). Learning convolutional neural networks for graphs. In International conference on machine learning.
277
+
278
+ Perozzi, B., Al-Rfou, R., and Skiena, S. (2014). Deepwalk: Online learning of social representations. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pages 701–710. ACM.
279
+
280
+ Pinkus, A. (1999). Approximation theory of the mlp model in neural networks. Acta numerica, 8:143–195.
281
+
282
+ Qi, C. R., Su, H., Mo, K., and Guibas, L. J. (2017). Pointnet: Deep learning on point sets for 3d classification and segmentation. CVPR.
283
+
284
+ Rudin, W. (1987). Real and Complex Analysis, 3rd Ed. McGraw-Hill, Inc., New York, NY, USA.
285
+
286
+ Saxe, A. M., McClelland, J. L., and Ganguli, S. (2014). Exact solutions to the nonlinear dynamics of learning in deep linear neural networks. ICLR.
287
+ Scarselli, F., Gori, M., Tsoi, A. C., Hagenbuchner, M., and Monfardini, G. (2009). The graph neural network model. IEEE Transactions on Neural Networks, 20(1):61–80.
288
+ Shervashidze, N., Schweitzer, P., Leeuwen, E. J. v., Mehlhorn, K., and Borgwardt, K. M. (2011). Weisfeiler-lehman graph kernels. Journal of Machine Learning Research.
289
+ Sperduti, A. and Starita, A. (1997). Supervised neural networks for the classification of structures. IEEE Transactions on Neural Networks, 8(3):714–735.
290
+ Szegedy, C., Vanhoucke, V., Ioffe, S., Shlens, J., and Wojna, Z. (2016). Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2818–2826.
291
+ Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, ł., and Polosukhin, I. (2017). Attention is all you need. In Advances in Neural Information Processing Systems, pages 5998–6008. Curran Associates, Inc.
292
+ Velickovic, P., Cucurull, G., Casanova, A., Romero, A., Lio, P., and Bengio, Y. (2018). Graph attention networks. ICLR.
293
+ Verma, S. and Zhang, Z.-L. (2019). Graph capsule convolutional neural networks. ICLR.
294
+ Weisfeiler, B. and Lehman, A. (1968). A reduction of a graph to a canonical form and an algebra arising during this reduction. Nauchno-Technicheskaya Informatsia, 2(9):12–16.
295
+ Xu, K., Hu, W., Leskovec, J., and Jegelka, S. (2019). How powerful are graph neural networks? ICLR.
296
+ Ying, R., You, J., Morris, C., Ren, X., Hamilton, W. L., and Leskovec, J. (2018). Hierarchical graph representation learning with differentiable pooling. In Advances in Neural Information Processing Systems, pages 4805–4815.
297
+ Zaheer, M., Kottur, S., Ravanbakhsh, S., Póczos, B., Salakhutdinov, R., and Smola, A. J. (2017). Deep sets. In Advances in Neural Information Processing Systems.
298
+ Zhang, M., Cui, Z., Neumann, M., and Chen, Y. (2018). An end-to-end deep learning architecture for graph classification. In Proceedings of AAAI Conference on Artificial Inteligence.
299
+
300
+ # A PROOFS OF THE UNIVERSALITY OF SEPARABLE NEURAL NETWORKS
301
+
302
+ Proof of Theorem 2. The proof relies on the Stone-Weierstrass theorem we recall below. We refer to (Rudin, 1987, Theorem 7.32) for a detailed proof of the following classical theorem.
303
+
304
+ Theorem 5 (Stone-Weierstrass). Let $\mathcal { A }$ be an algebra of real functions on a compact Hausdorff set $K$ . If $\mathcal { A }$ separates points of $K$ and contains a non-zero constant function, then $\mathcal { A }$ is uniformly dense in ${ \mathcal { C } } ( K , \mathbb { R } )$ .
305
+
306
+ We verify that under the assumptions of Theorem 2 the Stone-Weierstrass theorem applies. In this setting, we first prove the theorem for $m = 1$ and use induction for the general case.
307
+
308
+ Let $K \subset { \mathcal { X } }$ be a compact subset of $\mathcal { X }$ . We will denote
309
+
310
+ $$
311
+ \begin{array} { r } { \mathcal { A } _ { 0 } = \left\{ \psi \circ f \ : \ \exists d \geq 1 \mathrm { ~ s . t . ~ } \psi \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } ) , f \in \mathfrak { F } \right\} , } \end{array}
312
+ $$
313
+
314
+ and will proceed in two steps: we first show that $\mathcal { A } _ { \mathrm { 0 } }$ is uniformly dense in ${ \mathcal { C } } ( K , \mathbb { R } )$ , then that $\mathcal { A }$ is dense in $\mathcal { A } _ { 0 }$ , hence proving Theorem 2.
315
+
316
+ Lemma 1. $\mathcal { A } _ { 0 }$ is a subalgebra of ${ \mathcal { C } } ( K , \mathbb { R } )$ .
317
+
318
+ Proof. The subset $\mathcal { A } _ { \mathrm { 0 } }$ contains zero and all constants. Let $f , g \in { \mathcal { A } } _ { 0 }$ so that
319
+
320
+ $$
321
+ f ( x ) = \psi _ { f } \circ \varphi _ { f } ( x ) , g ( x ) = \psi _ { g } \circ \varphi _ { g } ( x ) ,
322
+ $$
323
+
324
+ with $\psi _ { f } : \mathbb { R } ^ { d _ { f } } \mathbb { R }$ and $\psi _ { g } : \mathbb { R } ^ { d _ { g } } \mathbb { R }$ . Consider $\psi : \mathbb { R } ^ { d _ { f } + d _ { g } } \mathbb { R }$ such that $\psi ( a , b ) = $ $\psi _ { f } ( a ) + \psi _ { g } ( b )$ . We define $\varphi ( \bar { \boldsymbol { x } } ) = ( \varphi _ { f } ( \boldsymbol { x } ) , \varphi _ { g } ( \boldsymbol { x } ) ) \in \mathbb { R } ^ { d _ { f } + d _ { g } }$ and by assumption $\varphi \in { \mathfrak { F } }$ . We have
325
+
326
+ $$
327
+ \begin{array} { r l } { ( f + g ) ( x ) = \psi ( \varphi _ { f } ( x ) , \varphi _ { g } ( x ) ) } & { { } } \\ { \qquad = \psi \circ \varphi ( x ) } & { { } } \end{array}
328
+ $$
329
+
330
+ so that $f + g \in { \mathcal { A } } _ { 0 }$ and we conclude that $\mathcal { A } _ { 0 }$ is a vectorial subspace of ${ \mathcal { C } } ( K , \mathbb { R } )$ . We proceed similarly for the product in order to finish the proof of the lemma. □
331
+
332
+ Because $\mathfrak { F } _ { 1 }$ separates the points of $\mathcal { X }$ by assumption, $A _ { 0 }$ also separates the points of $\mathcal { X }$ . Indeed, let $x \neq y$ two distinct points of $X$ so that $\exists f \in \mathfrak { F }$ such that $f ( x ) \neq f ( y )$ . There exists $g \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } )$ such that $g ( f ( x ) ) \bar { \neq } g ( f ( y ) )$ . From Theorem 5 we deduce that $A _ { 0 }$ is uniformly dense in ${ \mathcal { C } } ( K , \mathbb { R } )$ for all compact subsets $K \subset { \mathcal { X } }$ .
333
+
334
+ Finally we state that:
335
+
336
+ Lemma 2. For any compact subset $K \subset { \mathcal { X } }$ , $\mathcal { A }$ is uniformly dense in $\mathcal { A } _ { \mathrm { 0 } }$
337
+
338
+ Proof. Let $\epsilon > 0$ and $h = \psi _ { 0 } \circ f \in \mathcal { A } _ { 0 }$ with $f \in { \mathfrak { F } }$ and $\psi _ { 0 } \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } )$ . Thanks to the continuity of $f$ , the image $\tilde { K } = f ( K )$ is a compact of $\mathbb { R } ^ { d }$ . By Theorem 1 there exists an MLP $\psi$ such that $\| \psi - \psi _ { 0 } \| _ { \tilde { K } , \infty } \le \epsilon .$ . We have $\psi \circ f \in { \mathcal { A } }$ and $\| \psi _ { 0 } \circ f - \psi \circ f \| _ { K , \infty } \leq \epsilon$ which concludes the proof.
339
+
340
+ This last lemma completes the proof in the case $m = 1$ . For $m \geq 2$ consider $\mathcal { A } _ { 0 } = \{ \psi \circ f : \exists d \geq$ 1 s.t. $\psi \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } ^ { m } ) , f \in \mathfrak { F } \}$ and proceed in a similar manner than Lemma 2 by decomposing $\psi \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } ^ { m } )$ as
341
+
342
+ $$
343
+ \psi ( x ) = \left( \begin{array} { c } { { \psi _ { 1 } ( x ) } } \\ { { \psi _ { 2 } ( x ) } } \\ { { \vdots } } \\ { { \psi _ { m } ( x ) } } \end{array} \right) ,
344
+ $$
345
+
346
+ and applying Lemma 1 for each coefficient function $\psi _ { i } \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } )$ .
347
+
348
+ Proof of Proposition $^ { l }$ . Assume that there exists $x , y \in { \mathcal { X } }$ s.t. $\forall f \in \mathfrak { F } _ { 1 }$ , $f ( x ) = f ( y )$ . Then $K =$ $\{ x , y \}$ is a compact subset of $\mathcal { X }$ and let $\phi \in \mathcal { C } ( K , \mathbb { R } )$ be such that $\phi ( x ) = 1$ and $\phi ( y ) = 0$ . Thus, for all $f \in \mathfrak { F } _ { 1 }$ , $\begin{array} { r } { \operatorname* { m a x } _ { z \in \{ x , y \} } \| \phi ( z ) - f ( z ) \| \ge 1 / 2 } \end{array}$ which contradicts universality (see Definition 1).
349
+
350
+ # B GROUP ACTION ON HAUSDORFF SPACES
351
+
352
+ In what follows, $\mathcal { X }$ is always a topological set and $G$ a group of transformations acting on $\mathcal { X }$ . The orbits of $\mathcal { X }$ under the action of $G$ are the sets $G x = { \bar { \{ g \cdot x : g \in G \} } }$ . Moreover, we denote as $\mathcal { X } / G$ the quotient space of orbits, also defined by the equivalence relation: $x \sim y \iff \exists g \in G$ s.t. $x = g \cdot y$ . As stated in Section 5, graphs with node attributes can be defined using invariance by permutation of the labels. We prove here that the resulting spaces are Hausdorff.
353
+
354
+ Definition 4 (Group invariance). Let $G$ a group, a function $f : \mathcal { X } \mathcal { Y }$ is $G$ -invariant if
355
+
356
+ $$
357
+ \forall x \in { \mathcal { X } } , \forall g \in G , f ( x ) = f ( g \cdot x ) .
358
+ $$
359
+
360
+ Lemma 3 ((Bourbaki, 1998, I, $\ S 8 . 3 )$ ). Let $\mathcal { X }$ be a Hausdorff space and $\mathcal { R }$ an equivalence relation of $\mathcal { X }$ . Then $\mathcal { X } / \mathcal { R }$ is Hausdorff if and only if any two distinct equivalence classes in $\mathcal { X }$ are contained in disjoints saturated open subsets of $\mathcal { X }$ .
361
+
362
+ Thanks to this lemma we prove the following proposition.
363
+
364
+ Proposition 2. Let $G$ a finite group acting on an Hausdorff space $\mathcal { X }$ , then the orbit space $\mathcal { X } / G$ is Hausdorff.
365
+
366
+ Proof. Let $G x$ and $G y$ two distinct classes with disjoint open neighbourhood $U$ and $V$ . By finiteness of $G$ , the application $\pi : \mathcal { X } \to \mathcal { X } / G$ is open, hence the saturated sets $\tilde { U } ~ = ~ \pi ^ { - 1 } [ \pi ( U ) ]$ and $\tilde { V } = \pi ^ { - 1 } [ \pi ( V ) ]$ are open. Suppose that there exists $z \in \tilde { U } \cap \tilde { V }$ , then $\pi ( z ) \in \pi ( U ) \cap \pi ( V )$ and we finally get that $G z \subset U \cap V = \emptyset$ . Therefore $\tilde { U } \cap \tilde { V }$ is empty and $\mathcal { X } / G$ is Hausdorff by Lemma 3.
367
+
368
+ Proposition 2 directly implies that the spaces $\mathbf { G r a p h } _ { m }$ and Neighborhood $_ m$ are Hausdorff.
369
+
370
+ # C UNIVERSALITY OF THE NODE AGGREGATION SCHEME
371
+
372
+ We now provide more details on the aggregation and combination scheme of CLIP, and show that a simple application of Corollary 1 is sufficient to prove its universality for node neighborhoods. Each local aggregation step takes as input a couple $( x _ { i } , \bar { \{ x _ { j } \} } _ { j \in \mathcal { N } _ { i } } )$ where $x _ { i } \in \mathbb { R } ^ { m }$ is the representation of node $i$ , and $\{ x _ { j } \} _ { j \in \mathcal { N } _ { i } }$ is the set of vector representations of the neighbors of node $i$ . In the following, we show how to use Corollary 1 to design universal representations for node neighborhoods.
373
+
374
+ Definition 5. The set of node neighborhoods for $m$ -dimensional node attributes is defined as
375
+
376
+ $$
377
+ \mathbf { N e i g h b o r h o o d } _ { m } = \mathbb { R } ^ { m } \times \bigcup _ { n \leq n _ { \operatorname* { m a x } } } \left( \mathbb { R } ^ { n \times m } / \mathcal { P } _ { n } \right) ,
378
+ $$
379
+
380
+ where the set of permutation matrices $\mathcal { P } _ { n }$ is acting on $\mathbb { R } ^ { \times m }$ by $P \cdot v = P v$ .
381
+
382
+ The main difficulty to design universal neighborhood representations is that the node neighborhoods of Definition 5 are permutation invariant w.r.t. neighboring node attributes, and hence require permutation invariant representations. The graph neural network literature already contains several deep learning architectures for permutation invariant sets (Guttenberg et al., 2016; Qi et al., 2017; Zaheer et al., 2017; Xu et al., 2019), among which PointNet and DeepSet have the notable advantage of being provably universal for sets. Following Corollary 1, we compose a separable permutation invariant network with an MLP that will aggregate both information from the node itself and its neighborhood. While our final architecture is similar to Deepset (Zaheer et al., 2017), this section emphasizes that the general universality theorems of Section 3 are easily applicable in many settings including permutation invariant networks. The permutation invariant set representation used for the aggregation step of CLIP is as follows:
383
+
384
+ $$
385
+ \mathrm { N O D E A G G R E G A T I O N } ( x , S ) = \psi \left( x , \sum _ { y \in S } \varphi ( y ) \right) ,
386
+ $$
387
+
388
+ where $\psi$ and $\varphi$ are MLPs with continuous non-polynomial activation functions and $\psi ( x , y )$ denotes the result of the MLP $\psi$ applied to the concatenation of $x$ and $y$ .
389
+
390
+ Theorem 6. The set representation described in Eq. (9) is a universal representation of Neighborhoodm.
391
+
392
+ Proof. By construction, NODEAGGREGATION is a continuous and concatenable representation. Moreover, its final stage is an MLP, and we thus only have to prove separability in order to use Corollary 1 and prove universality. Let $( x ^ { 1 } , S ^ { 1 } ) , ( x ^ { 2 } , \mathbf { \bar { \xi } } S ^ { 2 } ) \in \mathbf { N e i g h b o r h o o d } _ { m }$ and suppose that $( x ^ { 1 } , S ^ { 1 } ) { \overset { . } { \neq } } ( x ^ { 2 } , { \bar { S } } ^ { 2 } )$ . First, if $x ^ { 1 } \neq x ^ { 2 }$ , the final MLP $\psi$ can separate $x ^ { 1 }$ and $x ^ { 2 }$ . Otherwise, $\dot { S } ^ { 1 } \neq S ^ { 2 }$ , and let us assume that $S ^ { 1 } \setminus S ^ { 2 } \ne \emptyset$ (otherwise $S ^ { 2 } \setminus S ^ { 1 } \ne \emptyset$ and the argument is identical). Since MLPs are universal representations of $\mathbb { R } ^ { m }$ , there exists an MLP $\varphi$ such that, $\forall s \in S ^ { 1 } \cup S ^ { 2 }$ ,
393
+
394
+ $$
395
+ \begin{array} { c } { { \varphi ( s ) \geq 1 \mathrm { i f } s \in S ^ { 1 } \setminus S ^ { 2 } , } } \\ { { | \varphi ( s ) | \leq \varepsilon \mathrm { o t h e r w i s e } , } } \end{array}
396
+ $$
397
+
398
+ Taking $\psi ( x , y ) = y$ and $\varepsilon = 1 / 3 \operatorname* { m a x } \{ | S ^ { 1 } | , | S ^ { 2 } | \}$ , we have
399
+
400
+ $$
401
+ \begin{array} { r l } & { \mathrm { N O D E A G G R E G A T I O N } ( x ^ { 1 } , S ^ { 1 } ) \ge 2 / 3 , } \\ & { \mathrm { N O D E A G G R E G A T I O N } ( x ^ { 2 } , S ^ { 2 } ) \le 1 / 3 , } \end{array}
402
+ $$
403
+
404
+ which proves separability and, using Corollary 1, the universality of the representation.
405
+
406
+ # D PROOF OF THE UNIVERSALITY OF CLIP
407
+
408
+ Proof of Theorem 3. First of all, as the activation functions of the MLPs are continuous, CLIP is made of continuous and concatenable functions, and is thus also continuous and concatenable. Second, as the node aggregation step (denoted NODEAGGREGATION below) is a universal set representation (see Appendix C), it is capable of approximating any continuous function. We will thus first replace this function by a continuous function $\phi$ , and then show that the result still holds for NODEAGGREGATION(1) by a simple density argument. Let $G ^ { 1 } = ( v ^ { 1 } , A ^ { 1 } )$ and $G ^ { 2 } = ( \underline { { { v } } } ^ { 2 } , A ^ { 2 } )$ be two distinct graphs of respective sizes $n _ { 1 }$ and $n _ { 2 }$ (up to a permutation). If $n ^ { 1 } \neq n ^ { 2 }$ , then $\psi ( x ) = x$ and $\phi ( x ) = 1$ returns the number of nodes, and hence $\dot { x _ { G ^ { 1 } } } = n ^ { 1 } \neq n ^ { 2 } = x _ { G ^ { 2 } }$ . Otherwise, let $V = \{ v _ { i } ^ { k } \} _ { i \in [ [ 1 , n ^ { 1 } ] ] , k \in \{ 1 , 2 \} }$ be the set of node attributes of $G ^ { 1 }$ and $G ^ { 2 }$ , $c ^ { 1 }$ be a coloring of $G ^ { 1 }$ , $\psi ( x ) = x$ and $\phi$ J Kbe a continuous function such that, $\forall x \in V$ and $S \subset V$ ,
409
+
410
+ $$
411
+ \phi ( x , S ) = \sum _ { i = 1 } ^ { n ^ { 1 } } \mathbb { 1 } \{ x = ( v _ { i } ^ { 1 } , c _ { i } ^ { 1 } ) \} \prod _ { j \neq i } \mathbb { 1 } \left\{ A _ { i j } ^ { 1 } = \mathbb { 1 } \{ ( v _ { j } ^ { 1 } , c _ { j } ^ { 1 } ) \in S \} \right\} .
412
+ $$
413
+
414
+ The existence of $\phi \in \mathcal { C } ( \mathbb { R } ^ { m } , \mathbb { R } )$ is assured by Urysohn’s lemma (see e.g. (Rudin, 1987, lemma 2.12)). Then, $x _ { G }$ counts the number of matching neighborhoods for the best coloring, and we have $x _ { G ^ { 1 } } = n ^ { 1 }$ and $x _ { G ^ { 2 } } \leq n ^ { 1 } - 1$ . Finally, taking $\varepsilon \stackrel { - } { < } 1 / 2 n ^ { 1 }$ in the definition of universal representation leads to the desired result, as then, using an $\varepsilon$ -approximation of $\phi$ as NODEAGGREGATION(1), we have $x _ { G ^ { 1 } } > n ^ { 1 } - 1 / 2 > x _ { G ^ { 2 } }$ . □
415
+
416
+ Proof of Theorem 4. Consider a continuous function $\psi : { \bf G r a p h } _ { m } \mathbb { R } ^ { d }$ and a compact $K ^ { \prime } \subset$ Graphm. Let extend K0 with K = K0 × [0, 1]nmax and we define φ : Graphm+nmax with $\phi ( ( v , c ) , { \overset { . . . } { A } } ) = \psi ( v , A )$ for all $c \in \mathcal { C } ( v , A )$ . Since $\infty$ -CLIP is universal there exists $\ddot { f } \in \infty$ -CLIP such that, for all $( ( v , c ) , A ) \in K$ ,
417
+
418
+ $$
419
+ \begin{array} { r } { \| \phi ( ( v , c ) , A ) - f ( ( v , c ) , A ) \| \le \varepsilon , } \end{array}
420
+ $$
421
+
422
+ hence
423
+
424
+ $$
425
+ \| \psi ( v , A ) - f ( ( v , c ) , A ) \| \leq \varepsilon .
426
+ $$
427
+
428
+ Moreover, observe that for any coloring $c \in \mathcal { C } ( v , A )$ , $\infty$ -CLIP and 1-CLIP applied to $( ( v , c ) , A )$ returns the same result, as all node attributes are dissimilar (by definition of the colorings) and ${ \mathcal { C } } ( ( v , c ) , A ) = \emptyset$ . Finally, 1-CLIP applied to $( v , A )$ is equivalent to applying 1-CLIP to $( ( v , C ) , A )$ where $C$ is a random coloring in $\mathcal { C } ( v , A )$ , and Eq. (12) thus implies that any random sample of 1-CLIP is within an $\varepsilon$ error of the target function $\psi$ . As a result, its expectation is also within an $\varepsilon$ error of the target function $\psi$ , which proves the universality of the expectation of 1-CLIP. □
429
+
430
+ # E EXPERIMENTAL DETAILS
431
+
432
+ # E.1 REAL-WORLD DATASETS
433
+
434
+ Table 3 summarizes the characteristics of all benchmark graph classification datasets used in Section 6.1. We now provide complementary information on these datasets.
435
+
436
+ Social Network Datasets (IMDBb, IMDBm): These datasets refer to collaborations between actors/actresses, where each graph is an ego-graph of every actor and the edges occur when the connected nodes/actors are playing in the same movie. The task is to classify the genre of the movie that the graph derives from. IMDBb is a single-class classification dataset, while IMDBm is multi-class. For both social network datasets, we used one-hot encodings of node degrees as node attribute vectors.
437
+
438
+ Bio-informatics Datasets (MUTAG, PROTEINS, PTC): MUTAG consists of mutagenic aromatic and heteroaromatic nitrocompounds with 7 discrete labels. PROTEINS consists of nodes, which correspond to secondary structureelements and the edges occur when the connected nodes are neighbors in the amino-acidsequence or in 3D space. It has 3 discrete labels. PTC consists of chemical compounds that reports the carcinogenicity for male and female rats and it has 19 discrete labels. For all bio-informatics datasets we used the node labels as node attribute vectors.
439
+
440
+ Experimentation protocol: We follow the same experimental protocol as described in $\mathrm { X u }$ et al. (2019), and thus report the results provided in this paper corresponding to the accuracy of our six baselines in Table 1. We optimized the CLIP hyperparameters by grid search according to 10-fold cross-validated accuracy means. We use 2-layer MLPs, an initial learning rate of 0.001 and decreased the learning rate by 0.5 every 50 epochs for all possible settings. For all datasets the hyperparameters we tested are: the number of hidden units within $\{ 3 2 , 6 4 \}$ , the number of colorings $\bar { c } \in \bar { \{ 1 , 2 , 4 , 8 \} }$ , the number of MPNN layers within $\{ 1 , 3 , 5 \}$ , the batch size within $\{ 3 2 , 6 4 \}$ , and the number of epochs, that means, we select a single epoch with the best cross-validation accuracy averaged over the 10 folds. Note that standard deviations are fairly high for all models due to the small size of these classic datasets.
441
+
442
+ Table 3: Characteristics of the benchmark graph classification datasets used in Section 6.1.
443
+ E.1.1 CLIP PERFORMANCES W.R.T. THE NUMBER OF COLORINGS $k$
444
+
445
+ <table><tr><td>Dataset</td><td>PTC</td><td>IMDBb</td><td>IMDBm</td><td>PROTEINS</td><td>MUTAG</td></tr><tr><td># graphs</td><td>344</td><td>1000</td><td>1500</td><td>1113</td><td>188</td></tr><tr><td>#classes</td><td>2</td><td>2</td><td>3</td><td>2</td><td>2</td></tr><tr><td>Avg # nodes</td><td>14.29</td><td>19.77</td><td>13.00</td><td>39.06</td><td>17.93</td></tr><tr><td>Avg degree</td><td>2.05</td><td>9.76</td><td>10.14</td><td>3.72</td><td>2.21</td></tr></table>
446
+
447
+ Table 4 summarizes the performances of CLIP while increasing the number of colorings $k$ . Overall we can see a small increase in performances and a reduction of the variances when $k$ is increasing. Nevertheless we should not jump to any conclusions since none of the models are statistically significantly better than the others.
448
+
449
+ Table 4: Ablation study: classification accuracies of $k$ -CLIP on benchmark datasets w.r.t $k$
450
+
451
+ <table><tr><td>Dataset</td><td>PTC</td><td>IMDBb</td><td>IMDBm</td><td>PROTEINS</td><td>MUTAG</td></tr><tr><td>0-CLIP</td><td>65.9±4.0</td><td>75.4±2.0</td><td>52.5±2.6</td><td>77.0±3.2</td><td>90.0±5.1</td></tr><tr><td>1-CLIP</td><td>65.3±12.8</td><td>75.2±3.9</td><td>52.2±4.0</td><td>75.1±4.5</td><td>91.1±7.0</td></tr><tr><td>4-CLIP</td><td>65.9±5.7</td><td>75.8±5.0</td><td>51.8±2.9</td><td>77.1±4.4</td><td>92.2±7.0</td></tr><tr><td>8-CLIP</td><td>67.9±7.1</td><td>75.7±3.8</td><td>52.5±3.0</td><td>76.8±4.8</td><td>93.9±4.1</td></tr><tr><td>16-CLIP</td><td>66.5±5.4</td><td>76.0±2.7</td><td>52.5±4.5</td><td>76.6±2.8</td><td>91.7±6.0</td></tr></table>
452
+
453
+ We note that on the IMDBb and PROTEINS datasets the difference between using or not a coloring scheme does not have a big impact on the performances. However, adding colors increases the performances of the algorithm on three out of five real world datasets. The property testing section (Section 6.2) shows empirically that the color scheme improves the expressiveness of CLIP.
454
+
455
+ # E.2 GRAPH PROPERTY TESTING
456
+
457
+ In Section 6.2 we evaluate the expressive power of CLIP on benchmark synthetic datasets. Our goal is to show that CLIP is able to distinguish basic graph properties, where classical MPNN cannot. We considered a binary classification task and we constructed balanced synthetic datasets2 for each of the examined graph properties. The 20-node graphs are generated using Erdös-Rényi model (Erdös and Rényi, 1959) (and its bipartite version for the bipartiteness) with different probabilities $p$ for edge creation. All nodes share the same (scalar) attribute. We thus have uninformative feature vectors.
458
+
459
+ In particular, we generated datasets for different classical tasks Kriege et al. (2018): 1) connectivity, 2) bipartiteness, 3) triangle-freeness, and 4) circular skip links (Murphy et al., 2019). In the following, we present the generating protocol of the synthetic datasets and the experimentation setup we used for the experiments.
460
+
461
+ # Synthetic datasets:
462
+
463
+ In every case of synthetic dataset we follow the same pattern: we generate a set of random graphs using Erdös-Rényi model, which contain a specific graph property and belong to the same class and by proper edge addition we remove this property, thus creating the second class of graphs. By this way, we assure that we do not change different structural characteristics other than the examined graph property.
464
+
465
+ - Connectivity dataset: this dataset consists of 1000 (20-node) graphs with 500 positive samples and 500 negative ones. The positive samples correspond to disconnected graphs with two 10-node connected components selected among randomly generated graphs with an Erdös-Rényi model probability of $p = 0 . 5$ . We constructed negative samples by adding to positive samples a random edge between the two connected components.
466
+
467
+ - Bipartiteness dataset: this dataset consists of 1000 (20-node) graphs with 500 positive samples and 500 negative ones. The positive samples correspond to bipartite graphs generated with an Erdös-Rényi (bipartite) model probability of $p = 0 . 5$ . For the negative samples (non-bipartite graphs) we chose the positive samples and for each of them we added an edge between randomly selected nodes from the same partition, in order to form odd cycles 3.
468
+
469
+ - Triangle-freeness dataset: this dataset consists of 1000 (20-node) graphs with 500 positive samples and 500 negative ones. The positive samples correspond to triangle-free graphs selected among randomly generated graphs with an Erdös-Rényi model probability of $p \ = \ 0 . 1$ . We constructed negative samples by randomly adding new edges to positive samples until it creates at least one triangle.
470
+
471
+ - Circular skip links: this dataset consists of 150 graphs of 41 nodes as described in (Murphy et al., 2019; Chen et al., 2019). The Circular Skip Links graphs are undirected regular graphs with node degree 4. We denote a Circular skip link graph by $G _ { n , k }$ an undirected graph of $n$ nodes, where $( i , { \bar { j } } ) \in E$ holds if and only if $| i - j | \equiv 1$ or $k ( { \bmod { n } } )$ This is a 10-class multiclass classification task whose objective is to classify each graph according to its isomorphism class.
472
+
473
+ Experimentation protocol: We evaluate the different configurations of CLIP and its competitors GIN and RP-GIN based on their hyper-parameters. For the architecture implementation of the GIN, we followed the best performing architecture, presented in $\mathrm { X u }$ et al. (2019). In particular, we used the summation as the aggregation operator, MLPs as the combination level for the node embedding generation and the sum operator for the readout function along with its refined version of concatenated graph representations across all iterations/layers of GIN, as described in $\mathrm { X u }$ et al. (2019).
474
+
475
+ In all the tested configurations for CLIP and its competitors (GIN, RP-GIN) we fixed the number of layers of the MLPs and the learning rate: we chose 2-layer MLPs and we used the Adam optimizer with initial learning rate of 0.001 along with a scheduler decaying the learning rate by 0.5 every 50 epochs. Concerning the other hyper-parameters, we optimized: the number of hidden units within $\{ \bar { 1 6 } , 3 2 , 6 4 \}$ (except for the CSL task where we only use 16 hidden units to be fair w.r.t. RP-GIN and Ring-GNN benchmarks), the number of MPNN layers within $\{ 1 , 2 , 3 , 5 \}$ , the batch size within $\{ 3 2 , 6 4 \}$ , and ran the model over 400 epochs. Regarding the RP-GIN architecture (Murphy et al., 2019) we optimized the one-hot encoding dimension of the first update within $\{ 5 , 1 0 , 1 5 , 2 0 , 2 5 , 3 0 \}$ and the number of inference permutations within $\{ 1 , 5 , 1 6 \}$ . Regarding the CLIP algorithm, we optimized the number of colorings $c \in \{ 1 , 2 , 4 , 8 , 1 6 \}$ . We then performed a 10-fold cross validation with early stopping for the hyper-parameter optimization and we reported the best 10-fold crossvalidated mean accuracy with its associated standard deviation.
md/train/rkEFLFqee/rkEFLFqee.md ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DECOMPOSING MOTION AND CONTENT FOR NATURAL VIDEO SEQUENCE PREDICTION
2
+
3
+ Ruben Villegas1 Jimei Yang2 Seunghoon Hong3,∗ Xunyu Lin4,\* Honglak Lee1,5
4
+
5
+ 1University of Michigan, Ann Arbor, USA
6
+ 2Adobe Research, San Jose, CA 95110
7
+ 3POSTECH, Pohang, Korea
8
+ 4Beihang University, Beijing, China
9
+ 5Google Brain, Mountain View, CA 94043
10
+
11
+ # ABSTRACT
12
+
13
+ We propose a deep neural network for the prediction of future frames in natural video sequences. To effectively handle complex evolution of pixels in videos, we propose to decompose the motion and content, two key components generating dynamics in videos. Our model is built upon the Encoder-Decoder Convolutional Neural Network and Convolutional LSTM for pixel-level prediction, which independently capture the spatial layout of an image and the corresponding temporal dynamics. By independently modeling motion and content, predicting the next frame reduces to converting the extracted content features into the next frame content by the identified motion features, which simplifies the task of prediction. Our model is end-to-end trainable over multiple time steps, and naturally learns to decompose motion and content without separate training. We evaluate the proposed network architecture on human activity videos using KTH, Weizmann action, and UCF-101 datasets. We show state-of-the-art performance in comparison to recent approaches. To the best of our knowledge, this is the first end-to-end trainable network architecture with motion and content separation to model the spatio-temporal dynamics for pixel-level future prediction in natural videos.
14
+
15
+ # 1 INTRODUCTION
16
+
17
+ Understanding videos has been one of the most important tasks in the field of computer vision. Compared to still images, the temporal component of videos provides much richer descriptions of the visual world, such as interaction between objects, human activities, and so on. Amongst the various tasks applicable on videos, the task of anticipating the future has recently received increased attention in the research community. Most prior works in this direction focus on predicting high-level semantics in a video such as action (Vondrick et al., 2015; Ryoo, 2011; Lan et al., 2014), event (Yuen and Torralba, 2010; Hoai and Torre, 2013) and motion (Pintea et al., 2014; Walker et al., 2014; Pickup et al., 2014; Walker et al., 2016). Forecasting semantics provides information about what will happen in a video, and is essential to automate decision making. However, the predicted semantics are often specific to a particular task and provide only a partial description of the future. Also, training such models often requires heavily labeled training data which leads to tremendous annotation costs especially with videos.
18
+
19
+ In this work, we aim to address the problem of prediction of future frames in natural video sequences. Pixel-level predictions provide dense and direct description of the visual world, and existing video recognition models can be adopted on top of the predicted frames to infer various semantics of the future. Spatio-temporal correlations in videos provide a self-supervision for frame prediction, which enables purely unsupervised training of a model by observing raw video frames. Unfortunately, estimating frames is an extremely challenging task; not only because of the inherent uncertainty of the future, but also various factors of variation in videos leading to complicated dynamics in raw pixel values. There have been a number of recent attempts on frame prediction (Srivastava et al., 2015; Mathieu et al., 2015; Oh et al., 2015; Goroshin et al., 2015; Lotter et al., 2015; Ranzato et al., 2014), which use a single encoder that needs to reason about all the different variations occurring in videos in order to make predictions of the future, or require extra information like foreground-background segmentation masks and static background (Vondrick et al., 2016).
20
+
21
+ We propose a Motion-Content Network (MCnet) for robust future frame prediction. Our intuition is to split the inputs for video prediction into two easily identifiable groups, motion and content, and independently capture each information stream with separate encoder pathways. In this architecture, the motion pathway encodes the local dynamics of spatial regions, while the content pathway encodes the spatial layout of the salient parts of an image. The prediction of the future frame is then achieved by transforming the content of the last observed frame given the identified dynamics up to the last observation. Somewhat surprisingly, we show that such a network is end-to-end trainable without individual path way supervision. Specifically, we show that an asymmetric architecture for the two pathways enables such decompositions without explicit supervision. The contributions of this paper are summarized below:
22
+
23
+ • We propose MCnet for the task of frame prediction, which separates the information streams (motion and content) into different encoder pathways.
24
+ • The proposed network is end-to-end trainable and naturally learns to decompose motion and content without separate training, and reduces the task of frame prediction to transforming the last observed frame into the next by the observed motion.
25
+ • We evaluate the proposed model on challenging real-world video datasets, and show that it outperforms previous approaches on frame prediction.
26
+
27
+ The rest of the paper is organized as follows. We briefly review related work in Section 2, and introduce an overview of the proposed algorithm in Section 3. The detailed configuration of the proposed network is described in Section 4. Section 5 describes training and inference procedure. Section 6 illustrates implementation details and experimental results on challenging benchmarks.
28
+
29
+ # 2 RELATED WORK
30
+
31
+ The problem of visual future prediction has received growing interests in the computer vision community. It has led to various tasks depending on the objective of future prediction, such as human activity (Vondrick et al., 2015; Ryoo, 2011; Lan et al., 2014), event (Yuen and Torralba, 2010; Hoai and Torre, 2013) and geometric path (Walker et al., 2014). Although previous work achieved reasonable success in specific tasks, they are often limited to estimating predefined semantics, and require fully-labeled training data. To alleviate this issue, approaches predicting representation of the future beyond semantic labels have been proposed. Walker et al. (2014) proposed a data-driven approach to predict the motion of a moving object, and coarse hallucination of the predicted motion. Vondrick et al. (2015) proposed a deep regression network to predict feature representations of the future frames. These approaches are supervised and provide coarse predictions of how the future will look like. Our work also focuses on unsupervised learning for prediction of the future, but to a more direct visual prediction task: frame prediction.
32
+
33
+ Compared to predicting semantics, pixel-level prediction has been less investigated due to the difficulties in modeling evolution of raw pixels over time. Fortunately, recent advances in deep learning provide a powerful tool for sequence modeling, and enable the creation of novel architectures for modeling complex sequential data. Ranzato et al. (2014) applied a recurrent neural network developed for language modeling to frame prediction by posing the task as classification of each image region to one of quantized patch dictionaries. Srivastava et al. (2015) applied a sequence-tosequence model to video prediction, and showed that Long Short-Term Memory (LSTM) is able to capture pixel dynamics. Oh et al. (2015) proposed an action-conditional encoder-decoder network to predict future frames in Atari games. In addition to the different choices of architecture, some other works addressed the importance of selecting right objective function: Lotter et al. (2015) used adversarial loss with combined CNN and LSTM architectures, and Mathieu et al. (2015) employed similar adversarial loss with additional regularization using a multi-scale encoder-decoder network. Finn et al. (2016) constructed a network that predicts transformations on the input pixels for next frame prediction. Patraucean et al. (2015) proposed a network that by explicitly predicting optical flow features is able to predict the next frame in a video. Vondrick et al. (2016) proposed a generative adversarial network for video which, by generating a background-foreground mask, is able to generate realistic-looking video sequences. However, none of the previously mentioned approaches exploit spatial and temporal information separately in an unsupervised fashion. In terms of the way data is observed, the closest work to ours is Xue et al. (2016). The differences are (1) Our model is deterministic and theirs is probabilistic, (2) our motion encoder is based on convolutional LSTM (Shi et al., 2015) which is a more natural module to model long-term dynamics, (3) our content encoder observes a single scale input and theirs observes many scales, and (4) we directly generate image pixels values, which is a more complicated task. We aim to exploit the existing spatio-temporal correlations in videos by decomposing the motion and content in our network architecture.
34
+
35
+ To the best of our knowledge, the idea of separating motion and content has not been investigated in the task of unsupervised deterministic frame prediction. The proposed architecture shares similarities to the two-stream CNN (Simonyan and Zisserman, 2014), which is designed for action recognition to jointly exploit the information from frames and their temporal dynamics. However, in contrast to their network we aim to learn features for temporal dynamics directly from the raw pixels, and we use the identified features from the motion in combination with spatial features to make pixel-level predictions of the future.
36
+
37
+ # 3 ALGORITHM OVERVIEW
38
+
39
+ In this section, we formally define the task of frame prediction and the role of each component in the proposed architecture. Let ${ \bf x } _ { t } \in \mathrm { R } ^ { w \times h \times c }$ denote the $t$ -th frame in an input video $\mathbf { x }$ , where $w , h$ , and $c$ denote width, height, and number of channels, respectively. The objective of frame prediction is to generate the future frame $\hat { \mathbf { x } } _ { t + 1 }$ given the input frames $\mathbf { x } _ { 1 : t }$ .
40
+
41
+ At the $t { \cdot }$ -th time step, our network observes a history of previous consecutive frames up to frame $t$ and generates the prediction of the next frame $\hat { \mathbf { x } } _ { t + 1 }$ as follows:
42
+
43
+ • Motion Encoder recurrently takes an image difference input between frame $\mathbf { x } _ { t }$ and $\mathbf { x } _ { t - 1 }$ starting from $t = 2$ , and produces the hidden representation $\mathbf { d } _ { t }$ encoding the temporal dynamics of the scene components (Section 4.1).
44
+ Content Encoder takes the last observed frame $\mathbf { x } _ { t }$ as an input, and outputs the hidden representation $\mathbf { s } _ { t }$ that encodes the spatial layout of the scene (Section 4.2).
45
+ Multi-Scale Motion-Content Residual takes the computed features, from both the motion and content encoders, at every scale right before pooling and computes residuals $\mathbf { r } _ { t }$ (He et al., 2015) to aid the information loss caused by pooling in the encoding phase (Section 4.3).
46
+ Combination Layers and Decoder takes the outputs from both encoder pathways and residual connections, $\mathbf { d } _ { t }$ , $\mathbf { s } _ { t }$ , and $\mathbf { r } _ { t }$ , and combines them to produce a pixel-level prediction of the next frame $\hat { \mathbf { x } } _ { t + 1 }$ (Section 4.4).
47
+
48
+ The overall architecture of the proposed algorithm is described in Figure 1. The prediction of multiple frames, $\hat { \mathbf { x } } _ { t + 1 : t + T }$ , can be achieved by recursively performing the above procedures over $T$ time steps (Section 5). Each component in the proposed architecture is described in the following section.
49
+
50
+ # 4 ARCHITECTURE
51
+
52
+ This section describes the detailed configuration of the proposed architecture, including the two encoder pathways, multi-scale residual connections, combination layers, and decoder.
53
+
54
+ # 4.1 MOTION ENCODER
55
+
56
+ The motion encoder captures the temporal dynamics of the scene’s components by recurrently observing subsequent difference images computed from $\mathbf { x } _ { t - 1 }$ and $\mathbf { x } _ { t }$ , and outputs motion features by
57
+
58
+ $$
59
+ \left[ \mathbf { d } _ { t } , \mathbf { c } _ { t } \right] = f ^ { \mathrm { d y n } } \left( \mathbf { x } _ { t } - \mathbf { x } _ { t - 1 } , \mathbf { d } _ { t - 1 } , \mathbf { c } _ { t - 1 } \right) ,
60
+ $$
61
+
62
+ where ${ \bf x } _ { t } - { \bf x } _ { t - 1 }$ denotes element-wise subtraction between frames at time $t$ and $t - 1$ , $\mathbf { d } _ { t } \in \mathbb { R } ^ { w ^ { \prime } \times h ^ { \prime } \times c ^ { \prime } }$ is the feature tensor encoding the motion across the observed difference image inputs, and $\mathbf { c } _ { t } ~ \in$ $\mathbb { R } ^ { w ^ { \prime } \times h ^ { \prime } \times c ^ { \prime } }$ is a memory cell that retains information of the dynamics observed through time. $f ^ { \mathrm { d y n } }$ is implemented in a fully-convolutional way to allow our model to identify local dynamics of frames rather than complicated global motion. For this, we use an encoder CNN with a Convolutional LSTM (Shi et al., 2015) layer on top.
63
+
64
+ ![](images/b14e2d7ec424a851a2e17a83ef8e07c7d7ba00e0ed72fbf2fe41c30066abfd0b.jpg)
65
+ Figure 1: Overall architecture of the proposed network. (a) illustrates MCnet without the MotionContent Residual skip connections, and (b) illustrates MCnet with such connections. Our network observes a history of image differences through the motion encoder and last observed image through the content encoder. Subsequently, our network proceeds to compute motion-content features and communicates them to the decoder for the prediction of the next frame.
66
+
67
+ # 4.2 CONTENT ENCODER
68
+
69
+ The content encoder extracts important spatial features from a single frame, such as the spatial layout 64 64 64 64of the scene and salient objects in a video. Specifically, it takes the last observed frame $\mathbf { x } _ { t }$ as an input, and produces content features by
70
+
71
+ $$
72
+ { \bf s } _ { t } = f ^ { \mathrm { c o n t } } \left( { \bf x } _ { t } \right) ,
73
+ $$
74
+
75
+ where $\mathbf { s } _ { t } \in \mathbb { R } ^ { w ^ { \prime } \times h ^ { \prime } \times c ^ { \prime } }$ is the feature encoding the spatial content of the last observed frame, and $f ^ { \mathrm { c o n t } }$ is implemented by a Convolutional Neural Network (CNN) that specializes on extracting features from single frame.
76
+
77
+ It is important to note that our model employs an asymmetric architecture for the motion and content encoder. The content encoder takes the last observed frame, which keeps the most critical clue to reconstruct spatial layout of near future, but has no information about dynamics. On the other hand, the motion encoder takes a history of previous image differences, which are less informative about the future spatial layout compared to the last observed frame, yet contain important spatio-temporal variations occurring over time. This asymmetric architecture encourages encoders to exploit each of two pieces of critical information to predict the future content and motion individually, and enables the model to learn motion and content decomposition naturally without any supervision.
78
+
79
+ # 4.3 MULTI-SCALE MOTION-CONTENT RESIDUAL
80
+
81
+ To prevent information loss after the pooling operations in our motion and content encoders, we use residual connections (He et al., 2015). The residual connections in our network communicate motion-content features at every scale into the decoder layers after unpooling operations. The residual feature at layer $l$ is computed by
82
+
83
+ $$
84
+ \mathbf { r } _ { t } ^ { l } = f ^ { \mathrm { r e s } } \left( \left[ \mathbf { s } _ { t } ^ { l } , \mathbf { d } _ { t } ^ { l } \right] \right) ^ { l } ,
85
+ $$
86
+
87
+ where $\mathbf { r } _ { t } ^ { l }$ is the residual output at layer $l$ , $\left[ \mathbf { s } _ { t } ^ { l } , \mathbf { d } _ { t } ^ { l } \right]$ is the concatenation of the motion and content features along the depth dimension at layer $l$ of their respective encoders, $f ^ { \mathrm { r e s } } \left( . \right) ^ { l }$ the residual function at layer $l$ implemented as consecutive convolution layers and rectification with a final linear layer.
88
+
89
+ # 4.4 COMBINATION LAYERS AND DECODER
90
+
91
+ The outputs from the two encoder pathways, $\mathbf { d } _ { t }$ and $\mathbf { s } _ { t }$ , encode a high-level representation of motion and content, respectively. Given these representations, the objective of the decoder is to generate a
92
+
93
+ pixel-level prediction of the next frame $\hat { \mathbf { x } } _ { t + 1 } \in \mathbb { R } ^ { w \times h \times c }$ . To this end, it first combines the motion and content back into a unified representation by
94
+
95
+ $$
96
+ \mathbf { f } _ { t } = g ^ { \mathrm { c o m b } } \left( \left[ \mathbf { d } _ { t } , \mathbf { s } _ { t } \right] \right) ,
97
+ $$
98
+
99
+ where $[ \mathbf { d } _ { t } , \mathbf { s } _ { t } ] \in \mathbb { R } ^ { w ^ { \prime } \times h ^ { \prime } \times 2 c ^ { \prime } }$ denotes the concatenation of the higher-level motion and content features in the depth dimension, and $\mathbf { f } _ { t } \in \mathbb { R } ^ { w ^ { \prime } \times h ^ { \prime } \times c ^ { \prime } }$ denotes the combined high-level representation of motion and content. $g ^ { \mathrm { c o m b } }$ is implemented by a CNN with bottleneck layers (Hinton and Salakhutdinov, 2006); it first projects both $\mathbf { d } _ { t }$ and $\mathbf { s } _ { t }$ into a lower-dimensional embedding space, and then puts it back to the original size to construct the combined feature $\mathbf { f } _ { t }$ . Intuitively, $\mathbf { f } _ { t }$ can be viewed as the content feature of the next time step, $\mathbf { s } _ { t + 1 }$ , which is generated by transforming $\mathbf { s } _ { t }$ using the observed dynamics encoded in $\mathbf { d } _ { t }$ . Then our decoder places $\mathbf { f } _ { t }$ back into the original pixel space by
100
+
101
+ $$
102
+ \begin{array} { r } { \hat { \mathbf { x } } _ { t + 1 } = g ^ { \mathrm { d e c } } \left( \mathbf { f } _ { t } , \mathbf { r } _ { t } \right) , } \end{array}
103
+ $$
104
+
105
+ where $\mathbf { r } _ { t }$ is a list containing the residual connections from every layer of the motion and content encoders before pooling sent to every layer of the decoder after unpooling. We employ the deconvolution network (Zeiler et al., 2011) for our decoder network $g ^ { \mathrm { d e c } }$ , which is composed of multiple successive operations of deconvolution, rectification and unpooling with the addition of the motioncontent residual connections after each unpooling operation. The output layer is passed through a tanh (.) activation function. Unpooling with fixed switches are used to upsample the intermediate activation maps.
106
+
107
+ # 5 INFERENCE AND TRAINING
108
+
109
+ Section 4 describes the procedures for single frame prediction, while this section presents the extension of our algorithm for the prediction of multiple time steps.
110
+
111
+ # 5.1 MULTI-STEP PREDICTION
112
+
113
+ Given an input video, our network observes the first $n$ frames as image difference between frame $\mathbf { x } _ { t }$ and $\mathbf { x } _ { t - 1 }$ , starting from $t = 2$ up to $t = n$ , to encode initial temporal dynamics through the motion encoder. The last frame ${ \bf x } _ { n }$ is given to the content encoder to be transformed into the first prediction $\hat { \mathbf { x } } _ { t + 1 }$ by the identified motion features.
114
+
115
+ For each time step $t \in [ n + 1 , n + T ]$ , where $T$ is the desired number of prediction steps, our network takes the difference image between the first prediction $\hat { \mathbf { x } } _ { t + 1 }$ and the previous image $\mathbf { x } _ { t }$ , and the first prediction $\hat { \mathbf { x } } _ { t + 1 }$ itself to predict the next frame $\hat { \mathbf { x } } _ { t + 2 }$ , and so forth.
116
+
117
+ # 5.2 TRAINING OBJECTIVE
118
+
119
+ To train our network, we use an objective fMathieu et al. (2015). Given the training data $D = \{ \mathbf { x } _ { 1 , . . . , T } ^ { ( i ) } \} _ { i = 1 } ^ { N }$ of different sub-losses similar to, our model is trained to minimize
120
+
121
+ $$
122
+ \begin{array} { r } { \mathcal { L } = \alpha \mathcal { L } _ { \mathrm { i m g } } + \beta \mathcal { L } _ { \mathrm { G A N } } , } \end{array}
123
+ $$
124
+
125
+ where $\alpha$ and $\beta$ are hyper-parameters that control the effect of each sub-loss during optimization. $\mathcal { L } _ { \mathrm { i m g } }$ is the loss in image space from Mathieu et al. (2015) defined by
126
+
127
+ $$
128
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { i m g } } = \mathcal { L } _ { p } \left( \mathbf { x } _ { t + k } , \hat { \mathbf { x } } _ { t + k } \right) + \mathcal { L } _ { g d l } \left( \mathbf { x } _ { t + k } , \hat { \mathbf { x } } _ { t + k } \right) , } \end{array}
129
+ $$
130
+
131
+ $$
132
+ \begin{array} { l } { { \displaystyle \mathcal { L } _ { p } \left( { \bf y } , { \bf z } \right) = \sum _ { k = 1 } ^ { T } \left| \left| { \bf y } - { \bf z } \right| \right| _ { p } ^ { p } } , \ ~ } \\ { { \displaystyle \mathcal { L } _ { g d l } \left( { \bf y } , { \bf z } \right) = \sum _ { i , j } ^ { h , w } \left| \left( \left| { \bf y } _ { i , j } - { \bf y } _ { i - 1 , j } \right| - \left| { \bf z } _ { i , j } - { \bf z } _ { i - 1 , j } \right| \right) \right| ^ { \lambda } } } \\ { { \displaystyle ~ + \left| \left( \left| { \bf y } _ { i , j - 1 } - { \bf y } _ { i , j } \right| - \left| { \bf z } _ { i , j - 1 } - { \bf z } _ { i , j } \right| \right) \right| ^ { \lambda } } . } \end{array}
133
+ $$
134
+
135
+ Here, $\mathbf { x } _ { t + k }$ and $\hat { \mathbf { x } } _ { t + k }$ are the target and predicted frames, respectively, and $p$ and $\lambda$ are hyperparameters for ${ \mathcal { L } } _ { p }$ and $\mathcal { L } _ { g d l }$ , respectively. Intuitively, ${ \mathcal { L } } _ { p }$ guides our network to match the average pixel values directly, while $\mathcal { L } _ { g d l }$ guides our network to match the gradients of such pixel values. Overall, $\mathcal { L } _ { \mathrm { i m g } }$ guides our network to learn parameters towards generating the correct average sequence given the input. Training to generate average sequences, however, results in somewhat blurry generations which is the reason we use an additional sub-loss. ${ \mathcal { L } } _ { \mathrm { G A N } }$ is the generator loss in adversarial training to allow our model to predict realistic looking frames and it is defined by
136
+
137
+ $$
138
+ \mathcal { L } _ { \mathrm { G A N } } = - \log D \left( \left[ \mathbf { x } _ { 1 : t } , G \left( \mathbf { x } _ { 1 : t } \right) \right] \right) ,
139
+ $$
140
+
141
+ where $\mathbf { x } _ { 1 : t }$ is the concatenation of the input images, $\mathbf { x } _ { t + 1 : t + T }$ is the concatenation of the ground-truth future images, $G \left( \mathbf { x } _ { 1 : t } \right) = \hat { \mathbf { x } } _ { t + 1 : t + T }$ is the concatenation of all predicted images along the depth dimension, and $D \left( . \right)$ is the discriminator in adversarial training. The discriminative loss in adversarial training is defined by
142
+
143
+ $$
144
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { d i s c } } = - \log D \left( \left[ \mathbf { x } _ { 1 : t } , \mathbf { x } _ { t + 1 : t + T } \right] \right) - \log \left( 1 - D \left( \left[ \mathbf { x } _ { 1 : t } , G \left( \mathbf { x } _ { 1 : t } \right) \right] \right) \right) . } \end{array}
145
+ $$
146
+
147
+ ${ \mathcal { L } } _ { \mathrm { G A N } }$ , in addition to $\mathcal { L } _ { \mathrm { i m g } }$ , allows our network to not only generate the target sequence, but also simultaneously enforce realism in the images through visual sharpness that fools the human eye. Note that our model uses its predictions as input for the next time-step during the training, which enables the gradients to flow through time and makes the network robust for error propagation during prediction. For more a detailed description about adversarial training, please refer to Appendix D.
148
+
149
+ # 6 EXPERIMENTS
150
+
151
+ In this section, we present experiments using our network for video generation. We first evaluate our network, MCnet, on the KTH (Schuldt et al., 2004) and Weizmann action (Gorelick et al., 2007) datasets, and compare against a baseline convolutional LSTM (ConvLSTM) (Shi et al., 2015). We then proceed to evaluate on the more challenging UCF-101 (Soomro et al., 2012) dataset, in which we compare against the same ConvLSTM baseline and also the current state-of-the-art method by Mathieu et al. (2015). For all our experiments, we use $\alpha = 1$ , $\lambda = 1$ , and $p = 2$ in the loss functions.
152
+
153
+ In addition to the results in this section, we also provide more qualitative comparisons in the supplementary material and in the videos on the project website: https://sites.google. com/a/umich.edu/rubenevillegas/iclr2017.
154
+
155
+ Architectures. The content encoder of MCnet is built with the same architecture as VGG16 (Simonyan and Zisserman, 2015) up to the third pooling layer. The motion encoder of MCnet is also similar to VGG16 up to the third pooling layer, except that we replace its consecutive 3x3 convolutions with single 5x5, 5x5, and $7 \mathrm { x } 7 $ convolutions in each layer. The combination layers are composed of 3 consecutive 3x3 convolutions (256, 128, and 256 channels in each layer). The multi-scale residuals are composed of 2 consecutive 3x3 convolutions. The decoder is the mirrored architecture of the content encoder where we perform unpooling followed by deconvolution. For the baseline ConvLSTM, we use the same architecture as the motion encoder, residual connections, and decoder, except we increase the number of channels in the encoder in order to have an overall comparable number of parameters with MCnet.
156
+
157
+ # 6.1 KTH AND WEIZMANN ACTION DATASETS
158
+
159
+ Experimental settings. The KTH human action dataset (Schuldt et al., 2004) contains 6 categories of periodic motions on a simple background: running, jogging, walking, boxing, hand-clapping and hand-waiving. We use person 1-16 for training and 17-25 for testing, and also resize frames to $1 2 8 \mathrm { x } 1 2 8$ pixels. We train our network and baseline by observing 10 frames and predicting 10 frames into the future on the KTH dataset. We set $\beta = 0 . 0 2$ for training. We also select the walking, running, one-hand waving, and two-hands waving sequences from the Weizmann action dataset (Gorelick et al., 2007) for testing the networks’ generalizability.
160
+
161
+ For all the experiments, we test the networks on predicting 20 time steps into the future. As for evaluation, we use the same SSIM and PSNR metrics as in Mathieu et al. (2015). The evaluation on KTH was performed on sub-clips within each video in the testset. We sample sub-clips every 3 frames for running and jogging, and sample sub-clips every 20 frames (skipping the frames we have already predicted) for walking, boxing, hand-clapping, and hand-waving. Sub-clips for running, jogging, and walking were manually trimmed to ensure humans are always present in the frames. The evaluation on Weizmann was performed on all sub-clips in the selected sequences.
162
+
163
+ ![](images/a4613d092003dc38238ba869a61c25db2807fc56496c74f12bda75bcd4e41fad.jpg)
164
+ Figure 2: Quantitative comparison between MCnet and ConvLSTM baseline with and without multiscale residual connections (indicated by $" +$ RES"). Given 10 input frames, the models predict 20 frames recursively, one by one. Left column: evaluation on KTH dataset (Schuldt et al., 2004). Right colum: evaluation on Weizmann (Gorelick et al., 2007) dataset.
165
+
166
+ Results. Figure 2 summarizes the quantitative comparisons among our MCnet, ConvLSTM baseline and their residual variations. In the KTH test set, our network outperforms the ConvLSTM baseline by a small margin. However, when we test the residual versions of MCnet and ConvLSTM on the dataset (Gorelick et al., 2007) with similar motions, we can see that our network can generalize well to the unseen contents by showing clear improvements, especially in long-term prediction. One reason for this result is that the test and training partitions of the KTH dataset have simple and similar image contents so that ConvLSTM can memorize the average background and human appearance to make reasonable predictions. However, when tested on unseen data, ConvLSTM has to internally take care of both scene dynamics and image contents in a mingled representation, which gives it a hard time for generalization. In contrast, the reason our network outperforms the ConvLSTM baseline on unseen data is that our network focuses on identifying general motion features and applying them to a learned content representation.
167
+
168
+ Figure 3 presents qualitative results of multi-step prediction by our network and ConvLSTM. As expected, prediction results by our full architecture preserves human shapes more accurately than the baseline. It is worth noticing that our network produces very sharp prediction over long-term time steps; it shows that MCnet is able to capture periodic motion cycles, which reduces the uncertainty of future prediction significantly. More qualitative comparisons are shown in the supplementary material and the project website.
169
+
170
+ # 6.2 UCF-101 DATASET
171
+
172
+ Experimental settings. This section presents results on the challenging real-world videos in the UCF-101 (Soomro et al., 2012) dataset. Having collected from YouTube, the dataset contains 101 realistic human actions taken in a wild and exhibits various challenges, such as background clutter, occlusion, and complicated motion. We employed the same network architecture as in the KTH dataset, but resized frames to $2 4 0 \mathrm { x } 3 2 0$ pixels, and trained the network to observe 4 frames and predict a single frame. We set $\beta = 0 . 0 0 1$ for training. We also trained our convolutional LSTM baseline in the same way. Following the same protocol as Mathieu et al. (2015) for data pre-processing and evaluation metrics on full images, all networks were trained on Sports-1M (Karpathy et al., 2014) dataset and tested on UCF-101 unless otherwise stated.1
173
+
174
+ ![](images/57c95513a034932d176e82012cb29ebd08dad0466bd953290918a2998722efb6.jpg)
175
+ Figure 3: Qualitative comparison between our MCNet model and ConvLSTM. We display predictions starting from the $1 2 ^ { \mathrm { t h } }$ frame, in every 3 timesteps. The first 3 rows correspond to KTH dataset for the action of jogging and the last 3 rows correspond to Weizmann dataset for the action of walking.
176
+
177
+ Results. Figure 4 shows the quantitative comparisons between our network trained for single-stepprediction and Mathieu et al. (2015). We can clearly see the advantage of our network over the baseline. The separation of motion and contents in two encoder pathways allows our network to identify key motion and content features, which are then fed into the decoder to yield predictions of higher quality compared to the baseline.2 In other words, our network only moves what shows motion in the past, and leaves the rest untouched. We also trained a residual version of MCnet on UCF-101, indicated by “MCnet $^ +$ RES UCF101", to compare how well our model generalizes when trained and tested on the same or different dataset(s). To our surprise, when tested with UCF-101, the MCnet trained on Sports-1M (MCnet $^ +$ RES) roughly matches the performance of the MCnet trained on UCF-101 (MCnet $^ +$ RES UCF101), which suggests that our model learns effective representations which can generalize to new datasets. Figure 5 presents qualitative comparisons between frames generated by our network and Mathieu et al. (2015). Since the ConvLSTM and Mathieu et al. (2015) lack explicit motion and content modules, they lose sense of the dynamics in the video and therefore the contents become distorted quickly. More qualitative comparisons are shown in the supplementary material and the project website.
178
+
179
+ ![](images/0e476f9ab07ef0f449a3c49aa1c132980617cfa38f63b273c4a345355d3fa9d8.jpg)
180
+ Figure 4: Quantitative comparison between our model, convolutional LSTM Shi et al. (2015), and Mathieu et al. (2015). Given 4 input frames, the models predict 8 frames recursively, one by one.
181
+
182
+ # 7 CONCLUSION
183
+
184
+ We proposed a motion-content network for pixel-level prediction of future frames in natural video sequences. The proposed model employs two separate encoding pathways, and learns to decompose motion and content without explicit constraints or separate training. Experimental results suggest that separate modeling of motion and content improves the quality of the pixel-level future prediction, and our model overall achieves state-of-the-art performance in predicting future frames in challenging real-world video datasets.
185
+
186
+ # 8 ACKNOWLEDGEMENTS
187
+
188
+ This work was supported in part by ONR N00014-13-1-0762, NSF CAREER IIS-1453651, gifts from the Bosch Research and Technology Center, and Sloan Research Fellowship. We also thank NVIDIA for donating K40c and TITAN X GPUs. We thank Ye Liu, Junhyuk Oh, Xinchen Yan, Lajanugen Logeswaran, Yuting Zhang, Sungryull Sohn, Kibok Lee, Rui Zhang, and other collaborators for helpful discussions. R. Villegas was partly supported by the Rackham Merit Fellowship.
189
+
190
+ # REFERENCES
191
+
192
+ C. Finn, I. J. Goodfellow, and S. Levine. Unsupervised learning for physical interaction through video prediction. In NIPS, 2016.
193
+ I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio. Generative adversarial nets. In NIPS. 2014.
194
+ L. Gorelick, M. Blank, E. Shechtman, M. Irani, and R. Basri. Actions as space-time shapes. Transactions on Pattern Analysis and Machine Intelligence, 29(12):2247–2253, December 2007.
195
+ R. Goroshin, M. Mathieu, and Y. LeCun. Learning to linearize under uncertainty. In NIPS. 2015.
196
+ K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. CoRR, abs/1512.03385, 2015.
197
+ G. Hinton and R. Salakhutdinov. Reducing the dimensionality of data with neural networks. Science, 2006.
198
+ M. Hoai and F. Torre. Max-margin early event detectors. IJCV, 2013.
199
+ A. Karpathy, G. Toderici, S. Shetty, T. Leung, R. Sukthankar, and L. Fei-Fei. Large-scale video classification with convolutional neural networks. In CVPR, 2014.
200
+ T. Lan, T. Chen, and S. Savarese. A hierarchical representation for future action prediction. In ECCV, 2014.
201
+ W. Lotter, G. Kreiman, and D. Cox. Unsupervised learning of visual structure using predictive generative networks. arXiv preprint arXiv:1504.08023, 2015.
202
+ M. Mathieu, C. Couprie, and Y. LeCun. Deep multi-scale video prediction beyond mean square error. arXiv preprint arXiv:1511.05440, 2015.
203
+ J. Oh, X. Guo, H. Lee, R. L. Lewis, and S. Singh. Action-conditional video prediction using deep networks in atari games. In NIPS. 2015.
204
+ V. Patraucean, A. Handa, and R. Cipolla. Spatio-temporal video autoencoder with differentiable memory. CoRR, abs/1511.06309, 2015.
205
+ L. C. Pickup, Z. Pan, D. Wei, Y. Shih, C. Zhang, A. Zisserman, B. Scholkopf, and W. T. Freeman. Seeing the arrow of time. In CVPR, 2014.
206
+ S. L. Pintea, J. C. van Gemert, and A. W. M. Smeulders. Dejavu: Motion prediction in static images. In European Conference on Computer Vision, 2014.
207
+ M. Ranzato, A. Szlam, J. Bruna, M. Mathieu, R. Collobert, and S. Chopra. Video (language) modeling: a baseline for generative models of natural videos. arXiv preprint arXiv:1412.6604, 2014.
208
+ M. S. Ryoo. Human activity prediction: Early recognition of ongoing activities from streaming videos. In ICCV, 2011.
209
+ C. Schuldt, I. Laptev, and B. Caputo. Recognizing human actions: A local svm approach. In ICPR, 2004.
210
+ X. Shi, Z. Chen, H. Wang, D.-Y. Yeung, W.-k. Wong, and W.-c. WOO. Convolutional lstm network: A machine learning approach for precipitation nowcasting. In Advances in Neural Information Processing Systems 28. 2015.
211
+ K. Simonyan and A. Zisserman. Two-stream convolutional networks for action recognition in videos. In NIPS. 2014.
212
+ K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015.
213
+ K. Soomro, A. R. Zamir, and M. Shah. UCF101: A dataset of 101 human actions classes from videos in the wild. arXiv preprint arXiv:1212.0402, 2012.
214
+ N. Srivastava, E. Mansimov, and R. Salakhudinov. Unsupervised learning of video representations using lstms. In ICML, 2015.
215
+ C. Vondrick, H. Pirsiavash, and A. Torralba. Anticipating the future by watching unlabeled video. arXiv preprint arXiv:1504.08023, 2015.
216
+ C. Vondrick, H. Pirsiavash, and A. Torralba. Generating videos with scene dynamics. In NIPS. 2016.
217
+ J. Walker, A. Gupta , and M. Hebert . Patch to the future: Unsupervised visual prediction. In CVPR, 2014.
218
+ J. Walker, C. Doersch, A. Gupta, and M. Hebert. An uncertain future: Forecasting from static images using variational autoencoders. CoRR, abs/1606.07873, 2016.
219
+ P. Weinzaepfel, J. Revaud, Z. Harchaoui, and C. Schmid. DeepFlow: Large displacement optical flow with deep matching. In ICCV, 2013.
220
+ T. Xue, J. Wu, K. L. Bouman, and W. T. Freeman. Visual dynamics: Probabilistic future frame synthesis via cross convolutional networks. NIPS, 2016.
221
+ J. Yuen and A. Torralba. A data-driven approach for event prediction. In ECCV, 2010.
222
+ M. D. Zeiler, G. W. Taylor, and R. Fergus. Adaptive deconvolutional networks for mid and high level feature learning. In ICCV, 2011.
223
+
224
+ ![](images/212232b8375c50f3bf84c011449ae12ba9ad5cbcc4377629b00f459634d92915.jpg)
225
+ Figure 5: Qualitative comparisons among MCnet and ConvLSTM and Mathieu et al. (2015). We display predicted frames (in every other frame) starting from the $5 ^ { \mathrm { t h } }$ frame. The green arrows denote the top-30 closest optical flow vectors within image patches between MCnet and ground-truth. More clear motion prediction can be seen in the project website.
226
+
227
+ ![](images/4fde2a6fb4a3a8455b1bf35d6b0fa255cff3e44e76f133c03192ab9870f66ffc.jpg)
228
+ Figure 6: Qualitative comparisons on KTH testset. We display predictions starting from the $1 2 ^ { \mathrm { t h } }$ frame, for every 3 timesteps. More clear motion prediction can be seen in the project website.
229
+
230
+ ![](images/6800b81e2a878255130308372182877efa0acdfddb1432a5bcbe476e792d1948.jpg)
231
+ Figure 7: Qualitative comparisons on KTH testset. We display predictions starting from the $1 2 ^ { \mathrm { t h } }$ frame, for every 3 timesteps. More clear motion prediction can be seen in the project website.
232
+
233
+ ![](images/b37e300e23885a8cd634505babbd4ac600c843953bdda6d0ba32e1626fa33bc3.jpg)
234
+ Figure 8: Qualitative comparisons on UCF-101. We display predictions (in every other frame) starting from the $5 ^ { \mathrm { t h } }$ frame. The green arrows denote the top-30 closest optical flow vectors within image patches between MCnet and ground-truth. More clear motion prediction can be seen in the project website.
235
+
236
+ # A QUALITATIVE AND QUANTITATIVE COMPARISON WITH CONSIDERABLE CAMERA MOTION AND ANALYSIS
237
+
238
+ In this section, we show frame prediction examples in which considerable camera motion occurs. We analyze the effects of camera motion on our best network and the corresponding baselines. First, we analyze qualitative examples on UCF101 (more complicated camera motion) and then on KTH (zoom-in and zoom-out camera effect).
239
+
240
+ UCF101 Results. As seen in Figure 9 and Figure 10, our model handles foreground and camera motion for a few steps. We hypothesize that for the first few steps, motion signals from images are clear. However, as images are predicted, motion signals start to deteriorate due to prediction errors. When a considerable amount of camera motion is present in image sequences, the motion signals are very dense. As predictions evolve into the future, our motion encoder has to handle large motion deterioration due to prediction errors, which cause motion signals to get easily confused and lost quickly.
241
+
242
+ ![](images/ea4e8497760e52fc98cc5f2fef65366cecf21cfe2b5f0385f38df693c48679f0.jpg)
243
+ Figure 9: Qualitative comparisons on UCF-101. We display predictions (in every other frame) starting from the $5 ^ { \mathrm { { \bar { t h } } } }$ frame. The green arrows denote the top-30 closest optical flow vectors within image patches between MCnet and ground-truth. More clear motion prediction can be seen in the project website.
244
+
245
+ ![](images/6ea92fc6fccaea6583f80e4acfecf7972ffa083c78deb020c10d5554d3bcea6e.jpg)
246
+ Figure 10: Qualitative comparisons on UCF-101. We display predictions (in every other frame) starting from the $5 ^ { \mathrm { t h } }$ frame. The green arrows denote the top-30 closest optical flow vectors within image patches between MCnet and ground-truth. More clear motion prediction can be seen in the project website.
247
+
248
+ KTH Results. We were unable to find videos with background motion in the KTH dataset, but we found videos where the camera is zooming in or out for the actions of boxing, handclapping, and handwaving. In Figure 11, we display qualitative for such videos. Our model is able to predict the zoom change in the cameras, while continuing the action motion. In comparison to the performance observed in UCF101, the background does not change much. Thus, the motion signals are well localized in the foreground motion (human), and do not get confused with the background and lost as quickly.
249
+
250
+ ![](images/b774886d63872a72949b555d4a6118dda26edef93f942d3472c9b1e63492c31c.jpg)
251
+ Figure 11: Qualitative comparisons on KTH testset. We display predictions starting from the $1 2 ^ { \mathrm { t h } }$ frame, in every 3 timesteps. More clear motion prediction can be seen in the project website.
252
+
253
+ # B EXTENDED QUANTITATIVE EVALUATION
254
+
255
+ In this section, we show additional quantitative comparison with a baseline based on copying the last observed frame through time for KTH and UCF101 datasets. Copying the last observed frame through time ensures perfect background prediction in videos where most of the motion comes from foreground (i.e. person performing an action). However, if such foreground composes a small part of the video, it will result in high prediction quality score regardless of the simple copying action.
256
+
257
+ In Figure 12 below, we can see the quantitative comparison in the datasets. Copying the last observed frame through time does a reasonable job in both datasets, however, the impact is larger in UCF101. Videos in the KTH dataset comprise simple background with minimal camera motion, which allows our network to easily predict both foreground and background motion, resulting in better image quality scores. However, videos in UCF101 contain more complicated and diverse background which in combination with camera motion present a much greater challenge to video prediction networks. From the qualitative results in Section A and Figures 5, 8, 9, and 10, we can see that our network performs better in videos that contain isolated areas of motion compared to videos with dense motion. A simple copy/paste operation of the last observed frame, ensures very high prediction scores in videos where very small motion occur. The considerable score boost by videos with small motion causes the simple copy/paste baseline to outperform MCnet in the overall performance on UCF101.
258
+
259
+ ![](images/53131bfb315fd2d7f528ca69060dcd38d0306adf2ea8f9acccaecc3985dd5a5a.jpg)
260
+ Figure 12: Extended quantitative comparison including a baseline based on copying the last observed frame through time.
261
+
262
+ # C UCF101 MOTION DISAMBIGUATION EXPERIMENTS
263
+
264
+ Due to the observed bias from videos with small motion, we perform experiments by measuring the image quality scores on areas of motion. These experiments are similar to the ones performed in Mathieu et al. (2015). We compute DeepFlow optical flow (Weinzaepfel et al., 2013) between the previous and the current groundtruth image of interest, compute the magnitude, and normalize it to $[ 0 , 1 ]$ . The computed optical flow magnitude is used to mask the pixels where motion was observed. We set the pixels where the optical flow magnitude is less than 0.2, and leave all other pixels untouched in both the groundtruth and predicted images. Additionally, we separate the test videos by the average $\ell _ { 2 }$ -norm of time difference between target frames. We separate the test videos into deciles based of the computed average $\ell _ { 2 }$ -norms, and compute image quality on each decile. Intuitively, the $1 ^ { s t }$ decile contains videos with the least overall of motion (i.e. frames that show the smallest change over time), and the $1 0 ^ { t h }$ decile contains videos with the most overall motion (i.e. frames that show the largest change over time).
265
+
266
+ As shown in Figure 13, when we only evaluate on pixels where rough motion is observed, MCnet reflects higher PSNR and SSIM, and clearly outperforms all the baselines in terms of SSIM. The SSIM results show that our network is able to predict a structure (i.e. textures, edges, etc) similar to the grountruth images within the areas of motion. The PSNR results, however, show that our method outperforms the simple copy/paste baseline for the first few steps, but then our method performs slightly worse. The discrepancies observed between PSNR and SSIM scores could be due to the fact that some of the predicted images may not reflect the exact pixel values of the groundtruth regardless of the structures being similar. SSIM scores are known to take into consideration features in the image that go beyond directly matching pixel values, reflecting more accurately how humans perceived image quality.
267
+
268
+ ![](images/7b7256d11c94469e3f55cce1fa8420becdea31e44b7d8b4debecd6d81fe465e0.jpg)
269
+ Figure 13: Extended quantitative comparison on UCF101 including a baseline based on copying the last observed frame through time using motion based pixel mask.
270
+
271
+ Figures 15 and 14 show the evaluation by separating the test videos into deciles based on the average $\ell _ { 2 }$ -norm of time difference between target frames. From this evaluation, it is proven that the copy last frame baseline scores higher in videos where motion is the smallest. The first few deciles (videos with small motion) show that our network is not just copying the last observed frame through time, otherwise it would perform similarly to the copy last frame baseline. The last deciles (videos with large motion) show our network outperforming all the baselines, including the copy last frame baseline, effectively confirming that our network does predict motion similar to the motion observed in the video.
272
+
273
+ ![](images/a8f9af98c589df0a1d8ea53c7895c439de206318ef8afded135f5e1466559709.jpg)
274
+ Figure 14: Quantitative comparison on UCF101 using motion based pixel mask, and separating dataset by average $\ell _ { 2 }$ -norm of time difference between target frames.
275
+
276
+ ![](images/6843ab4ca418e0deb9d507f9fedac9be79b84d6f6a09275d9829d109f2c86d85.jpg)
277
+ Figure 15: Quantitative comparison on UCF101 using motion based pixel mask, and separating dataset by average $\ell _ { 2 }$ -norm of time difference between target frames.
278
+
279
+ # D ADVERSARIAL TRAINING
280
+
281
+ Mathieu et al. (2015) proposed an adversarial training for frame prediction. Inspired by Goodfellow et al. (2014), they proposed a training procedure that involves a generative model $G$ and a discriminative model $D$ . The two models compete in a two-player minimax game. The discriminator $D$ is optimized to correctly classify its inputs as either coming from the training data (real frame sequence) or from the generator $G$ (synthetic frame sequence). The generator $G$ is optimized to generate frames that fool the discriminator into believing that they come from the training data. At training time, $D$ takes the concatenation of the input frames that go into $G$ and the images produced by $G$ . The adversarial training objective is defined as follows:
282
+
283
+ $$
284
+ \underset { G } { \operatorname* { m i n } } \underset { D } { \operatorname* { m a x } } ~ \log D \left( \left[ { \bf x } _ { 1 : t } , { \bf x } _ { t + 1 : t + T } \right] \right) + \log \left( 1 - D \left( \left[ { \bf x } _ { 1 : t } , G \left( { \bf x } _ { 1 : t } \right) \right] \right) \right) ,
285
+ $$
286
+
287
+ where $[ . , . ]$ denotes concatenation in the depth dimension, $\mathbf { x } _ { 1 : t }$ denotes the input frames to $G$ , $\mathbf { x } _ { t + 1 : t + T }$ are the target frames, and $G \left( \mathbf { x } _ { 1 : t } \right) = \hat { \mathbf { x } } _ { t + 1 : t + T }$ are the frames predicted by $G$ . In practice, we split the minimax objective into two separate, but equivalent, objectives: ${ \mathcal { L } } _ { \mathrm { G A N } }$ and ${ \mathcal { L } } _ { \mathrm { d i s c } }$ . During optimization, we minimize the adversarial objective alternating between ${ \mathcal { L } } _ { \mathrm { G A N } }$ and ${ \mathcal { L } } _ { \mathrm { d i s c } }$ . $\mathcal { L } _ { \mathrm { G A N } }$ is defined by
288
+
289
+ $$
290
+ \mathcal { L } _ { \mathrm { G A N } } = - \log D \left( \left[ \mathbf { x } _ { 1 : t } , G \left( \mathbf { x } _ { 1 : t } \right) \right] \right) ,
291
+ $$
292
+
293
+ where we optimize the parameters of $G$ to minimize ${ \mathcal { L } } _ { \mathrm { G A N } }$ while the parameters of $D$ stay untouched. As a result, $G$ is optimized to generate images that make $D$ believe that they come from the training data. Thus, the generated images look sharper, and more realistic. ${ \mathcal { L } } _ { \mathrm { d i s c } }$ is defined by
294
+
295
+ $$
296
+ \mathcal { L } _ { \mathrm { d i s c } } = - \log D \left( \left[ \mathbf { x } _ { 1 : t } , \mathbf { x } _ { t + 1 : t + T } \right] \right) - \log \left( 1 - D \left( \left[ \mathbf { x } _ { 1 : t } , G \left( \mathbf { x } _ { 1 : t } \right) \right] \right) \right) ,
297
+ $$
298
+
299
+ where we optimize the parameters of $D$ to minimize ${ \mathcal { L } } _ { \mathrm { d i s c } }$ , while the parameters of $G$ stay untouched. $D$ tells us whether its input came from the training data or the generator $G$ . Alternating between the two objectives, causes $G$ to generate very realistic images, and $D$ not being able to distinguish between generated frames and frames from the training data.
md/train/ryloogSKDS/ryloogSKDS.md ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DEEP ORIENTATION UNCERTAINTY LEARNING BASED ON A BINGHAM LOSS
2
+
3
+ Igor Gilitschenski1, Roshni Sahoo1, Wilko Schwarting1, Alexander Amini1,
4
+ Sertac Karaman2, Daniela Rus1
5
+ 1 Computer Science and Artificial Intelligence Lab, MIT
6
+ 2 Laboratory for Information and Decision Systems, MIT
7
+ {igilitschenski, rsahoo, wilkos, amini, sertac, rus}@mit.edu
8
+
9
+ # ABSTRACT
10
+
11
+ Reasoning about uncertain orientations is one of the core problems in many perception tasks such as object pose estimation or motion estimation. In these scenarios, poor illumination conditions, sensor limitations, or appearance invariance may result in highly uncertain estimates. In this work, we propose a novel learningbased representation for orientation uncertainty. By characterizing uncertainty over unit quaternions with the Bingham distribution, we formulate a loss that naturally captures the antipodal symmetry of the representation. We discuss the interpretability of the learned distribution parameters and demonstrate the feasibility of our approach on several challenging real-world pose estimation tasks involving uncertain orientations.
12
+
13
+ # 1 INTRODUCTION
14
+
15
+ Reasoning about uncertain poses and orientations, specifically 3-dimensional (3d) positions and 3-axes orientations, is one of the main inference tasks in computer vision (Sattler et al., 2019), robotics (Glover et al., 2011), aerospace (Crassidis & Markley, 2003), and other fields.
16
+
17
+ Proper representation and estimation of uncertainty is important, e.g. when dealing with structural ambiguities in object pose estimation or coping with sensor corruption.
18
+
19
+ In vision and robotics tasks, high levels of pose uncertainty may occur due to potentially adversarial conditions that arise in real-world scenarios. A principled approach to uncertainty quantification allows for better execution of planning and situation-awareness tasks such as grasping, tracking, and motion estimation.
20
+
21
+ When representing uncertainties over poses, the position can be modeled using a Gaussian distribution. This approach is well-motivated by the Central Limit Theorem and widely used in probabilistic deep learning models. However, this paradigm cannot be as easily applied to modeling periodic quantities, such as the orientation of an object. Therefore, Gaussian models become unsuitable particularly in learning regimes involving high uncertainties where one cannot assume local linearity of the underlying space. In this work, we set out to develop a principled probabilistic deep learning approach capable of coping with uncertain orientations.
22
+
23
+ Currently, most deep learning approaches that predict poses or rigid-body motions suffer from at least one of three drawbacks: 1) they do not model the uncertainty at all and merely focus on the accuracy of the predicted pose, 2) they make simplifying assumptions not taking into account that the orientation is defined on a periodic manifold, making the approach only suitable in low-noise regimes, or 3) even when trying to account for periodicity, no dependency is assumed between the orientation axes and usually an Euler angle-based representation is required. To this point, there are no probabilistic deep learning models for uncertainty of orientations that take the geometry of the underlying domain into account.
24
+
25
+ ![](images/8dd3507a6df732500949be3524c760ebc91aad24058d2ab9bcc69707af5af2e8.jpg)
26
+ Figure 1: Objects from the T-LESS dataset and the corresponding orientation uncertainty predicted by the model trained on the newly proposed Bingham loss, which is capable of capturing rotational symmetries.
27
+
28
+ In this work, we close this research gap by proposing a probabilistic deep learning model inspired by Directional Statistics (Mardia & Jupp, 1999). We present a loss based on the Bingham distribution (Bingham, 1974), an antipodally symmetric distribution on the sphere. With this loss, we represent uncertain orientations by modeling uncertainty over unit quaternions. Our contributions involve Bingham parameter learning using backpropagation through a Gram-Schmidt method to ensure orthonormalization, efficient approximate evaluation of the normalization constant of the Bingham distribution from a lookup table, and backpropagating through an interpolation scheme during learning. We also discuss interpretability of the Bingham distribution parameters and establish the feasibility of the approach through extensive evaluations.
29
+
30
+ In summary, this work makes the following contributions: 1) We propose the Bingham loss, a novel loss function for deep learning-based predictions of orientations and their uncertainty. 2) We provide a methodology for making the newly proposed loss and its normalization constant computationally tractable in a deep learning pipeline. 3) We demonstrate multi-modal orientation prediction using a Bingham variant of Mixture Density Networks. 4) We demonstrate how our approach outperforms the state-of-the-art on challenging pose and orientation estimation tasks1.
31
+
32
+ # 2 BACKGROUND: BINGHAM DISTRIBUTION FOR UNCERTAIN ORIENTATIONS
33
+
34
+ Unit quaternions are a widely used representation for object orientation in 3d space. They are more compact than rotation matrices, and unlike Euler angles, do not suffer from degeneracies such as Gimbal lock. Additionally, quaternions provide a convenient mathematical notation where the quaternion product, ${ \bf q } _ { 1 } \odot { \bf q } _ { 2 }$ , of two unit quaternions $\mathbf { q } _ { 1 }$ , $\mathbf { q } _ { 2 } \in \mathbb { H } _ { 1 }$ results in a concatenation of the rotations represented by each of the quaternions individually. A full introduction to this representation by given in Kuipers (1999) and notational aspects are discussed by Sommer et al. (2018). In this work, a quaternion $q _ { 1 } i + q _ { 2 } j + q _ { 3 } k + q _ { 4 }$ will be interpreted as a vector $\mathbf { q } \in \mathbb { R } ^ { 4 }$ . It is important to note that the definition of unit quaternions is equivalent to the vector q being of unit length $| | \mathbf { q } | | = 1$ . Furthermore, the quaternions $\mathbf { q }$ and $\mathbf { - q }$ represent the same orientation. Therefore, representing uncertain orientations using quaternions requires a probability distribution on the 4d hypersphere that exhibits antipodal symmetry, i.e. for the density function $f ( \cdot )$ of this distribution ${ \dot { f } } ( \mathbf { \bar { q } } ) = f ( - \mathbf { q } )$ has to hold.
35
+
36
+ A probability distribution exhibiting these properties was proposed by Bingham (1974). It arises by conditioning a zero mean Gaussian to unit length. The Bingham distribution is given in terms of its p.d.f. as $\bar { p } ( \mathbf { x } ; \mathbf { M } , \mathbf { Z } ) = N ( \mathbf { M } \mathbf { Z } \mathbf { M } ^ { \top } ) ^ { - 1 } \exp ( \mathbf { x } ^ { \top } \mathbf { M } \mathbf { Z } \mathbf { M } ^ { \top } \mathbf { x } )$ ,where $\mathbf { x } \in \mathbb { R } ^ { 4 }$ with $| | \mathbf { x } | | = 1$ , $N ( \mathbf { M } \mathbf { \bar { Z } } \mathbf { M } ^ { \top } )$ is a normalization constant, $\dot { \mathbf { M } } \in \mathbb { R } ^ { 4 \times 4 }$ orthogonal, and $\mathbf { Z } = \mathrm { d i a g } ( z _ { 1 } , z _ { 2 } , z _ { 3 } , 0 ) \in$ $\mathbb { R } ^ { 4 \times 4 }$ diagonal, with diagonal entries $z _ { i } < = 0$ and the last entry being zero. We use the notation $\mathrm { B i n g h a m } ( \mathbf { M } , \mathbf { Z } )$ . The restriction on the range of the diagonal entries in $\mathbf { Z }$ has numerical and representational convenience reasons. It can be shown that Bingham $\mathbf { \tau } _ { \mathrm { l } } ( \mathbf { M } , \mathbf { Z } ) = \mathrm { B i n g h a m } ( \mathbf { M } , \mathbf { Z } + c \mathbf { \bar { I } } )$ for all $c \in \mathbb { R }$ with $\mathbf { I } \in \mathbb { R } ^ { 4 \times 4 }$ denoting the identity matrix. Similarly, changing the order of diagonal entries in $\mathbf { Z }$ has no effect on the distribution as long as the columns in $\mathbf { M }$ are permuted accordingly.
37
+
38
+ In the definition above, the parameters $\mathbf { M }$ and $\mathbf { Z }$ bear some similarity to the mean and variance of a Gaussian. The density obtains its maxima at $\pm \mathbf { M } _ { : , 4 }$ (the fourth column of $\mathbf { M }$ ) which can be thought of as a mean orientation respecting the manifold structure. The diagonal entries of $\mathbf { Z }$ can be interpreted as dispersion parameters, and the first three columns of $\mathbf { M }$ can be interpreted as the directions of the dispersion (the Gaussian analog is the orientation of the covariance ellipsoid). Bingham distributions allow for representation of uniform priors over individual axes or even the entire space, making them superior to Gaussians in any of the usual orientation representations.
39
+
40
+ ![](images/9e1844f2c30eb42b33cba4e89d8c366ffb27182986c158e5eefb3a2605d67764.jpg)
41
+ Figure 2: Densities of the Bingham distribution represented for different dimensionality. For the circular case (a), the density is shown as a function of unit vectors on the plane. For the spherical case (b), it is shown as a heatmap on a 3d unit sphere. For the 4d case (c), which is of our particular interest, we visualize the mode of the Bingham in terms of the coordinate system orientation represented by the corresponding quaternion. Then, we draw samples from the distribution and visualize each sample as a potential coordinate arrow endpoint for each axis (i.e. each sample drawn from the Bingham distribution is represented by three points in the plot). This representation allows us to simultaneously represent the orientation and the corresponding uncertainty.
42
+
43
+ One of the main challenges of using the Bingham distribution is the computation of its normalization constant
44
+
45
+ $$
46
+ N ( \mathbf { M Z M } ^ { \top } ) = \int _ { | | q | | = 1 } \exp ( \mathbf { q } ^ { \top } \mathbf { M Z M } ^ { \top } \mathbf { q } ) \mathrm { d } \mathbf { q } ,
47
+ $$
48
+
49
+ which is a Hypergeometric function of matrix argument (Herz, 1955). Evaluating these functions imposes a high computational burden and is still an area of active research (Koev & Edelman, 2006; Kume et al., 2013; Koyama et al., 2014; Kume & Sei, 2018). Using the transformation theorem and the fact that M is orthogonal, the normalization constant can be simplified as $N ( \mathbf { M Z M } ^ { \top } ) = N ( \mathbf { Z } )$ , making it merely a function of the three parameters $z _ { i }$ $( i = 1 , 2 , 3$ ) and motivating the use of precomputed lookup tables in practice.
50
+
51
+ Furthermore, to make the uncertainty of a Bingham Distribution more interpretable in practice, we propose the use of Expected Absolute Angular Deviation (EAAD) which is defined as
52
+
53
+ $$
54
+ \mathrm { E A A D } ( \mathbf { Z } ) = \int _ { | | q | | = 1 } \theta ( \mathbf { q } , \mathbf { e } ) \cdot p ( \mathbf { q } ; \ \mathbf { I } , \mathbf { Z } ) \mathrm { d } \mathbf { q } ,
55
+ $$
56
+
57
+ where $p ( \cdot )$ is the $\mathrm { B i n g h a m } ( \mathbf { I } , \mathbf { Z } )$ density, $\mathbf { I }$ is the identity matrix, $\mathbf { e } ~ = ~ [ 0 , 0 , 0 , 1 ]$ is the vector corresponding to the unit quaternion representing the identity and $\theta ( \mathbf { q } , \mathbf { e } ) = 2 \cdot \operatorname { a r c c o s } ( | \langle \mathbf { q } , \mathbf { e } \rangle | )$ denotes the angular distance between $\mathbf { q }$ and $\mathbf { e }$ . The EAAD describes the expected angular deviation from the “mean” orientation. It can be loosely thought of as the orientation counterpart to the standard deviation in Euclidean space. For the same reason as in the normalization constant, the EAAD computation does not involve the parameter $\mathbf { M }$ .
58
+
59
+ # 3 DEEP ORIENTATION UNCERTAINTY LEARNING
60
+
61
+ The Bingham distribution is the main component of the proposed probabilistic framework for representing deep learned uncertain orientations. Drawing inspiration from Mixture Density Networks (Bishop, 1994), we propose using the Bingham distribution’s negative log-likelihood as a loss function
62
+
63
+ $$
64
+ \begin{array} { r } { L ( \mathbf { y } , \mathbf { M } , \mathbf { Z } ) = - \log p ( \mathbf { y } ; \mathbf { M } , \mathbf { Z } ) = - \mathbf { y } ^ { \top } \mathbf { M } \mathbf { Z } \mathbf { M } ^ { \top } \mathbf { y } + \log N ( \mathbf { Z } ) , } \end{array}
65
+ $$
66
+
67
+ with M, $\mathbf { Z }$ as defined above and y being the orientation label given in the training data. We use a neural network to learn $\mathbf { M }$ and $\mathbf { Z }$ , end-to-end, directly from the input data (e.g. RGB images). From this prediction, the point estimate of $\mathbf { y }$ is obtained as $\hat { \mathbf { y } } = \mathbf { M } _ { : , 4 }$ as the last column corresponds to the highest diagonal entry of $\mathbf { Z }$ and thus represents one of the modes of the distribution (the other being $- \hat { \mathbf { y } }$ due to antipodal symmetry).
68
+
69
+ ![](images/93d820669a8e990c2177fda9970ffe82317decc83b8b47b89262ba82eb327bfe.jpg)
70
+ Figure 3: The proposed orientation uncertainty estimation pipeline predicts the parameters of a Bingham distribution for representing uncertain unit quaternions. Backpropagation through an interpolator and use of a lookup table allows for avoiding evaluations of the computationally expensive Bingham normalization constant.
71
+
72
+ No costly evaluation of the normalization constant is required and no major computational challenges arise in the special case where the dispersion parameter $\mathbf { Z }$ is known and not predicted by a neural network. However, as our goal is the modeling of uncertainty, we propose methods for modeling M and $\mathbf { Z }$ as well as backpropagating through $N ( \mathbf { Z } )$ .
73
+
74
+ # 3.1 MODELING OF DISTRIBUTION PARAMETERS
75
+
76
+ In order to obtain predictions $\hat { \textbf { M } }$ and $\hat { \mathbf { Z } }$ , we require a 19 dimensional output $\mathbf { \tau } ( \mathbf { o } \in \mathbb { R } ^ { 1 9 } .$ ) of the predictor network (3 outputs for $\mathbf { Z }$ , 16 outputs for $\mathbf { M }$ ). On its own, these outputs do not satisfy the above-mentioned constraints on the Bingham distribution parameters. Thus, we define the differentiable transforms $T _ { \mathbf { M } } : \mathbb { R } ^ { 1 6 } \mathbb { R } ^ { 4 \times 4 }$ and $T _ { \mathbf { Z } } : \mathbb { R } ^ { 3 } \mathbb { R } ^ { 4 \times 4 }$ that transform these outputs such that the constraints are satisfied.
77
+
78
+ The transform $T _ { \mathbf { Z } }$ is obtained as $T _ { \mathbf { Z } } ( o _ { 1 } , o _ { 2 } , o _ { 3 } ) = \mathrm { d i a g } ( \hat { z } _ { 1 } , \hat { z } _ { 2 } , \hat { z } _ { 3 } , 0 )$ with $\hat { z } _ { i } = - \exp ( o _ { i } )$ . For computing $\hat { \textbf { M } }$ , we first subdivide $O _ { 4 } , \ldots , O _ { 1 9 }$ into four vectors $\mathbf { v } _ { i } ~ \in ~ \mathbb { R } ^ { 4 }$ $( i = 1 , \dots , 4 )$ . Then, we apply the Gram-Schmidt orthonormalization method to these vectors according to $\begin{array} { r l } { \hat { \mathbf { m } } _ { i } } & { { } = } \end{array}$ N $\begin{array} { r } { \mathrm { o r m a l i z e } ( \mathbf { v } _ { i } - \sum _ { k = 1 } ^ { i - 1 } \langle \hat { \mathbf { m } } _ { k } , \mathbf { v } _ { i } \rangle \cdot \hat { \mathbf { m } } _ { k } ) } \end{array}$ with $i \in \{ 1 , 2 , 3 , 4 \}$ and $\mathrm { N o r m a l i z e } ( \mathbf { x } ) = \mathbf { x } / \left| \left| \mathbf { x } \right| \right|$ . Finally, the prediction $\dot { \bf M }$ is obtained as $T _ { \mathbf { M } } ( o _ { 3 } , \ldots , o _ { 1 9 } ) = [ \hat { \mathbf { m } } _ { 1 } , \ldots , \hat { \mathbf { m } } _ { 4 } ]$ , and $\hat { \textbf { M } }$ is orthogonal by construction.
79
+
80
+ # 3.2 BACKPROPAGATION THROUGH THE BINGHAM NORMALIZATION CONSTANT
81
+
82
+ As mentioned earlier, computation of the Bingham normalization constant is numerically burdensome. This is also true for its derivatives which can be shown to be proportional to the normalization constant of Bingham distributions of higher dimension (Kume & Wood, 2007). A forward-backward pass for one single data point requires 4 evaluations of hypergeometric functions of matrix argument.
83
+
84
+ We avoid this by precomputing a lookup table for $N ( \mathbf { Z } )$ at $\mathrm { L }$ different locations $\mathbf { t } _ { i }$ (with $\mathbf { Z } _ { i } \mathbf { \Psi } =$ $\mathrm { d i a g } ( [ \mathbf { t } _ { i } ^ { \top } , 0 ] )$ . This table is then used to build an interpolator $\begin{array} { r } { f _ { N } ( \mathbf { z } ) = \sum _ { i - 1 } ^ { L } w _ { i } \phi ( | | \mathbf { z } - \mathbf { t } _ { i } | | ) } \end{array}$ with $\textbf { z } \in \mathbb { R } ^ { 3 }$ and $\phi$ denoting a radial basis function. The weights $w _ { i }$ can also be precomputed during generation of the interpolator. Thus, we can approximate ${ \cal N } ( { \bf Z } ) \approx f _ { N } ( { \bf z } )$ and $\nabla _ { \mathbf { z } } N ( \mathbf { Z } ) \approx \nabla _ { \mathbf { z } } f _ { N } ( \mathbf { z } )$ . To the best of our knowledge, this is the first time that a lookup table based interpolation mechanism has been included in the computation graph of a neural network.
85
+
86
+ # 3.3 MULTI-MODAL PREDICTION
87
+
88
+ A Bingham variant of Mixture Density Networks can be used to obtain multi-modal predictions. However, MDNs are hard to train even in the Gaussian case. Following the discussion in Makansi et al. (2019), we separate the training in two stages. In the first stage, we only learn to predict $\mathbf { M }$ and assume the dispersion to be fixed with $\mathbf { Z } = \mathrm { d i a g } ( - a , - a , - a , 0 )$ . In practice $a \in \mathbb { R } ^ { + }$ can usually be set to 1 as it merely scales the cost term. In the second stage, we train to predict M and $\mathbf { Z }$ jointly. Our evaluation will show that in high uncertainty regimes, this training method is also helpful for the unimodal case.
89
+
90
+ # 4 EXPERIMENTS
91
+
92
+ In this section we evaluate the proposed Bingham loss on its ability to learn calibrated uncertainty estimates for orientations. This goes beyond comparing point estimates of orientations; we evaluate how well the estimated distribution of orientations can explain the data. We will also show that the Bingham distribution representation is capable of capturing ambiguity and uncertainty in SO(3) better than state-of-the-art approaches.
93
+
94
+ We investigate characteristics and behaviors by training neural networks on two head-pose datasets, IDIAP (Odobez, 2003) and UPNA (Ariz et al., 2016), as well as the object pose dataset TLESS (Hodan et al., 2017). We show the capability of calibrated uncertainty estimation by applying ˇ artificial label-noise to IDIAP and UPNA and observing that the Bingham parametrization allows for accurate prediction of uncertainty. In addition to calibrated uncertainty estimation, we demonstrate advanced capabilities in the face of object orientation ambiguity on the T-LESS dataset by visualizing the predicted distributions for different orientation ambiguous objects, e.g. symmetric, and comparing to objects with clear orientation.
95
+
96
+ # 4.1 ARCHITECTURE AND EXPERIMENTAL SETUP
97
+
98
+ We seek to estimate the Bingham distribution parameters directly from image data. Our pipeline is shown in Figure 3 and begins by passing an image input to a convolutional encoder, in our case a standard ResNet-18 network followed by a fully connected layer, populating the entries of $o _ { 1 } , o _ { 2 } , o _ { 3 }$ and $v _ { 1 } , v _ { 2 } , v _ { 3 } , v _ { 4 }$ . Subsequently, $\mathbf { Z }$ is computed by constrained diagonalization of $O 1 , O 2 , O 3$ , and Gram-Schmidt orthonormalization of $v _ { 1 } , v _ { 2 } , v _ { 3 } , v _ { 4 }$ yields $\mathbf { M }$ , as described in Section 3.1. To evaluate the Bingham loss, the normalizer $N ( \mathbf { Z } )$ needs to be queried from the RBF lookup table, Section 3.2. Differentiation of the interpolator via finite differences enables us to back-propagate through the entire pipeline. All models were implemented in PyTorch and optimized with the Adam optimizer.
99
+
100
+ We create the lookup table by numerical integration. More precisely, we use Scipy’s tplquad method to compute a triple integral for each $\mathbf { Z }$ in the table. We set the relative error tolerance to 1e-3 and the absolute error tolerance to 1e-7. The actual computed integral is
101
+
102
+ $$
103
+ N ( \mathbf { Z } ) = \int _ { 0 } ^ { 2 \pi } \int _ { 0 } ^ { \pi } \int _ { 0 } ^ { \pi } \exp \big ( t ( \phi _ { 1 } , \phi _ { 2 } , \phi _ { 3 } ) ^ { \top } \mathbf { Z } t ( \phi _ { 1 } , \phi _ { 2 } , \phi _ { 3 } ) \big ) \cdot \sin ( \phi _ { 1 } ) ^ { 2 } \cdot \sin ( \phi _ { 2 } ) \mathrm { d } \phi _ { 1 } \mathrm { d } \phi _ { 2 } \mathrm { d } \phi _ { 3 } ,
104
+ $$
105
+
106
+ with
107
+
108
+ $$
109
+ t ( \phi _ { 1 } , \phi _ { 2 } , \phi _ { 3 } ) = \left[ { \sin ( \phi _ { 1 } ) \cdot \sin ( \phi _ { 2 } ) \cdot \cos ( \phi _ { 3 } ) } \right]
110
+ $$
111
+
112
+ to account for a transformation of coordinates from unit quaternions to 4d spherical coordinates. Because we use the Bingham log likelihood as our optimization objective, we compute the logarithm before the interpolation to avoid failure at locations where the interpolator wrongly outputs negative values.
113
+
114
+ # 4.2 BASELINES
115
+
116
+ We compare our work with the approach proposed by Prokudin et al. (2018). It also uses a loss based on directional statistics, specifically the Von Mises distribution. The Von Mises distribution can be thought of as a circular analog of the Normal distribution. In order to apply this approach to our setting, orientations are modeled with Euler angles. The loss then consists of the sum of log-likelihoods for each angle. While this approach can properly account for periodicity of the underlying data, we expect it to fail in cases where the underlying uncertainty is not axis aligned because it does not account for dependencies between uncertain rotation axes.
117
+
118
+ Furthermore, we also evaluate several different representations of the parameter matrix M. We consider the classical Gram-Schmidt (CGS), modified Gram-Schmidt (MGS), and the matrix representation of the quaternion (QM) used by Birdal et al. (2018). Finally, we also include two nonprobabilistic orientation prediction baselines. The first one is based on a Mean Square Error (MSE) between the predicted and ground truth quaternion. The second one is based on a cosine loss applied to each angle’s biternion as discussed by Prokudin et al. (2018).
119
+
120
+ # 4.3 EVALUATION METRICS
121
+
122
+ To evaluate error metrics over predicted orientations, it is unsuitable to compute the RMSE over angles, since it does not sufficiently consider the spherical nature of the underlying data. Instead, we make use of the Mean Absolute Angular Deviation (MAAD) which has also been used by Prokudin et al. (2018). It is based on the angular distance between two angles defined above. We also compute the EAAD to assess the quality of the results. Additionally, the difference between EAAD and MAAD serves as an indicator of the quality of the predicted uncertainty. The acceptable difference in practice is application dependent. For the cases of the Von Mises distribution parameters, EAAD computation is carried out in a similar way as for the Bingham defined above. EAAD is calculated over the learned dispersion parameters for each example and averaged. The quality of the respective model is measured in terms of log-likelihood to indicate the goodness of an individual fit. For MDNs, we additionally report a Mean Minimum Absolute Angular Deviation (MMAAD), which uses the component closest to ground-truth for absolute angular deviation computation. The MAAD and EAAD for MDNs are computed in a per-component fashion and then weighted using the predicted mixture weights.
123
+
124
+ # 4.4 CALIBRATED UNCERTAINTY ESTIMATION
125
+
126
+ We evaluate the distribution fit on the head pose datasets UPNA and IDIAP, which consist of head images from a video of several people inside a room. Each image is annotated with head orientation given by pan, tilt and roll angles. We use these datasets as they provide accurate labels and allow for carrying out experiments involving artificial label noise.
127
+
128
+ The results on the raw dataset are shown in Table 1. They demonstrate that the general performance for point estimates, indicated by MAAD, of the Bingham distribution remains on a similar level as the Von Mises distribution and the non-probabilistic approaches. In this setting, most motions of the subjects’ heads are aligned with the gravity axis allowing both distributions to successfully capture
129
+
130
+ Table 1: Bingham (BD), Von Mises (VM), Mean Square Error (MSE), and cosine based loss prediction performance on raw UPNA and IDIAP datasets.
131
+
132
+ <table><tr><td rowspan="2"></td><td colspan="3">UPNA</td><td colspan="3">IDIAP</td></tr><tr><td>EAAD</td><td>MAAD</td><td>LL</td><td>EAAD</td><td>MAAD</td><td>LL</td></tr><tr><td>BD-CGS</td><td>0.10</td><td>0.11</td><td>4.70</td><td>0.10</td><td>0.09</td><td>4.49</td></tr><tr><td>BD-MGS</td><td>0.10</td><td>0.13</td><td>3.87</td><td>0.10</td><td>0.10</td><td>4.58</td></tr><tr><td>BD-QM</td><td>0.10</td><td>0.16</td><td>0.31</td><td>0.10</td><td>0.09</td><td>4.74</td></tr><tr><td>VM</td><td>0.13</td><td>0.11</td><td>3.69</td><td>0.12</td><td>0.09</td><td>2.08</td></tr><tr><td>MSE</td><td>=</td><td>0.12</td><td>-</td><td></td><td>0.10</td><td></td></tr><tr><td>Cosine</td><td>=</td><td>0.12</td><td>=</td><td>=</td><td>0.10</td><td>=</td></tr></table>
133
+
134
+ the noise. However, the Bingham still attains a higher log-likelihood and a smaller gap between MAAD and EAAD. Similarly, the parametrization of the concentration matrix M has a relatively small impact on the estimation performance. Although MGS has stronger robustness guarantees than CGS (the latter has a quadratic dependency on the condition number of the input matrix, see Giraud et al. (2005) for a discussion of both), the condition of the input is not poor enough to impact performance. While the quaternion matrix approach is easier to train, it also loses some of the expressiveness of the Bingham distribution because the underlying mapping (from quaternions to the space of orthogonal matrices) is not surjective.
135
+
136
+ To estimate how well the predicted uncertainties are calibrated, we add artificial noise by drawing random perturbations from the Bingham distribution with varying $z _ { 1 } , z _ { 2 }$ , and $z _ { 3 }$ parameters and applying them to the quaternion labels before training. Both UPNA and IDIAP contain negligible amounts of noise, so the dispersion of the noise distribution should be captured by the learned $\mathbf { Z }$ to high accuracy. An evaluation of uncertainty and label noise is shown in Table 2. For the case of no noise, the Bingham uncertainty parameters approximate the highest certainty levels represented in the lookup table. Thus, the maximum and minimum values in the lookup table automatically become the bounds of what certainty levels can be represented by the proposed loss. When noise is applied to the training labels, the learned uncertainty parameters closely match the dispersion of label noise, so the predicted EAAD accurately captures the EAAD corresponding to the dispersion of the label noise distribution. We note that the MAAD is slightly higher than the true and estimated EAAD values. This overconfidence effect is typical in probabilistic deep learning and also arises when predicting the parameters of a Gaussian (Amini et al., 2019). In addition, we evaluated a scenario where the noise is newly sampled and applied to the true labels in each iteration (rather than corrupting the labels with the sampled noise prior to training). In this scenario, the EAAD computed from the learned dispersion parameters, the true EAAD, and the MAAD are approximately equal in value. While this scenario is less realistic in practice (and thus not visualized), it provides further evidence for representational consistency of the loss.
137
+
138
+ ![](images/a3018f6474f4a75f305d55ffc845593d9fb2b5503241b32b8d774c1fa3b4a48c.jpg)
139
+
140
+ Table 2: Testing accuracy of uncertainty calibration. Prior to training, we perturb the labels with noise sampled from the Bingham distribution with M equal to the identity and varying $z _ { 1 } , z _ { 2 } , z _ { 3 }$ . The figures represent the different noise distributions.
141
+
142
+ <table><tr><td rowspan="2"></td><td rowspan="2">-z1</td><td rowspan="2">-22 -23</td><td rowspan="2">EAAD</td><td rowspan="2"></td><td rowspan="2">-z1</td><td rowspan="2">-z2 -23</td><td rowspan="2"></td><td rowspan="2">EAAD MAAD</td><td rowspan="2">-21</td><td rowspan="2">-22 -z3</td><td rowspan="2"></td><td rowspan="2">EAAD MAAD</td><td rowspan="2">-21 -22</td><td rowspan="2">-z3</td><td rowspan="2"></td><td rowspan="2">EAAD MAAD</td><td rowspan="2">-z1</td><td rowspan="2">-22</td><td rowspan="2">-23</td><td rowspan="2">EAAD MAAD</td></tr><tr><td></td></tr><tr><td>Label noise</td><td></td><td>No noise</td><td>0</td><td></td><td>20</td><td>20</td><td>20</td><td>0.52</td><td>250</td><td>150</td><td>50</td><td>0.22</td><td>150</td><td>100</td><td>75</td><td>0.23</td><td>300</td><td>300</td><td>300</td><td>0.13</td></tr><tr><td>UPNA</td><td>497497</td><td>497</td><td>0.10</td><td>19</td><td></td><td>19</td><td>19</td><td>0.54</td><td>186</td><td>105</td><td>63</td><td>0.23</td><td>130</td><td>114</td><td>74</td><td>0.23</td><td>303</td><td>300</td><td>295</td><td>0.13</td></tr><tr><td rowspan="2">IDIAP</td><td></td><td></td><td></td><td></td><td>±0.4</td><td>±0.4</td><td>±0.5</td><td>0.69</td><td>±78</td><td>±30</td><td>±15</td><td>0.29</td><td>±35</td><td>±10</td><td>±14</td><td>0.28</td><td>±16</td><td>±16</td><td>±17</td><td>0.20</td></tr><tr><td></td><td>499499 499</td><td>0.10</td><td></td><td>19</td><td>19</td><td>18</td><td>0.55</td><td>167</td><td>164</td><td>47</td><td>0.24</td><td>93</td><td>87</td><td>76</td><td>0.25</td><td>300</td><td>294</td><td>280</td><td>0.13</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>±0.5</td><td>±0.5 ±0.3</td><td></td><td>0.59</td><td>±17</td><td>±20</td><td>士3</td><td>0.29</td><td>±8</td><td>±8</td><td>±7</td><td>0.28</td><td>±24</td><td>±25</td><td>±35 0.20</td><td></td></tr></table>
143
+
144
+ # 4.5 HANDLING AMBIGUOUS DATA
145
+
146
+ We use the T-LESS dataset for evaluating the proposed model using ambiguous data. It contains images of 30 different textureless objects taken from different cameras. We use the Kinect RGB single-object images all of which are split into training, test, and validation sets. At a coarse scale most of the objects in the dataset exhibit rotational or other symmetries. At a finer scale some of these ambiguities disappear due to smaller structures. On the one hand, we expect those to be more challenging to learn. On the other hand, capturing these structures allows for very precise orientation estimation. To be able to disregard these structures, we create a variant of T-LESS where we add blur to each image using a uniform $1 0 \mathrm { p x } \times 1 0 \mathrm { p x }$ kernel.
147
+
148
+ We carry out two sets of experiments. In the first set of experiments, we train orientation estimation models for 5 epochs using the Bingham loss (BD-5) and the Von Mises loss (VM-5) on the blurred and original set of images. This allows to investigate the uncertainty estimation properties before the network captures the finer grained structures. In the second set of experiments, we use the original set of images to evaluate multi-modal orientation prediction using the two-stage training approach for models with 1 (BD-MDN-1), 2 (BD-MDN-2), and 4 (BD-MDN-4) mixture components. Each stage is carried out for 30 epochs. The comparison methods use Von Mises (VM), Mean Square Error (MSE), and Cosine losses with an overall training duration of 60 epochs (or until convergence if that is earlier).
149
+
150
+ Table 3: Results on the T-LESS dataset in the high uncertainty regime.
151
+
152
+ <table><tr><td>Method</td><td>[Log-likelihood MAAD</td><td>EAAD</td></tr><tr><td>VM-5</td><td>-0.12</td><td>0.48 0.33</td></tr><tr><td>BD-5</td><td>2.82 1.57</td><td>1.58</td></tr><tr><td>VM-5 w. blur</td><td>-0.03 0.56</td><td>0.44</td></tr><tr><td>BD-5 w. blur</td><td>2.71 1.59</td><td>1.58</td></tr></table>
153
+
154
+ The results for the first set of experiments are visualized in Table 3. As expected, both approaches are on average far off in terms of the true orientation. While Von Mises performs better on the MAAD, we observe that there is a larger difference between the MAAD and EAAD values for the
155
+
156
+ Von Mises distribution than the Bingham distribution. This indicates that the uncertainty estimates of the Von Mises distribution may be overconfident. On the other hand the Bingham distribution better captures the uncertainty over individual axes. One interesting insight is that allowing for uniform distributions over individual non-aligned periodic axes can make it hard for the learning method to pick up on the proper pose and thus may require pre-training on the pure pose estimation task in such regimes.
157
+
158
+ In the second set of experiments, as visualized in Table 4, we use this training strategy for all Bingham MDN models resulting in robust convergence behavior. However, the unimodal Bingham (BD-MDN1) converges slower than Von Mises (VM) thus achieving a higher MAAD, which is adequately captured by the Bingham’s EAAD. For multiple mixture components, we obtain a very low MAAD and can observe again the phenomenon of the lookup table limitations in the EAAD. Thus, the
159
+
160
+ Table 4: Results on the T-LESS dataset involving multi modal prediction.
161
+
162
+ <table><tr><td>Method</td><td colspan="4">Log-likelihood MAAD MMAAD EAAD</td></tr><tr><td>VM</td><td>3.73</td><td>0.10</td><td>-</td><td>0.17</td></tr><tr><td>BD-MDN-1</td><td>5.00</td><td>0.20</td><td>=</td><td>0.21</td></tr><tr><td>BD-MDN-2</td><td>6.17</td><td>0.07</td><td>0.06</td><td>0.12</td></tr><tr><td>BD-MDN-4</td><td>6.19</td><td>0.06</td><td>0.05</td><td>0.10</td></tr><tr><td>MSE</td><td>-</td><td>0.22</td><td>-</td><td>1</td></tr><tr><td>Cosine</td><td>=</td><td>0.10</td><td>=</td><td>=</td></tr></table>
163
+
164
+ MAAD achieved during the first training stage can not only be used for inspecting the network’s accuracy but also for determining the minimum Z parameter values stored in the lookup table. Another interesting phenomenon can be observed in the EAAD and MAAD of the VM loss. As the representation required by Von Mises assumes that each axis is independent, EAAD is computed per rotation axis. This results in an overapproximation of the uncertainty overall. For the nonprobabilistic losses, the cosine loss achieves better performance which is probably due to better consideration of the underlying geometry. In summary, while the proposed Bingham loss shares the general challenges of training Mixture Density Networks, it better captures the underlying noise structure by explicitly modeling dependencies between rotation axes.
165
+
166
+ # 5 DISCUSSION AND RELATED WORK
167
+
168
+ Quantifying and representing uncertainty by and in neural networks has been a subject of extensive research initially focused on modeling probability distribution parameters (Nix & Weigend, 1994) and mixture distributions (Bishop, 1994) as neural network outputs. More recent approaches focus on improving understanding of the underlying uncertainties (Kendall & Gal, 2017), providing scalable techniques for estimating predictive uncertainty (Lakshminarayanan et al., 2017), and stabilizing training to avoid mode collapse (Makansi et al., 2019). The present work is orthogonal to these approaches in the sense that it focuses on proper modeling of the underlying geometric domain and coping with a computationally demanding normalization constant.
169
+
170
+ Handling of poses and orientations has been extensively studied in the context of Bayesian filtering for applications such as spacecraft attitude estimation (Crassidis & Markley, 2003) and ego-motion estimation (Bloesch et al., 2015), where one can often assume the underlying uncertainties to be small. This allows for leveraging local-linearity and using the Gaussian distribution. Recently, methods based on directional statistics enabled modeling of high uncertainty levels for inferring orientations (Gilitschenski et al., 2016) and full poses (Glover et al., 2011; Glover & Kaelbling, 2014; Srivatsan et al., 2016) by using the Bingham distribution. Drawing inspiration from these results, this work extends the applicability of these approaches to probabilistic deep learning models.
171
+
172
+ Particularly in computer vision, deep learning has been applied to spherical regression and pose estimation problems (Liao et al., 2019; Huang et al., 2018). These applications involve inferring object (Brachmann et al., 2014; Hodan et al., 2018; Li et al., 2018b;a; Manhardt et al., 2019; Sun- ˇ dermeyer et al., 2018; Tekin et al., 2018; Wang et al., 2019b;a), body (Yang et al., 2019), and camera poses (Clark et al., 2017; Sattler et al., 2019; Wang et al., 2017; 2018). In all of these scenarios there is a multitude of sources for potentially high uncertainties such as the use of low-resolution data (e.g. tracking pose of distant pedestrians), absence of textures (e.g. when operating on depth data), or motion blur (e.g. due to high speeds in ego-motion estimation). However, most of the existing approaches merely focus on inferring the pose but do not account for the underlying uncertainty.
173
+
174
+ The representation proposed in our work closes this gap by allowing for neural networks to output well-calibrated orientation uncertainty estimates.
175
+
176
+ Only a few approaches consider modeling the uncertainty of orientations for deep learning based pose estimation. PoseRBPF by Deng et al. (2019) discretizes the orientation space into over 190 000 bins and learns a codebook to allow for tractable inference. In contrast to that approach, we do not require an a priori discretization and can directly obtain interpretable estimates. Similarly to us, Prokudin et al. (2018) propose a loss based on directional statistics. By making use of the Von Mises distribution, their work can properly account for periodicity of circular data. However, as we have shown in our evaluations, this approach cannot properly account for dependencies between different axes and thus, struggles when the underlying uncertainty is not axis aligned.
177
+
178
+ # 6 CONCLUSION
179
+
180
+ In this work, we introduced the Bingham loss, a loss function based on the Bingham distribution that enables neural networks to predict uncertainty over unit quaternions and thus uncertain orientations. This allows for using (rotation-)symmetric objects and ambiguous sensor data in the context of pose and orientation estimation. In addition, we demonstrate how to cope with intractable likelihoods in deep learning pipelines by using non-linear interpolation and lookup tables as part of the computation graph.
181
+
182
+ The presented approach is directly usable in existing probabilistic deep learning techniques. Moreover, we demonstrate its applicability for mixture density models. The choice of parametrization remains one of the main design decisions in pose and orientation estimation pipelines. Our work supports the case for using quaternions over other parametrizations for deep learning. It also motivates further research on how to properly model dependencies between uncertain periodic and non-periodic quantities.
183
+
184
+ # ACKNOWLEDGMENTS
185
+
186
+ This work was supported in part by NSF Grant 1723943, the Office of Naval Research (ONR) Grant N00014-18-1-2830, and Toyota Research Institute (TRI). This article solely reflects the opinions and conclusions of its authors and not TRI, Toyota, or any other Toyota entity. Their support is gratefully acknowledged.
187
+
188
+ # REFERENCES
189
+
190
+ Alexander Amini, Wilko Schwarting, Ava Soleimany, and Daniela Rus. Deep Evidential Regression. arXiv preprint:1910.02600, 2019.
191
+ Mikel Ariz, Jose J. Bengoechea, Arantxa Villanueva, and Rafael Cabeza. A novel 2D/3D database ´ with automatic face annotation for head tracking and pose estimation. Computer Vision and Image Understanding, 148:201–210, 2016.
192
+ Christopher Bingham. An Antipodally Symmetric Distribution on the Sphere. The Annals of Statistics, 2(6):1201–1225, 1974.
193
+ Tolga Birdal, Umut Simsekli, Mustafa Onur Eken, and Slobodan Ilic. Bayesian Pose Graph Optimization via Bingham Distributions and Tempered Geodesic MCMC. In Advances in Neural Information Processing Systems (NeurIPS), 2018.
194
+ Christopher M. Bishop. Mixture Density Networks. Technical report, Neural Computing Research Group, Aston University, 1994.
195
+ Michael Bloesch, Sammy Omari, Marco Hutter, and Roland Siegwart. Robust visual inertial odometry using a direct EKF-based approach. In Proceedings of the International Conference on Intelligent Robots and Systems (IROS), 2015.
196
+ Eric Brachmann, Alexander Krull, Frank Michel, Stefan Gumhold, Jamie Shotton, and Carsten Rother. Learning 6D Object Pose Estimation Using 3D Object Coordinates. In Proceedings of the European Conference on Computer Vision (ECCV), 2014.
197
+
198
+ Ronald Clark, Sen Wang, Hongkai Wen, Andrew Markham, and Niki Trigoni. VINet: Visual-Inertial Odometry as a Sequence-to-Sequence Learning Problem. In Proceedings of the AAAI Conference on Artificial Intelligence (AAAI), 2017.
199
+
200
+ John L. Crassidis and F. Landis Markley. Unscented Filtering for Spacecraft Attitude Estimation. Journal of Guidance, Control, and Dynamics, 26(4):536–542, 2003.
201
+
202
+ Xinke Deng, Arsalan Mousavian, Yu Xiang, Fei Xia, Timothy Bretl, and Dieter Fox. PoseRBPF: A Rao-Blackwellized Particle Filter for 6D Object Pose Estimation. In Proceedings of Robotics: Science and Systems (RSS), 2019.
203
+
204
+ Igor Gilitschenski, Gerhard Kurz, Simon J. Julier, and Uwe D. Hanebeck. Unscented Orientation Estimation Based on the Bingham Distribution. Transactions on Automatic Control, 61(1), 2016.
205
+
206
+ Luc Giraud, Julien Langou, Miroslav Rozloznˇ ´ık, and Jasper van den Eshof. Rounding error analysis of the classical Gram-Schmidt orthogonalization process. Numerische Mathematik, 101(1), 2005.
207
+
208
+ Jared Glover and Leslie Kaelbling. Tracking the spin on a ping pong ball with the quaternion Bingham filter. In Proceedings of the International Conference on Robotics and Automation (ICRA), 2014.
209
+
210
+ Jared Glover, Radu Rusu, and Gary Bradski. Monte Carlo Pose Estimation with Quaternion Kernels and the Bingham Distribution. In Proceedings of Robotics: Science and Systems (RSS), 2011.
211
+
212
+ Carl S. Herz. Bessel Functions of Matrix Argument. The Annals of Mathematics, 61(3):474, 1955.
213
+
214
+ Toma´s Hoda ˇ n, Pavel Haluza, ˇ Stˇ epˇ an Obdr ´ zˇalek, Ji ´ ˇr´ı Matas, Manolis Lourakis, and Xenophon Zabulis. T-LESS: An RGB-D dataset for 6D pose estimation of texture-less objects. Winter Conference on Applications of Computer Vision (WACV), 2017.
215
+
216
+ Toma´s Hoda ˇ n, Frank Michel, Eric Brachmann, Wadim Kehl, Anders Glent Buch, Dirk Kraft, ˇ Bertram Drost, Joel Vidal, Stephan Ihrke, Xenophon Zabulis, Caner Sahin, Fabian Manhardt, Federico Tombari, Tae-Kyun Kim, Jiˇr´ı Matas, and Carsten Rother. BOP: Benchmark for 6D Object Pose Estimation. In Proceedings of the European Conference on Computer Vision (ECCV), 2018.
217
+
218
+ Siyuan Huang, Siyuan Qi, Yinxue Xiao, Yixin Zhu, Ying Nian Wu, and Song-Chun Zhu. Cooperative holistic scene understanding: Unifying 3d object, layout, and camera pose estimation. In Advances in Neural Information Processing Systems (NeurIPS), pp. 206–217, 2018.
219
+
220
+ Alex Kendall and Yarin Gal. What Uncertainties Do We Need in Bayesian Deep Learning for Computer Vision? In Advances in Neural Information Processing Systems (NeurIPS), 2017.
221
+
222
+ Plamen Koev and Alan Edelman. The efficient evaluation of the hypergeometric function of a matrix argument. Mathematics of Computation, 75(254):833–847, 2006.
223
+
224
+ Tamio Koyama, Hiromasa Nakayama, Kenta Nishiyama, and Nobuki Takayama. Holonomic gradient descent for the FisherBingham distribution on the d-dimensional sphere. Computational Statistics, 29(3-4):661–683, 2014.
225
+
226
+ Jack B. Kuipers. Quaternions and rotation sequences : a primer with applications to orbits, aerospace, and virtual reality. Princeton University Press, 1999.
227
+
228
+ Alfred Kume and Tomonari Sei. On the exact maximum likelihood inference of FisherBingham distributions using an adjusted holonomic gradient method. Statistics and Computing, 28(4): 835–847, 2018.
229
+
230
+ Alfred Kume and Andrew T.A. Wood. On the derivatives of the normalising constant of the Bingham distribution. Statistics & Probability Letters, 77(8):832–837, 2007.
231
+
232
+ Alfred Kume, Simon P. Preston, and Andrew T. A. Wood. Saddlepoint approximations for the normalizing constant of Fisher-Bingham distributions on products of spheres and Stiefel manifolds. Biometrika, 100(4):971–984, 2013.
233
+
234
+ Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
235
+
236
+ Chi Li, Jin Bai, and Gregory D Hager. A Unified Framework for Multi-view Multi-class Object Pose Estimation. In Proceedings of the European Conference on Computer Vision (ECCV), 2018a.
237
+
238
+ Yi Li, Gu Wang, Xiangyang Ji, Yu Xiang, and Dieter Fox. DeepIM: Deep Iterative Matching for 6D Pose Estimation. In Proceedings of the European Conference on Computer Vision (ECCV), 2018b.
239
+
240
+ Shuai Liao, Efstratios Gavves, and Cees G M Snoek. Spherical Regression: Learning Viewpoints, Surface Normals and 3D Rotations on N-Spheres. In Proceedings of the Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
241
+
242
+ Osama Makansi, Eddy Ilg, Ozgun Cicek, and Thomas Brox. Overcoming Limitations of Mixture Density Networks: A Sampling and Fitting Framework for Multimodal Future Prediction. In Proceedings of the Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
243
+
244
+ Fabian Manhardt, Wadim Kehl, and Adrien Gaidon. ROI-10D: Monocular Lifting of 2D Detection to 6D Pose and Metric Shape. In Proceedings of the Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
245
+
246
+ Kanti V. Mardia and Peter E. Jupp. Directional Statistics. Wiley, 1999.
247
+
248
+ David A. Nix and Andreas S. Weigend. Estimating the Mean and Variance of the Target Probability Distribution. In Proceedings of the International Conference on Neural Networks (ICNN), 1994.
249
+
250
+ Jean Marc Odobez. Idiap Head Pose Database. http://www.idiap.ch/dataset/ headpose, 2003.
251
+
252
+ Sergey Prokudin, Peter Gehler, and Sebastian Nowozin. Deep Directional Statistics: Pose Estimation with Uncertainty Quantification. In Proceedings of the European Conference on Computer Vision (ECCV), 2018.
253
+
254
+ Torsten Sattler, Qunjie Zhou, Marc Pollefeys, and Laura Leal-Taixe. Understanding the Limitations of CNN-Based Absolute Camera Pose Regression. In Proceedings of the Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
255
+
256
+ Hannes Sommer, Igor Gilitschenski, Michael Bloesch, Stephan Weiss, Roland Siegwart, and Juan Nieto. Why and How to Avoid the Flipped Quaternion Multiplication. Aerospace, 5(3):72, 2018.
257
+
258
+ Rangaprasad A. Srivatsan, Gillian T. Rosen, D. Feroze Naina Mohamed, and Howie Choset. Estimating SE(3) Elements Using a Dual Quaternion Based Linear Kalman Filter. In Proceedings of Robotics Science and Systems (RSS), 2016.
259
+
260
+ Martin Sundermeyer, Zoltan-Csaba Marton, Maximilian Durner, Manuel Brucker, and Rudolph Triebel. Implicit 3D Orientation Learning for 6D Object Detection from RGB Images. In Proceedings of the European Conference on Computer Vision (ECCV), 2018.
261
+
262
+ Bugra Tekin, Sudipta N Sinha, and Pascal Fua. Real-Time Seamless Single Shot 6D Object Pose Prediction. In Proceedings of the Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
263
+
264
+ Chen Wang, Danfei Xu, Yuke Zhu, Roberto Martin-Martin, Cewu Lu, Li Fei-Fei, and Silvio Savarese. DenseFusion: 6D Object Pose Estimation by Iterative Dense Fusion. In Proceedings of the Conference on Computer Vision and Pattern Recognition (CVPR), 2019a.
265
+
266
+ He Wang, Srinath Sridhar, Jingwei Huang, Julien Valentin, Shuran Song, and Leonidas J Guibas. Normalized Object Coordinate Space for Category-Level 6D Object Pose and Size Estimation. In Proceedings of the Conference on Computer Vision and Pattern Recognition (CVPR), 2019b.
267
+
268
+ Sen Wang, Ronald Clark, Hongkai Wen, and Niki Trigoni. DeepVO: Towards end-to-end visual odometry with deep Recurrent Convolutional Neural Networks. In Proceedings of the International Conference on Robotics and Automation (ICRA), 2017.
269
+
270
+ Sen Wang, Ronald Clark, Hongkai Wen, and Niki Trigoni. End-to-end, sequence-to-sequence probabilistic visual odometry through deep neural networks. The International Journal of Robotics Research, 2018.
271
+
272
+ Tsun-Yi Yang, Yi-Ting Chen, Yen-Yu Lin, and Yung-Yu Chuang. FSA-Net: Learning Fine-Grained Structure Aggregation for Head Pose Estimation From a Single Image. In Proceedings of the Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
md/train/yvQKLaqNE6M/yvQKLaqNE6M.md ADDED
@@ -0,0 +1,488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # YOU ONLY NEED ADVERSARIAL SUPERVISION FOR SEMANTIC IMAGE SYNTHESIS
2
+
3
+ Edgar Schonfeld¨ ∗ Bosch Center for Artificial Intelligence
4
+
5
+ Vadim Sushko \* Bosch Center for Artificial Intelligence
6
+
7
+ Dan Zhang Bosch Center for Artificial Intelligence
8
+
9
+ Jurgen Gall ¨ University of Bonn
10
+
11
+ Bernt Schiele Max Planck Institute for Informatics
12
+
13
+ Anna Khoreva Bosch Center for Artificial Intelligence
14
+
15
+ # ABSTRACT
16
+
17
+ Despite their recent successes, GAN models for semantic image synthesis still suffer from poor image quality when trained with only adversarial supervision. Historically, additionally employing the VGG-based perceptual loss has helped to overcome this issue, significantly improving the synthesis quality, but at the same time limiting the progress of GAN models for semantic image synthesis. In this work, we propose a novel, simplified GAN model, which needs only adversarial supervision to achieve high quality results. We re-design the discriminator as a semantic segmentation network, directly using the given semantic label maps as the ground truth for training. By providing stronger supervision to the discriminator as well as to the generator through spatially- and semantically-aware discriminator feedback, we are able to synthesize images of higher fidelity with better alignment to their input label maps, making the use of the perceptual loss superfluous. Moreover, we enable high-quality multi-modal image synthesis through global and local sampling of a 3D noise tensor injected into the generator, which allows complete or partial image change. We show that images synthesized by our model are more diverse and follow the color and texture distributions of real images more closely. We achieve an average improvement of 6 FID and 5 mIoU points over the state of the art across different datasets using only adversarial supervision.
18
+
19
+ ![](images/2332b0bef66597e89b06965264b3f2145c9ae3a3941cd18b8449b8be479a534b.jpg)
20
+ Figure 1: Existing semantic image synthesis models heavily rely on the VGG-based perceptual loss to improve the quality of generated images. In contrast, our model can synthesize diverse and high-quality images while only using an adversarial loss, without any external supervision.
21
+
22
+ # 1 INTRODUCTION
23
+
24
+ Conditional generative adversarial networks (GANs) (Mirza & Osindero, 2014) synthesize images conditioned on class labels (Zhang et al., 2019; Brock et al., 2019), text (Reed et al., 2016; Zhang et al., 2018a), other images (Isola et al., 2017; Huang et al., 2018), or semantic label maps (Wang et al., 2018; Park et al., 2019). In this work, we focus on the latter, addressing semantic image synthesis. Semantic image synthesis enables rendering of realistic images from user-specified layouts, without the use of an intricate graphic engine. Therefore, its applications range widely from content creation and image editing to generating training data that needs to adhere to specific semantic requirements (Wang et al., 2018; Chen & Koltun, 2017). Despite the recent progress on stabilizing GANs (Gulrajani et al., 2017; Miyato et al., 2018; Zhang & Khoreva, 2019) and developing their architectures (Zhang et al., 2019; Karras et al., 2019), state-of-the-art GAN-based semantic image synthesis models (Park et al., 2019; Liu et al., 2019) still greatly suffer from training instabilities and poor image quality when trained only with adversarial supervision (see Fig. 1). An established practice to overcome this issue is to employ a perceptual loss (Wang et al., 2018) to train the generator, in addition to the discriminator loss. The perceptual loss aims to match intermediate features of synthetic and real images, that are estimated via an external perception network. A popular choice for such a network is VGG (Simonyan & Zisserman, 2015), pre-trained on ImageNet (Deng et al., 2009). Although the perceptual loss substantially improves the accuracy of previous methods, it comes with the computational overhead introduced by utilizing an extra network for training. Moreover, it usually dominates over the adversarial loss during training, which can have a negative impact on the diversity and quality of generated images, as we show in our experiments. Therefore, in this work we propose a novel, simplified model that achieves state-of-the-art results without requiring a perceptual loss.
25
+
26
+ A fundamental question for GAN-based semantic image synthesis models is how to design the discriminator to efficiently utilize information from the given semantic label maps. Conventional methods (Park et al., 2019; Wang et al., 2018; Liu et al., 2019; Isola et al., 2017) adopt a multi-scale classification network, taking the label map as input along with the image, and making a global image-level real/fake decision. Such a discriminator has limited representation power, as it is not incentivized to learn high-fidelity pixel-level details of the images and their precise alignment with the input semantic label maps. To mitigate this issue, we propose an alternative architecture for the discriminator, re-designing it as an encoder-decoder semantic segmentation network (Ronneberger et al., 2015), and directly exploiting the given semantic label maps as ground truth via a $( N { + } 1 )$ -class cross-entropy loss (see Fig. 3). This new discriminator provides semantically-aware pixel-level feedback to the generator, partitioning the image into segments belonging to one of the $N$ real semantic classes or the fake class. Enabled by the discriminator per-pixel response, we further introduce a LabelMix regularization, which fosters the discriminator to focus more on the semantic and structural differences of real and synthetic images. The proposed changes lead to a much stronger discriminator, that maintains a powerful semantic representation of objects, giving more meaningful feedback to the generator, and thus making the perceptual loss supervision superfluous (see Fig. 1).
27
+
28
+ Next, we propose to enable multi-modal synthesis of the generator via 3D noise sampling. Previously, directly using 1D noise as input was not successful for semantic image synthesis, as the generator tended to mostly ignore it or synthesized images of poor quality (Isola et al., 2017; Wang et al., 2018). Thus, prior work (Wang et al., 2018; Park et al., 2019) resorted to using an image encoder to produce multi-modal outputs. In this work, we propose a lighter solution. Empowered by our stronger discriminator, the generator can effectively synthesize different images by simply re-sampling a 3D noise tensor, which is used not only as the input but also combined with intermediate features via conditional normalization at every layer. Such noise is spatially sensitive, so we can re-sample it both globally (channel-wise) and locally (pixel-wise), allowing to change not only the appearance of the whole scene, but also of specific semantic classes or any chosen areas (see Fig. 2). We call our model OASIS, as it needs only adversarial supervision for semantic image synthesis.
29
+
30
+ In summary, our main contributions are: (1) We propose a novel segmentation-based discriminator architecture, that gives more powerful feedback to the generator and eliminates the necessity of the perceptual loss supervision. (2) We present a simple 3D noise sampling scheme, notably increasing the diversity of multi-modal synthesis and enabling complete or partial change of the generated image. (3) With the OASIS model, we achieve high quality results on the ADE20K, Cityscapes and COCO-stuff datasets, on average improving the state of the art by 6 FID and 5 mIoU points, while relying only on adversarial supervision. We show that images synthesized by OASIS exhibit much higher diversity and more closely follow the color and texture distributions of real images. Our code and pretrained models are available at https://github.com/boschresearch/OASIS.
31
+
32
+ ![](images/f85a804b034c0634d48d2e3bf2e361e17ac6011c9cc05423ac8bd1db1c390e17.jpg)
33
+ Figure 2: OASIS multi-modal synthesis results. The 3D noise can be sampled globally (first 2 rows), changing the whole scene, or locally (last 2 rows), partially changing the image. For the latter, we sample different noise per region, like the bed segment (in red) or arbitrary areas defined by shapes.
34
+
35
+ # 2 RELATED WORK
36
+
37
+ Semantic image synthesis. Pix2pix (Isola et al., 2017) first proposed to use conditional GANs (Mirza & Osindero, 2014) for semantic image synthesis, adopting an encoder-decoder generator which takes semantic label maps as input, and employing a PatchGAN discriminator. Since then, various generator and discriminator modifications have been introduced (Wang et al., 2018; Park et al., 2019; Liu et al., 2019; Tang et al., 2020c;b; Ntavelis et al., 2020). Besides GANs, Chen & Koltun (2017) proposed to use a cascaded refinement network (CRN) for high-resolution semantic image synthesis, and SIMS (Qi et al., 2018) extended it with a non-parametric component, serving as a memory bank of source material to assist the synthesis. Further, Li et al. (2019) employed implicit maximum likelihood estimation (Li & Malik, 2018) to increase the variety of the CRN model. However, these approaches still underperform in comparison to state-of-the-art GAN models. Therefore, next we focus on the recent GAN architectures for semantic image synthesis.
38
+
39
+ Discriminator architectures. Pix2pix (Isola et al., 2017), Pix2pixHD (Wang et al., 2018) and SPADE (Park et al., 2019) all employed a multi-scale PatchGAN discriminator, that takes an image and its semantic label map as input. CC-FPSE (Liu et al., 2019) proposed a feature-pyramid discriminator, embedding both images and label maps into a joint feature map, and then consecutively upsampling it in order to classify it as real/fake at multiple scales. LGGAN (Tang et al., 2020c) introduced a classification-based feature learning module to learn more discriminative and class-specific features. In this work, we propose to use a pixel-wise semantic segmentation network as a discriminator instead of multi-scale image classifiers as in the above approaches, and to directly exploit the semantic label maps for its supervision. Segmentation-based discriminators have been shown to improve semantic segmentation (Souly et al., 2017) and unconditional image synthesis (Schonfeld et al., 2020), but to the best of our knowledge have not been explored for semantic image ¨ synthesis and our work is the first to apply adversarial semantic segmentation loss for this task.
40
+
41
+ Generator architectures. Conventionally, the semantic label map is provided to the image generation pipeline via an encoder (Isola et al., 2017; Wang et al., 2018; Tang et al., 2020c;b; Ntavelis et al., 2020). However, it is shown to be suboptimal at preserving the semantic information until the later stages of image generation. Therefore, SPADE introduced a spatially-adaptive normalization layer that directly modulates the label map onto the generator’s hidden layer outputs at various scales. Alternatively, CC-FPSE proposed to use spatially-varying convolution kernels conditioned on the label map. Struggling with generating diverse images from noise, both Pix2pixHD and SPADE resorted to having an image encoder in the generator design to enable multi-modal synthesis. The generator then combines the extracted image style with the label map to reconstruct the original image. By alternating the style vector, one can generate multiple outputs conditioned on the same label map. However, using an image encoder is a resource demanding solution. In this work, we enable multi-modal synthesis directly through sampling of a 3D noise tensor injected at every layer of the network. Differently from structured noise injection of Alharbi & Wonka (2020) and class-specific latent codes of Zhu et al. (2020), we inject the 3D noise along with label maps and adjust it to image resolution, also enabling re-sampling of selected semantic segments (see Fig. 2).
42
+
43
+ ![](images/385a4d678fa0c4a428fa112d74719636c21375e4d1d975ae6b45b15c542bda65.jpg)
44
+ Figure 3: SPADE (left) vs. OASIS (right). OASIS outperforms SPADE, while being simpler and lighter: it uses only adversarial loss supervision and a single segmentation-based discriminator, without relying on heavy external networks. Furthermore, OASIS learns to synthesize multi-modal outputs by directly re-sampling the 3D noise tensor, instead of using an image encoder as in SPADE.
45
+
46
+ Perceptual losses. Gatys et al. (2015); Gatys et al. (2016); Johnson et al. (2016) and Bruna et al. (2016) were pioneers at exploiting perceptual losses to produce high-quality images for superresolution and style transfer using convolutional networks. For semantic image synthesis, the VGGbased perceptual loss was first introduced by CRN, and later adopted by Pix2pixHD. Since then, it has become a default for training the generator (Park et al., 2019; Liu et al., 2019; Tan et al., 2020; Tang et al., 2020a). As the perceptual loss is based on a VGG network pre-trained on ImageNet (Deng et al., 2009), methods relying on it are constrained by the ImageNet domain and the representational power of VGG. With the recent progress on GAN training, e.g. by architecture designs and regularization techniques, the actual necessity of the perceptual loss requires a reassessment. We experimentally show that such loss imposes unnecessary constraints on the generator, significantly limiting sample diversity. While our model, trained without the VGG loss, achieves improved image diversity while not compromising image quality.
47
+
48
+ # 3 OASIS MODEL
49
+
50
+ In this section, we present our OASIS model, which, in contrast to other semantic image synthesis methods, needs only adversarial supervision for generator training. Using SPADE as a starting point (Sec. 3.1), we first propose to re-design the discriminator as a semantic segmentation network, directly using the given semantic label maps as ground truth (Sec. 3.2). Empowered by spatiallyand semantically-aware feedback of the new discriminator, we next re-design the SPADE generator, enabling its effective multi-modal synthesis via 3D noise sampling (Sec. 3.3).
51
+
52
+ # 3.1 THE SPADE BASELINE
53
+
54
+ We choose SPADE as our baseline as it is a state-of-the-art model and a relatively simple representative of conventional semantic image synthesis models. As depicted in Fig. 3, the discriminator of SPADE largely follows the PatchGAN multi-scale discriminator (Isola et al., 2017), adopting two image classification networks operating at different resolutions. Both of them take the channel-wise concatenation of the semantic label map and the real/synthesized image as input, and produce true/- fake classification scores. On the generator side, SPADE adopts spatially-adaptive normalization layers to effectively integrate the semantic label map into the synthesis process from low to high scales. Additionally, the image encoder is used to extract the style vector from the reference image and then combine it with a 1D noise vector for multi-modal synthesis. The training loss of SPADE consists of three terms, namely, an adversarial loss, a feature matching loss and the VGG-based perceptual loss: $\mathcal { L } = \mathrm { m a x } _ { G } \mathrm { m i n } _ { D } \mathcal { L } _ { \mathrm { a d v } } + \lambda _ { \mathrm { f m } } \mathcal { L } _ { \mathrm { f m } } + \lambda _ { \mathrm { v g g } } \mathcal { L } _ { \mathrm { v g g } }$ . Overall, SPADE is a resource demanding model at both training and test time, i.e., with two PatchGAN discriminators, an image encoder in addition to the generator, and the VGG loss. In the following, we revisit its architecture and introduce a simpler and more efficient model that offers better performance with less complexity.
55
+
56
+ # 3.2 OASIS DISCRIMINATOR
57
+
58
+ For the generator to learn to synthesize images that are well aligned with the input semantic label maps, we need a powerful discriminator that coherently captures discriminative semantic features at different image scales. While classification-based discriminators, such as PatchGAN, take label maps as input concatenated to images, they can afford to ignore them and make the decision solely on image patch realism. Thus, we propose to cast the discriminator task as a multi-class semantic segmentation problem to directly utilize label maps for supervision, and accordingly alter its architecture to an encoder-decoder segmentation network (see Fig. 3). Encoder-decoder networks have proven to be effective for semantic segmentation (Badrinarayanan et al., 2016; Chen et al., 2018). Thus, we build our discriminator architecture upon U-Net (Ronneberger et al., 2015), which consists of the encoder and decoder connected by skip connections. This discriminator architecture is multi-scale through its design, integrating information over up- and down-sampling pathways and through the encoder-decoder skip connections. For details on the architecture see App. C.1.
59
+
60
+ The segmentation task of the discriminator is formulated to predict the per-pixel class label of the real images, using the given semantic label maps as ground truth. In addition to the $N$ semantic classes from the label maps, all pixels of the fake images are categorized as one extra class. Overall, we have $N + 1$ classes in the semantic segmentation problem, and thus propose to use a $( N { + } 1 )$ -class cross-entropy loss for training. Considering that the $N$ semantic classes are usually imbalanced and that the per-pixel size of objects varies for different semantic classes, we weight each class by its inverse per-pixel frequency, giving rare semantic classes more weight. In doing so, the contributions of each semantic class are equally balanced, and, thus, the generator is also encouraged to adequately synthesize less-represented classes. Mathematically, the new discriminator loss is expressed as:
61
+
62
+ $$
63
+ \begin{array} { r } { \check { \mathcal { L } } _ { D } = - \mathbb { E } _ { ( x , t ) } \left[ \displaystyle \sum _ { c = 1 } ^ { N } \alpha _ { c } \sum _ { i , j } ^ { H \times W } t _ { i , j , c } \log D ( x ) _ { i , j , c } \right] ^ { \sim } - \mathbb { E } _ { ( z , t ) } \left[ \sum _ { i , j } ^ { H \times W } \log D ( G ( z , t ) ) _ { i , j , c = N + 1 } \right] , } \end{array}
64
+ $$
65
+
66
+ where $x$ denotes the real image; $( z , t )$ is the noise-label map pair used by the generator $G$ to synthesize a fake image; and the discriminator $D$ maps the real or fake image into a per-pixel $( N { + } 1 )$ -class prediction probability. The ground truth label map $t$ has three dimensions, where the first two correspond to the spatial position $( i , j ) \in H \times W$ , and the third one is a one-hot vector encoding the class $c \in \{ 1 , . . , N { + } 1 \}$ . The class balancing weight $\alpha _ { c }$ is the inverse of the per-pixel class frequency
67
+
68
+ $$
69
+ \alpha _ { c } = \frac { \mathbf { \bar { \alpha } } _ { H } \times W } { \sum _ { i , j } ^ { H \times W } E _ { t } \left[ \mathbb { 1 } \left[ t _ { i , j , c } = 1 \right] \right] } .
70
+ $$
71
+
72
+ LabelMix regularization. In order to encourage our discriminator to focus on differences in content and structure between the fake and the real classes, we propose a LabelMix regularization. Based on the semantic layout, we generate a binary mask $M$ to mix a pair $( x , { \hat { x } } )$ of real and fake images conditioned on the same label map: Labe $\operatorname { M i x } ( x , { \hat { x } } , M ) = M \odot x + ( 1 - M ) \odot { \hat { x } }$ , as visualized in Fig. 4. Given the mixed image, we further train the discriminator to be equivariant under the LabelMix operation. This is achieved by adding a consistency loss term $\mathcal { L } _ { c o n s }$ to Eq. 1:
73
+
74
+ $$
75
+ \mathcal { L } _ { c o n s } = \Big \| D _ { \mathrm { l o g i t s } } \Big ( \mathrm { L a b e l M i x } ( x , \hat { x } , M ) \Big ) - \mathrm { L a b e l M i x } \Big ( D _ { \mathrm { l o g i t s } } ( x ) , D _ { \mathrm { l o g i t s } } ( \hat { x } ) , M \Big ) \Big \| ^ { 2 } .
76
+ $$
77
+
78
+ where $D _ { \mathrm { l o g i t s } }$ are the logits attained before the last softmax activation layer, and $\| \cdot \|$ is the $L _ { 2 }$ norm. This consistency loss compares the output of the discriminator on the LabelMix image with the LabelMix of its outputs, penalizing the discriminator for inconsistent predictions. LabelMix is different to CutMix (Yun et al., 2019), which randomly samples the binary mask $M$ . A random mask will introduce inconsistency between the pixel-level classes and the scene layout provided by the label map. For an object with the semantic class $c$ , it will contain pixels from both real and fake images, resulting in two labels, i.e. $c$ and $N + 1$ . To avoid such inconsistency, the mask of LabelMix is generated according to the label map, providing natural borders between semantic regions, see Fig. 4 (Mask $M _ { ☉ }$ ). Under LabelMix regularization, the generator is encouraged to respect the natural semantic boundaries, improving pixel-level realism while also considering the class segment shapes.
79
+
80
+ ![](images/acdaa975c36b331a887c5af8984d7c5593a8d8e548e00830fc806c0a082277c2.jpg)
81
+ Figure 4: LabelMix regularization. Real $x$ and fake $\hat { x }$ images are mixed using a binary mask $M$ , sampled based on the label map, resulting in La $\mathrm { \ u b e l M i x } _ { ( x , \hat { x } ) }$ . The consistency regularization then minimizes the L2 distance between the logits of DLabelMix(x,xˆ) and LabelMix $( D _ { x } , D _ { \hat { x } } )$ . In this visualization, black corresponds to the fake class in the $N { + 1 }$ segmentation output.
82
+
83
+ Other variants. Besides the proposed $( N { + } 1 )$ -class cross entropy loss, there are other ways to train the segmentation-based discriminator with the label map. One can concatenate the label map to the input image, analogous to SPADE. Another option is to use projection, by taking the inner product between the last linear layer output and the embedded label map, analogous to class-label conditional GANs (Miyato & Koyama, 2018). For both alternatives, the training loss is pixel-level real/fake binary cross-entropy (Schonfeld et al., 2020). From the label map encoding perspective, ¨ these two variants use labels map as input (concatenated to image or at last linear layer), propagating it forward through the network. The $( N { + } 1 )$ -setting uses the label map for loss computation, so it is propagated backward via gradient updates. Backward propagation ensures that the discriminator learns semantic-aware features, in contrast to forward propagation, where the label map alignment is not as strongly enforced. Performance comparison of the label map encodings is shown in Table 5.
84
+
85
+ # 3.3 OASIS GENERATOR
86
+
87
+ To stay in line with the OASIS discriminator design, the training loss for the generator is changed to
88
+
89
+ $$
90
+ \mathcal { L } _ { G } = - \mathbb { E } _ { ( z , t ) } \left[ \sum _ { c = 1 } ^ { N } \alpha _ { c } \sum _ { i , j } ^ { H \times \bar { W } } t _ { i , j , c } \log D ( G ( z , t ) ) _ { i , j , c } \right] ^ { - } ,
91
+ $$
92
+
93
+ which is a direct outcome of the non-saturation trick (Goodfellow et al., 2014) to Eq. 1. We next re-design the generator to enable multi-modal synthesis through noise sampling. SPADE is deterministic in its default setup, but can be trained with an extra image encoder to generate multi-modal outputs. We introduce a simpler version, that enables synthesis of diverse outputs directly from input noise. For this, we construct a noise tensor of size $6 4 \times H \times W$ , matching the spatial dimensions of the label map $H \times W$ . Channel-wise concatenation of the noise and label map forms a 3D tensor used as input to the generator and also as a conditioning at every spatially-adaptive normalization layer. In doing so, intermediate feature maps are conditioned on both the semantic labels and the noise (see Fig. 3). With such a design, the generator produces diverse, noise-dependent images. As the 3D noise is channel- and pixel-wise sensitive, at test time, one can sample the noise globally, per-channel, and locally, per-segment or per-pixel, for controlled synthesis of the whole scene or of specific semantic objects. For example, when generating a scene of a bedroom, one can re-sample the noise locally and change the appearance of the bed alone (see Fig. 2). Note that for simplicity during training we sample the 3D noise tensor globally, i.e. per-channel, replicating each channel value spatially along the height and width of the tensor. We analyse alternative ways of sampling 3D noise during training in App. A.7. Using image styles via an encoder, as in SPADE, is also possible in our setting, by replacing noise with encoder features. Lastly, to further reduce the complexity, we remove the first residual block in the generator, reducing the number of parameters from 96M to 72M (see App. C.2) without a noticeable performance loss (see Table 3).
94
+
95
+ ![](images/357ef04e8b4f1473b1eefaadd27c06e2e8f13f75285d5facbfe6fdf4ae0ca490.jpg)
96
+ Figure 5: Qualitative comparison of OASIS with other methods on ADE20K. Trained with only adversarial supervision, our model generates images with better perceptual quality and structure.
97
+
98
+ # 4 EXPERIMENTS
99
+
100
+ We conduct experiments on three challenging datasets: ADE20K (Zhou et al., 2017), COCO-stuff (Caesar et al., 2018) and Cityscapes (Cordts et al., 2016). Following Qi et al. (2018), we also evaluate OASIS on ADE20K-outdoors, a subset of ADE20K containing outdoor scenes. We follow the experimental setting of Park et al. (2019). We did not use the GAN feature matching loss for OASIS, as we did not observe any improvement with it (see App. A.5), and used the VGG loss only for ablations with $\lambda _ { \mathrm { V G G } } = 1 0$ . We did not experience any training instabilities and, thus, did not employ any extra stabilization techniques. All our models use an exponential moving average (EMA) of the generator weights with 0.9999 decay. For further training details refer to App. C.3.
101
+
102
+ Following prior work (Isola et al., 2017; Wang et al., 2018; Park et al., 2019; Liu et al., 2019), we evaluate models quantitatively on the validation set using the Frechet Inception Distance (FID) ´ (Heusel et al., 2017) and mean Intersection-over-Union (mIoU). FID is known to be sensitive to both quality and diversity and has been shown to be well aligned with human judgement (Heusel et al., 2017). We show additional evaluation of quality and diversity with ”improved precision and recall” in App. A.9. Mean IoU is used to assess the alignment of the generated image with the ground truth label map, computed via a pre-trained semantic segmentation network. We use UperNet101 (Xiao et al., 2018) for ADE20K, multi-scale DRN-D-105 (Yu et al., 2017) for Cityscapes, and DeepLabV2 (Chen et al., 2015) for COCO-Stuff. We additionally propose to compare color and texture statistics between generated and real images on ADE20K to better understand how the perceptual loss influences performance. For this, we compute color histograms in LAB space and measure the earth mover’s distance between the real and generated sets (Rubner et al., 2000). We measure the texture similarity to the real data as the $\chi ^ { 2 }$ -distance between Local Binary Patterns histograms (Ojala et al., 1996). As different classes have different color and texture distributions, we aggregate histogram distances separately per class and then take the mean. Lower values for the texture and color distances indicate a closer similarity to real data.
103
+
104
+ # 4.1 MAIN RESULTS
105
+
106
+ We use SPADE as our baseline, using the authors’ implementation1. For a fair comparison, we train this model without the feature matching loss and using EMA (Yaz et al., 2018) at test phase, which we further refer to as $\mathrm { S P A D E + }$ . We found that the feature matching loss has a negligible impact (see App. A.5), while EMA significantly increases the performance for all metrics (see Table 1).
107
+
108
+ Table 1: Comparison with other methods across datasets.Bold denotes the best performance.
109
+
110
+ <table><tr><td rowspan="2">Method</td><td rowspan="2"># param</td><td rowspan="2">VGG</td><td colspan="2">ADE20K mIoU个</td><td colspan="2">ADE-outd.</td><td colspan="2">Cityscapes</td><td colspan="2">COCO-stuff</td></tr><tr><td>FID↓</td><td></td><td>FID↓</td><td>mIoU↑</td><td>FID↓</td><td>mIoU个</td><td>FID↓</td><td>mIoU↑</td></tr><tr><td>CRN SIMS</td><td>84M</td><td></td><td>73.3</td><td>22.4</td><td>99.0</td><td>16.5</td><td>104.7</td><td>52.4</td><td>70.4</td><td>23.7</td></tr><tr><td></td><td>56M</td><td></td><td>n/a</td><td>n/a</td><td>67.7</td><td>13.1</td><td>49.7</td><td>47.2</td><td>n/a</td><td>n/a</td></tr><tr><td>Pix2pixHD</td><td>183M</td><td></td><td>81.8</td><td>20.3</td><td>97.8</td><td>17.4</td><td>95.0</td><td>58.3</td><td>111.5</td><td>14.6</td></tr><tr><td>LGGAN CC-FPSE</td><td>n/a</td><td></td><td>31.6</td><td>41.6</td><td>n/a</td><td>n/a</td><td>57.7</td><td>68.4</td><td>n/a</td><td>n/a</td></tr><tr><td>SPADE</td><td>131M</td><td>:</td><td>31.7</td><td>43.7</td><td>n/a</td><td>n/a</td><td>54.3</td><td>65.5</td><td>19.2</td><td>41.6</td></tr><tr><td></td><td>102M</td><td></td><td>33.9 32.9</td><td>38.5</td><td>63.3</td><td>30.8</td><td>71.8</td><td>62.3</td><td>22.6</td><td>37.4</td></tr><tr><td rowspan="2">SPADE+ OASIS</td><td>102M</td><td>√</td><td>60.7</td><td>42.5</td><td>51.1</td><td>32.1</td><td>47.8</td><td>64.0</td><td>21.7</td><td>38.8</td></tr><tr><td>94M</td><td>× ×</td><td>28.3</td><td>21.0 48.8</td><td>65.4 48.6</td><td>22.7 40.4</td><td>61.4 47.7</td><td>47.6 69.3</td><td>99.1 17.0</td><td>16.1 44.1</td></tr></table>
111
+
112
+ Table 2: Multi-modal synthesis evaluation on ADE20K. Bold and red denote the best and the worst performance, respectively.
113
+
114
+ <table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Method |Multi-mod.</td><td rowspan=1 colspan=1>VGG</td><td rowspan=1 colspan=2>MS-SSIM↓</td><td rowspan=1 colspan=2>MS-SSIM↓</td><td rowspan=1 colspan=1>LPIPS↑</td><td rowspan=1 colspan=1>FID↓</td></tr><tr><td rowspan=1 colspan=1>SPADE+</td><td rowspan=1 colspan=1>Encoder</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=3>0.85</td><td rowspan=1 colspan=1>0.16</td><td rowspan=1 colspan=1>33.4</td><td rowspan=1 colspan=1>40.2</td></tr><tr><td rowspan=1 colspan=1>SPADE+</td><td rowspan=1 colspan=1>3D noise</td><td rowspan=1 colspan=1>x√</td><td rowspan=1 colspan=3>0.350.53</td><td rowspan=1 colspan=1>0.500.36</td><td rowspan=1 colspan=1>58.434.4</td><td rowspan=1 colspan=1>18.736.2</td></tr><tr><td rowspan=1 colspan=1>OASIS</td><td rowspan=1 colspan=1>3D noise</td><td rowspan=1 colspan=1>×√</td><td rowspan=1 colspan=3>0.650.88</td><td rowspan=1 colspan=1>0.350.15</td><td rowspan=1 colspan=1>28.331.6</td><td rowspan=1 colspan=1>48.850.8</td></tr></table>
115
+
116
+ ![](images/481520490c5ebd46092d8ba75ff4b732a1ae965c398c1a5042d01a233be0a3d2.jpg)
117
+ Figure 6: Histogram distances to real data.
118
+
119
+ OASIS outperforms the current state of the art on all datasets with an average improvement of 6 FID and 5 mIoU points (Table 1). Importantly, OASIS achieved the improvement via adversarial supervision alone. On the contrary, SPADE $^ +$ does not produce images of high visual quality without the perceptual loss, and struggles to learn the color and texture distribution of real images (Fig. 6). A strong discriminator is the key factor for good performance: without a rich training signal from the discriminator, the $\mathrm { S P A D E + }$ generator has to learn through minimizing the VGG loss. With the stronger OASIS discriminator, the perceptual loss does not overtake the generator supervision (see App. A.2), allowing to produce images with the color and texture distribution closer to the real data.
120
+
121
+ Fig. 5 shows a qualitative comparison of our results to previous models. Our approach noticeably improves image quality, synthesizing finer textures and more natural colors. With the powerful feedback from the discriminator, OASIS is able to learn the appearance of small or rarely occurring semantic classes (which is reflected in the per-class IoU scores presented in App. A.3), producing plausible results even for complex scenes with rare classes and reducing unnatural artifacts.
122
+
123
+ Multi-modal image synthesis. In contrast to previous work, OASIS can produce diverse images by directly re-sampling input 3D noise. As 3D noise modulates features directly at every layer of the generator at different scales, matching their resolution, it affects both global and local characteristics of the image. Thus, the noise can be sampled globally, varying the whole image, or locally, resulting in the selected object change while preserving the rest of the scene (see Fig. 2).
124
+
125
+ To measure the variation in the multi-modal generation, we evaluate MS-SSIM (Wang et al., 2003) and LPIPS (Zhang et al., 2018b) between images generated from the same label map. We generate 20 images and compute the mean pairwise scores, and then average over all label maps. The lower the MS-SSIM and the higher the LPIPS scores, the more diverse the generated images are. To assess the effect of the perceptual loss and the noise sampling on diversity, we train $\mathrm { S P A D E + }$ with 3D noise or the image encoder, and with or without the perceptual loss. Table 2 shows that OASIS, without perceptual loss, improves over $\mathrm { S P A D E + }$ with the image encoder, both in terms of image diversity (MS-SSIM, LPIPS) and quality (mean FID, mIoU across 20 realizations). Using 3D noise further increases diversity for $\mathrm { S P A D E + }$ . However, a strong quality-diversity tradeoff exists for $\mathrm { S P A D E + }$ : 3D noise improves diversity at the cost of quality, and the perceptual loss improves quality at the cost of diversity. For OASIS, the VGG loss also reduces diversity but does not noticeably affect quality. Note that in our experiments LabelMix does not notably affect diversity (see App. A.1).
126
+
127
+ # 4.2 ABLATIONS
128
+
129
+ We conduct ablations on ADE20K to evaluate our proposed changes. The main ablation shows the impact of our new discriminator, lighter generator, LabelMix and 3D noise. Further ablations are concerned with architecture changes and the label map encodings in the discriminator, where for fair comparison we use no 3D noise and LabelMix.
130
+
131
+ Main ablation. Table 3 shows that $\mathrm { S P A D E + }$ scores low on the image quality metrics without the perceptual loss. Replacing the $\mathrm { S P A D E + }$ discriminator with the OASIS discriminator, while keeping the generator fixed, improves FID and mIoU by more than 30 points. Changing the $\mathrm { S P A D E + }$ generator to the lighter OASIS generator leads to a negligible degradation of 0.3 in FID and 0.5 in mIoU. With LabelMix FID improves further by $\sim 1$ point (more ablations on LabelMix in App. A.4). Adding 3D noise improves FID but degrades mIoU, as diversity complicates the task of the pre-trained semantic segmentation network used to compute the score. For OASIS the perceptual loss deteriorates FID by more than 2 points, but improves mIoU. Overall, without the perceptual loss the new discriminator is the key to the performance boost over $\mathrm { S P A D E + }$ .
132
+
133
+ Table 3: OASIS ablation on ADE20K. Bold denotes the best performance.
134
+
135
+ <table><tr><td rowspan=1 colspan=1>G</td><td rowspan=1 colspan=1>D</td><td rowspan=1 colspan=1>VGG</td><td rowspan=1 colspan=1>LabelMix|</td><td rowspan=1 colspan=1>FID↓mIoU↑</td></tr><tr><td rowspan=1 colspan=1>SPADE+</td><td rowspan=1 colspan=1>SPADE+</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>60.7 21.0</td></tr><tr><td rowspan=1 colspan=1>SPADE+</td><td rowspan=1 colspan=1>OASIS</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>29.0 52.1</td></tr><tr><td rowspan=1 colspan=1>OASIS</td><td rowspan=1 colspan=1>OASIS</td><td rowspan=1 colspan=1>X×</td><td rowspan=1 colspan=1>×√</td><td rowspan=1 colspan=1>29.3 51.628.4 50.6</td></tr><tr><td rowspan=1 colspan=1>OASIS+3D noise</td><td rowspan=1 colspan=1>OASIS</td><td rowspan=1 colspan=1>X【</td><td rowspan=1 colspan=1>【</td><td rowspan=1 colspan=1>28.3 48.831.6 50.8</td></tr></table>
136
+
137
+ Ablation on the discriminator architecture. We train the OASIS generator with three alternative discriminators: the original multi-scale PatchGAN consisting of two networks, a single-scale PatchGAN, and a ResNet-based discriminator, corresponding to the encoder of the U-Net shaped OASIS discriminator. Table 4 shows that the alternative discriminators only perform well with perceptual supervision, while the OASIS discriminator achieves superior performance independent of it. The single-scale
138
+
139
+ Table 4: Ablation on the $D$ architecture. Bold denotes the best performance, red highlights collapsed runs.
140
+
141
+ <table><tr><td>D architecture</td><td>w/o VGG FID↓ mIoU↑</td><td>with VGG FID↓ mIoU↑</td></tr><tr><td>MS-PatchGAN (2x)</td><td>60.7 21.0</td><td>32.9 42.5</td></tr><tr><td>PatchGAN</td><td>197 0.62</td><td>34.2 42.2</td></tr><tr><td>ResNet-PatchGAN</td><td>147 0.42</td><td>32.4 45.1</td></tr><tr><td>OASIS</td><td>29.3 51.6</td><td>29.2 51.1</td></tr></table>
142
+
143
+ discriminators even collapse without the perceptual loss (highlighted in red in Table 4).
144
+
145
+ Ablation on the label map encoding. We study four different label map encodings: input concatenation, as in SPADE, projection conditioned on the label map (Miyato & Koyama, 2018), employing label maps as ground truth for the $N { + 1 }$ segmentation loss, or for the class-balanced $N { + 1 }$ loss (see Sec. 3.2). As shown in Table 5, input concatenation is not sufficient without additional perceptual loss supervision, leading to training collapse. Without perceptual loss, the $N { + 1 }$ loss outperforms the input concatenation and the projection in both the FID and mIoU metrics. The class balancing noticeably improves mIoU due to better supervision for rarely occurring semantic classes. More ablations can be found in App. A.
146
+
147
+ Table 5: Ablation on the label map encoding. Bold denotes the best performance, red highlights collapsed runs.
148
+
149
+ <table><tr><td>Label encoding</td><td>w/o VGG FID↓ mIoU↑</td><td>with VGG FID↓ mIoU↑</td></tr><tr><td>Input concatenation</td><td>280 0.02</td><td>30.0 43.9</td></tr><tr><td>Projection</td><td>32.4 44.9</td><td>28.0 46.9</td></tr><tr><td>N+1 loss</td><td>28.3 47.2</td><td>28.6 49.8</td></tr><tr><td>Balanced N+1 loss</td><td>29.3 51.6</td><td>29.2 51.1</td></tr></table>
150
+
151
+ # 5 CONCLUSION
152
+
153
+ In this work we propose OASIS, a semantic image synthesis model that only relies on adversarial supervision to achieve high fidelity image synthesis. In contrast to previous work, our model eliminates the need for a perceptual loss, which often imposes extra constraints on image quality and diversity. This is achieved via detailed spatial and semantic-aware supervision from our novel segmentation-based discriminator, which uses semantic label maps as ground truth for training. With this powerful discriminator, OASIS can easily generate diverse multi-modal outputs by re-sampling the 3D noise, both globally and locally, allowing to change the appearance of the whole scene and of individual objects. OASIS significantly improves over the state of the art in terms of image quality and diversity, while being simpler and more lightweight than previous methods.
154
+
155
+ # ACKNOWLEDGEMENT
156
+
157
+ Jurgen Gall has been supported by the Deutsche Forschungsgemeinschaft (DFG, German Research¨ Foundation) under Germany’s Excellence Strategy - EXC 2070 -390732324.
158
+
159
+ # REFERENCES
160
+
161
+ Yazeed Alharbi and Peter Wonka. Disentangled image generation through structured noise injection. In Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
162
+
163
+ Vijay Badrinarayanan, Alex Kendall, and Roberto Cipolla. Segnet: A deep convolutional encoderdecoder architecture for image segmentation. Transactions on Pattern Analysis and Machine Intelligence, 2016.
164
+
165
+ Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale GAN training for high fidelity natural image synthesis. In International Conference on Learning Representations (ICLR), 2019.
166
+
167
+ Joan Bruna, Pablo Sprechmann, and Yann LeCun. Super-resolution with deep convolutional sufficient statistics. In International Conference on Learning Representations (ICLR), 2016.
168
+
169
+ Holger Caesar, Jasper Uijlings, and Vittorio Ferrari. Coco-stuff: Thing and stuff classes in context. In Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
170
+
171
+ Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. Semantic image segmentation with deep convolutional nets and fully connected crfs. International Conference on Learning Representations (ICLR), 2015.
172
+
173
+ Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam. Encoderdecoder with atrous separable convolution for semantic image segmentation. In European Conference on Computer Vision (ECCV), 2018.
174
+
175
+ Qifeng Chen and Vladlen Koltun. Photographic image synthesis with cascaded refinement networks. In International Conference on Computer Vision (ICCV), 2017.
176
+
177
+ Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Rehfeld, Markus Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, and Bernt Schiele. The cityscapes dataset for semantic urban scene understanding. In Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
178
+
179
+ J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A Large-Scale Hierarchical Image Database. In Conference on Computer Vision and Pattern Recognition (CVPR), 2009.
180
+
181
+ L. A. Gatys, A. S. Ecker, and M. Bethge. Image style transfer using convolutional neural networks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
182
+
183
+ Leon Gatys, Alexander S Ecker, and Matthias Bethge. Texture synthesis using convolutional neural networks. In Advances in Neural Information Processing Systems (NeurIPs). 2015.
184
+
185
+ 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 (NeurIPS), 2014.
186
+
187
+ Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron C Courville. Improved training of Wasserstein GANs. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
188
+
189
+ Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. GANs trained by a two time-scale update rule converge to a local nash equilibrium. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
190
+
191
+ Xun Huang, Ming-Yu Liu, Serge Belongie, and Jan Kautz. Multimodal unsupervised image-toimage translation. In European Conference on Computer Vision (ECCV), 2018.
192
+
193
+ Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
194
+
195
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In European Conference on Computer Vision (ECCV), 2016.
196
+
197
+ Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
198
+
199
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015.
200
+
201
+ Tuomas Kynka¨anniemi, Tero Karras, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Improved ¨ precision and recall metric for assessing generative models. In Advances in Neural Information Processing Systems, pp. 3927–3936, 2019.
202
+
203
+ Ke Li and Jitendra Malik. Implicit maximum likelihood estimation. arXiv preprint arXiv:1809.09087, 2018.
204
+
205
+ Ke Li, Tianhao Zhang, and Jitendra Malik. Diverse image synthesis from semantic layouts via conditional imle. In Proceedings of the IEEE International Conference on Computer Vision, pp. 4220–4229, 2019.
206
+
207
+ Xihui Liu, Guojun Yin, Jing Shao, Xiaogang Wang, et al. Learning to predict layout-to-image conditional convolutions for semantic image synthesis. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
208
+
209
+ Mehdi Mirza and Simon Osindero. Conditional generative adversarial nets. arXiv:1411.1784, 2014.
210
+
211
+ Takeru Miyato and Masanori Koyama. cGANs with projection discriminator. In International Conference on Learning Representations (ICLR), 2018.
212
+
213
+ Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. In International Conference on Learning Representations (ICLR), 2018.
214
+
215
+ Evangelos Ntavelis, Andres Romero, Iason Kastanis, Luc Van Gool, and Radu Timofte. Sesame: ´ Semantic editing of scenes by adding, manipulating or erasing objects. arXiv:2004.04977, 2020.
216
+
217
+ Timo Ojala, Matti Pietikainen, and David Harwood. A comparative study of texture measures with ¨ classification based on featured distributions. Pattern recognition, 29(1):51–59, 1996.
218
+
219
+ Taesung Park, Ming-Yu Liu, Ting-Chun Wang, and Jun-Yan Zhu. Semantic image synthesis with spatially-adaptive normalization. In Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
220
+
221
+ Xiaojuan Qi, Qifeng Chen, Jiaya Jia, and Vladlen Koltun. Semi-parametric image synthesis. In Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
222
+
223
+ Suman Ravuri and Oriol Vinyals. Classification accuracy score for conditional generative models. In Advances in Neural Information Processing Systems, pp. 12268–12279, 2019.
224
+
225
+ Scott E. Reed, Zeynep Akata, Xinchen Yan, Lajanugen Logeswaran, Bernt Schiele, and Honglak Lee. Generative adversarial text to image synthesis. In International Conference on Machine learning (ICML), 2016.
226
+
227
+ Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In MICCAI, 2015.
228
+
229
+ Yossi Rubner, Carlo Tomasi, and Leonidas J Guibas. The earth mover’s distance as a metric for image retrieval. International Journal of Computer Vision (IJCV), 2000.
230
+
231
+ Mehdi SM Sajjadi, Olivier Bachem, Mario Lucic, Olivier Bousquet, and Sylvain Gelly. Assessing generative models via precision and recall. In Advances in Neural Information Processing Systems, pp. 5228–5237, 2018.
232
+
233
+ Edgar Schonfeld, Bernt Schiele, and Anna Khoreva. A u-net based discriminator for generative ¨ adversarial networks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
234
+
235
+ Konstantin Shmelkov, Cordelia Schmid, and Karteek Alahari. How good is my gan? In Proceedings of the European Conference on Computer Vision (ECCV), pp. 213–229, 2018.
236
+
237
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations (ICLR), 2015.
238
+
239
+ Nasim Souly, Concetto Spampinato, and Mubarak Shah. Semi supervised semantic segmentation using generative adversarial network. In International Conference on Computer Vision (ICCV), 2017.
240
+
241
+ Zhentao Tan, Dongdong Chen, Qi Chu, Menglei Chai, Jing Liao, Mingming He, Lu Yuan, and Nenghai Yu. Rethinking spatially-adaptive normalization. arXiv:2004.02867, 2020.
242
+
243
+ Hao Tang, Song Bai, and Nicu Sebe. Dual attention gans for semantic image synthesis. In Proceedings of the 28th ACM International Conference on Multimedia, pp. 1994–2002, 2020a.
244
+
245
+ Hao Tang, Xiaojuan Qi, Dan Xu, Philip HS Torr, and Nicu Sebe. Edge guided gans with semantic preserving for semantic image synthesis. arXiv:2003.13898, 2020b.
246
+
247
+ Hao Tang, Dan Xu, Yan Yan, Philip HS Torr, and Nicu Sebe. Local class-specific and global imagelevel generative adversarial networks for semantic-guided scene generation. In Conference on Computer Vision and Pattern Recognition (CVPR), 2020c.
248
+
249
+ Ting-Chun Wang, Ming-Yu Liu, Jun-Yan Zhu, Andrew Tao, Jan Kautz, and Bryan Catanzaro. Highresolution image synthesis and semantic manipulation with conditional GANs. In Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
250
+
251
+ Zhou Wang, Eero P Simoncelli, and Alan C Bovik. Multiscale structural similarity for image quality assessment. In Asilomar Conference on Signals, Systems & Computers, 2003.
252
+
253
+ Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In European Conference on Computer Vision (ECCV), 2018.
254
+
255
+ Yasin Yaz, Chuan-Sheng Foo, Stefan Winkler, Kim-Hui Yap, Georgios Piliouras, Vijay Chandrasekhar, et al. The unusual effectiveness of averaging in gan training. In International Conference on Learning Representations, 2018.
256
+
257
+ Fisher Yu, Vladlen Koltun, and Thomas Funkhouser. Dilated residual networks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
258
+
259
+ Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. Cutmix: Regularization strategy to train strong classifiers with localizable features. In International Conference on Computer Vision (ICCV), 2019.
260
+
261
+ Dan Zhang and Anna Khoreva. PA-GAN: Improving GAN training by progressive augmentation. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
262
+
263
+ H. Zhang, T. Xu, H. Li, S. Zhang, X. Wang, X. Huang, and D. N. Metaxas. StackGAN $^ { + + }$ : Realistic image synthesis with stacked generative adversarial networks. Transactions on Pattern Analysis and Machine Intelligence, 2018a.
264
+
265
+ Han Zhang, Ian J. Goodfellow, Dimitris N. Metaxas, and Augustus Odena. Self-attention generative adversarial networks. In International Conference on Machine learning (ICML), 2019.
266
+
267
+ Hang Zhang, Chongruo Wu, Zhongyue Zhang, Yi Zhu, Zhi Zhang, Haibin Lin, Yue Sun, Tong He, Jonas Mueller, R Manmatha, et al. Resnest: Split-attention networks. arXiv preprint arXiv:2004.08955, 2020.
268
+
269
+ Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Conference on Computer Vision and Pattern Recognition (CVPR), 2018b.
270
+
271
+ Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
272
+
273
+ Zhen Zhu, Zhiliang Xu, Ansheng You, and Xiang Bai. Semantically multi-modal image synthesis. In Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
274
+
275
+ # APPENDIX
276
+
277
+ This supplementary material to the main paper is structured as follows:
278
+
279
+ A Additional quantitative results.
280
+
281
+ A.1 Main ablation study on two datasets. A.2 The influence of the perceptual loss on training dynamics. A.3 Per-class IoU scores across different datasets. A.4 Comparing LabelMix and CutMix for consistency regularization. A.5 Ablation on the Feature Matching loss. A.6 Ablation on using multiple OASIS discriminators. A.7 Ablation on noise sampling strategies during training. A.8 Additional experiments on COCO-stuff. A.9Additional image quality metrics. B: Additional qualitative results. B.1 Visual comparison of OASIS to other works. B.2 Multi-modal synthesis results for different label maps. B.3 Interpolations between multi-modal images in latent space. B.4 Application to unlabelled data. B.5 Additional visual LabelMix examples.
282
+
283
+ C: A detailed description of the OASIS architecture and its training details. C.1 Discriminator architecture. C.2 Generator architecture. C.3 Learning objective and training details.
284
+
285
+ A QUANTITATIVE RESULTS
286
+
287
+ # A.1 SUMMARIZED MAIN ABLATION OVER TWO DATASETS
288
+
289
+ Table A: Summarized ablation on two datasets. Bold denotes the best performance. Red denotes the worst performance among experiments with 3D noise. Green denotes the major performance gains that are caused by the proposed OASIS discriminator and LabelMix.
290
+
291
+ <table><tr><td rowspan="2">Method</td><td colspan="3">Cityscapes</td><td colspan="2">ADE20K</td></tr><tr><td>FID↓</td><td>mIoU↑</td><td>MS-SSIM↓</td><td>FID↓ mIoU↑</td><td>MS-SSIM↓</td></tr><tr><td>SPADE+</td><td>61.4</td><td>47.6</td><td>1.0</td><td>60.7</td><td>21.0 1.0</td></tr><tr><td>+ OASIS D, G</td><td>54.1</td><td>67.6</td><td>1.0</td><td>29.3 51.6</td><td>1.0</td></tr><tr><td>+ 3D noise</td><td>51.5</td><td>66.3</td><td>0.62</td><td>28.9 47.3</td><td>0.63</td></tr><tr><td>+ LabelMix</td><td>47.7</td><td>69.3</td><td>0.64</td><td>28.3 48.8</td><td>0.65</td></tr><tr><td>+ VGG</td><td>46.1</td><td>72.0</td><td>0.84</td><td>31.6 50.8</td><td>0.88</td></tr></table>
292
+
293
+ In Table A we present a summarized version of our ablations for the ADE20K and Cityscapes dataset. The following observations can be made:
294
+
295
+ (1) Looking at the 2nd row of Table A, we see that the main performance gain comes from the discriminator design (major) (OASIS D,G). The OASIS generator is a lighter version of the SPADE generator, which does not result in a performance improvement (Table 3), but has significantly less parameters. A second source of improvement is LabelMix.
296
+
297
+ (2) The mIoU can drop when 3D noise is added, as diversity complicates the task of the pre-trained semantic segmentation network that is used to compute the mIoU score. Note that the purpose of noise is not to improve the image quality (FID) but to improve diversity (MS-SSIM).
298
+
299
+ (3) The perceptual loss can hurt performance and diversity by biasing the generator towards ImageNet, as in this case the target distribution is more difficult to recreate fully. By punishing diversity, the perceptual loss encourages generating images with more standard semantic features This facilitates the task of external pretrained segmenters, and consequently helps to raise the mIoU metric.
300
+
301
+ # A.2 THE INFLUENCE OF VGG ON TRAINING DYNAMICS
302
+
303
+ Table 1 and Figure 1 illustrate that performance of $\mathrm { S P A D E + }$ strongly depends on the perceptual loss. In contrast, OASIS achieves high quality without this loss (Table 1). We find the explanation in the fact, that the $\mathrm { S P A D E + }$ Patch-GAN discriminator does not provide a strong training signal for the generator. At the absence of strong supervision from the discriminator, the generator resorts to learning mostly from the VGG loss. The loss curves in Fig. A support this finding: throughout the training the $\mathrm { S P A D E + }$ model focuses on minimizing the VGG loss, keeping the adversarial generator loss more or less constant. In contrast, OASIS significantly improves adversarial generator loss during training, learning to fool the segmentation-based OASIS discriminator. That indicates a better adversarial balance, when the generator learns semantically meaningful features that the segmenter judges as real. The difference in scales of G loss for models comes from different objectives, since SPADE $^ +$ optimizes binary cross entropy, and OASIS minimizes multi-class cross entropy with $N { + 1 }$ classes.
304
+
305
+ ![](images/69b897b915e893b733765d9635c905143dfe176e9884abeaffe561080b77f49c.jpg)
306
+ Figure A: VGG and adversarial G losses for SPADE and OASIS, trained with the perceptual loss
307
+
308
+ # A.3 PER-CLASS IOU SCORES
309
+
310
+ As seen in Table 1 in the main paper, OASIS significantly outperforms previous approaches in mIoU. We found that the improvement comes mainly from the better IoU scores achieved for lessrepresented semantic classes. To illustrate the gain, we report per-class IoU scores on ADE20k, COCO-Stuff and Cityscapes in Tables B, C and D. For visualization purposes, we sorted the semantic classes of all datasets, ordering by their pixel-wise frequency in the training images.
311
+
312
+ Taking ADE20k as an example, Table B highlights that the relative gain in mIoU is especially high for the group of less-represented semantic classes, that cover less than $3 \%$ of all the images. For these rare classes the relative gain over the baseline exceeds $4 0 \%$ . We found that the gain majorly comes from the per-class balancing applied in the OASIS loss function. In order to illustrate this effect, we train OASIS without the proposed balancing. Table B reveals, this baseline reaches a bit higher score for frequent classes, but shows worse performance for the rarely occurring ones. This is expected, as the balancing down-weights the objects met frequently while up-weights infrequent classes. We thus conclude that the balancing draws the attention of the discriminator to rarely occurring semantic classes, which results in a much higher quality of the generation.
313
+
314
+ # A.4 ABLATION ON LABELMIX
315
+
316
+ Consistency regularization for the segmentation output of the discriminator requires a method of generating binary masks. Therefore, we compare the effectiveness of CutMix (Yun et al., 2019) and our proposed LabelMix. Both methods produce binary masks, but only LabelMix respects the boundaries between semantic classes in the label map. Table E compares the FID and mIoU scores of OASIS trained with both methods on the Cityscapes dataset. It can be seen that LabelMix improves both FID (51.5 vs. 47.7) and mIoU (66.3 vs. 69.3), in comparison to OASIS without consistency regularization. CutMix-based consistency regularization only improves the mIoU (66.3 vs. 67.4),
317
+
318
+ Table B: Per-class IoU scores on ADE20k. Bold denotes the best performance.
319
+
320
+ <table><tr><td rowspan=2 colspan=1>Classes IDsOccupied area</td><td rowspan=2 colspan=1>Classes IDsOccupied area</td><td rowspan=1 colspan=3>mIoU</td></tr><tr><td rowspan=1 colspan=1>SPADE+(with VGG)</td><td rowspan=1 colspan=1>OASIS without per-class balancing(without VGG)</td><td rowspan=1 colspan=1>OASIS(without VGG)</td></tr><tr><td rowspan=1 colspan=1>0-29</td><td rowspan=1 colspan=1>86.4%</td><td rowspan=1 colspan=1>63.7</td><td rowspan=1 colspan=1>69.1</td><td rowspan=1 colspan=1>68.8</td></tr><tr><td rowspan=1 colspan=1>30 - 59</td><td rowspan=1 colspan=1>7.2%</td><td rowspan=1 colspan=1>47.4</td><td rowspan=1 colspan=1>52.4</td><td rowspan=1 colspan=1>56.6</td></tr><tr><td rowspan=1 colspan=1>60-89</td><td rowspan=1 colspan=1>3.5%</td><td rowspan=1 colspan=1>45.3</td><td rowspan=1 colspan=1>47.0</td><td rowspan=1 colspan=1>51.5</td></tr><tr><td rowspan=1 colspan=1>90 - 119</td><td rowspan=1 colspan=1>1.8%</td><td rowspan=1 colspan=1>29.3</td><td rowspan=1 colspan=1>36.2</td><td rowspan=1 colspan=1>41.5</td></tr><tr><td rowspan=1 colspan=1>120 - 149</td><td rowspan=1 colspan=1>1.0%</td><td rowspan=1 colspan=1>26.2</td><td rowspan=1 colspan=1>31.2</td><td rowspan=1 colspan=1>39.7</td></tr><tr><td rowspan=1 colspan=1>0-149(all classes)</td><td rowspan=1 colspan=1>100%</td><td rowspan=1 colspan=1>42.4</td><td rowspan=1 colspan=1>47.2</td><td rowspan=1 colspan=1>51.6</td></tr></table>
321
+
322
+ Table D: Per-class IoU scores on Cityscapes.
323
+ Bold denotes the best performance.
324
+
325
+ Table C: Per-class IoU scores on COCO-Stuff. Bold denotes the best performance.
326
+
327
+ <table><tr><td rowspan=2 colspan=1>Classes IDs</td><td rowspan=2 colspan=1>Area</td><td rowspan=1 colspan=2>mIoU</td></tr><tr><td rowspan=1 colspan=1>SPADE+</td><td rowspan=1 colspan=1>OASIS</td></tr><tr><td rowspan=1 colspan=1>0-35</td><td rowspan=1 colspan=1>69.3%</td><td rowspan=1 colspan=1>51.1</td><td rowspan=1 colspan=1>59.0</td></tr><tr><td rowspan=1 colspan=1>36- 69</td><td rowspan=1 colspan=1>15.9%</td><td rowspan=1 colspan=1>43.9</td><td rowspan=1 colspan=1>50.3</td></tr><tr><td rowspan=1 colspan=1>70 - 103</td><td rowspan=1 colspan=1>8.7%</td><td rowspan=1 colspan=1>40.5</td><td rowspan=1 colspan=1>40.9</td></tr><tr><td rowspan=1 colspan=1>104 - 137</td><td rowspan=1 colspan=1>4.5%</td><td rowspan=1 colspan=1>35.9</td><td rowspan=1 colspan=1>36.6</td></tr><tr><td rowspan=1 colspan=1>138 - 171</td><td rowspan=1 colspan=1>1.4%</td><td rowspan=1 colspan=1>22.1</td><td rowspan=1 colspan=1>40.6</td></tr><tr><td rowspan=1 colspan=1>0-171(all classes)</td><td rowspan=1 colspan=1>100%</td><td rowspan=1 colspan=1>38.8</td><td rowspan=1 colspan=1>45.5</td></tr></table>
328
+
329
+ <table><tr><td rowspan=2 colspan=1>Classes IDs</td><td rowspan=2 colspan=1>Area</td><td rowspan=1 colspan=2>mIoU</td></tr><tr><td rowspan=1 colspan=1>SPADE+</td><td rowspan=1 colspan=1>OASIS</td></tr><tr><td rowspan=1 colspan=1>0-2</td><td rowspan=1 colspan=1>75.6%</td><td rowspan=1 colspan=1>91.6</td><td rowspan=1 colspan=1>89.6</td></tr><tr><td rowspan=1 colspan=1>3-6</td><td rowspan=1 colspan=1>18.3%</td><td rowspan=1 colspan=1>75.7</td><td rowspan=1 colspan=1>74.9</td></tr><tr><td rowspan=1 colspan=1>7- 10</td><td rowspan=1 colspan=1>3.9%</td><td rowspan=1 colspan=1>60.0</td><td rowspan=1 colspan=1>66.9</td></tr><tr><td rowspan=1 colspan=1>11 - 14</td><td rowspan=1 colspan=1>1.4%</td><td rowspan=1 colspan=1>60.3</td><td rowspan=1 colspan=1>66.0</td></tr><tr><td rowspan=1 colspan=1>15-18</td><td rowspan=1 colspan=1>0.6%</td><td rowspan=1 colspan=1>38.1</td><td rowspan=1 colspan=1>55.1</td></tr><tr><td rowspan=1 colspan=1>0-18(all classes)</td><td rowspan=1 colspan=1>100%</td><td rowspan=1 colspan=1>63.8</td><td rowspan=1 colspan=1>69.3</td></tr></table>
330
+
331
+ but not as much as LabelMix (69.3). We suspect that since the images are already partitioned through the label map, an additional partition through CutMix results in a dense patchwork of areas that differ by semantic class and real-fake class identity. This may introduce additional label noise during training for the discriminator. To avoid such inconsistency between semantic classes and real-fake identity, the mask of LabelMix is generated according to the label map, providing natural borders between semantic regions, so that the real and fake objects are placed side-by-side without interfering each other. Under LabelMix regularization, the generator is encouraged to respect the natural semantic class boundaries, improving pixel-level realism while also considering the class segment shapes.
332
+
333
+ # A.5 ABLATION ON FEATURE MATCHING LOSS
334
+
335
+ We measure the effect of the feature matching loss (FM) in the absence and presence of the perceptual loss (VGG). Table F and G present the results for OASIS on Cityscapes and SPADE $^ +$ o n ADE20K. For both $\mathrm { S P A D E + }$ and OASIS we observe that the feature matching loss does only affect the FID notably when no perceptual loss is used.
336
+
337
+ In the case where no perceptual loss is used, we observe that the feature matching prolongs the time until $\mathrm { S P A D E + }$ collapses, resulting in a better FID score (49.7 vs 60.7). Consequently, the mIoU also improves. Hence, the role of the FM loss in the training of $\mathrm { S P A D E + }$ is to stabilize the training through additional self-supervision. This observation is in line with the general observation that SPADE and other semantic image synthesis models require the help of additional losses because the adversarial supervision through the discriminator is not strong enough. In comparison, we did not observe any training collapses in OASIS, despite not using any extra losses. For OASIS, the feature matching loss results in a worse FID (by 0.8 points) in the absence of the perceptual loss. We also observe a degradation of 1.1 mIoU points through the FM loss, in the case where the perceptual supervision is present. This indicates that the FM loss negatively affects the strong supervision from the semantic segmentation adversarial loss of OASIS.
338
+
339
+ Table E: Ablation study on the impact of LabelMix and CutMix for consistency regularization (CR) in OASIS on Cityscapes. Bold denotes the best performance.
340
+
341
+ Table G: SPADE $^ +$ on ADE20K. Bold denotes the best performance.
342
+
343
+ <table><tr><td rowspan=1 colspan=1>Transformation</td><td rowspan=1 colspan=1>FID↓</td><td rowspan=1 colspan=1>mIoU↑</td></tr><tr><td rowspan=1 colspan=1>No CR</td><td rowspan=1 colspan=1>51.5</td><td rowspan=1 colspan=1>66.3</td></tr><tr><td rowspan=1 colspan=1>CutMix</td><td rowspan=1 colspan=1>52.1</td><td rowspan=1 colspan=1>67.4</td></tr><tr><td rowspan=1 colspan=1>LabelMix</td><td rowspan=1 colspan=1>47.7</td><td rowspan=1 colspan=1>69.3</td></tr></table>
344
+
345
+ Table F: OASIS on Cityscapes. Bold denotes the best performance.
346
+
347
+ <table><tr><td>VGG</td><td>FM</td><td>FID↓</td><td>mIoU↑</td></tr><tr><td></td><td></td><td>47.7</td><td>69.3</td></tr><tr><td></td><td></td><td>48.5</td><td>69.1</td></tr><tr><td>xxν/</td><td>x/x&#x27;</td><td>46.1</td><td>72.0</td></tr><tr><td></td><td></td><td>46.5</td><td>70.9</td></tr></table>
348
+
349
+ <table><tr><td>VGG</td><td>FM</td><td>FID↓</td><td>mIoU↑</td></tr><tr><td></td><td></td><td>60.7</td><td>21.0</td></tr><tr><td></td><td></td><td>49.7</td><td>32.5</td></tr><tr><td>xx//</td><td>x/x</td><td>32.9</td><td>42.5</td></tr><tr><td></td><td></td><td>32.6</td><td>42.9</td></tr></table>
350
+
351
+ # A.6 ABLATION ON USING MORE THAN ONE OASIS DISCRIMINATOR
352
+
353
+ A major difference between SPADE and OASIS is that OASIS employs only one discriminator, while SPADE uses two PatchGAN discriminators at different scales. Naturally, the question arises how OASIS performs with two discriminators at different scales, as in SPADE. For this, Table H presents the FID and mIoU performance of OASIS with two discriminators operating at scales 1 and 0.5 on Cityscapes. One can see that an additional discriminator at scale 0.5 does not improve performance, but slightly worsens it. The reason that no performance gain is visible is that the OASIS discriminator already encodes multi-scale information through its U-Net structure: skip connections between encoder, decoder and individual blocks integrate information at all scales. In contrast, SPADE requires two discriminators to capture information at different scales.
354
+
355
+ Table H: Comparison of using 1 and 2 discriminators at different scales for OASIS on Cityscapes. Bold denotes the best performance.
356
+
357
+ <table><tr><td># of OASIS D</td><td>FID↓</td><td>mIoU↑</td></tr><tr><td>1discriminator</td><td>47.7</td><td>69.3</td></tr><tr><td>2 discriminators at different scales (1 and 0.5)</td><td>48.7</td><td>68.8</td></tr></table>
358
+
359
+ # A.7 ABLATION ON NOISE SAMPLING STRATEGIES DURING TRAINING
360
+
361
+ Our 3D noise can contain the same sampled vector for each pixel, or different vectors for different regions. This allows for different noise sampling schemes during training. Table I shows the effect of using different methods of sampling 3D noise for different locations during training: Image-level sampling creates one global 1D noise vector and replicates it along the height and width of the label map to create a 3D noise tensor. Region-level sampling relies on generating one 1D noise vector per label, and stacking them in 3D to match the height and width of the label map. Pixel-level sampling creates different noise for every spatial position, with no replication taking place. Mix switches between image-level and region-level sampling via a coin flip decision at every training step. With no obvious winner in performance, we choose the simplest scheme (image-level) for our experiments.
362
+
363
+ By choosing image-level sampling for training, we thus generate a single 1D latent noise vector of size 64, broadcast it to $6 4 \mathrm { x H x W }$ and concatenate with the label map (NxHxW). This new composite tensor is used as input to the 1st generator layer and at all SPADE-norm layers. The noise is not ignored for the following reasons:
364
+
365
+ (1) The noise modulates the activations directly at every layer, so it is very hard to ignore. Here, it is important to emphasize how the noise is used: For SPADE it was observed that label maps are paid more attention to if they are used for location-sensitive conditional batch normalization (CBN). Analogously, we observe that the noise is also paid more attention to when it is injected via CBN. Like label maps, which are 3D tensors of stacked one-hot vectors, we stack noise vectors into a 3D tensor of the same dimensions. Thus, in the same way that SPADE is spatially sensitive to labels, OASIS is spatially sensitive to both labels and noise.
366
+
367
+ (2) The 3D broadcasting strategy provides a spatially uniform signal making it easy to embed semantic meaning into the latent code (see interpolations, Fig. I , J). As noise modulates features at different scales in the generator, matching their resolution, it affects both global and local characteristics. This is why a generator trained with image-level noise can perform region-level manipulation at inference (Fig. F, H). However, more evolved spatial noise sampling schemes can be explored in the future.
368
+
369
+ Table I: Different noise sampling strategies during training. Bold denotes the best performance.
370
+
371
+ <table><tr><td rowspan=2 colspan=1>Sampling</td><td rowspan=2 colspan=4>CityscapesFID↓ mIoU↑ MS-SSIM↓</td><td rowspan=2 colspan=3>CityscapesFID↓ mIoU↑ MS-SSIM↓</td></tr><tr><td rowspan=1 colspan=1>FID↓</td></tr><tr><td rowspan=1 colspan=1>image-level</td><td rowspan=1 colspan=1>47.7</td><td rowspan=1 colspan=1>69.3</td><td rowspan=1 colspan=2>0.64</td><td rowspan=1 colspan=1>28.3</td><td rowspan=1 colspan=1>48.8</td><td rowspan=1 colspan=1>0.65</td></tr><tr><td rowspan=1 colspan=1>region-level</td><td rowspan=1 colspan=1>48.1</td><td rowspan=1 colspan=1>69.7</td><td rowspan=1 colspan=2>0.62</td><td rowspan=1 colspan=1>28.8</td><td rowspan=1 colspan=1>48.1</td><td rowspan=1 colspan=1>0.58</td></tr><tr><td rowspan=1 colspan=1>pixel-level</td><td rowspan=1 colspan=1>50.9</td><td rowspan=1 colspan=1>65.5</td><td rowspan=1 colspan=2>0.84</td><td rowspan=1 colspan=1>28.6</td><td rowspan=1 colspan=1>34.0</td><td rowspan=1 colspan=1>0.68</td></tr><tr><td rowspan=1 colspan=1>mix</td><td rowspan=1 colspan=1>46.4</td><td rowspan=1 colspan=1>70.9</td><td rowspan=1 colspan=2>0.68</td><td rowspan=1 colspan=1>28.5</td><td rowspan=1 colspan=1>47.6</td><td rowspan=1 colspan=1>0.66</td></tr></table>
372
+
373
+ # A.8 ADDITIONAL EXPERIMENTS ON COCO-STUFF
374
+
375
+ We performed all our extensive ablations on ADE20K and Cityscapes, due to their shorter training time. Training on ADE20K and Cityscapes takes circa 10 days on 4 Tesla V100 GPUs while training on COCO-stuff can stretch to 4 weeks. Therefore, we only executed essential experiments on COCOstuff. We compare the results of these experiments in Table J. For $\mathrm { S P A D E + }$ , it can be seen that without the external perceptual supervision of VGG, training collapses (with FID 99.1 at the best checkpoint before collapse). In contrast, for OASIS image quality is better without VGG (16.7 vs 18.0 FID). When 3D noise is added to OASIS, sampling of multi-modal images is enabled (0.61 vs $1 . 0 ~ \mathrm { M S } -$ SSIM), with very similar performance in synthesis quality (17.0 vs 16.7 FID) and slightly worse mIoU (44.1 vs $4 5 . 5 \ \mathrm { m I o U }$ ) due to the increased variation of generated samples, as the semantic segmentation task of the pre-trained segmentation network becomes harder.
376
+
377
+ Table J: Performance on COCO-stuff. Bold denotes the best perfromance.
378
+
379
+ <table><tr><td>Model</td><td>VGG</td><td colspan="3">3D noisel FID↓ mIoU↑ MS-SSIM↓</td></tr><tr><td>SPADE</td><td>√</td><td>X</td><td>22.6 37.4</td><td>1.0</td></tr><tr><td>SPADE+</td><td>×</td><td>×</td><td>99.1 16.1</td><td>1.0</td></tr><tr><td>SPADE+</td><td>√</td><td>×</td><td>21.7 38.8</td><td>1.0</td></tr><tr><td>OASIS</td><td>X</td><td>×</td><td>16.7 45.5</td><td>1.0</td></tr><tr><td>OASIS</td><td>√</td><td>X</td><td>18.0 44.2</td><td>1.0</td></tr><tr><td>OASIS</td><td>X</td><td>√</td><td>17.0 44.1</td><td>0.61</td></tr></table>
380
+
381
+ # A.9 ADDITIONAL EVALUATION METRICS
382
+
383
+ Currently, the FID score is the most widely adopted metric for quantifying image quality of GAN models. However, it is often argued that the FID score does not adequately disentangle synthesis quality and diversity (Kynka¨anniemi et al., 2019). Recently, a series of metrics have been proposed ¨ to address this issue by measuring scores related to the concepts of precision and recall (Ravuri & Vinyals, 2019; Shmelkov et al., 2018; Sajjadi et al., 2018; Kynka¨anniemi et al., 2019). Here, we have ¨ a closer look at the ”improved precision and recall” score proposed by (Kynka¨anniemi et al., 2019), ¨ where precision is the probability that a generated image falls into the estimated support of the real image distribution, and recall is the probability that a real image falls into the estimated support of the generator distribution. Precision and recall can be interpreted as sample quality and diversity. Table K presents a comparison of precision (P) and recall R) between $\mathrm { S P A D E + }$ and OASIS. It can be seen that OASIS outperforms SPADE $^ +$ both in terms of image quality and variety.
384
+
385
+ Table K: Comparison of the precision and recall metric between SPADE $^ +$ and OASIS. Bold denotes the best performance.
386
+
387
+ <table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=2>ADE20KP个 R↑</td><td rowspan=1 colspan=2>ADE-outd.P↑ R↑</td><td rowspan=1 colspan=2>CityscapesP个 R↑</td><td rowspan=1 colspan=2>COCO-StuffP个 R↑</td></tr><tr><td rowspan=1 colspan=1>SPADE+</td><td rowspan=1 colspan=1>0.71</td><td rowspan=1 colspan=1>0.52</td><td rowspan=1 colspan=1>0.62</td><td rowspan=1 colspan=1>0.51</td><td rowspan=1 colspan=1>0.54</td><td rowspan=1 colspan=1>0.34</td><td rowspan=1 colspan=1>0.63</td><td rowspan=1 colspan=1>0.56</td></tr><tr><td rowspan=1 colspan=1>OASIS</td><td rowspan=1 colspan=1>0.77</td><td rowspan=1 colspan=1>0.57</td><td rowspan=1 colspan=1>0.77</td><td rowspan=1 colspan=1>0.56</td><td rowspan=1 colspan=1>0.58</td><td rowspan=1 colspan=1>0.55</td><td rowspan=1 colspan=1>0.67</td><td rowspan=1 colspan=1>0.59</td></tr></table>
388
+
389
+ # B QUALITATIVE RESULTS
390
+
391
+ # B.1 COMPARISON TO OTHER METHODS
392
+
393
+ In this section we present a visual comparison between OASIS and other semantic image synthesis methods. Firstly, we show images generated by SPADE (Park et al., 2019), CC-FPSE (Liu et al., 2019) and OASIS on ADE20k, COCO-Stuff, and Cityscapes (in Figures B, C, and D, respectively). A further comparison for SPADE, SPADE+ and OASIS is presented in Figure E. We observed that OASIS often produces more visually plausible images than the previous methods. Our method commonly produces finer textures, especially for complex and large semantic objects, e.g building facades, mountains, water.
394
+
395
+ We also note that OASIS usually generates brighter and more diverse colors, compared to other methods. As we showed in Section 4 in the main paper, the diversity in colors partially comes from the fact that the feature space of the OASIS generator is not constrained by the VGG loss. We observed that images, generated by SPADE and CC-FPSE, typically have closer colors, while OASIS frequently generates objects with completely different color tones. This also forms one of the failure modes of our approach, when the colors of objects fall out of distribution and seem unnatural (see Figure G).
396
+
397
+ # B.2 MULTI-MODAL IMAGE SYNTHESIS
398
+
399
+ Multi-modal image synthesis for a given label map is easy for OASIS: we simply re-sample noise like in a conventional unconditional GAN model. Since OASIS employs a 3D noise tensor (64- channels $\times$ heigh $\times$ width), the noise can be re-sampled entirely (”globally”) or only for specific regions in the 2D image plane (”locally”). For our visualizations, we replicate a single 64-dimensional noise vector along the spatial dimensions for global sampling. For local sampling, we re-sample a new noise vector and use it to replace the global noise vector at every spatial position within a restricted area of interest. The results are shown in Figure F. The generated images are diverse and of high quality. We observe different degrees of variety for different object classes. For example, buildings change drastically in appearance and often change their spatial orientation with respect to the road. On the other side, many common objects (like tables) vary in color, texture, and illumination, but do not change shapes as they are restricted by the fine details of the region that is outlined for them in the label map.
400
+
401
+ Local noise re-sampling does not have to be restricted to only semantic class areas: in Figure H we sample a different noise vector for the left and right half of the image, as well as for arbitrarily shaped regions. In effect, the two areas can differ substantially. However, often a bridging element is found between two areas, such as clouds extending partly from one region to the other region of the image.
402
+
403
+ # B.3 LATENT SPACE INTERPOLATIONS
404
+
405
+ In Figure I we present images that are the results of linear interpolations in the latent space (see Fig. I), using an OASIS model trained on the ADE20K dataset. To generate the images, we sample two noise vectors $z \in \mathbb { R } ^ { 6 4 }$ and interpolate them with three intermediate points. The images are synthesized for these five different noise inputs while the label map is held fixed. Note that in Figure I we only vary the noise globally, not locally (See Section 3.3 in the main paper). In contrast, Figure J shows local interpolations. For this, we only re-sample the 3D noise in the area corresponding to a single semantic class. The effect is that only the appearance of the selected semantic class varies while the rest of the image remains fixed. It can be observed that strong changes in a local area can slightly affect the surroundings if the local area is also very big. As such, the clouds are slightly different in the first and last panel of the mountain row and tree row in Figure J.
406
+
407
+ We see from Figure I and J that the trajectories in the latent space are smooth and semantically meaningful. For example, we observe transitions from winter to summer, day to night, green trees to leafless trees, shiny parquet to matt carpet, as well as smooth transitions between buildings with different architectural styles.
408
+
409
+ # B.4 APPLICATION TO UNLABELLED DATA
410
+
411
+ OASIS has a unique property that its discriminator is trained to be an image segmenter. We observed that it shows good performance on this task, reaching the mIoU of 40.0 on ADE20K validation set. For comparison, current state of the art on ADE20K is a mIoU of 46.91, achieved by ResNeST (Zhang et al., 2020). Such a good segmentation performance allows OASIS to be applied to unlabelled images: given an unseen image without a ground truth annotation, OASIS can predict a label map via the discriminator. Subsequently feeding this prediction to the generator allows to synthesize a scene with the same layout but different style. This property is shown in Fig. K. Due to the good segmentation performance, the recreated scenes closely follow the ground truth label map of the original image. The high sensitivity of OASIS to the 3D noise enforces good variability, so the recreations are different from each other. We believe that creating multiple versions of one image while retaining the layout can be useful for data-augmentation.
412
+
413
+ # B.5 LABELMIX
414
+
415
+ Figure L shows additional visual examples of LabelMix regularization, as described in Section 3.2 in the main paper. It can be seen that the discriminator prediction on the mixed images often differs from the mix of individual predictions on real and fake images. In particular, regions that are classified as real in the latter are classified as fake when the images are mixed. This means that the discriminator takes the global context into account for local predictions and thereby often bases the prediction on arbitrary details that should not affect the real-fake class identity. In return, the consistency regularization helps to minimize the difference between these two predictions.
416
+
417
+ ![](images/e50c53e283617bfeef899b2a45f7d86bcf07a02a7b5fa04631fddcf58fda726c.jpg)
418
+ Figure B: Qualitative comparison of OASIS with other methods on ADE20K.
419
+
420
+ ![](images/221ce18936dfe0da7c4a8c36c752725a08611e0dd58386e47ee6a3e103c0e2f9.jpg)
421
+ Figure C: Qualitative comparison of OASIS with other methods on COCO-Stuff.
422
+
423
+ ![](images/399f3a9f3e87062760176e240e479e3894594ad019bb8fcdbc9dc3d6de2b8560.jpg)
424
+ Figure D: Qualitative comparison of OASIS with other methods on Cityscapes.
425
+
426
+ ![](images/936d6b871373ed940973834ef9d4dd846c2f5f7cc58540d53fc1321f52ea8379.jpg)
427
+ Figure E: Qualitative comparison of OASIS with SPADE and SPADE $^ +$ using ADE20K (row 1-3), COCO-stuff (row 4-6) and Cityscapes (row 7-9).
428
+
429
+ ![](images/4ec13a1c49a3ebe17b625f551ab0220c46d66fdc276e9fc6d8d06c6ca4a6bb0c.jpg)
430
+ Figure F: Images generated by OASIS on ADE20K with $2 5 6 \times 2 5 6$ resolution using different 3D noise inputs. For each label map the noise is re-sampled globally (first row) or locally in the areas marked in red (second row). Note that the images are not stitched together but generated in single forward passes.
431
+
432
+ ![](images/e6e6792e352a4549ea9f5cb014ff4704f4949d971a754709b2c426a071f3c230.jpg)
433
+ Figure G: Failure mode of OASIS. Our model generates diverse images, sometimes producing object with outlier colors and textures. We compare to Park et al. (2019) and Liu et al. (2019).
434
+
435
+ ![](images/920e592673c7690bf09dcf8a4b9f82eccfb6fa7efb8bd7949ecd221f9c363508.jpg)
436
+ Figure H: Images generated by OASIS in one forward pass (no collage), with different noise vectors for different image regions.
437
+
438
+ ![](images/a5f108b01e438a6ee73b3af288d549001e8cfc2459938fd48d7701559489d0e9.jpg)
439
+ Figure I: Global latent space interpolations between images generated by OASIS for various outdoor and indoor scenes in the ADE20K dataset at resolution $2 5 6 \times 2 5 6$ .
440
+
441
+ ![](images/9a5e4e46440c67344a51893b1752d01a18d8b0e5a2a07e684d30473ab5301c7d.jpg)
442
+ Figure J: Latent space interpolations in local regions of the 3D noise, corresponding to a single semantic class. The noise is only changed within the restricted area. Trained on the ADE20K dataset at resolution $2 5 6 \times 2 5 6$ .
443
+
444
+ ![](images/5f120d2929c5a476e0f6d3cd550c83758db35a85776e17cd1a58cb16c70e6018.jpg)
445
+ Figure K: After training, the OASIS discriminator can be used to segment images. Columns 1- 3 show the ground truth label map, real image, and segmentation of the discriminator. Using the predicted label map the generator can produce multiple versions of the original image by resampling noise (Recreations 1-3). Note that this alleviates the need of ground truth maps during inference.
446
+
447
+ ![](images/3a1a6e3b6a99e65601b5d029d316bc29e9f03b8f632ba7a7e0494050e27e6219.jpg)
448
+ Figure L: Visual examples of LabelMix regularization. Real $x$ and fake $\hat { x }$ images are mixed using a binary mask $M$ , sampled based on the label map, resulting in LabelMix $( x , { \hat { x } } )$ . The consistency regularization then minimizes the distance between the logits of DLabelMix(x,xˆ) and L $\mathrm { \ a b e l M i x } _ { ( D _ { x } , D _ { \hat { x } } ) }$ . In this visualization, black corresponds to the fake class in the $N { + 1 }$ segmentation output.
449
+
450
+ # C ARCHITECTURAL AND TRAINING DETAILS
451
+
452
+ The architecture of OASIS builds upon SPADE Park et al. (2019). In the following, we describe in detail our proposed changes to the discriminator and the generator.
453
+
454
+ # C.1 DISCRIMINATOR ARCHITECTURE
455
+
456
+ This OASIS discriminator follows a U-Net architecture and is built from ResNet blocks, inspired in their design by Brock et al. (2019). The architecture of the OASIS discriminator is outlined in Table L. It has in total 22M learnable parameters and is bigger than the multi-scale PatchGAN discriminator (5.5M) used by SPADE Park et al. (2019). The increased capacity of the OASIS discriminator allows it to learn a more powerful representation and provide more informative feedback to the generator.
457
+
458
+ Table L: The OASIS discriminator. N refers to the number of semantic classes.
459
+
460
+ <table><tr><td>Operation</td><td>Input</td><td>Size</td><td>Output</td><td>Size</td></tr><tr><td>ResBlock-Down</td><td>image</td><td>(3,256,256)</td><td>down_1</td><td>(128,128,128)</td></tr><tr><td>ResBlock-Down</td><td>down_1</td><td>(128,128,128)</td><td>down_2</td><td>(128,64,64)</td></tr><tr><td>ResBlock-Down</td><td>down_2</td><td>(128,64,64)</td><td>down_3</td><td>(256,32,32)</td></tr><tr><td>ResBlock-Down</td><td>down_3</td><td>(256,32,32)</td><td>down_4</td><td>(256,16,16)</td></tr><tr><td>ResBlock-Down</td><td>down_4</td><td>(256,16,16)</td><td>down_5</td><td>(512,8,8)</td></tr><tr><td>ResBlock-Down</td><td>down_5</td><td>(512,8,8)</td><td>down_6</td><td>(512,4,4)</td></tr><tr><td>ResBlock-Up</td><td>down_6</td><td>(512,4,4)</td><td>up_1</td><td>(512,8,8)</td></tr><tr><td>ResBlock-Up</td><td>cat(up_1, down_5)</td><td>(1024,8,8)</td><td>up_2</td><td>(256,16,16)</td></tr><tr><td>ResBlock-Up</td><td>cat(up_2, down_4)</td><td>(512,16,16)</td><td>up_3</td><td>(256,32,32)</td></tr><tr><td>ResBlock-Up</td><td>cat(up_3, down_3)</td><td>(512,32,32)</td><td>up_4</td><td>(128,64,64)</td></tr><tr><td>ResBlock-Up</td><td>cat(up_4, down_2)</td><td>(256,64,64)</td><td>up_5</td><td>(128,128,128)</td></tr><tr><td>ResBlock-Up</td><td>cat(up_5, down_1)</td><td>(256,128,128)</td><td>up_6</td><td>(64,256,256)</td></tr><tr><td>Conv2D</td><td>up_6</td><td>(64,256,256)</td><td>out</td><td>(N+1,256,256)</td></tr></table>
461
+
462
+ # C.2 GENERATOR ARCHITECTURE
463
+
464
+ The generator architecture is built from SPADE ResNet blocks and includes a concatenation of 3D noise with the label map along the channel dimension as an option. The generator can be either trained directly on the label maps or with 3D noise concatenated to the label maps. The latter option is shown in Table M.
465
+
466
+ OASIS generator drops the first residual block used in Park et al. (2019), which decreases the number of learnable parameters from 96M to 72M. The optional 3D noise injection brings additionally 2M parameters. This sampling scheme is five times lighter than the image encoder used by SPADE (10M).
467
+
468
+ # C.3 LEARNING OBJECTIVE AND TRAINING DETAILS
469
+
470
+ Learning objective. We train our model with $( N { + } 1 )$ -class cross entropy as an adversarial loss. Additionally, the discriminator is regularized with the proposed LabelMix consistency regularization. The full OASIS learning objective thus takes the following form:
471
+
472
+ $$
473
+ \begin{array} { l } { { \displaystyle { \mathcal E } _ { G } ^ { 0 \mathrm { A S I S } } = - { \mathbb E } _ { ( z , t ) } \left[ \displaystyle { \sum _ { c = 1 } ^ { N } \alpha _ { c } \sum _ { i , j } ^ { H \times W } t _ { i , j , c } \log D ( G ( z , t ) ) _ { i , j , c } } \right] } , } \\ { { \displaystyle { \mathcal E } _ { D } ^ { 0 \mathrm { A S I S } } = - { \mathbb E } _ { ( x , t ) } \left[ \displaystyle { \sum _ { c = 1 } ^ { N } \alpha _ { c } \sum _ { i , j } ^ { H \times W } t _ { i , j , c } \log D ( x ) _ { i , j , c } } \right] - { \mathbb E } _ { ( z , t ) } \left[ \displaystyle { \sum _ { i , j } ^ { H \times W } \log D ( G ( z , t ) ) _ { i , j , c = N + 1 } } \right] + } } \\ { { \displaystyle \qquad + \lambda _ { \mathrm { L M } } \Big \| D _ { \mathrm { l o g i t s } } \Big ( \mathrm { L a b e l M i x } ( x , \hat { x } , M ) \Big ) - \mathrm { L a b e l M i x } \Big ( D _ { \mathrm { l o g i t s } } ( x ) , D _ { \mathrm { l o g i t s } } ( \hat { x } ) , M \Big ) \Big \| _ { 2 } ^ { 2 } , } } \end{array}
474
+ $$
475
+
476
+ where $x$ denotes the real image and $( z , t )$ is the noise-label map.
477
+
478
+ Table M: The OASIS generator. N refers to the number of semantic classes, z is noise sampled from a unit Gaussian, y is the label map, interp interpolates a given input to the appropriate spatial dimensions of the current layer.
479
+
480
+ <table><tr><td>Operation</td><td>Input</td><td>Size</td><td>Output Size</td><td></td></tr><tr><td>Concatenate</td><td>z_3D Y</td><td>(64,256,256) (N,256,256)</td><td>Z-Y</td><td>(64+N,256,256)</td></tr><tr><td>Conv2D</td><td>interp(z-y)</td><td>(64+N,8,8)</td><td>X</td><td>(1024,8,8)</td></tr><tr><td>SPADE-ResBlock</td><td>X interp(z-y)</td><td>(1024,8,8) (64+N,8,8)</td><td>up_1</td><td>(1024,16,16)</td></tr><tr><td>SPADE-ResBlock</td><td>up_1 interp(z-y)</td><td>(1024,16,16) (64+N,16,16)</td><td>up_2</td><td>(512,32,32)</td></tr><tr><td>SPADE-ResBlock</td><td>up_2 interp(z-y)</td><td>(512,32,32) (64+N,32,32)</td><td>up_3</td><td>(256,64,64)</td></tr><tr><td>SPADE-ResBlock</td><td>up_3 interp(z-y)</td><td>(256,64,64) (64+N,64,64)</td><td>up_4</td><td>(128,128,128)</td></tr><tr><td>SPADE-ResBlock</td><td>up_4 interp(z-y)</td><td>(128,128,128) (64+N,128,128)</td><td>up_5</td><td>(64,256,256)</td></tr><tr><td>Conv2D,LeakyRelu, TanH</td><td>up_5</td><td>(64,256,256)</td><td>X</td><td>(3,256,256)</td></tr></table>
481
+
482
+ Our objective function is different from SPADE. Their model uses hinge adversarial loss and adds the VGG perceptual loss and a feature matching loss to train the generator. For an easier comparison, we provide the objective function of SPADE:
483
+
484
+ $$
485
+ \begin{array} { r l } & { \mathcal { L } _ { G } ^ { \mathrm { S P A D E } } = - \mathbb { E } _ { ( z , t ) } \left[ D ( t , G ( z , t ) ) \right] + \lambda _ { \mathrm { F M } } \mathbb { E } _ { ( z , t , x ) } \displaystyle \sum _ { i = 1 } ^ { T } \| D _ { k } ^ { ( i ) } ( t , x ) - D _ { k } ^ { ( i ) } ( t , G ( z , t ) ) \| _ { 1 } + } \\ & { ~ + \lambda _ { \mathrm { V G G } } \mathbb { E } _ { ( z , t , x ) } \displaystyle \sum _ { i = 1 } ^ { N } \| F ^ { ( i ) } ( x ) - F ^ { ( i ) } ( G ( z , t ) ) \| _ { 1 } , } \\ & { \mathcal { L } _ { D } ^ { \mathrm { S P A D E } } = - \mathbb { E } _ { ( t , x ) } \left[ \operatorname* { m i n } _ { \ldots \ldots \ldots } ( D , - 1 + D _ { i } ( t , x ) ) \right] - \mathbb { E } _ { ( z , t ) } \left[ \operatorname* { m i n } ( 0 , - 1 - \log D ( t , G ( z , t ) ) \right] , } \end{array}
486
+ $$
487
+
488
+ Training details. We follow the experimental setting of (Park et al., 2019). The image resolution is set to $2 5 6 \mathrm { x } 2 5 6$ for ADE20K and COCO-Stuff and 256x512 for Cityscapes. The Adam (Kingma & Ba, 2015) optimizer was used with momentums $\beta ~ = ~ ( 0 , 0 . 9 9 9 )$ and constant learning rates $( 0 . 0 0 0 1 , 0 . 0 0 0 4 )$ for $G$ and $D$ . We did not apply the GAN feature matching loss, and used the VGG perceptual loss only for ablations with $\lambda _ { \mathrm { V G G } } = 1 0$ . The coefficient for LabelMix $\lambda _ { \mathrm { L M } }$ was set to 5 for ADE20k and Cityscapes, and to 10 for COCO-Stuff. All our models use an exponential moving average (EMA) of the generator weights with 0.9999 decay (Brock et al., 2019). All the experiments were run on 4 Tesla V100 GPUs, with a batch size of 20 for Cityscapes, and 32 for ADE20k and COCO-Stuff. The training epochs are 200 on ADE20K and Cityscapes, and 100 for the larger COCO-Stuff dataset. On average, a complete forward-backward pass with batch size 32 on Ade20k takes around $0 . 9 5 \mathrm { m s }$ per training image.
md/train/zv-typ1gPxA/zv-typ1gPxA.md ADDED
@@ -0,0 +1,393 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RETRIEVAL-AUGMENTED GENERATION FOR CODE SUMMARIZATION VIA HYBRID GNN
2
+
3
+ Shangqing Liu1∗, Yu Chen2†, Xiaofei Xie1†, Jingkai Siow1, Yang Liu1
4
+ 1 Nanyang Technology University
5
+ 2 Rensselaer Polytechnic Institute
6
+
7
+ # ABSTRACT
8
+
9
+ Source code summarization aims to generate natural language summaries from structured code snippets for better understanding code functionalities. However, automatic code summarization is challenging due to the complexity of the source code and the language gap between the source code and natural language summaries. Most previous approaches either rely on retrieval-based (which can take advantage of similar examples seen from the retrieval database, but have low generalization performance) or generation-based methods (which have better generalization performance, but cannot take advantage of similar examples). This paper proposes a novel retrieval-augmented mechanism to combine the benefits of both worlds. Furthermore, to mitigate the limitation of Graph Neural Networks (GNNs) on capturing global graph structure information of source code, we propose a novel attention-based dynamic graph to complement the static graph representation of the source code, and design a hybrid message passing GNN for capturing both the local and global structural information. To evaluate the proposed approach, we release a new challenging benchmark, crawled from diversified large-scale open-source $C$ projects (total $\mathbf { 9 5 k + }$ unique functions in the dataset). Our method achieves the state-of-the-art performance, improving existing methods by 1.42, 2.44 and 1.29 in terms of BLEU-4, ROUGE-L and METEOR.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ With software growing in size and complexity, developers tend to spend nearly $90 \%$ (Wan et al., 2018) effort on software maintenance (e.g., version iteration and bug fix) in the completed life cycle of software development. Source code summary, in the form of natural language, plays a critical role in the comprehension and maintenance process and greatly reduces the effort of reading and comprehending programs. However, manually writing code summaries is tedious and timeconsuming, and with the acceleration of software iteration, it has become a heavy burden for software developers. Hence, source code summarization which automates concise descriptions of programs is meaningful.
14
+
15
+ Automatic source code summarization is a crucial yet far from the settled problem. The key challenges include: 1) the source code and the natural language summary are heterogeneous, which means they may not share common lexical tokens, synonyms, or language structures and 2) the source code is complex with complicated logic and variable grammatical structure, making it hard to learn the semantics. Conventionally, information retrieval (IR) techniques have been widely used in code summarization (Eddy et al., 2013; Haiduc et al., 2010; Wong et al., 2015; 2013). Since code duplication (Kamiya et al., 2002; Li et al., 2006) is common in “big code” (Allamanis et al., 2018), early works summarize the new programs by retrieving the similar code snippet in the existing code database and use its summary directly. Essentially, the retrieval-based approaches transform the code summarization to the code similarity calculation task, which may achieve promising performance on similar programs, but are limited in generalization, i.e. they have poorer performance on programs that are very different from the code database.
16
+
17
+ To improve the generalization performance, recent works focus on generation-based approaches. Some works explore Seq2Seq architectures (Bahdanau et al., 2014; Luong et al., 2015) to generate summaries from the given source code. The Seq2Seq-based approaches (Iyer et al., 2016; Hu et al., 2018a; Alon et al., 2018) usually treat the source code or abstract syntax tree parsed from the source code as a sequence and follow a paradigm of encoder-decoder with the attention mechanism for generating a summary. However, these works only rely on sequential models, which are struggling to capture the rich semantics of source code e.g., control dependencies and data dependencies. In addition, generation-based approaches typically cannot take advantage of similar examples from the retrieval database, as retrieval-based approaches do.
18
+
19
+ To better learn the semantics of the source code, Allamanis et al. (Allamanis et al., 2017) lighted up this field by representing programs as graphs. Some follow-up works (Fernandes et al., 2018) attempted to encode more code structures (e.g., control flow, program dependencies) into code graphs with graph neural networks (GNNs), and achieved the promising performance than the sequencebased approaches. Existing works (Allamanis et al., 2017; Fernandes et al., 2018) usually convert code into graph-structured input during preprocessing, and directly consume it via modern neural networks (e.g., GNNs) for computing node and graph embeddings. However, most GNN-based encoders only allow message passing among nodes within a $k$ -hop neighborhood (where $k$ is usually a small number such as 4) to avoid over-smoothing (Zhao & Akoglu, 2019; Chen et al., 2020a), thus capture only local neighborhood information and ignore global interactions among nodes. Even there are some works (Li et al., 2019) that try to address this challenging with deep GCNs (i.e., 56 layers) (Kipf & Welling, 2016) by the residual connection (He et al., 2016), however, the computation cost cannot endure in the program especially for a large and complex program.
20
+
21
+ To address these challenges, we propose a framework for automatic code summarization, namely Hybrid GNN (HGNN). Specifically, from the source code, we first construct a code property graph (CPG) based on the abstract syntax tree (AST) with different types of edges (i.e., Flow To, Reach). In order to combine the benefits of both retrieval-based and generation-based methods, we propose a retrieval-based augmentation mechanism to retrieve the source code that is most similar to the current program from the retrieval database (excluding the current program itself), and add the retrieved code as well as the corresponding summary as auxiliary information for training the model. In order to go beyond local graph neighborhood information, and capture global interactions in the program, we further propose an attention-based dynamic graph by learning global attention scores (i.e., edge weights) in the augmented static CPG. Then, a hybrid message passing (HMP) is performed on both static and dynamic graphs. We also release a new code summarization benchmark by crawling data from popular and diversified projects containing $\mathbf { 9 5 k + }$ functions in $C$ programming language and make it public 1. We highlight our main contributions as follows:
22
+
23
+ • We propose a general-purpose framework for automatic code summarization, which combines the benefits of both retrieval-based and generation-based methods via a retrieval-based augmentation mechanism.
24
+ • We innovate a Hybrid GNN by fusing the static graph (based on code property graph) and dynamic graph (via structure-aware global attention mechanism) to mitigate the limitation of the GNN on capturing global graph information.
25
+ • We release a new challenging $C$ benchmark for the task of source code summarization.
26
+ • We conduct an extensive experiment to evaluate our framework. The proposed approach achieves the state-of-the-art performance and improves existing approaches by 1.42, 2.44 and 1.29 in terms of BLEU-4, ROUGE-L and METEOR metrics.
27
+
28
+ # 2 HYBRID GNN FRAMEWORK
29
+
30
+ In this section, we introduce the proposed framework Hybrid GNN (HGNN), as shown in Figure 1, which mainly includes four components: 1) Retrieval-augmented Static Graph Construction $( c . f .$ , Section 2.2), which incorporates retrieved code-summary pairs to augment the original code for learning. 2) Attention-based Dynamic Graph Construction $\cdot c . f .$ , Section 2.3), which allows message passing among any pair of nodes via a structure-aware global attention mechanism. 3) HGNN, $( c . f .$
31
+
32
+ ![](images/67270edb63893de2c823bd6b296d28457864a196600edd32ca6318547e24e833.jpg)
33
+ Figure 1: The overall architecture of the proposed HGNN framework.
34
+
35
+ Section 2.4), which incorporates information from both static graphs and dynamic graphs with Hybrid Message Passing. 4) Decoder $\cdot f .$ , Section 2.5), which utilizes an attention-based LSTM (Hochreiter & Schmidhuber, 1997) model to generate a summary.
36
+
37
+ # 2.1 PROBLEM FORMULATION
38
+
39
+ In this work, we focus on generating natural language summaries for the given functions (Wan et al., 2018; Zhang et al., 2020). A simple example is illustrated in Listing 1, which is crawled from Linux Kernel. Our goal is to generate the best summary “set the time of day clock” based on the given source code. Formally, we define a dataset as $D = \{ ( c , s ) | c \in C , s \in S \}$ , where $c$ is the source code of a function in the function set $C$ and $s$ represents its targeted summary in the summary set $S$ . The task of code summarization is, given a source code $c$ , to generate the best summary consisting of a sequence of tokens $\hat { s } = ( t _ { 1 } , t _ { 2 } , . . . , t _ { T } )$ that maximizes the conditional likelihood $\hat { s } = \mathrm { a r g m a x } _ { s } P ( s | c )$ .
40
+
41
+ ![](images/de9e235655b5495ca7886df50a290477a93cacb7df5787c32648c2989857d443.jpg)
42
+ Listing 1: An example in our dataset crawled from Linux Kernel.
43
+
44
+ # 2.2 RETRIEVAL-AUGMENTED STATIC GRAPH
45
+
46
+ # 2.2.1 GRAPH INITIALIZATION
47
+
48
+ The source code of a function can be represented as Code Property Graph (CPG) (Yamaguchi et al., 2014), which is built on the abstract syntax tree (AST) with different type of edges (i.e., Flow To, Control, Define/Use, Reach). Formally, one raw function $c$ could be represented by a multi-edged graph $g ( \mathcal { V } , \mathcal { E } )$ , where $\nu$ is the set of AST nodes, $( v , u ) \in \mathcal { E }$ denotes the edge between the node $v$ and the node $u$ . A node $v$ consists of two parts: the node sequence and the node type. An illustrative example is shown in Figure 2. For example, in the red node, $a \% 2 = = 0$ is the node sequence and Condition is the node type. An edge $( v , u )$ has a type, named edge type, e.g., AST type and Flow To type. For more details about the CPG, please refer to Appendix A.
49
+
50
+ Initialization Representation. Given a CPG, we utilize a BiLSTM to encode its nodes. We represent each token of the node sequence and each edge type using the learned embedding matrix $E ^ { s e q t o k e n }$ and $E ^ { e d g e t y p e }$ , respectively. Then nodes and edges of the CPG can be encoded as:
51
+
52
+ $$
53
+ \begin{array} { r } { h _ { 1 } , . . . , h _ { l } = \mathrm { B i L S T M } ( E _ { v , 1 } ^ { s e q t o k e n } , . . . , E _ { v , l } ^ { s e q t o k e n } ) } \\ { e n c o d e \_ n o d e ( v ) = [ { h } _ { l } ^ { \right. } ; { h } _ { 1 } ^ { \left. } ] \quad \quad } \end{array}
54
+ $$
55
+
56
+ ![](images/1f65e53fb376534af98285be7a60b636f01f3e756c105b663fcf47da0d26adcb.jpg)
57
+ Figure 2: An example of Code Property Graph (CPG).
58
+
59
+ where $l$ is the number of tokens in the node sequence of $v$ . For the sake of simplicity, in the following section, we use $h _ { v }$ and $e _ { v , u }$ to represent the embedding of the node $v$ and the edge $( v , u )$ , respectively, i.e., encode_node $( v )$ and encode_edge $( v , u )$ . Given the source code $c$ of a function as well as the CPG $g ( \mathcal { V } , \mathcal { E } )$ , $\pmb { H } _ { c } \in \mathbb { R } ^ { m \times d }$ denotes the initial node matrix of the CPG, where $m$ is the total number of nodes in the CPG and $d$ is the dimension of the node embedding.
60
+
61
+ # 2.2.2 RETRIEVAL-BASED AUGMENTATION
62
+
63
+ While retrieval-based methods can perform reasonably well on examples that are similar to those examples from a retrieval database, they typically have low generalization performance and might perform poorly on dissimilar examples. On the contrary, generation-based methods usually have better generalization performance, but cannot take advantage of similar examples from the retrieval database. In this work, we propose to combine the benefits of the two worlds, and design a retrieval-augmented generation framework for the task of code summarization.
64
+
65
+ In principle, the goal of code summarization is to learn a mapping from source code $c$ to the natural language summary $s = f ( c )$ . In other words, for any source code $c ^ { \prime }$ , a code summarization system can produce its summary $s ^ { \prime } = f ( c ^ { \prime } )$ . Inspired by this observation, conceptually, we can derive the following formulation $s = f ( c ) - f ( c ^ { \prime } ) + s ^ { \prime }$ . This tells us that we can actually compute the semantic difference between $c$ and $c ^ { \prime }$ , and further obtain the desired summary $s$ for $c$ by considering both the above semantic difference and $s ^ { \prime }$ which is the summary for $c ^ { \prime }$ . Mathmatically, our goal becomes to learn a function which takes as input $( c , c ^ { \prime } , s ^ { \prime } )$ , and outputs the summary $s$ for $c$ , that is, $s = g ( c , c ^ { \prime } , s ^ { \prime } )$ . This motivates us to design our Retrieval-based Augmentation mechanism, as detailed below.
66
+
67
+ Step 1: Retrieving. For each sample $( c , s ) \in D$ , we retrieve the most similar sample: $( c ^ { \prime } , s ^ { \prime } ) =$ $\underset { . } { \mathrm { a r g m a x } } _ { ( c ^ { \prime } , s ^ { \prime } ) \in D ^ { \prime } } s i m ( \underline { { c } } , c ^ { \prime } )$ , where $c \neq c ^ { \prime }$ , $D ^ { \prime }$ is a given retrieval database and $s i m ( c , c ^ { \prime } )$ is the text similarity. Following Zhang et al. (2020), we utilize Lucene for retrieval and calculate the similarity score $z$ between the source code $c$ and the retrieved code $c ^ { \prime }$ via dynamic programming (Bellman, 1966), namely, $\begin{array} { r } { z = 1 - \frac { d i s ( c , c ^ { \prime } ) } { m a x ( | c | , | c ^ { \prime } | ) } } \end{array}$ , where $d i s ( c , c ^ { \prime } )$ is the text edit distance.
68
+
69
+ Step 2: Retrieved Code-based Augmentation. Given the retrieved source code $c ^ { \prime }$ for the current sample $c$ , we adopt a fusion strategy to inject retrieved semantics into the current sample. The fusion strategy is based on their initial graph representations ( ${ \mathbf { } } _ { . } H _ { c }$ and $\pmb { H } _ { c ^ { \prime } }$ ) with an attention mechanism:
70
+
71
+ • To capture the relevance between $c$ and $c ^ { \prime }$ , we design an attention function, which computes the attention score matrix $A ^ { a u g }$ based on the embeddings of each pair of nodes in CPGs of $c$ and $c ^ { \prime }$ :
72
+
73
+ $$
74
+ A ^ { a u g } \propto \mathrm { e x p } ( \mathrm { R e L U } ( H _ { c } W ^ { C } ) \mathrm { R e L U } ( H _ { c ^ { \prime } } W ^ { Q } ) ^ { T } )
75
+ $$
76
+
77
+ where $W ^ { C } , W ^ { Q } \in \mathbb { R } ^ { d \times d }$ is the weight matrix with $d$ -dim embedding size and ReLU is the rectified linear unit.
78
+
79
+ • We then multiply the attention matrix $A ^ { a u g }$ with the retrieved representation $\pmb { H } _ { c ^ { \prime } }$ to inject the retrieved features into $\pmb { H } _ { c }$ :
80
+
81
+ $$
82
+ \pmb { H } _ { c } ^ { \prime } = z \pmb { A } ^ { a u g } \pmb { H } _ { c ^ { \prime } }
83
+ $$
84
+
85
+ where $z \in [ 0 , 1 ]$ is the similarity score and computed from Step 1, which is introduced to weaken the negative impact of $c ^ { \prime }$ on the original training data $c$ , i.e., when the similarity of $c$ and $c ^ { \prime }$ is low.
86
+
87
+ • Finally, we merge $\pmb { H } _ { c } ^ { \prime }$ and the original $\pmb { H } _ { c }$ to get the final representation of $c$
88
+
89
+ $$
90
+ c o m p = H _ { c } + H _ { c } ^ { \prime }
91
+ $$
92
+
93
+ where comp is the augmented node representation additionally encoding the retrieved semantics.
94
+
95
+ Step 3: Retrieved Summary-based Augmentation. We further encode the retrieved summary $s ^ { \prime }$ with another BiLSTM model. We represent each token $t _ { i } ^ { \prime }$ of $s ^ { \prime }$ using the learned embedding matrix $E ^ { s e q t o k e n }$ . Then $s ^ { \prime }$ can be encoded as:
96
+
97
+ $$
98
+ h _ { t _ { 1 } ^ { \prime } } , . . . , h _ { t _ { T } ^ { \prime } } = \mathrm { B i L S T M } ( E _ { t _ { 1 } ^ { \prime } } ^ { s e q t o k e n } , . . . , E _ { t _ { T } ^ { \prime } } ^ { s e q t o k e n } )
99
+ $$
100
+
101
+ where $\boldsymbol { h } _ { t _ { i } ^ { \prime } }$ is the hidden state of the BiLSTM model for the token $t _ { i } ^ { \prime }$ in $s ^ { \prime }$ and $T$ is the length of $s ^ { \prime }$ . We multiply $[ h _ { t _ { 1 } ^ { \prime } } ; . . . ; h _ { t _ { T } ^ { \prime } } ]$ with the similarity score $z$ , computed from Step 1, and concatenate it with the graph encoding results (i.e., the GNN encoder outputs) to obtain the input, namely, [GNNoutput; $z h _ { t _ { 1 } ^ { \prime } } ; . . . ; z h _ { t _ { T } ^ { \prime } } ]$ , to the decoder.
102
+
103
+ # 2.3 ATTENTION-BASED DYNAMIC GRAPH
104
+
105
+ Due to that GNN-based encoders usually consider the $k$ -hop neighborhood, the global relation among nodes in the static graph (see Section 2.2.1) may be ignored. In order to better capture the global semantics of source code, based on the static graph, we propose to dynamically construct a graph via structure-aware global attention mechanism, which allows message passing among any pair of nodes. The attention-based dynamic graph can better capture the global dependency among nodes, and thus supplement the static graph.
106
+
107
+ Structure-aware Global Attention. The construction of the dynamic graph is motivated by the structure-aware self-attention mechanism proposed in Zhu et al. (2019). Given the static graph, we compute a corresponding dense adjacency matrix $A ^ { d y n }$ based on a structure-aware global attention mechanism, and obtain the constructed graph, namely, attention-based dynamic graph.
108
+
109
+ $$
110
+ A _ { v , u } ^ { d y n } = \frac { \mathrm { R e L U } ( h _ { v } ^ { T } W ^ { Q } ) ( \mathrm { R e L U } ( h _ { u } ^ { T } W ^ { K } ) + \mathrm { R e L U } ( e _ { v , u } ^ { T } W ^ { R } ) ) ^ { T } } { \sqrt { d } }
111
+ $$
112
+
113
+ where $h _ { v } , h _ { u } \in c o m p$ are the augmented node embedding for any node pair $( v , u )$ in the CPG. Note that the global attention considers each pair of nodes of the CPG, regardless of whether there is an edge between them. $e _ { v , u } \in \mathbb { R } ^ { d _ { e } }$ is the edge embedding and $W ^ { Q }$ , $W ^ { \breve { K } } \in \mathbb { R } ^ { d \times d }$ , $W ^ { R } \in \mathbb { R } ^ { d _ { e } \times d }$ are parameter matrices, $d _ { e }$ and $d$ are the dimensions of edge embedding and node embedding, respectively. The adjacency matrix $A ^ { d y n }$ will be further row normalized to obtain $\tilde { A } ^ { d y n }$ , which will be used to compute dynamic message passing (see Section 2.4).
114
+
115
+ $$
116
+ \tilde { A } ^ { d y n } = \mathrm { s o f t m a x } ( A ^ { d y n } )
117
+ $$
118
+
119
+ # 2.4 HYBRID GNN
120
+
121
+ To better incorporate the information of the static graph and the dynamic graph, we propose the Hybrid Message Passing (HMP), which are performed on both retrieval-augmented static graph and attention-based dynamic graph.
122
+
123
+ Static Message Passing. For every node $v$ at each computation hop $k$ in the static graph, we apply an aggregation function to calculate the aggregated vector $\boldsymbol { h } _ { v } ^ { k }$ by considering a set of neighboring node embeddings computed from the previous hop.
124
+
125
+ $$
126
+ \pmb { h } _ { v } ^ { k } = \mathrm { S U M } ( \{ \pmb { h } _ { u } ^ { k - 1 } | \forall u \in \mathcal { N } _ { ( v ) } \} )
127
+ $$
128
+
129
+ where $\mathcal { N } _ { ( v ) }$ is a set of the neighboring nodes which are directly connected with $v$ . For each node $v$ $h _ { v } ^ { 0 }$ is the initial augmented node embedding of $v$ , i.e., $\mathbf { \boldsymbol { h } } _ { v } \in c o m p$ .
130
+
131
+ Dynamic Message Passing. The node information and edge information are propagated on the attention-based dynamic graph with the adjacency matrices $\check { \tilde { A } } ^ { d y n }$ , defined as
132
+
133
+ $$
134
+ \pmb { h } _ { v } ^ { ' k } = \sum _ { u } \tilde { \pmb { A } } _ { v , u } ^ { d y n } ( \pmb { W } ^ { V } \pmb { h } _ { u } ^ { ' k - 1 } + \pmb { W } ^ { F } \pmb { e } _ { v , u } )
135
+ $$
136
+
137
+ where $v$ and $u$ are any pair of nodes, $W ^ { V } \in \mathbb { R } ^ { d \times d }$ , $W ^ { F } \in \mathbb { R } ^ { d \times d _ { e } }$ are learned matrices, and $e _ { v , u }$ is the embedding of the edge connecting $v$ and $u$ . Similarly, $h _ { v } ^ { ' 0 }$ is the initial augmented node embedding of $v$ in comp.
138
+
139
+ Hybrid Message Passing. Given the static/dynamic aggregated vectors $h _ { v } ^ { k } / h _ { v } ^ { ' k }$ for static and dynamic graphs, we fuse both vectors and feed the resulting vector to a Gated Recurrent Unit (GRU) to update node representations.
140
+
141
+ $$
142
+ \pmb { f } _ { v } ^ { k } = \mathrm { G R U } ( \pmb { f } _ { v } ^ { k - 1 } , \mathrm { F u s e } ( \pmb { h } _ { v } ^ { k } , \pmb { h } _ { v } ^ { ' k } ) )
143
+ $$
144
+
145
+ where $\pmb { f } _ { v } ^ { 0 }$ is the augmented node initialization in comp. The fusion function Fuse is designed as a gated sum of two inputs.
146
+
147
+ $$
148
+ \begin{array} { r l } { \operatorname { F u s e } ( \pmb { a } , \pmb { b } ) = z \odot \pmb { a } + ( 1 - z ) \odot \pmb { b } } & { { } z = \sigma ( W _ { z } [ \pmb { a } ; \pmb { b } ; \pmb { a } \odot \pmb { b } ; \pmb { a } - \pmb { b } ] + b _ { z } ) } \end{array}
149
+ $$
150
+
151
+ where $W _ { z }$ and $b _ { z }$ are learnable weight matrix and vector, $\odot$ is the component-wise multiplication, $\sigma$ is a sigmoid function and $_ { z }$ is a gating vector. After $n$ hops of GNN computation, we obtain the final node representation $f _ { v } ^ { n }$ and then apply max-pooling over all nodes $\{ f _ { v } ^ { n } | \forall v \in \mathcal { V } \}$ to get the graph representation.
152
+
153
+ # 2.5 DECODER
154
+
155
+ The decoder is similar with other state-of-the-art Seq2seq models (Bahdanau et al., 2014; Luong et al., 2015) where an attention-based LSTM decoder is used. The decoder takes the input of the concatenation of the node representation and the representation of the retrieved summary $s ^ { \prime }$ , namely, $[ f _ { v _ { 1 } } ^ { n } ; . . . ; f _ { v _ { m } } ^ { n } ; z h _ { t _ { 1 } ^ { \prime } } ; . . . ; z h _ { t _ { T } ^ { \prime } } ] ,$ , where $m$ is the number of nodes in the input CPG graph. The initial hidden state of the decoder is the fusion (Eq. 11) of the graph representation and the weighted (i.e., multiply similarity score $z$ ) final state of the retrieved summary BiLSTM encoder.
156
+
157
+ We train the model with the cross-entropy loss, defined as $\begin{array} { r } { \mathcal { L } = \sum _ { t } - \log P ( s _ { t } ^ { * } | c , s _ { < t } ^ { * } ) } \end{array}$ , where $s _ { t } ^ { * }$ is the word at the $t$ -th position of the ground-truth output and $c$ is the source code of the function. To alleviate the exposure bias, we utilize schedule teacher forcing (Bengio et al., 2015). During the inference, we use beam search to generate final results.
158
+
159
+ # 3 EXPERIMENTS
160
+
161
+ # 3.1 SETUP
162
+
163
+ We evaluate our proposed framework against a number of state-of-the-art methods. Specifically, we classify the selected baseline methods into three groups: 1) Retrieval-based approaches: TFIDF (Haiduc et al., 2010) and NNGen (Liu et al., 2018), 2) Sequence-based approaches: CODENN (Iyer et al., 2016; Barone & Sennrich, 2017), Transformer (Ahmad et al., 2020), HybridDRL (Wan et al., 2018), Rencos (Zhang et al., 2020) and Dual model (Wei et al., 2019), 3) Graphbased approaches: SeqGNN (Fernandes et al., 2018). In addition, we implemented two another graph-based baselines: GCN2Seq and GAT2Seq, which respectively adopt the Graph Convolution (Kipf & Welling, 2016) and Graph Attention (Velickovic et al., 2018) as the encoder and a LSTM as the decoder for generating summaries. Note that Rencos (Zhang et al., 2020) combines the retrieval information into Seq2Seq model, we classify it into Sequence-based approaches. More detailed description about baselines and the configuration of HGNN can be found in the Appendix B and C.
164
+
165
+ Existing benchmarks (Barone & Sennrich, 2017; Hu et al., 2018b) are all based on high-level programming language i.e., Java, Python. Furthermore, they have been confirmed to have extensive duplication, making the model overfit to the training data that overlapped with the testset (Fernandes et al., 2018; Allamanis, 2019). We are the first to explore neural summarization on $C$ programming language, and make our $C$ Code Summarization Dataset (CCSD) public to benefit academia and industry. We crawled from popular $C$ repositories on GitHub and extracted function-summary pairs based on the documents of functions. After a deduplication process, we kept $\mathbf { 9 5 k + }$ unique functionsummary pairs. To further test the model generalization ability, we construct in-domain functions and out-of-domain functions by dividing the projects into two sets, denoted as $a$ and $b$ . For each project in $a$ , we randomly select some of the functions in this project as the training data and the unselected functions are the in-domain validation/test data. All functions in projects $b$ are regarded as out-of-domain test data. Finally, we obtain 84,316 training functions, 4,432 in-domain validation functions, 4,203 in-domain test functions and 2,330 out-of-domain test functions. For the retrieval augmentation, we use the training set as the retrieval database, i.e., $D ^ { \prime } = D$ (see Step 1 in Section 2.2.2). For more details about data processing, please refer to Appendix D.
166
+
167
+ Table 1: Automatic evaluation results (in $\%$ ) on the CCSD test set.
168
+
169
+ <table><tr><td rowspan="2">Methods</td><td colspan="3">In-domain</td><td colspan="3">Out-of-domain</td><td colspan="3">Overall</td></tr><tr><td>BLEU-4</td><td>ROUGE-L METEOR</td><td></td><td></td><td>BLEU-4 ROUGE-L METEOR</td><td></td><td>BLEU-4</td><td>ROUGE-L METEOR</td><td></td></tr><tr><td>TF-IDF</td><td>15.20</td><td>27.98</td><td>13.74</td><td>5.50</td><td>15.37</td><td>6.84</td><td>12.19</td><td>23.49</td><td>11.43</td></tr><tr><td>NNGen</td><td>15.97</td><td>28.14</td><td>13.82</td><td>5.74</td><td>16.33</td><td>7.18</td><td>12.76</td><td>23.93</td><td>11.58</td></tr><tr><td>CODE-NN</td><td>10.08</td><td>26.17</td><td>11.33</td><td>3.86</td><td>15.25</td><td>6.19</td><td>8.24</td><td>22.28</td><td>9.61</td></tr><tr><td>Hybrid-DRL</td><td>9.29</td><td>30.00</td><td>12.47</td><td>6.30</td><td>24.19</td><td>10.30</td><td>8.42</td><td>28.64</td><td>11.73</td></tr><tr><td>Transformer</td><td>12.91</td><td>28.04</td><td>13.83</td><td>5.75</td><td>18.62</td><td>9.89</td><td>10.69</td><td>24.65</td><td>12.02</td></tr><tr><td>Dual Model</td><td>11.49</td><td>29.20</td><td>13.24</td><td>5.25</td><td>21.31</td><td>9.14</td><td>9.61</td><td>26.40</td><td>11.87</td></tr><tr><td>Rencos</td><td>14.80</td><td>31.41</td><td>14.64</td><td>7.54</td><td>23.12</td><td>10.35</td><td>12.59</td><td>28.45</td><td>13.21</td></tr><tr><td>GCN2Seq</td><td>9.79</td><td>26.59</td><td>11.65</td><td>4.06</td><td>18.96</td><td>7.76</td><td>7.91</td><td>23.67</td><td>10.23</td></tr><tr><td>GAT2Seq</td><td>10.52</td><td>26.17</td><td>11.88</td><td>3.80</td><td>16.94</td><td>6.73</td><td>8.29</td><td>22.63</td><td>10.00</td></tr><tr><td>SeqGNN</td><td>10.51</td><td>29.84</td><td>13.14</td><td>4.94</td><td>20.80</td><td>9.50</td><td>8.87</td><td>26.34</td><td>11.93</td></tr><tr><td>HGNN w/oaugment&amp; static</td><td>11.75</td><td>29.59</td><td>13.86</td><td>5.57</td><td>22.14</td><td>9.41</td><td>9.98</td><td>26.94</td><td>12.05</td></tr><tr><td>HGNN w/o augment &amp; dynamic</td><td>11.85</td><td>29.51</td><td>13.54</td><td>5.45</td><td>21.89</td><td>9.59</td><td>9.93</td><td>26.80</td><td>12.21</td></tr><tr><td>HGNN w/o augment</td><td>12.33</td><td>29.99</td><td>13.78</td><td>5.45</td><td>22.07</td><td>9.46</td><td>10.26</td><td>27.17</td><td>12.32</td></tr><tr><td>HGNN w/o static</td><td>15.93</td><td>33.67</td><td>15.67</td><td>7.72</td><td>24.69</td><td>10.63</td><td>13.44</td><td>30.47</td><td>13.98</td></tr><tr><td>HGNN w/o dynamic</td><td>15.77</td><td>33.84</td><td>15.67</td><td>7.64</td><td>24.72</td><td>10.73</td><td>13.31</td><td>30.59</td><td>14.01</td></tr><tr><td>HGNN</td><td>16.72</td><td>34.29</td><td>16.25</td><td>7.85</td><td>24.74</td><td>11.05</td><td>14.01</td><td>30.89</td><td>14.50</td></tr></table>
170
+
171
+ Similar to previous works (Zhang et al., 2020; Wan et al., 2018; Fernandes et al., 2018; Iyer et al., 2016), BLEU (Papineni et al., 2002), METEOR (Banerjee & Lavie, 2005) and ROUGE-L (Lin, 2004) are used as our automatic evaluation metrics. These metrics are popular for evaluating machine translation and text summarization tasks. Except for these automatic metrics, we also conduct a human evaluation study. We invite $5 \mathrm { P h D }$ students and 10 master students as volunteers, who have rich C programming experiences. The volunteers are asked to rank summaries generated from the anonymized approaches from 1 to 5 (i.e., 1: Poor, 2: Marginal, 3: Acceptable, 4: Good, 5: Excellent) based on the relevance of the generated summary to the source code and the degree of similarity between the generated summary and the actual summary. Specifically, we randomly choose 50 functions for each model with the corresponding generated summaries and ground-truths. We calculate the average score and the higher the score, the better the quality.
172
+
173
+ # 3.2 COMPARISON WITH THE BASELINES
174
+
175
+ Table 1 shows the evaluation results including two parts: the comparison with baselines and the ablation study. Consider the comparison with state-of-the-art baselines, in general, we find that our proposed model outperforms existing methods by a significant margin on both in-domain and out-of-domain datasets, and shows good generalization performance. Compared with others, on in-domain dataset, the retrieval-based approaches could achieve competitive performance on BLEU-4, however ROUGE-L and METEOR are fare less than ours. Moreover, they do not perform well on the out-of-domain dataset. Compared with the graph-based approaches (i.e., GCN2Seq, GAT2Seq and SeqGNN), even without augmentation (HGNN w/o augment), our approach still outperforms them, which further demonstrates the effectiveness of Hybrid GNN for additionally capturing global graph information. Compared with Rencos that also considers the retrieved information in the Seq2Seq model, its performance is still lower than HGNN. On the overall dataset including both of in-domain and out-of-domain data, our model achieves 14.01, 30.89 and 14.50, outperforming current state-of-the-art method Rencos by 1.42, 2.44 and 1.29 in terms of BLEU-4, ROUGE-L and METEOR metrics.
176
+
177
+ # 3.3 ABLATION STUDY
178
+
179
+ We also conduct an ablation study to evaluate the impact of different components of our framework, e.g., retrieval-based augmentation, static graph and dynamic graph in the last row of Table 1. Overall, we found that 1) retrieval-augmented mechanism could contribute to the overall model performance (HGNN vs. HGNN w/o augment). Compared with HGNN, we see that the performance of HGNN w/o static and HGNN w/o dynamic decreases, which demonstrates the effectiveness of the Hybrid GNN and 2) the performance without static graph is worse than the performance without dynamic graph in ROUGE-L and METEOR, however, BLEU-4 is higher than the performance without dynamic graph. To further understand the impact of the static graph and dynamic graph, we evaluate the performance without augmentation and static graph/dynamic graph (see HGNN w/o augment& static and HGNN w/o augment& dynamic). Compared with HGNN w/o augment, the results further confirm the effectiveness of the Hybrid GNN (i.e., static graph and dynamic graph).
180
+
181
+ Table 2: Human evaluation results on the CCSD test set.
182
+
183
+ <table><tr><td>Metrics</td><td>NNGen</td><td>Transformer</td><td>Rencos</td><td>SeqGNN</td><td>HGNN</td></tr><tr><td>Relevance</td><td>3.23</td><td>3.17</td><td>3.48</td><td>3.09</td><td>3.69</td></tr><tr><td>Similarity</td><td>3.18</td><td>3.02</td><td>3.32</td><td>3.06</td><td>3.51</td></tr></table>
184
+
185
+ Table 3: Examples of generated summaries on the CCSD test set.
186
+
187
+ <table><tr><td rowspan=1 colspan=1>Example</td><td rowspan=1 colspan=1>Example 1</td><td rowspan=1 colspan=1>Example 2</td></tr><tr><td rowspan=1 colspan=1>Source Code</td><td rowspan=1 colspan=1>static void strInit(Str *p){p-&gt;z = 0;p-&gt;nAlloc = 0;p-&gt;nUsed = 0;}</td><td rowspan=1 colspan=1>void ReleaseCedar(CEDAR *c){if (c == NULL)return;if((Release(c-&gt;ref) == 0)CleanupCedar(c);1</td></tr><tr><td rowspan=1 colspan=1>Ground-Truth</td><td rowspan=1 colspan=1>initializeastr object</td><td rowspan=1 colspan=1>release reference of the cedar</td></tr><tr><td rowspan=1 colspan=1>NNGen</td><td rowspan=1 colspan=1>free the string</td><td rowspan=1 colspan=1>release the virtual host</td></tr><tr><td rowspan=1 colspan=1>Transformer</td><td rowspan=1 colspan=1>reset a string</td><td rowspan=1 colspan=1>release of the cancel object</td></tr><tr><td rowspan=1 colspan=1>Rencos</td><td rowspan=1 colspan=1>append araw string to the jsonstring</td><td rowspan=1 colspan=1>release of the cancel object</td></tr><tr><td rowspan=1 colspan=1>SeqGNN</td><td rowspan=1 colspan=1>initialize the string</td><td rowspan=1 colspan=1>release cedarcommunication mode</td></tr><tr><td rowspan=1 colspan=1>HGNN</td><td rowspan=1 colspan=1>initializeastringobject</td><td rowspan=1 colspan=1>releasereferenceofcedar</td></tr></table>
188
+
189
+ We also conduct experiments to investigate the impact of code-based augmentation and summarybased augmentation. Overall, we found that the summary-based augmentation could contribute more than the code-based augmentation. For example, after adding the code-based augmentation, the performance can be 10.22, 27.54 and 12.49 in terms of BLUE-4, ROUGE-L and METEOR on the overall dataset. With the summary-based augmentation, the results can reach to 13.76, 30.59 and 14.11. Compared with the results without augmentation (i.e., 10.26. 27.17, 12.32 with $H G N N w / o$ augment), we can see that code-based augmentation could have some improvement, but the effect is not significant compared with summary-based augmentation. We conjecture that, due to that the code and summary are heterogeneous, the summary-based augmentation has a more direct impact on the code summarization task. When combining both code-based augmentation and summary-based augmentation, we can achieve the best results (i.e., 14.01, 30.89, 14.50). We plan to explore more code-based augmentation (e.g., semantic-equivalent code transformation) in our future work.
190
+
191
+ # 3.4 HUMAN EVALUATION
192
+
193
+ As shown in Table 2, we perform a human evaluation on the overall dataset to assess the quality of the generated summaries by our approach, NNGen, Transformer, Rencos and SeqGNN in terms of relevance and similarity. As depicted in Table 1, NNGen, Rencos and SeqGNN are the best retrieval-based, sequence-based, and graph-based approaches, respectively. We also compare with Transformer as it has been widely used in natural language processing. The results show that our method can generate better summaries which are more relevant with the source code and more similar with the ground-truth summaries.
194
+
195
+ # 3.5 CASE STUDY
196
+
197
+ To perform qualitative analysis, we present two examples with generated summaries by different methods from the overall data set, shown in Table 3. We can see that, in the first example, our approach can learn more code semantics, i.e., $p$ is a self-defined struct variable. Thus, we could generate a token object for the variable $p$ . However, other models can only produce string. Example 2 is a more difficult function with the functionality to “release reference of cedar”, as compared to other baselines, our approach effectively captures the functionality and generates a more precise summary.
198
+
199
+ # 3.6 EXTENSION ON THE PYTHON DATASET
200
+
201
+ We conducted additional experiments on a public dataset, i.e., the Python Code Summarization Dataset (PCSD), which was also used in Rencos (the most competitive baseline in our paper). We follow the setting of Rencos and split PCSD into the training set, validation set and testing set with fractions of $60 \%$ , $20 \%$ and $20 \%$ . We construct the static graph based on AST. The decoding step is set to 50, followed by Rencos, and the other settings are the same with CCSD. We compare our methods on PCSD against various competitive baselines, i.e., NNGen, CODE-NN, Rencos and
202
+
203
+ Table 4: Automatic evaluation results (in $\%$ ) on the PCSD test set.
204
+
205
+ <table><tr><td>Methods</td><td>BLEU-4</td><td>ROUGE-L</td><td>METEOR</td></tr><tr><td>NNGen</td><td>21.60</td><td>31.61</td><td>15.96</td></tr><tr><td>CODE-NN</td><td>16.39</td><td>28.99</td><td>13.68</td></tr><tr><td>Transformer</td><td>17.06</td><td>31.16</td><td>14.37</td></tr><tr><td>Rencos</td><td>24.02</td><td>36.21</td><td>18.07</td></tr><tr><td>HGNN w/ostatic</td><td>24.06</td><td>38.28</td><td>18.66</td></tr><tr><td>HGNN w/o dynamic</td><td>24.13</td><td>38.64</td><td>18.93</td></tr><tr><td>HGNN</td><td>24.42</td><td>39.91</td><td>19.48</td></tr></table>
206
+
207
+ Transformer, which are either retrieval-based, generation-based or hybrid methods. The results are shown in Table 4. The results indicate that, compared with the best results from NNGen, CODE-NN, Rencos and Transformer, our method can improve the performance by 0.40, 3.70 and 1.41 in terms of BLEU-4, ROUGE-L and METEOR. We also conduct the ablation study on PCSD to demonstrate the usefulness of the static graph (i.e., HGNN w/o dynamic) and dynamic graph (i.e., HGNN w/o static). The results also demonstrate that both static graph and dynamic graph can contribute to our framework. In summary, the results on both our released benchmark (CCSD) and existing benchmark (PCSD) demonstrate the effectiveness and the scalability of our method.
208
+
209
+ # 4 RELATED WORK
210
+
211
+ Source Code Summarization Early works (Eddy et al., 2013; Haiduc et al., 2010; Wong et al., 2015; 2013) for code summarization focused on using information retrieval to retrieve summaries. Later works attempted to employ attentional Seq2Seq model on the source code (Iyer et al., 2016; Siow et al., 2020) or some variants, i.e., AST (Hu et al., 2018a; Alon et al., 2018; Liu et al., 2020) for generation. However, these works are based on sequential models, ignoring rich code semantics. Some latest attempts (LeClair et al., 2020; Fernandes et al., 2018) embedded program semantics into GNNs. but they mainly rely on simple representations, which are limited to learn full semantics.
212
+
213
+ Graph Neural Networks Over the past few years, GNNs (Li et al., 2015; Hamilton et al., 2017; Kipf & Welling, 2016; Chen et al., 2020b) have attracted increasing attention with many successful applications in computer vision (Norcliffe-Brown et al., 2018), natural language processing (Xu et al., 2018a; Chen et al., 2020d;c;e). Because by design GNNs can model graph-structured data, recently, some works have extended the widely used Seq2Seq architectures to Graph2Seq architectures for various tasks including machine translation (Beck et al., 2018), and graph (e.g., AMR, SQL)-to-text generation (Zhu et al., 2019; Xu et al., 2018b). Some works have also attempted to encode programs with graphs for diverse tasks e.g., VARNAMING/VARMISUSE (Allamanis et al., 2017), Source Code Vulnerability Detection (Zhou et al., 2019). As compared to these works, we innovate a hybrid message passing GNN performed on both static graph and dynamic graph for message fusion.
214
+
215
+ # 5 CONCLUSION AND FUTURE WORK
216
+
217
+ In this paper, we proposed a general-purpose framework for automatic code summarization. A novel retrieval-augmented mechanism is proposed for combining the benefits of both retrieval-based and generation-based approaches. Moreover, to capture global semantics among nodes, we develop a hybrid message passing GNN based on both static and dynamic graphs. The evaluation shows that our approach improves state-of-the-art techniques substantially. Our future work includes: 1) we plan to introduce more information such as API knowledge to learn the better semantics of programs, 2) we explore more code-based augmentation techniques to improve the performance and 3) we plan to adopt the existing techniques such as (Du et al., 2019; Xie et al., 2019a;b; Ma et al., 2018) to evaluate the robustness of the trained model.
218
+
219
+ # 6 ACKNOWLEDGMENTS
220
+
221
+ This research is partially supported by the National Research Foundation, Singapore under its the AI Singapore Programme (AISG2-RP-2020-019), the National Research Foundation, Prime Ministers Office, Singapore under its National Cybersecurity R&D Program (Award No. NRF2018NCRNCR005-0001), NRF Investigatorship NRF-NRFI06-2020-0001, the National Research Foundation through its National Satellite of Excellence in Trustworthy Software Systems (NSOE-TSS) project under the National Cybersecurity R&D (NCR) Grant award no. NRF2018NCR-NSOE003-0001.
222
+
223
+ # REFERENCES
224
+
225
+ Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. A transformer-based approach for source code summarization. arXiv preprint arXiv:2005.00653, 2020.
226
+
227
+ Miltiadis Allamanis. The adverse effects of code duplication in machine learning models of code. In Proceedings of the 2019 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, pp. 143–153, 2019.
228
+
229
+ Miltiadis Allamanis, Marc Brockschmidt, and Mahmoud Khademi. Learning to represent programs with graphs. arXiv preprint arXiv:1711.00740, 2017.
230
+
231
+ Miltiadis Allamanis, Earl T Barr, Premkumar Devanbu, and Charles Sutton. A survey of machine learning for big code and naturalness. ACM Computing Surveys (CSUR), 51(4):1–37, 2018.
232
+
233
+ Uri Alon, Shaked Brody, Omer Levy, and Eran Yahav. code2seq: Generating sequences from structured representations of code. arXiv preprint arXiv:1808.01400, 2018.
234
+
235
+ Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014.
236
+
237
+ Satanjeev Banerjee and Alon Lavie. Meteor: An automatic metric for mt evaluation with improved correlation with human judgments. In Proceedings of the acl workshop on intrinsic and extrinsic evaluation measures for machine translation and/or summarization, pp. 65–72, 2005.
238
+
239
+ Antonio Valerio Miceli Barone and Rico Sennrich. A parallel corpus of python functions and documentation strings for automated code documentation and code generation. arXiv preprint arXiv:1707.02275, 2017.
240
+
241
+ Daniel Beck, Gholamreza Haffari, and Trevor Cohn. Graph-to-sequence learning using gated graph neural networks. arXiv preprint arXiv:1806.09835, 2018.
242
+
243
+ Richard Bellman. Dynamic programming. Science, 153(3731):34–37, 1966.
244
+
245
+ Samy Bengio, Oriol Vinyals, Navdeep Jaitly, and Noam Shazeer. Scheduled sampling for sequence prediction with recurrent neural networks. In Advances in Neural Information Processing Systems, pp. 1171–1179, 2015.
246
+
247
+ Deli Chen, Yankai Lin, Wei Li, Peng Li, Jie Zhou, and Xu Sun. Measuring and relieving the oversmoothing problem for graph neural networks from the topological view. In AAAI, pp. 3438–3445, 2020a.
248
+
249
+ Yu Chen, Lingfei Wu, and Mohammed Zaki. Iterative deep graph learning for graph neural networks: Better and robust node embeddings. Advances in Neural Information Processing Systems, 33, 2020b.
250
+
251
+ Yu Chen, Lingfei Wu, and Mohammed J. Zaki. Graphflow: Exploiting conversation flow with graph neural networks for conversational machine comprehension. In Proceedings of the TwentyNinth International Joint Conference on Artificial Intelligence, pp. 1230–1236. International Joint Conferences on Artificial Intelligence Organization, 2020c.
252
+
253
+ Yu Chen, Lingfei Wu, and Mohammed J. Zaki. Reinforcement learning based graph-to-sequence model for natural question generation. In Proceedings of the 8th International Conference on Learning Representations, Apr. 26-30, 2020d.
254
+
255
+ Yu Chen, Lingfei Wu, and Mohammed J Zaki. Toward subgraph guided knowledge graph question generation with graph neural networks. arXiv preprint arXiv:2004.06015, 2020e.
256
+
257
+ Xiaoning Du, Xiaofei Xie, Yi Li, Lei Ma, Yang Liu, and Jianjun Zhao. Deepstellar: Model-based quantitative analysis of stateful deep learning systems. In Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, pp. 477–487, 2019.
258
+
259
+ Brian P Eddy, Jeffrey A Robinson, Nicholas A Kraft, and Jeffrey C Carver. Evaluating source code summarization techniques: Replication and expansion. In 2013 21st International Conference on Program Comprehension (ICPC), pp. 13–22. IEEE, 2013.
260
+
261
+ Patrick Fernandes, Miltiadis Allamanis, and Marc Brockschmidt. Structured neural summarization. arXiv preprint arXiv:1811.01824, 2018.
262
+
263
+ Sonia Haiduc, Jairo Aponte, Laura Moreno, and Andrian Marcus. On the use of automated text summarization techniques for summarizing source code. In 2010 17th Working Conference on Reverse Engineering, pp. 35–44. IEEE, 2010.
264
+
265
+ Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Advances in neural information processing systems, pp. 1024–1034, 2017.
266
+
267
+ 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.
268
+
269
+ Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8): 1735–1780, 1997.
270
+
271
+ Xing Hu, Ge Li, Xin Xia, David Lo, and Zhi Jin. Deep code comment generation. In Proceedings of the 26th Conference on Program Comprehension, pp. 200–210, 2018a.
272
+
273
+ Xing Hu, Ge Li, Xin Xia, David Lo, Shuai Lu, and Zhi Jin. Summarizing source code with transferred api knowledge. 2018b.
274
+
275
+ Srinivasan Iyer, Ioannis Konstas, Alvin Cheung, and Luke Zettlemoyer. Summarizing source code using a neural attention model. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2073–2083, 2016.
276
+
277
+ Siyuan Jiang, Ameer Armaly, and Collin McMillan. Automatically generating commit messages from diffs using neural machine translation. In 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 135–146. IEEE, 2017.
278
+
279
+ Toshihiro Kamiya, Shinji Kusumoto, and Katsuro Inoue. Ccfinder: a multilinguistic token-based code clone detection system for large scale source code. IEEE Transactions on Software Engineering, 28(7):654–670, 2002.
280
+
281
+ Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
282
+
283
+ Alexander LeClair, Sakib Haque, Linfgei Wu, and Collin McMillan. Improved code summarization via a graph neural network. arXiv preprint arXiv:2004.02843, 2020.
284
+
285
+ Guohao Li, Matthias Müller, Ali K. Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as cnns? In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pp. 9266–9275. IEEE, 2019. doi: 10.1109/ICCV. 2019.00936. URL https://doi.org/10.1109/ICCV.2019.00936.
286
+
287
+ Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. arXiv preprint arXiv:1511.05493, 2015.
288
+
289
+ Zhenmin Li, Shan Lu, Suvda Myagmar, and Yuanyuan Zhou. Cp-miner: Finding copy-paste and related bugs in large-scale software code. IEEE Transactions on software Engineering, 32(3): 176–192, 2006.
290
+
291
+ Chin-Yew Lin. ROUGE: A package for automatic evaluation of summaries. In Text Summarization Branches Out, pp. 74–81. Association for Computational Linguistics, July 2004.
292
+
293
+ Shangqing Liu, Cuiyun Gao, Sen Chen, Nie Lun Yiu, and Yang Liu. Atom: Commit message generation based on abstract syntax tree and hybrid ranking. IEEE Transactions on Software Engineering, 2020.
294
+
295
+ Zhongxin Liu, Xin Xia, Ahmed E Hassan, David Lo, Zhenchang Xing, and Xinyu Wang. Neuralmachine-translation-based commit message generation: how far are we? In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, pp. 373–384, 2018.
296
+
297
+ Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-based neural machine translation. arXiv preprint arXiv:1508.04025, 2015.
298
+
299
+ Lei Ma, Felix Juefei-Xu, Fuyuan Zhang, Jiyuan Sun, Minhui Xue, Bo Li, Chunyang Chen, Ting Su, Li Li, Yang Liu, et al. Deepgauge: Multi-granularity testing criteria for deep learning systems. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, pp. 120–131, 2018.
300
+
301
+ Will Norcliffe-Brown, Stathis Vafeias, and Sarah Parisot. Learning conditioned graph structures for interpretable visual question answering. In Advances in Neural Information Processing Systems, pp. 8344–8353, 2018.
302
+
303
+ Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting on association for computational linguistics, pp. 311–318. Association for Computational Linguistics, 2002.
304
+
305
+ Jing Kai Siow, Cuiyun Gao, Lingling Fan, Sen Chen, and Yang Liu. Core: Automating review recommendation for code changes. In 2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER), pp. 284–295. IEEE, 2020.
306
+
307
+ 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.
308
+
309
+ Petar Velickovic, Guillem Cucurull, A. Casanova, A. Romero, P. Liò, and Yoshua Bengio. Graph attention networks. ArXiv, abs/1710.10903, 2018.
310
+
311
+ Yao Wan, Zhou Zhao, Min Yang, Guandong Xu, Haochao Ying, Jian Wu, and Philip S Yu. Improving automatic source code summarization via deep reinforcement learning. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, pp. 397–407, 2018.
312
+
313
+ Bolin Wei, Ge Li, Xin Xia, Zhiyi Fu, and Zhi Jin. Code generation as a dual task of code summarization. In Advances in Neural Information Processing Systems, pp. 6563–6573, 2019.
314
+
315
+ Edmund Wong, Jinqiu Yang, and Lin Tan. Autocomment: Mining question and answer sites for automatic comment generation. In 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 562–567. IEEE, 2013.
316
+
317
+ Edmund Wong, Taiyue Liu, and Lin Tan. Clocom: Mining existing source code for automatic comment generation. In 2015 IEEE 22nd International Conference on Software Analysis, Evolution, and Reengineering (SANER), pp. 380–389. IEEE, 2015.
318
+
319
+ Xiaofei Xie, Lei Ma, Felix Juefei-Xu, Minhui Xue, Hongxu Chen, Yang Liu, Jianjun Zhao, Bo Li, Jianxiong Yin, and Simon See. Deephunter: a coverage-guided fuzz testing framework for deep neural networks. In Proceedings of the 28th ACM SIGSOFT International Symposium on Software Testing and Analysis, pp. 146–157, 2019a.
320
+
321
+ Xiaofei Xie, Lei Ma, Haijun Wang, Yuekang Li, Yang Liu, and Xiaohong Li. Diffchaser: Detecting disagreements for deep neural networks. In IJCAI, pp. 5772–5778, 2019b.
322
+
323
+ Kun Xu, Lingfei Wu, Zhiguo Wang, and Vadim Sheinin. Graph2seq: Graph to sequence learning with attention-based neural networks. arXiv preprint arXiv:1804.00823, 2018a.
324
+
325
+ Kun Xu, Lingfei Wu, Zhiguo Wang, Mo Yu, Liwei Chen, and Vadim Sheinin. Sql-to-text generation with graph-to-sequence model. arXiv preprint arXiv:1809.05255, 2018b.
326
+
327
+ Fabian Yamaguchi, Nico Golde, Daniel Arp, and Konrad Rieck. Modeling and discovering vulnerabilities with code property graphs. In 2014 IEEE Symposium on Security and Privacy, pp. 590–604. IEEE, 2014.
328
+
329
+ Jian Zhang, Xu Wang, Hongyu Zhang, Hailong Sun, and Xudong Liu. Retrieval-based neural source code summarization. In Proceedings of the 42nd International Conference on Software Engineering. IEEE, 2020.
330
+
331
+ Lingxiao Zhao and Leman Akoglu. Pairnorm: Tackling oversmoothing in gnns. arXiv preprint arXiv:1909.12223, 2019.
332
+
333
+ Yaqin Zhou, Shangqing Liu, Jingkai Siow, Xiaoning Du, and Yang Liu. Devign: Effective vulnerability identification by learning comprehensive program semantics via graph neural networks. In Advances in Neural Information Processing Systems, pp. 10197–10207, 2019.
334
+
335
+ Jie Zhu, Junhui Li, Muhua Zhu, Longhua Qian, Min Zhang, and Guodong Zhou. Modeling graph structure in transformer for better amr-to-text generation. arXiv preprint arXiv:1909.00136, 2019.
336
+
337
+ # Appendices
338
+
339
+ A DETAILS ON CODE PROPERTY GRAPH
340
+
341
+ Code Property Graph (CPG) (Yamaguchi et al., 2014), which is constructed on abstract syntax tree (AST), combines different edges (i.e., Flow to, Control) to represent the semantics of the program. We describe each representation combining with Figure 2 as follows:
342
+
343
+ • Abstract Syntax Tree (AST). AST contains syntactic information for a program and omits irrelevant details that have no effect on the semantics. Figure 2 shows the completed AST nodes on the left simple program and each node has a code sequence in the first line and type attribute in the second line. The black arrows represent the child-parent relations among ASTs.
344
+
345
+ • Control Flow Graph (CFG). Compared with AST highlighting the syntactic structure, CFG displays statement execution order, i.e., the possible order in which statements may be executed and the conditions that must be met for this to happen. Each statement in the program is treated as an independent node as well as a designated entry and exit node. Based on the keywords $i f , f o r$ , goto, break and continue, control flow graphs can be easily built and “Flow to” with green dashed arrows in Figure 2 represents this flow order.
346
+
347
+ • Program Dependency Graph (PDG). PDG includes data dependencies and control dependencies: 1) data dependencies are described as the definition of a variable in a statement reaches the usage of the same variable at another statement. In Figure 2, the variable $\mathbf { \nabla } ^ { 6 }$ is defined in the statement “int $b = a { + } { + } ^ { \prime \prime }$ and used in “call $( b ) ^ { \dagger }$ . Hence, there is a “Reach” edge with blue arrows point from “int $b = a { + } { + } ^ { , , , }$ to “call $( b ) ^ { \dagger }$ . Furthermore, Define/Use edge with orange double arrows denotes the definition and usage of the variable. 2) different from CFG displaying the execution process of the complete program, control dependencies define the execution of a statement may be dependent on the value of a predicate, which more focus on the statement itself. For instance, the statements “int $b = a { + } { + } ^ { \prime \prime }$ and “call(b)” are only performed “if a is even”. Therefore, a red double arrow “Control” points from $\begin{array} { r } { \cdot \bullet _ { i f } ( a \ \mathcal { I } _ { o } \ : 2 ) = = O ^ { \ast } } \end{array}$ to “int $b = a { + } { + } ^ { , , , }$ and “call(b)”.
348
+
349
+ # B DETAILS ON BASELINE METHODS
350
+
351
+ We compare our approach with existing baselines. They can be divided into three groups: Retrievalbased approaches, Sequence-based approaches and Graph-based approaches. For papers that provide the source code, we directly reproduce their methods on CCSD dataset. Otherwise, we reimplement their approaches with reference to the papers.
352
+
353
+ # B.1 RETRIEVAL-BASED APPROACHES
354
+
355
+ TF-IDF (Haiduc et al., 2010) is the abbreviation of Term Frequency-Inverse Document Frequency, which is adopted in the early code summarization (Haiduc et al., 2010). It transforms programs into weight vectors by calculating term frequency and inverse document frequency. We retrieve the summary of the most similar programs by calculating the cosine similarity on the weighted vectors.
356
+
357
+ NNGen (Liu et al., 2018) is a retrieved-based approach to produce commit messages for code changes. We reproduce such an algorithm on code summarization. Specifically, we retrieve the most similar top- $\mathbf { \nabla } \cdot \mathbf { k }$ code snippets on a bag-of-words model and prioritizes the summary in terms of BLEU-4 scores in top-k code snippets.
358
+
359
+ # B.2 SEQUENCE-BASED APPROACHES
360
+
361
+ CODE-NN (Iyer et al., 2016; Barone & Sennrich, 2017) adopts an attention-based Seq2Seq model to generate summaries on the source code.
362
+
363
+ Transformer (Ahmad et al., 2020) adopts the transformer architecture (Vaswani et al., 2017) with self-attention to capture long dependency in the code for source code summrization.
364
+
365
+ Hybrid-DRL (Wan et al., 2018) is a reinforcement learning-based approach, which incorporates AST and sequential code snippets into a deep reinforcement learning framework and employ evaluation metrics e.g., BLEU as the reward.
366
+
367
+ Dual Model (Wei et al., 2019) propose a dual training framework by training code summarization and code generation tasks simultaneously to boost each task performance.
368
+
369
+ Rencos (Zhang et al., 2020) is the retrieval-based Seq2Seq model for code summarization. it utilized a pretrained Seq2Seq model during the testing phase by computing a joint probability conditioned on both the original source code and retrieved the most similar source code for the summary generation. Compared with Rencos, we propose a novel retrieval-augmented mechanism for the similar source code and use it at the model training phase.
370
+
371
+ # B.3 GRAPH-BASED APPROACHES
372
+
373
+ We also compared with some latest GNN-based works, employing graph neural network for source code summarization.
374
+
375
+ GCN2Seq, GAT2Seq modify Graph Convolution Network (Kipf & Welling, 2016) and Graph Attention Network (Velickovic et al., 2018) to perform convolution operation and attention operation on the code property graph for learning and followed by a LSTM to generate summaries. We implement the related code from scratch.
376
+
377
+ SeqGNN (Fernandes et al., 2018) combines GGNNs and standard sequence encoders for summarization. They take the code and relationships between elements of the code as input. Specially, a BiLSTM is employed on the code sequence to learn representations and each source code token is modelled as a node in the graph, and employed GGNN for graph-level learning. Since our node sequences are sub-sequence of source code rather than individual token, we adjust to slice the output of BiLSTM and sum each token representation in node sequences as node initial representation for summarization. Furthermore, we implement the related code from scratch.
378
+
379
+ # C MODEL SETTINGS
380
+
381
+ We embed the most frequent 40,000 words in the training set with 512-dims and set the hidden size of BiLSTM to 256 and the concatenated state size for both directions is 512. The dropout is set to 0.3 after the word embedding layer and BiLSTM. We set GNN hops to 1 for the best performance. The optimizer is selected with Adam with an initial learning rate of 0.001. The batch size is set to 64 and early stop for 10. The beam search width is set to 5 as usual. All experiments are conducted on the DGX server with four Nvidia Graphics Tesla V100 and each epoch takes 6 minutes averagely. All hyperparameters are tuned with grid search on the validation set.
382
+
383
+ # D DETAILS ON DATA PREPARATION
384
+
385
+ It is non-trivial to obtain high-quality datasets for code summarization. We noticed that despite some previous works (Barone & Sennrich, 2017; Hu et al., 2018b) released their datasets, however, they are all based on high-level programming languages i.e. Java, Python. We are the first to explore summarization on $C$ programming language. Specifically, we crawled from popular $C$ repositories (e.g., Linux and QEMU) on GitHub, and then extracted separate function-summary pairs from these projects. Specifically, we extracted functions and associated comments marked by special characters $" / \ast * \ast "$ and $" * / "$ over the function declaration. These comments can be considered as explanations of the functions. We filtered out functions with line exceeding 1000 and any other comments inside the function, and the first sentence was selected as the summary. A similar practice can be found in (Jiang et al., 2017). Totally, we collected $\mathbf { 5 0 0 k + }$ raw function-summary pairs. Furthermore, functions with token size greater than 150 were removed for computational efficiency and there were $\mathbf { 1 3 0 k + }$ functions left. Since duplication is very common in existing datasets (Fernandes et al., 2018), followed by Allamanis (2019), we performed a de-duplication process and removed functions with similarity over $80 \%$ . Specifically, we calculated the cosine similarity by encoding the raw functions into vectors with sklearn. Finally, we kept $\mathbf { 9 5 k + }$ unique functions. We name this dataset $C$ Code Summarization Dataset (CCSD). To testify model generalization ability, we randomly selected some projects as the out-of-domain test set with 2,330 examples and the remaining were randomly split into train/validation/test with 84,316/4,432/4,203 examples. The open-source code analysis platform Joern (Yamaguchi et al., 2014) was applied to construct the code property graph.
386
+
387
+ Table 5: More Examples of generated summaries on the CCSD test set.
388
+
389
+ <table><tr><td rowspan=1 colspan=1>Example</td><td rowspan=1 colspan=1>Example 1</td><td rowspan=1 colspan=1>Example 2</td></tr><tr><td rowspan=1 colspan=1>Source Code</td><td rowspan=1 colspan=1>static void counterMutexFree(sqlite3_mutex *p){assert(g.isInit);g.m.xMutexFree (p-&gt;pReal);if(p-&gt;eType==SQLITE_MUTEX_FASTI1 p-&gt;eType==s QLITE_MUTEX_RECURSIVE){free(p);1}</td><td rowspan=1 colspan=1>static void _exit wimax_subsys_exit (void){wimax_id_table_release();genl_unregister_family(&amp;wimax_gnl_family);}</td></tr><tr><td rowspan=1 colspan=1>Ground-Truth</td><td rowspan=1 colspan=1>free a countable mutex</td><td rowspan=1 colspan=1>shutdown the wimax stack</td></tr><tr><td rowspan=1 colspan=1>NNGen</td><td rowspan=1 colspan=1>enter a countable mutex</td><td rowspan=1 colspan=1>unregisters pmcraid event family return value none</td></tr><tr><td rowspan=1 colspan=1>Transformer</td><td rowspan=1 colspan=1>leaveamutex</td><td rowspan=1 colspan=1>de initialize wimax driver</td></tr><tr><td rowspan=1 colspan=1>Rencos</td><td rowspan=1 colspan=1>try to enter a mutex</td><td rowspan=1 colspan=1>unregister the wimax device subsystem</td></tr><tr><td rowspan=1 colspan=1>SeqGNN</td><td rowspan=1 colspan=1>free a mutex allocated bysqlite3 mutex</td><td rowspan=1 colspan=1>this function is called when the driver is not held</td></tr><tr><td rowspan=1 colspan=1>HGNN</td><td rowspan=1 colspan=1>releasea mutex</td><td rowspan=1 colspan=1>free the wimax stack</td></tr><tr><td rowspan=1 colspan=1>Retrieved_code</td><td rowspan=1 colspan=1> static int counterMutexTry(sqlite3_mutex *p){assert(g.isInit );assert(p-&gt;eType&gt;=0 );assert(p-&gt;eType&lt;MAX_MUTEXES);g.aCounter[p-&gt;eType]++;if(g.disableTry)return SQLITE_BUSY;return g.m.xMutexTry(p-&gt;pReal);}</td><td rowspan=1 colspan=1>static int _init wimax_subsys_init(void){int result;d_fnstart(4,NULL,&quot;()\n&quot;);d_parse_params(D_LEVEL,D_LEVEL_SIZE,wimax_debug_params,&quot;wimax.debug&quot;);result = genl_register_family(&amp;wimax_gnl_family);if(unlikely(result&lt;0)){pr_err(&quot;cannot register genericnetlink family: %d\n&quot;, result);goto error_register_family;}d_fnend(4,NULL,&quot;()= O\n&quot;);return 0;error_register_family:d_fnend(4,NULL,&quot;()= %d\n&quot;,result);return result;1</td></tr><tr><td rowspan=1 colspan=1>Retrieved_summary</td><td rowspan=1 colspan=1>tryto enter amutex</td><td rowspan=1 colspan=1>shutdown the wimax stack</td></tr><tr><td rowspan=1 colspan=1>Example</td><td rowspan=1 colspan=1>Example 3</td><td rowspan=1 colspan=1>Example 4</td></tr><tr><td rowspan=1 colspan=1>Source Code</td><td rowspan=1 colspan=1>static void udc_dd_free(struct lpc32xx_udc *udc,struct lpc32xx_usbd_dd_gad *dd){dma_pool_free(udc-&gt;dd_cache,dd,dd-&gt;this_dma);}</td><td rowspan=1 colspan=1>void ReleaseSockEvent(SOCK_EVENT *event){if (event == NULL){return;1if(Release(event-&gt;ref) == 0){CleanupSockEvent (event);}1</td></tr><tr><td rowspan=1 colspan=1>Ground-Truth</td><td rowspan=1 colspan=1>free a dma descriptor</td><td rowspan=1 colspan=1>release of the socket event</td></tr><tr><td rowspan=1 colspan=1>NNGen</td><td rowspan=1 colspan=1>allocateadmadescriptor</td><td rowspan=1 colspan=1>clean up of the socket event</td></tr><tr><td rowspan=1 colspan=1>Transformer</td><td rowspan=1 colspan=1>free the usb device</td><td rowspan=1 colspan=1>set the event</td></tr><tr><td rowspan=1 colspan=1>Rencos</td><td rowspan=1 colspan=1>allocatea dma descriptor</td><td rowspan=1 colspan=1>set of the sock event</td></tr><tr><td rowspan=1 colspan=1>SeqGNN</td><td rowspan=1 colspan=1>free dma buffers</td><td rowspan=1 colspan=1>release of the socket</td></tr><tr><td rowspan=1 colspan=1>HGNN</td><td rowspan=1 colspan=1>freeadma descriptor</td><td rowspan=1 colspan=1>release the sock event</td></tr><tr><td rowspan=1 colspan=1>Retrieved_code</td><td rowspan=1 colspan=1>static struct lpc32xx_usbd_dd_gad*udc_dd_alloc(structlpc32xx_udc *udc){dma_addr_t dma;struct lpc32xx_usbd_dd_gad *dd;dd =dma_pool_alloc(udc-&gt;dd_cache,GFP_ATOMIC|GFP_DMA,&amp;dma);if (dd)dd-&gt;this_dma = dma;return dd;1</td><td rowspan=1 colspan=1>void SetL2TPServerSockEvent(L2TP_SERVER *12tp,SOCK_EVENT *e){if (12tp == NULL){return;}if (e != NULL){AddRef(e-&gt;ref);}if(12tp-&gt;SockEvent != NULL){ReleaseSockEvent (12tp-&gt;SockEvent);12tp-&gt;SockEvent = NULL;}12tp-&gt;SockEvent = e;}</td></tr><tr><td rowspan=1 colspan=1>Retrieved_summary</td><td rowspan=1 colspan=1>allocatea dma descriptor</td><td rowspan=1 colspan=1>set a sock event to the l2tp server</td></tr><tr><td rowspan=1 colspan=1></td><td></td><td></td></tr></table>
390
+
391
+ # E MORE EXAMPLES
392
+
393
+ We show more examples along with the retrieved code and summary by dynamic programming in Table 5 and we can find that HGNN can generate more high-quality summries based on our approach.