ZHANGYUXUAN-zR commited on
Commit
81c0357
·
verified ·
1 Parent(s): 2ade668

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. md/dev/3FvF1db-bKT/3FvF1db-bKT.md +385 -0
  2. md/dev/3RBY8fKjHeu/3RBY8fKjHeu.md +243 -0
  3. md/dev/83LJRUzXWj/83LJRUzXWj.md +355 -0
  4. md/dev/9Vrb9D0WI4/9Vrb9D0WI4.md +0 -0
  5. md/dev/9XFSbDPmdW/9XFSbDPmdW.md +0 -0
  6. md/dev/9rKTy4oZAQt/9rKTy4oZAQt.md +408 -0
  7. md/dev/AXDNM76T1nc/AXDNM76T1nc.md +324 -0
  8. md/dev/BT03V9Re9a/BT03V9Re9a.md +491 -0
  9. md/dev/CAjxVodl_v/CAjxVodl_v.md +0 -0
  10. md/dev/CZZFRxbOLC/CZZFRxbOLC.md +334 -0
  11. md/dev/D78Go4hVcxO/D78Go4hVcxO.md +500 -0
  12. md/dev/DHyHRBwJUTN/DHyHRBwJUTN.md +0 -0
  13. md/dev/EbMuimAbPbs/EbMuimAbPbs.md +442 -0
  14. md/dev/Fkckkr3ya8/Fkckkr3ya8.md +0 -0
  15. md/dev/HjwK-Tc_Bc/HjwK-Tc_Bc.md +304 -0
  16. md/dev/HtqnVSCj3q/HtqnVSCj3q.md +0 -0
  17. md/dev/KWCZfuqshd/KWCZfuqshd.md +199 -0
  18. md/dev/MAMOi89bOL/MAMOi89bOL.md +235 -0
  19. md/dev/MkbcAHIYgyS/MkbcAHIYgyS.md +555 -0
  20. md/dev/NHeAUKlTO8/NHeAUKlTO8.md +404 -0
  21. md/dev/OdnNBNIdFul/OdnNBNIdFul.md +0 -0
  22. md/dev/Pyd6Rh9r1OT/Pyd6Rh9r1OT.md +285 -0
  23. md/dev/RYTBAtyXqJ/RYTBAtyXqJ.md +348 -0
  24. md/dev/SF9o3-yP1WR/SF9o3-yP1WR.md +485 -0
  25. md/dev/TCl7CbQ29hH/TCl7CbQ29hH.md +375 -0
  26. md/dev/UKd6dpVGdu/UKd6dpVGdu.md +347 -0
  27. md/dev/VAeAUWHNrty/VAeAUWHNrty.md +270 -0
  28. md/dev/WcZUevpX3H3/WcZUevpX3H3.md +251 -0
  29. md/dev/XrGEkCOREX2/XrGEkCOREX2.md +250 -0
  30. md/dev/_XNtisL32jv/_XNtisL32jv.md +342 -0
  31. md/dev/aD7uesX1GF_/aD7uesX1GF_.md +0 -0
  32. md/dev/bhUPJnS2g0X/bhUPJnS2g0X.md +0 -0
  33. md/dev/ebSOK1nV2r/ebSOK1nV2r.md +0 -0
  34. md/dev/ex60CCi5GS/ex60CCi5GS.md +272 -0
  35. md/dev/iAWNOXfLz0/iAWNOXfLz0.md +380 -0
  36. md/dev/iBBcRUlOAPR/iBBcRUlOAPR.md +261 -0
  37. md/dev/iC4UHbQ01Mp/iC4UHbQ01Mp.md +301 -0
  38. md/dev/iEvAf8i6JjO/iEvAf8i6JjO.md +364 -0
  39. md/dev/kTcRljax0x9/kTcRljax0x9.md +234 -0
  40. md/dev/kxXvopt9pWK/kxXvopt9pWK.md +322 -0
  41. md/dev/mxzIrQIOGIK/mxzIrQIOGIK.md +517 -0
  42. md/dev/o4uFFg9_TpV/o4uFFg9_TpV.md +282 -0
  43. md/dev/pfNyExj7z2/pfNyExj7z2.md +334 -0
  44. md/dev/rwE8SshAlxw/rwE8SshAlxw.md +464 -0
  45. md/dev/tGHi1HFNBx1/tGHi1HFNBx1.md +0 -0
  46. md/dev/toR64fsPir/toR64fsPir.md +496 -0
  47. md/dev/uy602F8cTrh/uy602F8cTrh.md +213 -0
  48. md/dev/voV_TRqcWh/voV_TRqcWh.md +299 -0
  49. md/dev/w1UbdvWH_R3/w1UbdvWH_R3.md +0 -0
  50. md/dev/xkjqJYqRJy/xkjqJYqRJy.md +658 -0
md/dev/3FvF1db-bKT/3FvF1db-bKT.md ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LOCAL AUGMENTATION FOR GRAPH NEURAL NETWORKS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Data augmentation has been widely used in image data and linguistic data but remains under-explored for Graph Neural Networks (GNNs). Existing methods focus on augmenting the graph data from a global perspective and largely fall into two genres: structural manipulation and adversarial training with feature noise injection. However, recent graph data augmentation methods ignore the importance of local information for the GNNs’ message passing mechanism. In this work, we introduce the local augmentation, which enhances the locality of node representations by their subgraph structures. Specifically, we model the data augmentation as a feature generation process. Given a node’s features, our local augmentation approach learns the conditional distribution of its neighbors’ features and generates more neighbors’ features to boost the performance of downstream tasks. Based on the local augmentation, we further design a novel framework: LA-GNN, which can apply to any GNN models in a plug-and-play manner. Extensive experiments and analyses show that local augmentation consistently yields performance improvement for various GNN architectures across a diverse set of benchmarks.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Graph Neural Networks (GNNs) and their variants (Abu-El-Haija et al., 2019; Kipf & Welling, 2017; Velickovi ˇ c et al., 2018) have achieved state-of-the-art performance for many tasks on graphs such as ´ recommendation system (Ying et al., 2018) and traffic prediction (Guo et al., 2019). However, most of the GNN models, such as GCN (Kipf & Welling, 2017) and GAT (Velickovi ˇ c et al., 2018), learn ´ the node representations by aggregating information over only the 2-hop neighborhood. Such shallow architectures limit their ability to extract information from higher-layer neighborhoods (Wang & Derr, 2021). But deep GNNs are prone to over-smoothing (Li et al., 2018), which suggests the node representations tend to converge to a certain vector and thus become indistinguishable. One solution to address this problem is to preserve the locality of node representations when increasing the number of layers. For example, JKNet (Xu et al., 2018) densely connects (Huang et al., 2017) each hidden layer to the final layer. GCNII (Chen et al., 2020) employs an initial residual to construct a skip connection from the input layer. Besides, Zeng et al. (2021) pointed out that the key for GNN is to smooth the local neighborhood into informative representation, no matter how deep it is. And they decouple the depth and scope of GNNs to help capture local graph structure. Prior works have emphasized the importance of local information, but one property of the graph is that the number of nodes in the local neighborhood is far fewer than higher-order neighbors. And this property limits the expressive power of GNNs due to the limited neighbors in the local structure. A very intuitive idea is to use data augmentation to increase the number of nodes in the local substructure.
12
+
13
+ However, existing graph data augmentation methods ignore the importance of local information and only perturb at the topology-level and feature-level from a global perspective, which can be divided into two categories: topology-level augmentation (Rong et al., 2020; Wang et al., 2020b; Zhao et al., 2021) and feature-level augmentation (Deng et al., 2019; Feng et al., 2019; Kong et al., 2020). Topology-level augmentation perturbs the adjacency matrix, yielding different graph structures. On the other hand, existing feature-level augmentation mainly exploits perturbation of node attributes guided by adversarial training (Deng et al., 2019; Feng et al., 2019; Kong et al., 2020). These augmentation techniques have two drawbacks. 1) Some of they employ full-batch training for augmentation, which is computationally expensive, and introduce some additional side effects such as over-smoothing. 2) The type of feature-level augmentation is coarse-grained, which focuses on global augmentation and overlooks the local information of the neighborhood. Moreover, to our best knowledge, none of the existing approaches combines both the feature representations and the graph topology, especially the local subgraph structures, for graph-level data augmentation.
14
+
15
+ In this work, we propose a framework: Local Augmentation for Graph Neural Networks (LA-GNNs), to further enhance the locality of node representations based on both the topology-level and featurelevel information in the substructure. The term "local augmentation" refers to the generation of neighborhood features via a generative model conditioned on local structures and node features. Specifically, our proposed framework learns the conditional distribution of the connected neighbors’ representations given the representation of the central node, bearing some similarities with the Skipgram (Mikolov et al., 2013) and Deepwalk Perozzi et al. (2014), with the difference that our method does not base on word or graph embedding.
16
+
17
+ The motivation behind this work concludes three-fold. 1) Existing feature-level augmentation works primarily pay attention to global augmentation without considering the informative neighborhood. 2) The distributions of the representations of the neighbors are closely connected to the central node, making ample room for feature augmentation. 3) Preserving the locality of node representations is key to avoiding over-smoothing $\mathrm { { X u } }$ et al., 2018; Klicpera et al., 2019; Chen et al., 2020). And there are several benefits in applying local augmentation for the GNN training. First, local augmentation is essentially a data augmentation technique that can improve the generalization of the GNN models and prevent over-fitting. Second, we can recover some missing contextual information of the local neighborhood in an attributed graph via the generative model (Jia & Benson, 2020). Third, our proposed framework is flexible and can be applied to various popular backbone networks such as GCN (Kipf & Welling, 2017), GAT (Velickovi ˇ c et al., 2018), GCNII (Chen et al., 2020), and ´ GRAND (Feng et al., 2020) to enhance their performance. Extensive experimental results demonstrate that our proposed framework could improve the performance of GNN variants on 7 benchmark datasets.
18
+
19
+ # 2 BACKGROUND
20
+
21
+ Notations. Let $G = ( V , E )$ represent the graph, where $V$ is the set of vertices $\{ v _ { 1 } , \cdots , v _ { N } \}$ with $| V | = N$ and $E$ is the set of edges. The adjacency matrix is defined as $\mathbf { A } \in \{ 0 , 1 \} ^ { N \times N }$ , and nod $\mathbf { A } _ { i j } = 1$ f and only if denote the d $( v _ { i } , v _ { j } ) \in E$ . Let ee ma $\mathcal { N } _ { i } \overset { \cdot } { = } \{ v _ { j } \vert \mathbf { A } _ { i j } = 1 \}$ the neighborhood of. The feature matrix $v _ { i }$ $\mathbf { D }$ $\begin{array} { r } { \dot { \bf D } _ { i i } = \dot { \sum } _ { j = 1 } ^ { n } { \bf A } _ { i j } } \end{array}$ is denoted as $\mathbf { X } \in \mathbb { R } ^ { N \times F }$ where each node $v$ is associated with a $F$ -dimensional feature vector $\mathbf { X } _ { v }$ . $\mathbf { Y } \in \{ 0 , 1 \} ^ { N \times C }$ denote the one-hot label matrix, where $\mathbf { Y } _ { i } \in \{ 0 , 1 \} ^ { C }$ is a one-hot vector and $\begin{array} { r } { \sum _ { j = 1 } ^ { C } \mathbf { Y } _ { i j } = 1 } \end{array}$ for any $v _ { i } \in V$ .
22
+
23
+ GNN. Graph Neural Network (GNN) is a type of neural network that directly operates on the graph structure, such as GCN and GAT (Kipf & Welling, 2017; Velickovi ˇ c et al., 2018), that capture the ´ dependence of graphs via message passing between the nodes of a graph as
24
+
25
+ $$
26
+ \mathbf { H } ^ { ( \ell ) } = f ( \mathbf { A } , \mathbf { H } ^ { ( \ell - 1 ) } ) ,
27
+ $$
28
+
29
+ where $f$ denotes the specific GNN layer for different models, $\mathbf { H } ^ { ( \ell ) }$ are the hidden vectors of the $\ell$ -th layer and $\mathbf { H } ^ { ( 0 ) } = \mathbf { X }$ . For example, $\dot { f ( \mathbf { A } , \mathbf { H } ) } = \sigma ( \hat { \mathbf { A } } \mathbf { H } \mathbf { W } )$ for GCN, where $\hat { \mathbf { A } } = \tilde { \mathbf { D } } ^ { - \frac { 1 } { 2 } } \tilde { \mathbf { A } } \tilde { \mathbf { D } } ^ { - \frac { 1 } { 2 } } ,$ $\tilde { \bf D }$ is the degree matrix of $\tilde { \mathbf { A } }$ , i.e., $\begin{array} { r } { \tilde { \bf D } _ { i i } = \sum _ { j } \tilde { \bf A } _ { i j } } \end{array}$ , and $\tilde { \mathbf { A } } = \mathbf { A } + \mathbf { I }$ .
30
+
31
+ Topology-level Augmentation. Topology-level augmentation usually perturbs $\mathbf { A }$ to generate different graph structures, which can be formulated as $\mathbf { A } ^ { \prime } = \mathcal { F } ( \mathbf { A } , \mathbf { X } )$ , where $\mathcal F ( \cdot )$ is a structure perturbation function. For example, DropEdge (Rong et al., 2020) considers $\mathcal { F } ( \mathbf { A } , \mathbf { X } ) = \mathbf { A } - \mathbf { A _ { s } }$ which is independent of $\mathbf { X }$ , where $\mathbf { A _ { s } }$ is a sparse matrix consists of a subset of the original edges $E$ . GAUG-O (Zhao et al., 2021) leverages their proposed neural edge predictors to produce a different structure $\mathbf { A } ^ { \prime }$ where $\begin{array} { r } { \mathbf { A } _ { i j } ^ { \prime } = \left\lfloor \frac { 1 } { 1 + e ^ { - \left( \log \mathbf { P } _ { i j } + G \right) / \tau } } + \frac { 1 } { 2 } \right\rfloor } \end{array}$ , $\mathbf { P } _ { i j } = \alpha \mathbf { M } _ { i j } + ( 1 - \alpha ) \mathbf { A } _ { i j }$ , $\mathbf { M } = { \boldsymbol { \sigma } } \left( \mathbf { Z } \mathbf { Z } ^ { T } \right)$ , $\mathbf { Z } = f \left( \mathbf { A } , f ( \mathbf { A } , \mathbf { X } ) \right)$ , $\tau$ is the temperature of Gumbel-Softmax distribution, $G \sim { \mathrm { G u m b e l } } ( 0 , 1 )$ is a Gumbel random variate, and $\alpha$ is a hyperparameter mediating the influence of edge predictor on the original graph.
32
+
33
+ # Feature-level Augmentation.
34
+
35
+ Besides, feature-level augmentation function can be defines as $\mathbf { X } ^ { \prime } \ = \ \mathcal { H } ( \mathbf { A } , \mathbf { X } )$ , where $\mathcal { H } ( \cdot )$ is a feature perturbation function. FLAG (Kong et al., 2020) defines the perturbation function as $\begin{array} { r } { \mathcal { H } ( \mathbf { A } , \mathbf { X } ) = \textbf { X } + \boldsymbol { \delta } } \end{array}$ where
36
+
37
+ Table 1: Comparison of existing graph data augmentation.
38
+
39
+ <table><tr><td colspan="4">GraphData Augmentation</td></tr><tr><td>Method</td><td>ConsideredPart</td><td>Type</td><td>Perturbed Part</td></tr><tr><td>DropEdge</td><td>A</td><td>Sampling</td><td>A</td></tr><tr><td>GAUG-O</td><td>A&amp;X</td><td>Reconstruction</td><td></td></tr><tr><td>FLAG</td><td>X</td><td>Noise Injection</td><td></td></tr><tr><td>G-GCN</td><td>A&amp;X</td><td>Reconstruction</td><td>AXX</td></tr><tr><td>Local Augmentation</td><td>A&amp;X</td><td>Generation</td><td>X</td></tr></table>
40
+
41
+ perturbation $\pmb { \delta }$ is updated iteratively during the adversarial training phase. G-GCN (plain) (Zhu et al., 2020) obtains the global attribute feature matrix $\mathbf { X } ^ { ( a ) } \in \bar { \mathbb { R } ^ { N \times d _ { a } } }$ through minimizing the objective Qv∈V Qa∈CA(v) v a Pk∈U expX(a)v ·Vk where $U$ is the set of all attributes, $C A ( v )$ is the sampled context attributes of $v$ , and $\mathbf { V } \in \mathbb { R } ^ { d _ { a } \times F }$ denotes the parameters. Obviously, the perturbation function of G-GCN has no close-form solution. In this work, we propose a novel feature-level augmentation method, named local augmentation. And the comparison of the details of various graph data augmentation techniques can be found in Table 1.
42
+
43
+ # 3 LOCAL AUGMENTATION
44
+
45
+ In this section, we describe details of the proposed method. The local augmentation framework consists of three modules: learning the conditional distribution via a generative model, the active learning trick, and the downstream GNN models, as illustrated in Figure 1. Note that the proposed algorithm enhances the locality of node representations through augmenting 1-hop neighbors in a generative way. Specifically, we exploit a generative model to learn the conditional distribution of the connected neighbors’ representations given the representation of a node. We describe the details of learning the conditional distribution and the motivation for why local augmentation is able to improve the performance in a probabilistic view in Sec. 3.1, detail the architecture of downstream GNN models in Sec. 3.2. We finally elaborate the training procedure of both the generative model and the downstream GNN models with the active learning trick in Sec. 3.3.
46
+
47
+ ![](images/a25e0a452d09cb122f2cc05b960b1e984bdab4b6769823194b1ac823b6b03d23.jpg)
48
+ Figure 1: A schematic depiction of our local augmentation. The purple and yellow circles on the graph correspond to the central node and its augmented neighbors respectively. After augmenting the neighborhood, we exploit the initial and the generated feature matrix as input for downstream GNNs.
49
+
50
+ # 3.1 LEARNING THE CONDITIONAL DISTRIBUTION
51
+
52
+ We start by reviewing the semi-supervised learning of GNNs in a probabilistic view. Most existing GNN models (Kipf & Welling, 2017; Velickovi ˇ c et al., 2018) are viewed as a classification function ´ to predict the class labels of the graph nodes. In this work, we use a GNN classification estimator $P _ { \theta } ( \mathbf { Y } | \mathbf { A } , \mathbf { X } )$ $\theta$ is the parameter) to model the conditional distribution of label $\mathbf { Y }$ with respect to the graph structure A and feature matrix X. Given training samples $\{ \mathbf { A } , \mathbf { X } , \mathbf { Y } \}$ , the parameter $\theta$ can be estimated using Maximum Likelihood Estimation (MLE), by optimizing the following likelihood function:
53
+
54
+ $$
55
+ \operatorname* { m a x } \prod _ { k \in \mathbf { K } } P _ { \theta } \left( \mathbf { Y } _ { k } | \mathbf { A } , \mathbf { X } \right) ,
56
+ $$
57
+
58
+ where $\mathbf { K }$ is the set of node indices of the training dataset whose labels are visible during the semi-supervised training. To further boost the performance of GNN, we introduce a new model $P _ { \theta } ( { \bf Y } , \overline { { { \bf X } } } | { \bf A } , { \bf X } )$ , where $\overline { { \mathbf { X } } }$ is generated features by feature-level augmentation. For this model, the MLE method needs to optimize a marginalized probability $P _ { \theta }$ over the generated feature matrix $\overline { { \mathbf { X } } }$ :
59
+
60
+ $$
61
+ \operatorname* { m a x } \prod _ { k \in \mathbf { K } } \int _ { \overline { { \mathbf { X } } } } P _ { \theta } \left( \mathbf { Y } _ { k } , \overline { { \mathbf { X } } } | \mathbf { A } , \mathbf { X } \right) .
62
+ $$
63
+
64
+ For Bayesian tractability, we decompose $P _ { \theta }$ in Eq.(3) as a product of two posterior probabilities:
65
+
66
+ $$
67
+ \begin{array} { r } { P _ { \theta , \phi } ( \mathbf { Y } _ { k } , \overline { { \mathbf { X } } } | \mathbf { A } , \mathbf { X } ) : = P _ { \theta } ( \mathbf { Y } _ { k } | \mathbf { A } , \mathbf { X } , \overline { { \mathbf { X } } } ) Q _ { \phi } ( \overline { { \mathbf { X } } } | \mathbf { A } , \mathbf { X } ) , } \end{array}
68
+ $$
69
+
70
+ where $P _ { \theta } ( \mathbf { Y } _ { k } | \mathbf { A } , \mathbf { X } , \mathbf { \overline { { X } } } )$ and $Q _ { \phi } ( { \overline { { \mathbf { X } } } } | \mathbf { A } , \mathbf { X } )$ denote the probabilistic distributions approximated by the downstream GNN and the (feature-level augmentation) generator respectively, parameterized by $\theta$ and $\phi$ . There are two benefits in the decomposition above. First, it allows us to decouple the training of the downstream predictor $P _ { \theta }$ and the generator $Q _ { \phi }$ , enabling the generator to easily generalize to other downstream tasks. Moreover, inspired by the successes of data augmentation via deep-learning-based generative modeling (Antoniou et al., 2017), the representation power of Eq.(4) is superior than that of a single predictor $P _ { \theta } \left( \mathbf { Y } _ { k } | \mathbf { A } , \mathbf { X } \right)$ without data augmentation.
71
+
72
+ Consequently, once a generator $Q _ { \phi }$ is trained very well, our training procedure can optimize $P _ { \theta } ( \mathbf { Y } _ { k } | \mathbf { A } , \mathbf { X } , \mathbf { \overline { { X } } } )$ with samples $\overline { { \mathbf { X } } }$ drawn from the fixed conditional distribution $Q _ { \phi }$ . Now, we show how to train the generator as follows.
73
+
74
+ Generator To learn a feature augmentation generator, a naive solution is to learn one single distribution for all the neighbors using the MLE method, i.e., solving the following optimization problem
75
+
76
+ $$
77
+ \operatorname* { m a x } _ { \psi } \sum _ { j \in \mathcal { N } _ { i } } \log p _ { \psi } \left( \mathbf { X } _ { j } | \mathbf { X } _ { i } \right) = \operatorname* { m a x } _ { \psi } \log \prod _ { j \in \mathcal { N } _ { i } } p _ { \psi } \left( \mathbf { X } _ { j } | \mathbf { X } _ { i } \right) ,
78
+ $$
79
+
80
+ where $\{ \mathbf { X } _ { j \mid j \in \mathcal { N } _ { i } } , \mathbf { X } _ { i } \}$ . Then $p _ { \psi }$ can be used to augment features for all the neighbors. However, this method ignores the differences between all the neighbors, which may induce severe noise.
81
+
82
+ To overcome the limitation, we assume that each neighbor satisfies a different conditional distribution. Specifically, there exists a conditional distribution $p ( \cdot | \mathbf { X } _ { i } , \mathbf { z } _ { j } )$ with latent random variable $\mathbf { z } _ { j }$ , such that we have $\mathbf { X } _ { j } \sim p ( \mathbf { X } | \mathbf { X } _ { i } , \mathbf { z } _ { j } )$ for $\mathbf { X } _ { j \mid j \in \mathcal { N } _ { i } }$ . Once we obtain $p ( \cdot | \mathbf { X } _ { i } , \mathbf { z } _ { j } )$ in some way, we can generate augmented features $\overline { { \mathbf { X } } }$ , and then we can train $P _ { \theta } ( \mathbf { Y } _ { k } | \mathbf { A } , \mathbf { X } , \mathbf { \overline { { X } } } )$ instead of $P _ { \theta } ( \mathbf { Y } _ { k } | \mathbf { A } , \mathbf { X } )$ to improve the final performance of $P _ { \theta }$ . Below, we will present how to find $p ( \cdot | \mathbf { X } _ { i } , \mathbf { z } _ { j } )$ , which will produce the generator $Q _ { \phi }$ .
83
+
84
+ To achieve our purpose, a suitable method is the conditional variational auto-encoder (CVAE) (Kingma & Welling, 2013; Sohn et al., 2015), which can help learn the distribution of the latent variable $\mathbf { z } _ { j }$ , and the conditional distribution $p ( \cdot | \mathbf { X } _ { i } , \mathbf { z } _ { j } )$ . So, a CVAE model $Q _ { \phi } \left( \overline { { \mathbf { X } } } | \mathbf { A } , \mathbf { X } \right)$ is adopted as our generator, where $\phi = \{ \varphi , \psi \}$ , $\varphi$ denotes the variational parameters and $\psi$ represents the generative parameters. To derive the optimization problem for CVAE, $\log p _ { \psi } \left( \mathbf { X } _ { j } | \mathbf { X } _ { i } \right)$ can be written with latent variables $\mathbf { z }$ as follows, following previous work (Pandey & Dukkipati, 2017; Sohn et al., 2015):
85
+
86
+ $$
87
+ \begin{array} { l } { \log p _ { \psi } ( \mathbf { X } _ { j } | \mathbf { X } _ { i } ) = \displaystyle \int q _ { \varphi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) \log \frac { p _ { \psi } ( \mathbf { X } _ { j } , \mathbf { z } | \mathbf { X } _ { i } ) } { q _ { \varphi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) } \mathrm { d } \mathbf { z } + K L ( q _ { \varphi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) \| p _ { \psi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) ) } \\ { \displaystyle \qquad \geq \int q _ { \varphi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) \log \frac { p _ { \psi } ( \mathbf { X } _ { j } , \mathbf { z } | \mathbf { X } _ { i } ) } { q _ { \varphi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) } \mathrm { d } \mathbf { z } , } \end{array}
88
+ $$
89
+
90
+ and the evidence lower bound (ELBO) can be written as:
91
+
92
+ $$
93
+ \mathcal { L } ( \mathbf { X } _ { j } , \mathbf { X } _ { i } ; \psi , \varphi ) = - K L ( q _ { \varphi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) | | p _ { \psi } ( \mathbf { z } | \mathbf { X } _ { i } ) ) + \int q _ { \varphi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) \log p _ { \psi } ( \mathbf { X } _ { j } | \mathbf { X } _ { i } , \mathbf { z } ) \mathrm { d } \mathbf { z } ,
94
+ $$
95
+
96
+ where the encoder $q _ { \varphi } ( \mathbf { z } | \mathbf { X } _ { j } , \mathbf { X } _ { i } ) \ = \ { \mathcal { N } } ( f ( \mathbf { X } _ { j } , \mathbf { X } _ { i } ) , g ( \mathbf { X } _ { j } , \mathbf { X } _ { i } ) )$ and decoder $p _ { \psi } ( { \bf X } _ { j } | { \bf X } _ { i } , { \bf z } ) =$ $\mathcal { N } ( h ( \mathbf { X } _ { i } , \mathbf { z } ) , c I )$ . The encoder is a two-layer MLP. $f$ and $g$ share the first layer, and their second layers employ different parameters. The decoder $h$ is two-layer MLP. For simplicity and tractability, the implemented generator $Q \left( \overline { { \mathbf { X } } } | \mathbf { A } , \mathbf { X } \right)$ uses the same parameters across all nodes $v _ { i } \in V$ .
97
+
98
+ Optimization of the MLE Now, we present how to optimize the MLE Eq.(4) using the feature matrix produced from the generator. Once the augmented feature matrix can be sampled from the generator, we can optimize the parameters of Eq.(4) in the following way. Firstly, the parameter $\bar { \phi } = \{ \psi , \varphi \}$ can be optimized by maximizing the ELBO of the generator (6), i.e., we train the generator. Secondly, the parameter $\theta$ is optimized by maximizing the MLE Eq.(4) with $\phi$ fixed, which is the conditional distribution of ${ \bf Y } _ { k }$ given A, $\mathbf { X }$ , and $\overline { { \mathbf { X } } }$ , i.e., we train the downstream GNN model.
99
+
100
+ In this paper, the MLE is formulated by a downstream GNN model as follows:
101
+
102
+ $$
103
+ P _ { \theta } \left( \mathbf { Y } _ { k } \mid \mathbf { A } , \mathbf { X } , { \overline { { \mathbf { X } } } } \right) \propto - { \overline { { \mathcal { L } } } } ( \theta | \mathbf { A } , \mathbf { X } , { \overline { { \mathbf { X } } } } , \phi ) ,
104
+ $$
105
+
106
+ $$
107
+ \begin{array} { r } { \overline { { \mathcal { L } } } ( \theta | \mathbf { A } , \mathbf { X } , \overline { { \mathbf { X } } } , \phi ) = - \sum _ { k \in \mathbf { T } } \sum _ { f = 1 } ^ { C } \mathbf { Y } _ { k f } \ln \Big ( \mathrm { s o f t m a x } \big ( \mathrm { G N N } ( \mathbf { A } , \mathbf { X } , \overline { { \mathbf { X } } } ) \big ) _ { k f } \Big ) . } \end{array}
108
+ $$
109
+
110
+ # 3.2 THE ARCHITECTURE OF LA-GNN
111
+
112
+ We discuss the details of downstream GNN models. And we use GCN, GAT, GCNII, and GRAND as the backbones and test them on semi-supervised node classification tasks. We name the modified GNN architecture as LA-GNN, where LA means local augmentation.
113
+
114
+ LA-GCN A 2-layer LA-GCN is defined as follows:
115
+
116
+ $$
117
+ \mathbf { H } ^ { ( 2 ) } = \sigma \left( \hat { \mathbf { A } } \left( \sigma \left( \hat { \mathbf { A } } \mathbf { X } \mathbf { W } _ { 1 } ^ { ( 1 ) } \right) \bigg | \bigg | \sigma \left( \hat { \mathbf { A } } \overline { { \mathbf { X } } } _ { 1 } \mathbf { W } _ { 2 } ^ { ( 1 ) } \right) \bigg | \bigg | \cdots \bigg | \bigg | \sigma \left( \hat { \mathbf { A } } \overline { { \mathbf { X } } } _ { n } \mathbf { W } _ { n + 1 } ^ { ( 1 ) } \right) \right) \mathbf { W } ^ { ( 2 ) } \right) ,
118
+ $$
119
+
120
+ where $\overline { { \mathbf { X } } } _ { i }$ $\bar { \mathsf { \bar { c } } } _ { i } ( i = 1 , 2 , \cdots , n )$ is the augmented feature matrix produced by the generator, $\parallel$ denotes an operator of column-wise concatenation, $\mathbf { W } _ { i } ^ { ( 1 ) } \left( i = 1 , 2 , \cdots , n \right)$ denotes the parameters of the first LA-GCN layer, and $\mathbf { W } ^ { ( 2 ) }$ denotes the parameters of the second LA-GCN layer.
121
+
122
+ LA-GCNII Since GCNII (Chen et al., 2020) applies a fully-connected neural network on $\mathbf { X }$ to obtain a lower-dimensional initial representation $\mathbf { H } ^ { ( 0 ) }$ before the forward propagation, we apply a fully-connected neural network on $\mathbf { X }$ and $\overline { { \mathbf { X } } }$ to obtain $\mathbf { H } ^ { ( 0 ) }$ for LA-GCNII as follows:
123
+
124
+ $$
125
+ \mathbf { H } ^ { ( 0 ) } = \sigma ( \mathbf { X } \mathbf { W } _ { 1 } ^ { ( 0 ) } ) \| \sigma ( \overline { { \mathbf { X } } } _ { 1 } \mathbf { W } _ { 2 } ^ { ( 0 ) } ) \| \cdots \| \sigma ( \overline { { \mathbf { X } } } _ { n } \mathbf { W } _ { n + 1 } ^ { ( 0 ) } ) .
126
+ $$
127
+
128
+ $\mathbf { H } ^ { ( 0 ) }$ is fed into the next forward propagation layer. Besides, we do not modify the architecture of GAT and GRAND, and just add our generated feature matrix to the input.
129
+
130
+ # 3.3 ACTIVE LEARNING
131
+
132
+ In this section, we introduce a trick for the overall training framework. After the training of the generator finishes, it contains an issue of using $Q _ { \phi } ( { \overline { { \mathbf { X } } } } | \mathbf { A } , \mathbf { X } )$ of Eq.(4) for inference because $Q$ may generate some samples from the side part of the distribution. This critical question makes the inferences inefficient. Inspired by Nielsen & Okoniewski (2019), we introduce active learning to capture the suitable generated feature matrix and the corresponding generator, which improves the inference efficiency and helps the optimization of the MLE. During active learning, the probability of each feature is proportional to its uncertainty evaluated by an acquisition function. We adopt the Bayesian Active Learning by Disagreement (BALD) acquisition function (Houlsby et al., 2011) to sample the most important inferences with the approximation from the Monte Carlo (MC) dropout samples as
133
+
134
+ $$
135
+ { \cal U } ( \overline { { \mathbf { X } } } ) \approx H \left[ \frac { 1 } { N } \sum _ { n = 1 } ^ { N } P \left( \mathbf { Y } _ { k } | \overline { { \mathbf { X } } } , \omega _ { n } \right) \right] - \frac { 1 } { N } \sum _ { n = 1 } ^ { N } H \left[ P \left( \mathbf { Y } _ { k } | \overline { { \mathbf { X } } } , \omega _ { n } \right) \right] ,
136
+ $$
137
+
138
+ where $N$ is the number of MC samples and $\omega _ { n }$ are the parameters of the network sampled for the $n$ -th MC dropout sample. A high BLAD score indicates a network with high uncertainty about the generated feature matrix. So it tends to be selected to improve the GNN model. Finally, the overall algorithm framework is summarized in Algorithm 1, which shows the optimization of Eq.(4).
139
+
140
+ Algorithm 1 The framework to train the Generator $Q _ { \phi }$ and the downstream GNN $P _ { \theta }$ using the initial feature matrix $\mathbf { X }$ and the generated feature matrix $\overline { { \mathbf { X } } }$ selected by the acquisition function
141
+
142
+ 1: Initialize $U { = }$ -inf, $\overline { { \mathbf { X } } }$ , $Q _ { \phi }$ , $\overline { { \mathbf { X } } } ^ { \prime }$ , and $Q _ { \phi } ^ { \prime }$
143
+ 2: for $i = 1$ to the number of generator iterations do
144
+ 3: Train the generator $Q _ { \phi }$ using $\mathbf { A }$ and $\mathbf { X }$
145
+ 4: Generate feature matrix $\overline { { \mathbf { X } } }$ using $Q _ { \phi }$
146
+ 5: Compute $U ( { \overline { { \mathbf { X } } } } )$ using Eq.(10).
147
+ 6: if $U ( { \overline { { \mathbf { X } } } } ) > U$ then
148
+ 7: $U = U ( { \overline { { \mathbf { X } } } } )$
149
+ 8: if $i > N _ { w a r m u p }$ then
150
+ 9: Train GNN $P _ { \theta }$ using $\mathbf { A }$ and $\overline { { \mathbf { X } } }$ for the number of continued GNN training iterations
151
+ 10: X 0 = X , Q 0φ = Q φ
152
+ 11: $\overline { { \mathbf { X } } } = \overline { { \mathbf { X } } } ^ { \prime }$ , $Q _ { \phi } = Q _ { \phi } ^ { \prime }$
153
+ 12: Train the downstream GNN $P _ { \theta }$ with the generated feature matrix $\overline { { \mathbf { X } } }$ , and generator $Q _ { \phi }$
154
+
155
+ # 4 DISCUSSION
156
+
157
+ In this section, we discuss the motivation of this work and provide some analysis.
158
+
159
+ Connection to EP-B and GraphSAGE We discuss how our proposed model distinguishes from the classical representation learning models on graphs. Previous methods such as EP-B (GarcíaDurán & Niepert, 2017) and GraphSAGE (Hamilton et al., 2017) rely on reconstruction loss function between the central node and its neighbors’ embeddings. EP-B aims to minimize the reconstruction error by optimizing the objective $\begin{array} { r } { \operatorname* { m i n } { \sum _ { u \in V \backslash \{ v \} } } \left[ \gamma + d ( \widetilde { \mathbf { X } } _ { v } , \mathbf { X } _ { v } ) - d ( \widetilde { \mathbf { X } } _ { v } , \mathbf { X } _ { u } ) \right] } \end{array}$ where $\mathbf { X } _ { v }$ represents the target node; $\mathbf { X } _ { u }$ denotes the neighbor nodes; $\widetilde { \mathbf { X } } _ { v } = \mathrm { A G G } ( \mathbf { X } _ { l } | l \in \mathcal { N } ( v ) )$ indicates the reconstruction from neighbors; and $\gamma$ refers to the bias. Besides, GraphSAGE exploits the negative sampling to differentiate the representations of remote node-pairs. GraphSAGE enforce nearby nodes to have similar representations and to enforce disparate nodes to be distinct by minimizing the objective $\operatorname* { m i n } - E _ { u \sim \mathcal { N } ( v ) } \overset { \cdot } { \log } \left( \left( \sigma ( \mathbf { X } _ { u } ^ { T } \mathbf { X } _ { v } ) \right) \right) - \lambda E _ { v _ { n } \sim P _ { n } ( v ) } \log \left( \left( \sigma ( - \mathbf { X } _ { v _ { n } } ^ { T } \mathbf { X } _ { v } ) \right) \right)$ where $\mathbf { X } _ { v }$ denotes target node; $\mathbf { X } _ { u }$ represents the neighbor node; ${ \bf X } _ { v _ { n } }$ is disparate node; and $P _ { n } ( v )$ is the negative sampling. These approaches build upon the assumption that adjacent nodes share similar attributes. In contrast, our model does not rely on such assumption and instead generates the neighboring node features from the conditional distribution of central node representations. Given the target node, $\mathbf { X } _ { v }$ , our aim is to learn the conditional distribution of the neighbor nodes, $\mathbf { X } _ { u }$ . A comparison between the reconstruction-based representation learning on graphs and our proposed framework is illustrated in Figure 2. And our local augmentation method is the third paradigm to exploit neighbors in a generative way.
160
+
161
+ ![](images/02db34de261ebadeed56e54daa7a15cd3eaa86f7795ea776ca63ea498b28e4a9.jpg)
162
+ Figure 2: (a) The original graph. (b) EP-B exploits the neighbors to reconstruct the central node’s embedding. (c) GraphSAGE encourages nearby nodes to have similar embeddings. (d) Given the representation of the central node, our aim is to infer the representations of the connected distribution of neighbors.
163
+
164
+ Local Augmentation vs. General Augmentation General image augmentation algorithms include geometric transformations, feature space augmentation, adversarial training, and generative adversarial networks (Shorten & Khoshgoftaar, 2019). It is impossible to apply geometric transformations directly to graph data augmentation since graphs are sensitive to node permutation. General adversarial training, feature space augmentation, and generative adversarial networks don’t take the graph structure into account. Graphs consist of a set of identities with certain pairs of these identities connected by edges. We need to consider node features and the graph structure when designing the graph data augmentation framework. Our proposed method of local augmentation fully considers these two points. By extracting the neighbors’ feature vectors, we have enough data points to learn the distribution. There are two benefits to designing local augmentation. First, by taking the sub-graph structure and feature representation associated with this sub-graph structure as input for the generative model, we can learn the information of the sub-graph structure. Second, the number of data points to learn the distribution depends on the node degree. This assures that we have enough data points compared with the general feature augmentation and we can learn a better distribution.
165
+
166
+ Complementing missing information Jia & Benson (2020) points out that some attribute information might be missing on a subset of vertices. By learning the distribution of node representations from the observed data, we can utilize the produced node representations from the generative model to complement the information missing in the nodes’ attributes, which boosts the robustness of downstream tasks. And we show that our model still works in the scenario that nodes lose a certain percentage of attributes. In other words, we can exploit the well-learned distribution to complement the contextual information of the local neighborhood to enhance the locality of the node representations.
167
+
168
+ # 5 EXPERIMENTS
169
+
170
+ In this section, we evaluate the performance of our proposed model on semisupervised node classification tasks on a variety of public graph datasets and compare our model with the state-of-the-art graph neural networks. We also carry out additional experiments to showcase the necessity of our design and its robustness to missing information.
171
+
172
+ Table 2: Classification results on fixed split $( \% )$
173
+
174
+ <table><tr><td>Method</td><td>Cora</td><td>Citeseer</td><td>Pubmed</td></tr><tr><td>Chebyshev (Defferrard et al.,2016)</td><td>81.2</td><td>69.8</td><td>74.4</td></tr><tr><td>APPNP (Klicpera et al.,2019)</td><td>83.8</td><td>71.6</td><td>79.7</td></tr><tr><td>MixHop (Abu-El-Haija et al.,2019)</td><td>81.9</td><td>71.4</td><td>80.8</td></tr><tr><td>Graph U-net (Gao&amp; Ji,2019)</td><td>84.4</td><td>73.2</td><td>79.6</td></tr><tr><td>GSNN-M (Wang et al.,2020a)</td><td>83.9</td><td>72.2</td><td>79.1</td></tr><tr><td>S²GC (Zhu &amp; Koniusz,2021)</td><td>83.5</td><td>73.6</td><td>80.2</td></tr><tr><td>GCN (Kipf &amp; Welling,2017)</td><td>81.6</td><td>70.3</td><td>78.9</td></tr><tr><td>G-GCN (Zhu et al.,2020)</td><td>83.7</td><td>71.3</td><td>80.9</td></tr><tr><td>DropEdge-GCN (Rong et al.,2020)</td><td>82.8</td><td>72.3</td><td>79.6</td></tr><tr><td>GAUG-O-GCN (Zhao et al.,2021)</td><td>83.6</td><td>73.3</td><td>79.3</td></tr><tr><td>LA-GCN</td><td>84.1</td><td>72.5</td><td>81.3</td></tr><tr><td>GAT (Velickovic et al., 2018)</td><td>83.0</td><td>70.4</td><td>0OM</td></tr><tr><td>LA-GAT</td><td>83.9</td><td>72.3</td><td>OOM</td></tr><tr><td>GCNII (Chen et al.,2020) LA-GCNII</td><td>85.2</td><td>73.1</td><td>80.0</td></tr><tr><td></td><td>85.2</td><td>73.7</td><td>81.6</td></tr><tr><td>GRAND (Feng et al.,2020)</td><td>85.4</td><td>75.4</td><td>82.7</td></tr><tr><td>LA-GRAND</td><td>85.8</td><td>75.8</td><td>83.3</td></tr></table>
175
+
176
+ # 5.1 DATASETS
177
+
178
+ We utilize seven public graph datasets (Cora, Citeseer, Pubmed, Squirrel, Actor, Chameleon, and Cornell) for semisupervised node classification tasks. The details of these datasets can be found in the appendix.
179
+
180
+ # 5.2 SEMI-SUPERVISED NODE CLASSIFICATION
181
+
182
+ Baselines and Experimental Setup. We apply the standard fixed splits (Yang et al., 2016) on three datasets Cora, Citeseer, and Pubmed, with 20 nodes per class for training, 500 nodes for validation, and 1,000 nodes for testing. And we consider four backbones: GCN (Kipf & Welling, 2017), GAT (Velickovi ˇ c et al., 2018), GCNII (Chen ´ et al., 2020), and GRAND (Feng et al., 2020) to evaluate our proposed framework and compare our model against state-of-the-art models including 1) backbone models: Chebyshev (Defferrard et al., 2016), GCN, GAT,
183
+
184
+ Table 3: Classification results on random split $( \% )$
185
+
186
+ <table><tr><td>Method</td><td>Squirrel</td><td>Actor</td><td>Chameleon</td><td>Cornell</td></tr><tr><td>APPNP</td><td>21.6</td><td>32.1</td><td>33.0</td><td>58.7</td></tr><tr><td>S²GC</td><td>21.3</td><td>27.8</td><td>30.2</td><td>57.2</td></tr><tr><td>GCN</td><td>22.5</td><td>26.2</td><td>25.1</td><td>55.7</td></tr><tr><td>DropEdge-GCN</td><td>21.9</td><td>26.5</td><td>25.0</td><td>53.6</td></tr><tr><td>LA-GCN</td><td>23.2</td><td>27.0</td><td>28.9</td><td>56.1</td></tr><tr><td>GAT</td><td>24.2</td><td>27.2</td><td>34.8</td><td>55.8</td></tr><tr><td>LA-GAT</td><td>28.2</td><td>27.4</td><td>38.6</td><td>56.5</td></tr><tr><td>GCNII</td><td>25.3</td><td>31.9</td><td>30.2</td><td>57.3</td></tr><tr><td>LA-GCNII</td><td>28.6</td><td>32.7</td><td>32.5</td><td>56.6</td></tr></table>
187
+
188
+ APPNP (Klicpera et al., 2019), Graph U-net (Gao & Ji, 2019), MixHop (Abu-El-Haija et al., 2019), GCNII, GSNN-M (Wang et al., 2020a), $\mathrm { { \cal S } ^ { 2 } { \cal G } { \cal C } }$ (Zhu & Koniusz, 2021), and GRAND and 2) featurelevel and topology-level augmentation models: G-GNNs (Zhu et al., 2020), DropEdge (Rong et al.,
189
+
190
+ 2020) and GAUG-O (Zhao et al., 2021). For four datasets Squirrel, Actor, Chameleon, and Cornell, we take 10 random splits (Shchur et al., 2018) where $10 \%$ , $30 \%$ , and $60 \%$ of the date for training, validation, testing; measure the performance of GCN, GAT, GCNII, and corresponding modified models.
191
+
192
+ Results For three datasets Cora, Citeseer, and Pubmed, we report the mean classification accuracy on the test nodes of all our models after 100 runs and report the values after running the experiments of their models with our server under their setting hyperparameters in their original papers. The results of the evaluation experiments are summarized in Tables 2, 3, and in the appendix, which demonstrate that the backbone models equipped with our method achieve the best performance across all the datasets except the Cornell dataset. More specifically, we can improve upon GCN by a margin of $2 . 5 \%$ , $2 . 2 \%$ , and $2 . 4 \%$ on Cora, Citeseer, and Pubmed respectively. Moreover, LA-GNN outperforms other backbone models including GAT and GCNII as well as data augmentation models (Zhu et al., 2020; Rong et al., 2020; Zhao et al., 2021) on these citation network datasets. Besids, we also provide the analysis of the distribution of our generated feature matrix. And Figure 3 shows the distribution of the attributes of the original
193
+
194
+ and inference neighbors, which can demonstrate our inference feature matrix follow the distribution of the initial feature matrix.
195
+
196
+ ![](images/410d67587b543d15cc65cba5cdc78b6ecc62b88dfffe4c1dfb7018aab80db729.jpg)
197
+ Figure 3: The distribution of the attribute bin of the inference neighbors vs. the distribution of the attribute bin of the original neighbors, with KL divergence $= 0 . 0 0 2 6$ . The value of each feature bin is the sum of the attribute values of multiple dimensions of the feature vector. We split the feature vector into multiple feature bins.
198
+
199
+ # 5.3 ABLATION STUDY
200
+
201
+ In this section, to demonstrate the effectiveness of our proposed generative framework, we conduct experiments that compare LA-GNN to several of its ablated variants without generative modeling. The results are shown in Table 4. ${ } " \mathrm { G C N } +$ width" only increases the first network layer width for GCN and GCNII to match LAGNN without giving generated samples as input. $" +$ concatenation" only replaces the generated feature matrix of LA-GNN with the original feature matrix of the central node. $" +$ plain neighborhood" replaces the generated feature matrix of LA-GNN with a neighborhood feature matrix where each row corresponds to the feature vector of the randomly sampled neighbor. The
202
+
203
+ Table 4: Effects of different components of our framework evaluated on the standard split of the Cora, Citeseer and Pubmed dataset.
204
+
205
+ <table><tr><td>Method</td><td>Cora</td><td>Citeseer</td><td>Pubmed</td></tr><tr><td>GCN</td><td>81.6</td><td>70.3</td><td>78.9</td></tr><tr><td>GCNII</td><td>85.2</td><td>73.1</td><td>80.0</td></tr><tr><td>GCN + width</td><td>82.0</td><td>71.4</td><td>79.5</td></tr><tr><td>GCN + concatenation</td><td>81.8</td><td>71.6</td><td>78.8</td></tr><tr><td>GCN + plain neighborhood</td><td>80.9</td><td>68.8</td><td>75.0</td></tr><tr><td>GCNII + width</td><td>85.1</td><td>73.1</td><td>80.2</td></tr><tr><td>GCNII + concatenation</td><td>85.2</td><td>73.3</td><td>80.2</td></tr><tr><td>GCNII + plain neighborhood</td><td>83.3</td><td>71.9</td><td>78.1</td></tr><tr><td>LA-GCN</td><td>84.1</td><td>72.5</td><td>81.3</td></tr><tr><td>LA-GCNII</td><td>85.2</td><td>73.7</td><td>81.6</td></tr></table>
206
+
207
+ results show that the first two variants provide no notable improvement for the backbone models, and the third variant even results in degradation. By eliminating the possibility that these confounding factors irrelevant to our core approach may contribute to the final performance, it’s evident that the performance gain in Table 2 and 3 are due to our proposed generative local augmentation framework.
208
+
209
+ # 5.4 ROBUSTNESS TO MISSING INFORMATION
210
+
211
+ In this section, we conduct experiments to verify that our proposed framework can robustify downstream tasks against missing information in the feature attributes. Specifically, we mask a certain percentage of the attributes of each feature vector and use the same pipeline to do augmentation for the masked feature matrix. As shown in Table 5, we can see that as the mask ratio increases, the gap of the performance between the GCN and LA-GCN enlarges in most cases in Cora and Citeseer, which corroborates our insight discussed in Section 4. Since there exists large redundancy in the features of the Pubmed dataset, the performance of GCN and LA-GCN decreases little as the mask ratio increases and the gap of the performance does not enlarge. To conclude, our model can complement the contextual information of the local neighborhood to enhance the locality of the node representations.
212
+
213
+ Table 5: Summary of results on recovering study in terms of classification accuracy $( \% )$ . $\downarrow$ means a decrease compared with the accuracy if features are not masked.
214
+
215
+ <table><tr><td>Dataset</td><td colspan="4">Cora</td><td colspan="4">Citeseer</td><td colspan="4">Pubmed</td></tr><tr><td>Mask Ratio</td><td>0.1</td><td>0.2</td><td>0.4</td><td>0.8</td><td>0.1</td><td>0.2</td><td>0.4</td><td>0.8</td><td>0.1</td><td>0.2</td><td>0.4</td><td>0.8</td></tr><tr><td>GCN</td><td>81.0(↓0.6)</td><td>80.6(↓1.0)</td><td>80.1(↓1.5)</td><td>76.0 (↓5.6)</td><td>70.1(↓0.2)</td><td>69.3 (↓1.0)</td><td>67.2 (↓3.1)</td><td>61.0(↓9.3)</td><td>78.5(↓0.4)</td><td>78.5(↓0.4)</td><td>77.5 (↓1.4)</td><td>76.9 (↓2.0)</td></tr><tr><td>LA-GCN</td><td>83.5 (↓0.6)</td><td>83.1(↓1.0)</td><td>81.6(↓2.5)</td><td>81.1 (↓3.0)</td><td>72.2(↓0.3)</td><td>71.7 (↓0.8)</td><td>69.3 (↓3.2)</td><td>65.9 (↓6.6)</td><td>81.4(↓0.1)</td><td>80.9 (↓0.6)</td><td>80.5 (↓1.0)</td><td>79.4 (↓2.1)</td></tr></table>
216
+
217
+ # 6 RELATED WORK
218
+
219
+ Graph Neural Networks In general, convolution in the graph domain involves non-spectral (spatial) and spectral approaches. Non-spectral methods generalize convolutions operating on spatially close neighbors to the graph domain, such as Duvenaud et al. (2015); Atwood & Towsley (2016); Niepert et al. (2016); Monti et al. (2017). Spectral approaches define the convolution operations based on the spectral formulation, such as Bruna et al. (2014); Defferrard et al. (2016); Kipf & Welling (2017). Recently, several methods (Abu-El-Haija et al., 2019; Liao et al., 2019) based on GCN have been proposed to obtain the higher-order filters. Besides, GAT (Velickovi ˇ c et al., 2018), Graph ´ U-Nets (Gao & Ji, 2019) combine attention networks and pooling operation with GNN separately, which achieve state-of-the-art performance on node and link classification tasks. In this work, local augmentation can be applied on various backbone models to improve performance.
220
+
221
+ Graph Generative Models Generative models (Goodfellow et al., 2014; Kingma & Welling, 2013) are powerful tools of learning data distribution through unsupervised learning, and they have achieved tremendous success in various applications. Recently, researchers have proposed several interesting generative models for graph data generation. Variational graph auto-encoder (VGAE) (Kipf & Welling, 2016) makes use of latent variables and learns interpretable latent representations for undirected graphs. Salha et al. (2019) replace the GCN encoder in VGAE with a simple linear model and emphasize the effectiveness of a simple node encoding scheme. Xu et al. (2019) propose a generative model framework to learn node representations, by sampling graph generation sequences constructed from observed graph data. ConDgen (Yang et al., 2019) exploits the GCN encoder to handle the inherent challenges of flexible context-structure conditioning and permutation-invariant generation. Besides, some methods have been proposed to apply the graph generative models in various applications such as graph matching (Simonovsky & Komodakis, 2018), molecule design (Liu et al., 2018), retrosynthesis prediction (Shi et al., 2020) and chemical design (Samanta et al., 2018). Compared with these approaches mainly focusing on structure generation, our model takes full use of the power of the generative model for feature representation generation, which can serve as an enhanced technique for the downstream backbone models.
222
+
223
+ # 7 CONCLUSION
224
+
225
+ We propose local augmentation, a brand-new technique that exploits the generative model to learn the conditional distribution of the central node’s neighbors’ feature representations given its representation. We can augment more 1-hop neighbors from a well-trained generative model to enhance the performance of backbone GNN models. Experiments show that our model can improve performance across various GNN architectures and benchmark datasets by enriching local information. Besides, our model achieves new state-of-the-art results on various semi-supervised node classification tasks. One limitation of our proposed framework is that we do not exploit the 2-hop neighbors or use the random walk to find more related neighbors for the central node. And one future work is that we can extract more $^ { 2 / 3 }$ -hop neighbors if the central node’s degree is small and learn the conditional distribution for random sampling nodes if the graph is large.
226
+
227
+ # REFERENCES
228
+
229
+ Martín Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. Tensorflow: A system for large-scale machine learning. In 12th {USENIX} symposium on operating systems design and implementation ({OSDI} 16), pp. 265–283, 2016.
230
+
231
+ Sami Abu-El-Haija, Bryan Perozzi, Amol Kapoor, Nazanin Alipourfard, Kristina Lerman, Hrayr Harutyunyan, Greg Ver Steeg, and Aram Galstyan. Mixhop: Higher-order graph convolutional architectures via sparsified neighborhood mixing. In international conference on machine learning, pp. 21–29. PMLR, 2019.
232
+
233
+ Antreas Antoniou, Amos Storkey, and Harrison Edwards. Data augmentation generative adversarial networks. arXiv preprint arXiv:1711.04340, 2017.
234
+
235
+ James Atwood and Don Towsley. Diffusion-convolutional neural networks. In Advances in neural information processing systems, pp. 1993–2001, 2016.
236
+
237
+ Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. In International Conference on Learning Representations, 2014.
238
+
239
+ Ming Chen, Zhewei Wei, Zengfeng Huang, Bolin Ding, and Yaliang Li. Simple and deep graph convolutional networks. In International Conference on Machine Learning, pp. 1725–1735. PMLR, 2020.
240
+
241
+ Michaël Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. In Advances in Neural Information Processing Systems, 2016.
242
+
243
+ Zhijie Deng, Yinpeng Dong, and Jun Zhu. Batch virtual adversarial training for graph convolutional networks. arXiv preprint arXiv:1902.09192, 2019.
244
+
245
+ David Duvenaud, Dougal Maclaurin, Jorge Aguilera-Iparraguirre, Rafael Gómez-Bombarelli, Timothy Hirzel, Alán Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for learning molecular fingerprints. In Advances in Neural Information Processing Systems, 2015.
246
+
247
+ Fuli Feng, Xiangnan He, Jie Tang, and Tat-Seng Chua. Graph adversarial training: Dynamically regularizing based on graph structure. IEEE Transactions on Knowledge and Data Engineering, 2019.
248
+
249
+ Wenzheng Feng, Jie Zhang, Yuxiao Dong, Yu Han, Huanbo Luan, Qian Xu, Qiang Yang, Evgeny Kharlamov, and Jie Tang. Graph random neural network for semi-supervised learning on graphs. In NeurIPS’20, 2020.
250
+
251
+ Hongyang Gao and Shuiwang Ji. Graph u-nets. In international conference on machine learning, pp. 2083–2092. PMLR, 2019.
252
+
253
+ Alberto García-Durán and Mathias Niepert. Learning graph representations with embedding propagation. In Advances in Neural Information Processing Systems, 2017.
254
+
255
+ Ian J Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial networks. In Advances in Neural Information Processing Systems, 2014.
256
+
257
+ Shengnan Guo, Youfang Lin, Ning Feng, Chao Song, and Huaiyu Wan. Attention based spatialtemporal graph convolutional networks for traffic flow forecasting. In Proceedings of the AAAI Conference on Artificial Intelligence, pp. 922–929, 2019.
258
+
259
+ William L Hamilton, Rex Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Advances in Neural Information Processing Systems, 2017.
260
+
261
+ Neil Houlsby, Ferenc Huszár, Zoubin Ghahramani, and Máté Lengyel. Bayesian active learning for classification and preference learning. arXiv preprint arXiv:1112.5745, 2011.
262
+
263
+ Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4700–4708, 2017.
264
+
265
+ Junteng Jia and Austion R Benson. Residual correlation in graph neural network regression. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 588–598, 2020.
266
+
267
+ Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
268
+
269
+ Thomas N Kipf and Max Welling. Variational graph auto-encoders. NIPS Workshop on Bayesian Deep Learning, 2016.
270
+
271
+ Thomas N. Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In International Conference on Learning Representation, 2017.
272
+
273
+ Johannes Klicpera, Aleksandar Bojchevski, and Stephan Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. In International Conference on Learning Representation, 2019.
274
+
275
+ Kezhi Kong, Guohao Li, Mucong Ding, Zuxuan Wu, Chen Zhu, Bernard Ghanem, Gavin Taylor, and Tom Goldstein. Flag: Adversarial data augmentation for graph neural networks. arXiv preprint arXiv:2010.09891, 2020.
276
+
277
+ Qimai Li, Zhichao Han, and Xiao-Ming Wu. Deeper insights into graph convolutional networks for semi-supervised learning. In Proceedings of the AAAI Conference on Artificial Intelligence, 2018.
278
+
279
+ Renjie Liao, Zhizhen Zhao, Raquel Urtasun, and Richard S Zemel. Lanczosnet: Multi-scale deep graph convolutional networks. In International Conference on Learning Representations, 2019.
280
+
281
+ Qi Liu, Miltiadis Allamanis, Marc Brockschmidt, and Alexander L Gaunt. Constrained graph variational autoencoders for molecule design. In Advances in Neural Information Processing Systems, 2018.
282
+
283
+ Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg Corrado, and Jeffrey Dean. Distributed representations of words and phrases and their compositionality. In Advances in Neural Information Processing Systems, 2013.
284
+
285
+ 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 Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 5115–5124, 2017.
286
+
287
+ Christopher Nielsen and Michal M Okoniewski. Gan data augmentation through active learning inspired sample acquisition. In CVPR Workshops, pp. 109–112, 2019.
288
+
289
+ Mathias Niepert, Mohamed Ahmed, and Konstantin Kutzkov. Learning convolutional neural networks for graphs. In International conference on machine learning, pp. 2014–2023. PMLR, 2016.
290
+
291
+ Gaurav Pandey and Ambedkar Dukkipati. Variational methods for conditional multimodal deep learning. In 2017 International Joint Conference on Neural Networks (IJCNN), pp. 308–315. IEEE, 2017.
292
+
293
+ 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. In Advances in Neural Information Processing Systems, 2019.
294
+
295
+ Hongbin Pei, Bingzhe Wei, Kevin Chen-Chuan Chang, Yu Lei, and Bo Yang. Geom-gcn: Geometric graph convolutional networks. In International Conference on Learning Representations, 2020.
296
+
297
+ Bryan Perozzi, Rami Al-Rfou, and Steven Skiena. Deepwalk: Online learning of social representations. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 701–710, 2014.
298
+
299
+ Yu Rong, Wenbing Huang, Tingyang Xu, and Junzhou Huang. Dropedge: Towards deep graph convolutional networks on node classification. In International Conference on Learning Representation, 2020.
300
+
301
+ Benedek Rozemberczki, Carl Allen, and Rik Sarkar. Multi-scale attributed node embedding. Journal of Complex Networks, 9(2):cnab014, 2021.
302
+
303
+ Guillaume Salha, Romain Hennequin, and Michalis Vazirgiannis. Keep it simple: Graph autoencoders without graph convolutional networks. Workshop on Graph Representation Learning, 33rd Conference on Neural Information Processing Systems (NeurIPS), 2019.
304
+
305
+ Bidisha Samanta, Abir De, Niloy Ganguly, and Manuel Gomez-Rodriguez. Designing random graph models using variational autoencoders with applications to chemical design. arXiv preprint arXiv:1802.05283, 2018.
306
+
307
+ Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Galligher, and Tina Eliassi-Rad. Collective classification in network data. AI magazine, 29(3):93–93, 2008.
308
+
309
+ Oleksandr Shchur, Maximilian Mumme, Aleksandar Bojchevski, and Stephan Günnemann. Pitfalls of graph neural network evaluation. arXiv preprint arXiv:1811.05868, 2018.
310
+
311
+ Chence Shi, Minkai Xu, Hongyu Guo, Ming Zhang, and Jian Tang. A graph to graphs framework for retrosynthesis prediction. In International Conference on Machine Learning, pp. 8818–8827. PMLR, 2020.
312
+
313
+ Connor Shorten and Taghi M Khoshgoftaar. A survey on image data augmentation for deep learning. Journal of Big Data, 6(1):1–48, 2019.
314
+
315
+ Martin Simonovsky and Nikos Komodakis. Graphvae: Towards generation of small graphs using variational autoencoders. In International Conference on Artificial Neural Networks, pp. 412–422. Springer, 2018.
316
+
317
+ Kihyuk Sohn, Honglak Lee, and Xinchen Yan. Learning structured output representation using deep conditional generative models. Advances in neural information processing systems, 28:3483–3491, 2015.
318
+
319
+ Jie Tang, Jimeng Sun, Chi Wang, and Zi Yang. Social influence analysis in large-scale networks. In Proceedings of the 15th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 807–816, 2009.
320
+
321
+ Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. In International Conference on Learning Representations, 2018.
322
+
323
+ Haibo Wang, Chuan Zhou, Xin Chen, Jia Wu, Shirui Pan, and Jilong Wang. Graph stochastic neural networks for semi-supervised learning. In Advances in Neural Information Processing Systems, 2020a.
324
+
325
+ Minjie Wang, Da Zheng, Zihao Ye, Quan Gan, Mufei Li, Xiang Song, Jinjing Zhou, Chao Ma, Lingfan Yu, Yu Gai, Tianjun Xiao, Tong He, George Karypis, Jinyang Li, and Zheng Zhang. Deep graph library: A graph-centric, highly-performant package for graph neural networks. arXiv preprint arXiv:1909.01315, 2019.
326
+
327
+ Yiwei Wang, Wei Wang, Yuxuan Liang, Yujun Cai, Juncheng Liu, and Bryan Hooi. Nodeaug: Semi-supervised node classification with data augmentation. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 207–217, 2020b.
328
+
329
+ Yu Wang and Tyler Derr. Tree decomposed graph neural network. In Proceedings of the 30th ACM International Conference on Information & Knowledge Management, pp. 2040–2049, 2021.
330
+
331
+ Da Xu, Chuanwei Ruan, Kamiya Motwani, Evren Korpeoglu, Sushant Kumar, and Kannan Achan. Generative graph convolutional network for growing graphs. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 3167–3171. IEEE, 2019.
332
+
333
+ Keyulu Xu, Chengtao Li, Yonglong Tian, Tomohiro Sonobe, Ken-ichi Kawarabayashi, and Stefanie Jegelka. Representation learning on graphs with jumping knowledge networks. In International Conference on Machine Learning, pp. 5453–5462. PMLR, 2018.
334
+
335
+ Carl Yang, Peiye Zhuang, Wenhan Shi, Alan Luu, and Pan Li. Conditional structure generation through graph variational generative adversarial nets. In NeurIPS, pp. 1338–1349, 2019.
336
+
337
+ Zhilin Yang, William Cohen, and Ruslan Salakhudinov. Revisiting semi-supervised learning with graph embeddings. In International Conference on Machine Learning, pp. 40–48, 2016.
338
+
339
+ Rex Ying, Ruining He, Kaifeng Chen, Pong Eksombatchai, William L Hamilton, and Jure Leskovec. Graph convolutional neural networks for web-scale recommender systems. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 974–983, 2018.
340
+
341
+ Hanqing Zeng, Muhan Zhang, Yinglong Xia, Ajitesh Srivastava, Andrey Malevich, Rajgopal Kannan, Viktor Prasanna, Long Jin, and Ren Chen. Decoupling the depth and scope of graph neural networks. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021.
342
+
343
+ Tong Zhao, Yozen Liu, Leonardo Neves, Oliver Woodford, Meng Jiang, and Neil Shah. Data augmentation for graph neural networks. In The Thirty-Fifth AAAI Conference on Artificial Intelligence, 2021.
344
+
345
+ Danhao Zhu, Xin-Yu Dai, and Jiajun Chen. Pre-train and learn: Preserve global information for graph neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, 2020.
346
+
347
+ Hao Zhu and Piotr Koniusz. Simple spectral graph convolution. In International Conference on Learning Representations, 2021.
348
+
349
+ A PROOF OF EQ.(6)
350
+
351
+ We give more details of the derivation of the generator ELBO as follows:
352
+
353
+ $$
354
+ \begin{array} { r l } { \log _ { \rho } | \mathbf { X } _ { i } | \mathbb { X } _ { j } - j } & { \neq \langle z | \mathbf { z } | \mathbf { z } | \mathbf { X } _ { j } , ~ \mathbf { X } _ { i } \rangle \log _ { \rho } \langle ~ \mathbf { X } _ { i } | \mathbf { X } _ { j } \rangle \mathrm { d } \mathbf { z } } \\ & { = \int \langle z | \mathbf { z } | \mathbf { A } _ { \mathbf { x } } \mathbf { x } , ~ \mathbf { X } _ { i } | \log _ { \rho } | \mathbf { X } _ { i } \mathbf { X } _ { j } | \log _ { \rho } \langle ~ \mathbf { X } _ { i } | \mathbf { X } _ { j } , ~ \mathbf { X } _ { i } \rangle } \\ & { \quad - \int \langle z | \mathbf { z } | \mathbf { z } | \mathbf { X } _ { i } , ~ \mathbf { X } _ { i } \rangle \log _ { \rho } | \langle ~ \mathbf { X } _ { i } | \mathbf { X } _ { j } \rangle \mathrm { d } \mathbf { z } | } \\ & { = \int \langle \exp \{ \mathbf { X } _ { i } \mathbf { X } _ { j } \} | \exp \{ \exp \{ | \mathbf { X } _ { i } \mathbf { X } _ { j } | \} \} \exp \{ | \langle \mathbf { X } _ { i } \mathbf { X } _ { j } , ~ \mathbf { X } _ { i } , ~ \mathbf { X } _ { j } | \} \mathrm { d } \mathbf { z } } \\ & { \quad - \int \langle z | \mathbf { z } | \mathbf { X } _ { i } \rangle \exp \{ | \langle \mathbf { X } _ { j } | \mathbf { X } _ { i } , ~ \mathbf { X } _ { j } \rangle | \} } \\ & { \quad - \int \langle z | \mathbf { z } | \mathbf { z } | \mathrm { X } _ { i } \rangle \exp \{ | \langle \mathbf { X } _ { i } | \mathbf { X } _ { j } \rangle | \} } \\ & { = \int \langle z | \mathbf { z } | \mathbf { X } _ { i } \mathbf { X } _ { j } \rangle \log _ { \rho } \langle \mathbf { X } _ { i } | \mathbf { X } _ { j } \rangle \exp \{ | \langle \mathbf { X } _ { i } | \mathbf { X } _ { j } \rangle | } \\ & { \quad - \int \langle z | \mathbf { z } | \mathbf { Z } _ { j } \rangle \exp \{ | \langle \mathbf { X } _ { j } | \mathbf { X } _ { j } \rangle | } \\ & \quad - \int \langle z | \mathbf { z } | \mathbf { Z } _ { j } \rangle \exp \{ \end{array}
355
+ $$
356
+
357
+ $$
358
+ \begin{array} { r l } { L _ { E L B O } = \displaystyle { \int } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , \mathbf X _ { i } ) \log \frac { p _ { \phi } ( { \mathbf x } _ { j } , { \mathbf X _ { i } } ) \log } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , { \mathbf X _ { i } } ) } } \mathrm { d } { \mathbf z } } \\ { } & { ~ = \displaystyle { \int } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , \mathbf X _ { i } ) \log \frac { p _ { \psi } ( { \mathbf X _ { j } } , { \mathbf X _ { i } } , { \mathbf z } ) } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , { \mathbf X _ { i } } ) p _ { \psi } ( { \mathbf X _ { i } } ) } } \mathrm { d } { \mathbf z } } \\ { } & { ~ = \displaystyle { \int } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , \mathbf X _ { i } ) \log \frac { p _ { \phi } ( { \mathbf X _ { j } } | \mathbf X _ { i } , { \mathbf z } ) p _ { \psi } ( { \mathbf X _ { i } } , { \mathbf z } ) } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , { \mathbf X _ { i } } ) p _ { \psi } ( { \mathbf X _ { i } } ) } } \mathrm { d } { \mathbf z } } \\ { } & { ~ = \displaystyle { \int } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , \mathbf X _ { i } ) \log \frac { p _ { \phi } ( { \mathbf X _ { j } } | \mathbf X _ { i } , { \mathbf z } ) p _ { \psi } ( { \mathbf z } | \mathbf X _ { i } ) } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , { \mathbf X _ { i } } ) } } \mathrm { d } { \mathbf z } } \\ { } & ~ = \displaystyle { \int } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , \mathbf X _ { i } ) \log \frac { p _ { \phi } ( { \mathbf z } | \mathbf X _ { j } , { \mathbf z } ) p _ { \phi } ( { \mathbf Z } | \mathbf X _ { i } ) } { q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , { \mathbf X _ { i } } ) } } \\ { } & ~ = \displaystyle { \int } q _ { \mathcal { G } } ( { \mathbf z } | \mathbf X _ { j } , \mathbf X _ { i } \end{array}
359
+ $$
360
+
361
+ # B REPRODUCIBILITY
362
+
363
+ # B.1 DATASETS DETAILS
364
+
365
+ Cora, Citeseer, and Pubmed are standard citation network benchmark datasets Sen et al. (2008). In these datasets, nodes represent documents, and edges denote citations; node feature corresponds to elements of a bag-of-words representation of a document, and node label corresponds to one of the academic topics. Besides, we utilize four datasets used in Pei et al. (2020) for evaluation. Chameleon and squirrel are two page-page networks on specific topics in Wikipedia Rozemberczki et al. (2021). In these datasets, nodes represent web pages, and edges denote mutual links between pages; node features correspond to several informative nouns in the Wikipedia pages and labels correspond to the number of the average monthly traffic of the web page. WebKB1 is a webpage dataset collected from various universities. We use the one subdataset of it, Cornell. In this dataset, nodes represent web pages, and edges are hyperlinks between them; node features correspond to the bag-of-words representation of web pages and labels correspond to five categories, student, project, course, staff, and faculty. Film dataset is the actor-only induced subgraph of the film-directoractor-writer network Tang et al. (2009). In this dataset, Nodes represent actors, and edges denote co-occurrence on the same Wikipedia page; node features correspond to some keywords in the Wikipedia pages and labels correspond to five categories in terms of words of actor’s Wikipedia. All the dataset statistics are summarized in Table 6.
366
+
367
+ Table 6: Datasets statistics
368
+
369
+ <table><tr><td>Dataset</td><td>Cora</td><td>Cite.</td><td>Pubm.</td><td>Cham.</td><td>Squi.</td><td>Actor</td><td>Corn.</td></tr><tr><td>#Nodes</td><td>2708</td><td>3327</td><td>19717</td><td>2277</td><td>5201</td><td>7600</td><td>183</td></tr><tr><td>#Edges</td><td>5429</td><td>4732</td><td>44338</td><td>36101</td><td>217073</td><td>33544</td><td>295</td></tr><tr><td>#Features</td><td>1433</td><td>3703</td><td>500</td><td>2325</td><td>2089</td><td>931</td><td>1703</td></tr><tr><td># Classes</td><td>7</td><td>6</td><td>3</td><td>5</td><td>5</td><td>5</td><td>5</td></tr></table>
370
+
371
+ # B.2 IMPLEMENTATION DETAILS
372
+
373
+ We use Pytorch (Paszke et al., 2019) to implement LA-GNNs. The codes of $S ^ { 2 } G C$ (Zhu & Koniusz, 2021), LA-GCN, LA-GAT, LA-GCNII, LA-GRAND, and DropEdge-GCN are implemented referring to Pytorch implementation of $\mathrm { S } ^ { 2 } \mathrm { G } \mathrm { C } ^ { 2 }$ , $\mathrm { G C N } ^ { 3 }$ (Kipf & Welling, 2017), $\mathrm { G A T ^ { 4 } }$ (Velickovi ˇ c et al., 2018), ´ $\mathrm { G C N I I } ^ { 5 }$ (Chen et al., 2020) $\mathrm { G R A N D } ^ { 6 }$ (Feng et al., 2020), and DropEdge- $\mathbf { \Delta } G \mathbf { C N } ^ { 7 }$ (Rong et al., 2020). Besides, we implement APPNP (Klicpera et al., 2019) with DGL (Wang et al., 2019) version of APPNP8. The datasets Cora, Citeseer, Pubmed are downloaded from TensorFlow (Abadi et al., 2016) implementation of $\mathrm { G C N ^ { 9 } }$ , and the datasets Chameleon, Squirrel, Actor, and Cornell are downloaded from the implementation of Geom- $\mathrm { G C N ^ { 1 0 } }$ (Pei et al., 2020). All the experiments in this work are conducted on a single NVIDIA Tesla V100 with 32GB memory size. The operating system behind the Docker where the experiments are running is Red Hat 4.8.2-16. And the software that we use for experiments are Python 3.6.8, numpy 1.19.2, sklearn 0.0, scipy 1.5.4, networkx 2.5.1, torch 1.6.0, torchvision 0.7.0, CUDA 10.2.89, and CUDNN 8.0.2.
374
+
375
+ # B.3 HYPERPARAMETER DETAILS
376
+
377
+ LA-GNNs introduce an additional parameter, that is the hidden layer for generated feature matrix $\overline { { \mathbf { X } } }$ before concatenation. The difference of architectures between GCN and LA-GCN can be found in Figure 4, and the LA-GCNII architecture can be found in Figure 5.
378
+
379
+ ![](images/d7816fad620dd0825bfeea46796303662cc8614bc99cb04d713507ea99f5f1a5.jpg)
380
+ Figure 4: GCN and LA-GCN architectures. The difference between GCN and LA-GCN architectures is that the LA-GCN has an additional convolutional layer for $\overline { { \mathbf { X } } }$ and it uses a concatenation operation to mix the hidden representations.
381
+
382
+ ![](images/5443477c1a5cf6f340de4b0323cbbb8400ffee35c029505e3e5d44d84aa3e826.jpg)
383
+ Figure 5: LA-GCNII architecture. The difference between GCNII and LA-GCNII is that the LAGCNII has an additional MLP layer for $\overline { { \mathbf { X } } }$ and it uses a concatenation operation to mix the hidden representations.
384
+
385
+ The difference of hyperparameters between the GCN and LA-GCN is only the hidden layer size before concatenation. For the LA-GCNII, LA-GAT, LA-GRAND, we tune the hyperparameters in the same way as described in their original papers with validation set.
md/dev/3RBY8fKjHeu/3RBY8fKjHeu.md ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DayDreamer: World Models for Physical Robot Learning
2
+
3
+ # Philipp Wu\*
4
+
5
+ Alejandro Escontrela\* Danijar Hafner\*
6
+
7
+ Ken Goldberg Pieter Abbeel
8
+
9
+ University of California, Berkeley \*Equal contribution
10
+
11
+ Abstract: To solve tasks in complex environments, robots need to learn from experience. Deep reinforcement learning is a common approach to robot learning but requires a large amount of trial and error to learn, limiting its deployment in the physical world. As a consequence, many advances in robot learning rely on simulators. On the other hand, learning inside of simulators fails to capture the complexity of the real world, is prone to simulator inaccuracies, and the resulting behaviors do not adapt to changes in the world. The Dreamer algorithm has recently shown great promise for learning from small amounts of interaction by planning within a learned world model, outperforming pure reinforcement learning in video games. Learning a world model to predict the outcomes of potential actions enables planning in imagination, reducing the amount of trial and error needed in the real environment. However, it is unknown whether Dreamer can facilitate faster learning on physical robots. In this paper, we apply Dreamer to 4 robots to learn online and directly in the real world, without any simulators. Dreamer trains a quadruped robot to roll off its back, stand up, and walk from scratch and without resets in only 1 hour. We then push the robot and find that Dreamer adapts within 10 minutes to withstand perturbations or quickly roll over and stand back up. On two different robotic arms, Dreamer learns to pick and place objects from camera images and sparse rewards, approaching human-level teleoperation performance. On a wheeled robot, Dreamer learns to navigate to a goal position purely from camera images, automatically resolving ambiguity about the robot orientation. Using the same hyperparameters across all experiments, we find that Dreamer is capable of online learning in the real world, which establishes a strong baseline. We release our infrastructure for future applications of world models to robot learning. Videos are available on the project website: https://danijar.com/daydreamer
12
+
13
+ ![](images/17f2d11eee9937e70f62a1993623ebccd221887d067e71919c350fa57662f4d3.jpg)
14
+ Figure 1: To study the applicability of Dreamer for sample-efficient robot learning, we apply the algorithm to learn robot locomotion, manipulation, and navigation tasks from scratch in the real world on 4 robots, without simulators. The tasks evaluate a diverse range of challenges, including continuous and discrete actions, dense and sparse rewards, proprioceptive and camera inputs, as well as sensor fusion of multiple input modalities. Learning successfully using the same hyperparameters across all experiments, Dreamer establishes a strong baseline for real world robot learning.
15
+
16
+ # 1 Introduction
17
+
18
+ Teaching robots to solve complex tasks in the real world is a foundational problem of robotics research. Deep reinforcement learning (RL) offers a popular approach to robot learning that enables robots to improve their behavior over time through trial and error. However, current algorithms require too much interaction with the environment to learn successful behaviors. Recently, modern world models have shown great promise for data efficient learning in simulated domains and video games (Hafner et al., 2019; 2020). Learning world models from past experience enables robots to imagine the future outcomes of potential actions, reducing the amount of trial and error in the real environment needed to learn.
19
+
20
+ While learning accurate world models can be challenging, they offer compelling properties for robot learning. By predicting future outcomes, world models allow for planning and behavior learning given only small amounts of real world interaction (Gal et al., 2016; Ebert et al., 2018). Moreover, world models summarize general dynamics knowledge about the environment that, once learned, could be reused for a wide range of downstream tasks (Sekar et al., 2020). World models also learn representations that fuse multiple sensor modalities and integrate them into latent states, reducing the need for sophisticated state estimators. Finally, world models generalize well from available offline data (Yu et al., 2021), which further accelerates learning in the real world.
21
+
22
+ ![](images/e30f877426a1aa2686b70c08629a56889403c96105b017890f8ea57b7982c4a2.jpg)
23
+ Figure 2: Dreamer follows a simple pipeline for online learning on robot hardware without simulators. The current learned policy collects experience on the robot. This experience is added to the replay buffer. The world model is trained on replayed off-policy sequences through supervised learning. An actor critic algorithm optimizes a neural network policy from imagined rollouts in the latent space of the world model. We parallelize data collection and neural network learning.
24
+
25
+ Despite the promises of world models, learning accurate world models for the real world is a open challenge. In this paper, we leverage recent advances of the Dreamer world model for training a variety of robots in the most straight-forward and fundamental problem setting: online reinforcement learning in the real world, without simulators or demonstrations. As shown in Figure 2, Dreamer learns a world model from a replay buffer of past experience, learns behaviors from rollouts imagined in the latent space of the world model, and continuously interacts with the environment to explore and improve its behaviors. Our aim is to push the limits of robot learning directly in the real world and offer a robust platform to enable future work that develops the benefits of world models for robot learning. The key contributions of this paper are summarized as follows:
26
+
27
+ • Dreamer on Robots We apply Dreamer to 4 robots, demonstrating successful learning directly in the real world, without introducing new algorithms. The tasks cover a range of challenges, including different action spaces, sensory modalities, and reward structures.
28
+ • Walking in 1 Hour We teach a quadruped from scratch in the real world to roll off its back, stand up, and walk in only 1 hour. Afterwards, we find that the robot adapts to being pushed within 10 minutes, learning to withstand pushes or quickly roll over and get back on its feet.
29
+ • Visual Pick and Place We train robotic arms to pick and place objects from sparse rewards, which requires localizing objects from pixels and fusing images with proprioceptive inputs. The learned behavior outperforms model-free agents and approaches the performance of a human teleoperator using the same control interface as the robot.
30
+ • Open Source We publicly release the software infrastructure for all our experiments, which supports different action spaces and sensory modalities, offering a flexible platform for future research of world models for robot learning in the real world.
31
+
32
+ ![](images/bbd9aa6b3f541685e1ecf9dd1c4451b92904b361a6547ee2e39414769cb64de4.jpg)
33
+ Figure 3: Neural Network Training We leverage the Dreamer algorithm (Hafner et al., 2019; 2020) for fast robot learning in real world. Dreamer consists of two main neural network components, the world model and the policy. Left: The world model follows the structure of a deep Kalman filter that is trained on subsequences drawn from the replay buffer. The encoder fuses all sensory modalities into discrete codes. The decoder reconstructs the inputs from the codes, providing a rich learning signal and enabling human inspection of model predictions. A recurrent state-space model (RSSM) is trained to predict future codes given actions, without observing intermediate inputs.
34
+
35
+ Right: The world model enables massively parallel policy optimization from imagined rollouts in the compact latent space using a large batch size, without having to reconstruct sensory inputs. Dreamer trains a policy network and value network from the imagined rollouts and a learned reward function.
36
+
37
+ # 2 Approach
38
+
39
+ We leverage the Dreamer algorithm (Hafner et al., 2019; 2020) for online learning on physical robots, without the need for simulators. Figure 2 shows an overview of the approach. Dreamer learns a world model from a replay buffer of past experiences, uses an actor critic algorithm to learn behaviors from trajectories predicted by the learned model, and deploys its behavior in the environment to continuously grow the replay buffer. We decouple learning updates from data collection to meet latency requirements and to enable fast training without waiting for the environment. In our implementation, a learner thread continuously trains the world model and actor critic behavior, while an actor thread in parallel computes actions for environment interaction.
40
+
41
+ World Model Learning The world model is a deep neural network that learns to predict the environment dynamics, as shown in Figure 3 (left). Because sensory inputs can be large images, we predict future representations rather than future inputs. This reduces accumulating errors and enables massively parallel training with a large batch size. Thus, the world model can be thought of as a fast simulator of the environment that the robot learns autonomously, starting from a blank slate and continuously improving its model as it explores the real world. The world model is based on the Recurrent State-Space Model (RSSM; Hafner et al., 2018), which consists of four components:
42
+
43
+ $$
44
+ { \begin{array} { r l r l } & { \operatorname { e n c } _ { \theta } { \big ( } s _ { t } \ { \big | } \ s _ { t - 1 } , a _ { t - 1 } , x _ { t } { \big ) } } & & { { \mathrm { D e c o d e r ~ N e t w o r k : } } \quad \operatorname* { d e c } _ { \theta } { \big ( } s _ { t } { \big ) } \approx x _ { t } } \\ & { \operatorname { d y n } _ { \theta } { \big ( } s _ { t } \ { \big | } \ s _ { t - 1 } , a _ { t - 1 } { \big ) } } & & { { \mathrm { R e w a r d ~ N e t w o r k : } } \quad \operatorname { r e w } _ { \theta } { \big ( } s _ { t + 1 } { \big ) } \approx r _ { t } } \end{array} }
45
+ $$
46
+
47
+ Physical robots are often equipped with multiple sensors of different modalities, such as proprioceptive joint readings, force sensors, and high-dimensional inputs such as RGB and depth camera images. The encoder network fuses all sensory inputs $x _ { t }$ together into the stochastic representations $z _ { t }$ . The dynamics model learns to predict the sequence of stochastic representations by using its recurrent state $h _ { t }$ . The decoder reconstructs the sensory inputs to provide a rich signal for learning representations and enables human inspection of model predictions. In our experiments, the robot has to discover task rewards by interacting with the real world, which the reward network learns to predict. Using manually specified rewards as a function of the decoded sensory inputs is also possible. We optimize all components of the world model jointly by stochastic backpropagation (Kingma and Welling, 2013; Rezende et al., 2014).
48
+
49
+ Actor Critic Learning While the world model represents task-agnostic knowledge about the dynamics, the actor critic algorithm learns a behavior that is specific to the task at hand. As shown in Figure 3 (right), we learn behaviors from rollouts that are predicted in the latent space of the world model, without decoding observations. This enables massively parallel behavior learning with typical batch sizes of 16K on a single GPU. The actor critic algorithm consists of an actor network $\pi ( a _ { t } | s _ { t } )$ and a critic network $v ( s _ { t } )$ .
50
+
51
+ The role of the actor network is to learn a distribution over successful actions $a _ { t }$ for each latent model state $s _ { t }$ that maximizes the sum of future predicted task rewards. The critic network learns to predict the sum of future task rewards through temporal difference learning (Sutton and Barto, 2018). This allows the algorithm to take into account rewards beyond the planning horizon of $H = 1 6$ steps to learn long-term strategies. Given a predicted trajectory of model states, the critic is trained to regress the return of the trajectory. We compute $\lambda$ -returns following Hafner et al. (2020; 2019):
52
+
53
+ $$
54
+ V _ { t } ^ { \lambda } \doteq r _ { t } + \gamma \Big ( ( 1 - \lambda ) v ( s _ { t + 1 } ) + \lambda V _ { t + 1 } ^ { \lambda } \Big ) , \quad V _ { H } ^ { \lambda } \doteq v ( s _ { H } ) .
55
+ $$
56
+
57
+ While the critic network is trained to regress the $\lambda$ -returns, the actor network is trained to maximize them. Different gradient estimators are available for computing the policy gradient for optimizing the actor, such as Reinforce (Williams, 1992) and the reparameterization trick (Kingma and Welling, 2013; Rezende et al., 2014) that directly backpropagates return gradients through the differentiable dynamics network (Henaff et al., 2019). Following Hafner et al. (2020), we choose reparameterization gradients for continuous control tasks and Reinforce gradients for tasks with discrete actions. In addition to maximizing returns, the actor is also incentivized to maintain high entropy to prevent collapse to a deterministic policy and maintain some amount of exploration throughout training:
58
+
59
+ $$
60
+ \begin{array} { r } { \mathcal { L } ( \pi ) \doteq - \operatorname { E } \bigl [ \sum _ { t = 1 } ^ { H } \ln \pi ( a _ { t } \mid s _ { t } ) \mathrm { s g } ( V _ { t } ^ { \lambda } - v ( s _ { t } ) ) + \eta \mathrm { H } \bigl [ \pi ( a _ { t } \mid s _ { t } ) \bigr ] \bigr ] } \end{array}
61
+ $$
62
+
63
+ We optimize the actor and critic using the Adam optimizer (Kingma and Ba, 2014). To compute the $\lambda$ -returns, we use a slowly updated copy of the critic network as common in the literature (Mnih et al., 2015; Lillicrap et al., 2015). The actor and critic gradients do not affect the world model, as this would lead to incorrect and overly optimistic model predictions. The hyperparameters are listed in Appendix D.
64
+
65
+ # 3 Experiments
66
+
67
+ We evaluate Dreamer on 4 robots, each with a different task, and compare its performance to appropriate algorithmic and human baselines. The experiments are representative of common robotic tasks, such as locomotion, manipulation, and navigation. The tasks pose a diverse range of challenges, including continuous and discrete actions, dense and sparse rewards, proprioceptive and image observations, and sensor fusion. The goal of the experiments is to evaluate whether the recent successes of learned world models enables sample-efficient robot learning directly in the real world. Specifically, we aim to answer the following research questions:
68
+
69
+ • Does Dreamer enable robot learning directly in the real world, without simulators? • Does Dreamer succeed across various robot platforms, sensory modalities, and action spaces? • How does the data-efficiency of Dreamer compare to previous reinforcement learning algorithms?
70
+
71
+ Implementation We build on the official implementation of DreamerV2 (Hafner et al., 2020). We develop an asynchronous actor and learner setup, which is essential in environments with high control rates, such as the quadruped, and also accelerates learning for slower environments, such as the robot arms. The actor thread computes online actions for the robot and sends trajectories of 128 time steps to the replay buffer. The learner thread samples data from the replay buffer, updates the world model, and optimizes the policy using imagination rollouts. Policy weights are synced from the learner to the actor every 20 seconds. We use an RSSM with 256 units to speed up the training computation. We use identical hyperparameters across all experiments, enabling off-the-shelf training on different robot embodiments.
72
+
73
+ ![](images/159d86a4fe017221206965fa98efc6ce35e16bebec7536f231b04a5fa470830b.jpg)
74
+ Figure 4: A1 Quadruped Walking Starting from lying on its back with the feet in the air, Dreamer learns to roll over, stand up, and walk in 1 hour of real world training time, without simulators or resets. In contrast, SAC only learns to roll over but neither to stand up nor to walk. For SAC, we also had to help the robot out of a dead-locked leg configuration during training. On the right we show training curves for both SAC and Dreamer. The maximum reward is 14. The filled circles indicate times where the robot fell on its back, requiring the learning of a robust strategy for getting back up. After 1 hour of training, we start pushing the robot and find that it adapts its behavior within 10 minutes to withstand light pushes and quickly roll back on its feet for hard pushes. The graph shows a single training run with the shaded area indicating one standard deviation within each time bin.
75
+
76
+ Baselines We compare to a strong learning algorithm for each of our experimental setups. The A1 quadruped robot uses continuous actions and low-dimensional inputs, allowing us to compare to SAC (Haarnoja et al., 2018a;b), a popular algorithm for data-efficient continuous control. For the visual pick and place experiments on the XArm and UR5 robots, inputs are images and proprioceptive readings and actions are discrete, suggesting algorithms from the DQN (Mnih et al., 2015) line of work as baselines. We choose Rainbow (Hessel et al., 2018) as a powerful representative of this category, an algorithm that combines many improvements of DQN. To input the proprioceptive readings, we concatenate them as broadcasted planes to the RGB channels of the image, a common practice in the literature (Schrittwieser et al., 2019). For the UR5, we additionally compare against PPO (Schulman et al., 2017), with similar modifications for fusing image and proprioceptive readings. In addition, we compare against a human operator controlling the robot arm through the robot control interface. For the Sphero navigation task, inputs are images and actions are continuous. The state-ofthe-art baseline in this category is DrQv2 (Yarats et al., 2021), which uses image augmentation to increase sample-efficiency.
77
+
78
+ # 3.1 A1 Quadruped Walking
79
+
80
+ This high-dimensional continuous control task requires training a quadruped robot to roll over from its back, stand up, and walk forward at a fixed target velocity. Prior work in quadruped locomotion requires either extensive training in simulation under domain randomization, using recovery controllers to avoid unsafe states, or defining the action space as parameterized trajectory generators that restrict the space of motions (Rusu et al., 2016; Peng et al., 2018; Rudin et al., 2021; Lee et al., 2020; Yang et al., 2019). In contrast, we train in the end-to-end reinforcement learning setting directly on the robot, without simulators or resets. We use the Unitree A1 robot that consists of 12 direct drive motors. The motors are controlled at $2 0 \mathrm { H z }$ via continuous actions that represent motor angles that are realized by a PD controller on the hardware. Actions are filtered with a Butterworth filter to protect the motor from high-frequency actions. The input consists of motor angles, orientations, and angular velocities. Due to space constraints, we manually intervene when the robot has reached the end of the available training area, without modifying the joint configuration or orientation that the robot is in.
81
+
82
+ ![](images/69e7a0dc11e3a7ecd812dec526777f2a39e7aed63605587ef789903e7f57fb8c.jpg)
83
+ Figure 8: Within 10 minutes of perturbing the learned walking behavior, the robot adapts to withstanding pushes or quickly rolling over and back on its feet.
84
+
85
+ The reward function is the sum of five terms. An upright reward is computed from the base frame up vector $\hat { z } ^ { T }$ , terms for matching the standing pose are computed from the joint angles of the hips, shoulders, and knees, and a forward velocity term is computed from the projected forward velocity $\boldsymbol { s } _ { v } \boldsymbol { x }$ and the total velocity $s _ { v }$ . Without the reward curriculum, the agent receives spurious reward values due to the velocity estimator’s dependence on foot-ground contact events. Each of the five terms is active while its preceding terms are satisfied to at least 0.7 and otherwise set to 0:
86
+
87
+ ![](images/69863294723843746383e47fe99dcd32744e499d1c526f51df4121c52ff99fe8.jpg)
88
+ Figure 5: UR5 Multi Object Visual Pick and Place This task requires learning to locate three ball objects from third-person camera images, grasp them, and move them into the other bin. The arm is free to move within and above the bins and sparse rewards are given for grasping a ball and for dropping it in the opposite bin. The environment requires the world model to learn multi-object dynamics in the real world and the sparse reward structure poses a challenge for policy optimization. Dreamer overcomes the challenges of visual localization and sparse rewards on this task, learning a successful strategy within a few hours of autonomous operation.
89
+
90
+ $$
91
+ \begin{array} { r l } { r ^ { \mathrm { u p r } } \doteq ( \hat { z } ^ { T } [ 0 , 0 , 1 ] - 1 ) / 2 } & { { } r ^ { \mathrm { h i p } } \doteq 1 - \frac 1 4 \| q ^ { \mathrm { h i p } } + 0 . 2 \| _ { 1 } \quad r ^ { \mathrm { s h o u l d e r } } \doteq 1 - \frac 1 4 \| q ^ { \mathrm { s h o u l d e r } } + 0 . 2 \| _ { 1 } } \end{array}
92
+ $$
93
+
94
+ $$
95
+ \begin{array} { r l } { r ^ { \mathrm { k n e e } } \doteq 1 - \frac 1 4 \parallel q ^ { \mathrm { k n e e } } - 1 . 0 \parallel _ { 1 } } & { { } r ^ { \mathrm { v e l o c i t y } } \doteq 5 \big ( \operatorname* { m a x } ( 0 , ^ { \mathcal { B } } v _ { x } ) / \parallel ^ { \mathcal { B } } v \parallel _ { 2 } \cdot \mathrm { c l i p } ( ^ { \mathcal { B } } v _ { x } / 0 . 3 , - 1 , 1 ) + 1 \big ) } \end{array}
96
+ $$
97
+
98
+ As shown in Figure 4, after one hour of training, Dreamer learns to consistently flip the robot over from its back, stand up, and walk forward. In the first 5 minutes of training, the robot manages to roll off its back and land on its feet. 20 minutes later, it learns how to stand up on its feet. About 1 hour into training, the robot learns a pronking gait to walk forward at the desired velocity. After succeeding at this task, we tested the robustness of the algorithms by repeatedly knocking the robot off of its feet with a large pole, shown in Figure 8. Within 10 minutes of additional online learning, the robot adapts and withstand pushes or quickly rolls back on its feet. In comparison, SAC quickly learns to roll off its back but fails to stand up or walk given the small data budget.
99
+
100
+ # 3.2 UR5 Multi-Object Visual Pick and Place
101
+
102
+ Common in warehouse and logistics environments, pick and place tasks require a robot manipulator to transport items from one bin into another. Figure 5 shows a successful pick and place cycle of this task. The task is challenging because of sparse rewards, the need to infer object positions from pixels, and the challenging dynamics of multiple moving objects. The sensory inputs consist of proprioceptive readings (joint angles, gripper position, end effector Cartesian position) and a 3rd person RGB image of the scene. Successfully grasping one of the 3 objects, detected by partial gripper closure, results in a $+ 1$ reward, releasing the object in the same bin gives a $- 1$ reward, and placing in the opposite bin gives a $+ 1 0$ reward. We control the UR5 robot from Universal Robotics at $2 \ \mathrm { H z }$ . Actions are discrete for moving the end effector in increments along X, Y, and $\textsf { Z }$ axes and for toggling the gripper state. Movement in the Z axis is only enabled while holding an object and the gripper automatically opens once above the correct bin. We estimate human teleoperation performance by recording 3 demonstrators for 20 minutes each, controlling the UR5 with a joystick.
103
+
104
+ Dreamer reaches an average pick rate of 2.5 objects per minute within 8 hours. The robot initially struggles to learn as the reward signal is very sparse, but begins to gradually improve after 2 hours of training. The robot first learns to localize the objects and toggles the gripper when near an object. Over time, grasping becomes precise and the robot learns to push objects out of corners. Figure 5 shows the learning curves of Dreamer compared to Rainbow DQN, PPO, and the human baseline. Both Rainbow DQN and PPO only learn the short-sighted behavior of grasping and immediately dropping objects in the same bin. In contrast, Dreamer approaches human-level teleoperation performance after 8 hours. We hypothesize that Rainbow DQN and PPO fail because they require larger amounts of experience, which is not feasible for us to collect in the real world.
105
+
106
+ # 3.3 XArm Visual Pick and Place
107
+
108
+ While the UR5 robot is a high performance industrial robot, the XArm is an accessible low-cost 7 DOF manipulation, which we control at approximately $0 . 5 \ : \mathrm { H z }$ . Similar to Section 3.2, the task requires localizing and grasping a soft object and moving it from one bin to another and back, shown in Figure 6. We connect the object to the gripper with a string, which makes it less likely for the object to get stuck in corners at the cost of more complex dynamics. The sparse reward, discrete action space, and observation space match the UR5 setup except for the addition of depth image observations.
109
+
110
+ ![](images/dfce202941b6d7b7a3b4e91b152da625264b3b1c43837193ab53e137e11b01f3.jpg)
111
+ Figure 6: XArm Visual Pick and Place The XArm is an affordable robot arm that operates slower than the UR5. To demonstrate successful learning on this robot, we use a third-person RealSense camera with RGB and depth modalities, as well as proprioceptive inputs for the robot arm, requiring the world model to learn sensor fusion. The pick and place task uses a soft object. While soft objects would be challenging to model accurately in a simulator, Dreamer avoids this issue by directly learning on the real robot without a simulator. While Rainbow and PPO using R3M visual embeddings converge to the local optimum of grasping and ungrasping the object in the same bin, Dreamer learns a successful pick and place policy from sparse rewards in under 10 hours.
112
+
113
+ Dreamer learns a policy that enables the XArm to achieve an average pick rate of 3.1 objects per minute in 10 hours of time, which is comparable to human performance on this task. Figure 6 shows that Dreamer learns to solve the task within 10 hours, whereas the Rainbow algorithm, a top model-free algorithm for discrete control from pixels, fails to learn. We additionally compare Dreamer against a PPO baseline that utilizes R3M (Nair et al., 2022) pretrained visual embeddings for the state, but notice no improvement in performance. Interestingly, we observed that Dreamer learns to sometimes use the string to pull the object out of a corner before grasping it, demonstrating multi-modal behaviors. Moreover, we observed that when lighting conditions change drastically (such as sharp shadows during sunrise), performance initially collapses but Dreamer then adapts to the changing conditions and exceeds its previous performance after a few hours of additional training, reported in Appendix A.
114
+
115
+ # 3.4 Sphero Navigation
116
+
117
+ We evaluate Dreamer on a visual navigation task that requires maneuvering a wheeled robot to a fixed goal location given only RGB images as input. We use the Sphero Ollie robot, a cylindrical robot with two controllable motors, which we control through continuous torque commands at $2 \ : \mathrm { H z }$ Because the robot is symmetric and the robot only has access to image observations, it has to infer the heading direction from the history of observations. The robot is provided with a dense reward equal to the negative L2 distance, which is computed using a oracle vision pipeline that detects the Sphero’s position (this information is not provided to the agent). As the goal is fixed, after 100 environment steps, we end the episode and randomize the robot’s position through a sequence of high power random motor actions.
118
+
119
+ In 2 hours, Dreamer learns to quickly and consistently navigate to the goal and stay near the goal for the remainder of the episode. As shown in Figure 7, Dreamer achieves an average distance to the goal of 0.15, measured in units of the area size and averaged across time steps. We find that DrQv2, a model-free algorithm specifically designed to continuous control from pixels, achieves similar performance. This result matches the simulated experiments of Yarats et al. (2021) that showed the two algorithms to perform similarly for continuous control tasks from images.
120
+
121
+ # 4 Related Work
122
+
123
+ Existing work on robot learning commonly leverages large amounts of simulated experience before deploying to the real world (Rusu et al., 2016; Peng et al., 2018; OpenAI et al., 2018; Lee et al., 2020; Irpan et al., 2020; Kumar et al., 2021; Siekmann et al., 2021; Escontrela et al., 2022), leverage fleets of robots to collect experience datasets (Kalashnikov et al., 2018; Dasari et al., 2019; Kalashnikov et al., 2021; Ebert et al., 2021), or rely on external information such as human expert demonstrations or task priors to achieve sample-efficient learning (Xie et al., 2019; Schoettler et al., 2019; James et al., 2021; Shah and Levine, 2022; Bohez et al., 2022; Sivakumar et al., 2022). However, designing simulated tasks and collecting expert demonstrations is time-consuming. Moreover, many of these approaches require specialized algorithms for leveraging offline experience, demonstrations, or simulator inaccuracies. In contrast, our experiments show that learning end-to-end from rewards in the physical world is feasible for a diverse range of tasks through world models.
124
+
125
+ ![](images/372acb53fc3f9ab9f178baac319f8b0cb0c4ee1ca96f374bada7397c4ec23630.jpg)
126
+ Figure 7: Sphero Navigation This task requires the Sphero robot to navigate to a goal location given a top-down RGB image as the only input. The task requires the robot to localize itself from raw pixels, to infer its orientation from the sequence of past images because it is ambiguous from a single image, and to control the robot from under-actuated motors that require building up momentum over time. Dreamer learns a successful policy on this task in under 2 hours.
127
+
128
+ Relatively few works have demonstrated end-to-end learning from scratch in the physical world. Visual Foresight (Finn et al., 2016; Finn and Levine, 2017; Ebert et al., 2018) learns a video prediction model to solve real world tasks by online planning, but is limited to short-horizon tasks and requires generating images during planning, making it computationally expensive. Yang et al. (2019; 2022) learn quadruped locomotion through a model-based approach by predicting foot placement and leveraging a domain-specific controller to achieve them. Ha et al. (2020) learn a quadruped walking policy by relying on a scripted reset policy, so the robot does not have to learn to stand up. SOLAR (Zhang et al., 2019) learns a latent dynamics model from images and demonstrates reaching and pushing with a robot arm. Nagabandi et al. (2019) learns manipulation policies by planning through a learned dynamics model from state observations. In comparison, our experiments show successful learning across 4 challenging robot tasks that cover a wide range of challenges and sensory modalities, with a single learning algorithm and hyperparameter setting.
129
+
130
+ # 5 Discussion
131
+
132
+ We applied Dreamer to physical robot learning, finding that modern world models enable sampleefficient robot learning for a range of tasks, from scratch in the real world and without simulators. We also find that the approach is generally applicable in that it can solve robot locomotion, manipulation, and navigation tasks without changing hyperparameters. Dreamer taught a quadruped robot to roll off the back, stand up, and walk in 1 hour from scratch, which previously required extensive training in simulation followed by transfer to the real world or parameterized trajectory generators and given reset policies. We also demonstrate learning to pick and place objects from pixels and sparse rewards on two robot arms in 8–10 hours.
133
+
134
+ Limitations While Dreamer shows promising results, learning on hardware over many hours creates wear on robots that may require human intervention or repair. Additionally, more work is required to explore the limits of Dreamer and our baselines by training for a longer time. Finally, we see tackling more challenging tasks, potentially by combining the benefits of fast real world learning with those of simulators, as an impactful future research direction.
135
+
136
+ Acknowledgements We thank Stephen James and Justin Kerr for helpful suggestions and help with printing the protective shell of the quadruped robot. We thank Ademi Adeniji for help with setting up the XArm robot and Raven Huang for help with setting up the UR5 robot. This work was supported in part by an NSF Fellowship, NSF NRI #2024675, and the Vanier Canada Graduate Scholarship.
137
+
138
+ References
139
+ D. Hafner, T. Lillicrap, J. Ba, and M. Norouzi. Dream to control: Learning behaviors by latent imagination. arXiv preprint arXiv:1912.01603, 2019.
140
+ D. Hafner, T. Lillicrap, M. Norouzi, and J. Ba. Mastering atari with discrete world models. arXiv preprint arXiv:2010.02193, 2020.
141
+ Y. Gal, R. McAllister, and C. E. Rasmussen. Improving pilco with bayesian neural network dynamics models. In Data-Efficient Machine Learning workshop, ICML, 2016.
142
+ F. Ebert, C. Finn, S. Dasari, A. Xie, A. Lee, and S. Levine. Visual foresight: Model-based deep reinforcement learning for vision-based robotic control. arXiv preprint arXiv:1812.00568, 2018.
143
+ R. Sekar, O. Rybkin, K. Daniilidis, P. Abbeel, D. Hafner, and D. Pathak. Planning to explore via selfsupervised world models. In International Conference on Machine Learning, pages 8583–8592. PMLR, 2020.
144
+ T. Yu, A. Kumar, R. Rafailov, A. Rajeswaran, S. Levine, and C. Finn. Combo: Conservative offline model-based policy optimization. Advances in neural information processing systems, 34: 28954–28967, 2021.
145
+ D. Hafner, T. Lillicrap, I. Fischer, R. Villegas, D. Ha, H. Lee, and J. Davidson. Learning latent dynamics for planning from pixels. arXiv preprint arXiv:1811.04551, 2018.
146
+ D. P. Kingma and M. Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
147
+ D. J. Rezende, S. Mohamed, and D. Wierstra. Stochastic backpropagation and approximate inference in deep generative models. arXiv preprint arXiv:1401.4082, 2014.
148
+ R. S. Sutton and A. G. Barto. Reinforcement learning: An introduction. MIT press, 2018.
149
+ R. J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3-4):229–256, 1992.
150
+ M. Henaff, A. Canziani, and Y. LeCun. Model-predictive policy learning with uncertainty regularization for driving in dense traffic. arXiv preprint arXiv:1901.02705, 2019.
151
+ D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
152
+ 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, 2015.
153
+ T. P. Lillicrap, J. J. Hunt, A. Pritzel, N. Heess, T. Erez, Y. Tassa, D. Silver, and D. Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
154
+ T. Haarnoja, A. Zhou, P. Abbeel, and S. Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. arXiv preprint arXiv:1801.01290, 2018a.
155
+ T. Haarnoja, A. Zhou, K. Hartikainen, G. Tucker, S. Ha, J. Tan, V. Kumar, H. Zhu, A. Gupta, P. Abbeel, et al. Soft actor-critic algorithms and applications. arXiv preprint arXiv:1812.05905, 2018b.
156
+ M. Hessel, J. Modayil, H. Van Hasselt, T. Schaul, G. Ostrovski, W. Dabney, D. Horgan, B. Piot, M. Azar, and D. Silver. Rainbow: Combining improvements in deep reinforcement learning. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
157
+ 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.
158
+ J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
159
+ D. Yarats, R. Fergus, A. Lazaric, and L. Pinto. Mastering visual continuous control: Improved data-augmented reinforcement learning. arXiv preprint arXiv:2107.09645, 2021.
160
+ A. A. Rusu, M. Vecerik, T. Rothörl, N. Heess, R. Pascanu, and R. Hadsell. Sim-to-real robot learning from pixels with progressive nets, 2016.
161
+ X. B. Peng, M. Andrychowicz, W. Zaremba, and P. Abbeel. Sim-to-real transfer of robotic control with dynamics randomization. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pages 1–8, May 2018. doi:10.1109/ICRA.2018.8460528.
162
+ N. Rudin, D. Hoeller, P. Reist, and M. Hutter. Learning to walk in minutes using massively parallel deep reinforcement learning, 2021.
163
+ J. Lee, J. Hwangbo, L. Wellhausen, V. Koltun, and M. Hutter. Learning quadrupedal locomotion over challenging terrain. Science Robotics, 5(47), oct 2020. doi:10.1126/scirobotics.abc5986. URL https://doi.org/10.1126%2Fscirobotics.abc5986.
164
+ Y. Yang, K. Caluwaerts, A. Iscen, T. Zhang, J. Tan, and V. Sindhwani. Data efficient reinforcement learning for legged robots, 2019.
165
+ S. Nair, A. Rajeswaran, V. Kumar, C. Finn, and A. Gupta. R3m: A universal visual representation for robot manipulation, 2022.
166
+ OpenAI, M. Andrychowicz, B. Baker, M. Chociej, R. Jozefowicz, B. McGrew, J. Pachocki, A. Petron, M. Plappert, G. Powell, A. Ray, J. Schneider, S. Sidor, J. Tobin, P. Welinder, L. Weng, and W. Zaremba. Learning dexterous in-hand manipulation, 2018.
167
+ A. Irpan, C. Harris, J. Ibarz, K. Rao, M. Khansari, and S. Levine. Rl-cyclegan: Improving deep-rl robotics with simulation-to-real. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2020), 2020.
168
+ A. Kumar, Z. Fu, D. Pathak, and J. Malik. Rma: Rapid motor adaptation for legged robots, 2021.
169
+ J. Siekmann, K. Green, J. Warila, A. Fern, and J. Hurst. Blind bipedal stair traversal via sim-to-real reinforcement learning, 2021.
170
+ A. Escontrela, X. B. Peng, W. Yu, T. Zhang, A. Iscen, K. Goldberg, and P. Abbeel. Adversarial motion priors make good substitutes for complex reward functions, 2022.
171
+ D. Kalashnikov, A. Irpan, P. Pastor, J. Ibarz, A. Herzog, E. Jang, D. Quillen, E. Holly, M. Kalakrishnan, V. Vanhoucke, and S. Levine. Qt-opt: Scalable deep reinforcement learning for vision-based robotic manipulation, 2018.
172
+ S. Dasari, F. Ebert, S. Tian, S. Nair, B. Bucher, K. Schmeckpeper, S. Singh, S. Levine, and C. Finn. Robonet: Large-scale multi-robot learning, 2019.
173
+ D. Kalashnikov, J. Varley, Y. Chebotar, B. Swanson, R. Jonschkowski, C. Finn, S. Levine, and K. Hausman. Mt-opt: Continuous multi-task robotic reinforcement learning at scale, 2021.
174
+ F. Ebert, Y. Yang, K. Schmeckpeper, B. Bucher, G. Georgakis, K. Daniilidis, C. Finn, and S. Levine. Bridge data: Boosting generalization of robotic skills with cross-domain datasets, 2021.
175
+ A. Xie, F. Ebert, S. Levine, and C. Finn. Improvisation through physical understanding: Using novel objects as tools with visual foresight. arXiv preprint arXiv:1904.05538, 2019.
176
+ G. Schoettler, A. Nair, J. Luo, S. Bahl, J. A. Ojea, E. Solowjow, and S. Levine. Deep reinforcement learning for industrial insertion tasks with visual inputs and natural rewards, 2019.
177
+ S. James, K. Wada, T. Laidlow, and A. J. Davison. Coarse-to-fine q-attention: Efficient learning for visual robotic manipulation via discretisation, 2021.
178
+ D. Shah and S. Levine. Viking: Vision-based kilometer-scale navigation with geographic hints, 2022.
179
+ S. Bohez, S. Tunyasuvunakool, P. Brakel, F. Sadeghi, L. Hasenclever, Y. Tassa, E. Parisotto, J. Humplik, T. Haarnoja, R. Hafner, M. Wulfmeier, M. Neunert, B. Moran, N. Siegel, A. Huber, F. Romano, N. Batchelor, F. Casarini, J. Merel, R. Hadsell, and N. Heess. Imitate and repurpose: Learning reusable robot movement skills from human and animal behaviors, 2022.
180
+ A. Sivakumar, K. Shaw, and D. Pathak. Robotic telekinesis: Learning a robotic hand imitator by watching humans on youtube, 2022.
181
+ C. Finn, I. Goodfellow, and S. Levine. Unsupervised learning for physical interaction through video prediction. In Advances in neural information processing systems, pages 64–72, 2016.
182
+ C. Finn and S. Levine. Deep visual foresight for planning robot motion. In Robotics and Automation (ICRA), 2017 IEEE International Conference on, pages 2786–2793. IEEE, 2017.
183
+ Y. Yang, T. Zhang, E. Coumans, J. Tan, and B. Boots. Fast and efficient locomotion via learned gait transitions. In Conference on Robot Learning, pages 773–783. PMLR, 2022.
184
+ S. Ha, P. Xu, Z. Tan, S. Levine, and J. Tan. Learning to walk in the real world with minimal human effort. arXiv preprint arXiv:2002.08550, 2020.
185
+ M. Zhang, S. Vikram, L. Smith, P. Abbeel, M. Johnson, and S. Levine. Solar: deep structured representations for model-based reinforcement learning. In International Conference on Machine Learning, 2019.
186
+ A. Nagabandi, K. Konoglie, S. Levine, and V. Kumar. Deep dynamics models for learning dexterous manipulation, 2019.
187
+ G. I. Parisi, R. Kemker, J. L. Part, C. Kanan, and S. Wermter. Continual lifelong learning with neural networks: A review. Neural Networks, 113:54–71, 2019. ISSN 0893-6080.
188
+ T. Miki, J. Lee, J. Hwangbo, L. Wellhausen, V. Koltun, and M. Hutter. Learning robust perceptive locomotion for quadrupedal robots in the wild. Science Robotics, 7(62), jan 2022. doi:10.1126/ scirobotics.abk2822.
189
+ L. Smith, J. C. Kew, X. B. Peng, S. Ha, J. Tan, and S. Levine. Legged robots that keep on learning: Fine-tuning locomotion policies in the real world, 2021.
190
+ T.-Y. Yang, T. Zhang, L. Luu, S. Ha, J. Tan, and W. Yu. Safe reinforcement learning for legged locomotion, 2022. URL https://arxiv.org/abs/2203.02638.
191
+ S. Ha, P. Xu, Z. Tan, S. Levine, and J. Tan. Learning to walk in the real world with minimal human effort, 2020. URL https://arxiv.org/abs/2002.08550.
192
+ L. Smith, I. Kostrikov, and S. Levine. A walk in the park: Learning to walk in 20 minutes with model-free reinforcement learning, 2022. URL https://arxiv.org/abs/2208.07860.
193
+ S. Levine, P. Pastor, A. Krizhevsky, J. Ibarz, and D. Quillen. Learning hand-eye coordination for robotic grasping with deep learning and large-scale data collection. The International Journal of Robotics Research, 37(4-5):421–436, 2018.
194
+ L. Pinto and A. Gupta. Supersizing self-supervision: Learning to grasp from 50k tries and 700 robot hours, 2015.
195
+ H. Ha and S. Song. Flingbot: The unreasonable effectiveness of dynamic manipulation for cloth unfolding. Conference on Robot Learning, 2021.
196
+ S. James and A. J. Davison. Q-attention: Enabling efficient learning for vision-based robotic manipulation, 2021.
197
+ E. Tzeng, C. Devin, J. Hoffman, C. Finn, P. Abbeel, S. Levine, K. Saenko, and T. Darrell. Adapting deep visuomotor representations with weak pairwise constraints, 2015.
198
+ 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.
199
+ M. P. Deisenroth, G. Neumann, J. Peters, et al. A survey on policy search for robotics. Foundations and Trends in Robotics, 2(1–2):1–142, 2013.
200
+ K. Chua, R. Calandra, R. McAllister, and S. Levine. Deep reinforcement learning in a handful of trials using probabilistic dynamics models. In Advances in Neural Information Processing Systems, pages 4754–4765, 2018.
201
+ A. Nagabandi, G. Yang, T. Asmar, R. Pandya, G. Kahn, S. Levine, and R. S. Fearing. Learning image-conditioned dynamics models for control of under-actuated legged millirobots, 2017.
202
+ P. Becker-Ehmck, M. Karl, J. Peters, and P. van der Smagt. Learning to fly via deep model-based reinforcement learning. arXiv preprint arXiv:2003.08876, 2020.
203
+ F. Deng, I. Jang, and S. Ahn. Dreamerpro: Reconstruction-free model-based reinforcement learning with prototypical representations. arXiv preprint arXiv:2110.14565, 2021.
204
+ M. Okada and T. Taniguchi. Dreaming: Model-based reinforcement learning by latent imagination without reconstruction. In 2021 IEEE International Conference on Robotics and Automation (ICRA), pages 4209–4215. IEEE, 2021.
205
+ H. Bharadhwaj, M. Babaeizadeh, D. Erhan, and S. Levine. Information prioritization through empowerment in visual model-based rl. arXiv preprint arXiv:2204.08585, 2022.
206
+ K. Paster, L. E. McKinney, S. A. McIlraith, and J. Ba. Blast: Latent dynamics models from bootstrapping. In Deep RL Workshop NeurIPS 2021, 2021.
207
+ K. Hsu, M. J. Kim, R. Rafailov, J. Wu, and C. Finn. Vision-based manipulators need to also see from their hands, 2022. URL https://arxiv.org/abs/2203.12677.
208
+
209
+ # A Adaptation
210
+
211
+ Real world robot learning faces practical challenges such as changing environmental conditions and time varying dynamics. We found that Dreamer is able to adapt to the current environmental conditions with no change to the learning algorithm. This shows promise for using Dreamer in continual learning settings (Parisi et al., 2019). Adaptation of the quadruped to external perturbations is reported in Section 3.1 and Figure 8.
212
+
213
+ The XArm, situated near large windows, is able to adapt and maintain performance under the presence of changing lighting conditions. The XArm experiments were conducted after sundown to keep the lighting conditions constant throughout training. Figure A.1 shows the learning curve of the XArm. As expected, the performance of the XArm drops during sunrise. However, the XArm is able to adapt to the change in lighting conditions in about 5 hours time and recover the original performance, which is faster than it would be to train from scratch. A careful inspection of the image observations at these times, as shown in Figure A.1, reveals that the robot received observations with strong light rays covering the scene which greatly differs from the original training observations.
214
+
215
+ ![](images/db6cf431ae9355646aa06c810c30e311d8db38009707b4dea4bad788085ac2bb.jpg)
216
+ Figure A.1: The left two images are raw observations consumed by Dreamer. The leftmost image is an image observation as seen by the XArm at night, when it was trained. The next image shows an observation during sunrise. Despite the vast difference in pixel space, the XArm is able to recover, and then surpass, the original performance in approximately 5 hours. Even after 24 hours when the lighting shifts to night time conditions, the XArm is able to maintain performance.
217
+
218
+ # B Imagination
219
+
220
+ ![](images/24fe88bf92baa43778d9defa3450750bc0d2c910fa9c12c5902630d7c2316e1e.jpg)
221
+ Figure B.1: To introspect the policy, we can roll out trajectories in the latent space of Dreamer, then decode the images to visualize the intent of the actor network. Each row is an imagined trajectory, showing every 2nd frame. Top: Latent rollouts on the UR5 environment. Multiple objects introduce more visual complexity that the network has to model. Note the second trajectory, which shows a static orange ball becoming a green ball. Bottom: Latent rollouts on the XArm environment.
222
+
223
+ # C Detailed Related Work
224
+
225
+ RL for locomotion A common approach is to train RL agents from large amounts of simulated data under domain and dynamics randomization (Peng et al., 2018; Lee et al., 2020; Rudin et al., 2021; Siekmann et al., 2021; Escontrela et al., 2022; Miki et al., 2022; Kumar et al., 2021; Rusu et al., 2016; Bohez et al., 2022), then freezing the learned policy and deploying it to the real world. Smith et al. (2021) explored pre-training policies in simulation and fine-tuning them with real world data. Yang et al. (2019) investigate learning a dynamics model using a multi-step loss and using model predictive control to accomplish a specified task. Yang et al. (2022) train locomotion policies in the real world but require a recovery controller trained in simulation to avoid unsafe states. In contrast, we use no simulators or reset policies and directly train on the physical robot. While prior work in locomotion has successfully learned walking behaviors in the real world, these works generally required several domain-specific assumptions or pretraining with simulators. Ha et al. (2020) achieved successful walking on the Minitaur robot in 90 minutes. However, the authors manually programmed a reset policy that was used when the robot fell on its back, while in our work the robot must learn to flip over and stand up. Additionally, the Minitaur robot is simpler than the A1 as it has 8 actuators compared to 12 on the A1. In recent work, Smith et al. (2022) utilize a high update-to-data ratio (UTD) RL algorithm to learn walking from 20 minutes of robot training data. However, their work assumes the availability of a reset policy and therefore comprises of a different learning problem compared to the problem we tackle of learning to flip over and walk from scratch. Additionally, we show our approach generalizes to environments with image observations and sparse rewards.
226
+
227
+ RL for manipulation Learning promises to enable robot manipulators to solve contact rich tasks in open real world environments. One class of methods attempts to scale up experience collection through a fleet of robots (Kalashnikov et al., 2018; 2021; Ebert et al., 2021; Dasari et al., 2019; Levine et al., 2018). In contrast, we only leverage one robot, but parallelize an agent’s experience by using the learned world model. Another common approach is to leverage expert demonstrations or other task priors (Pinto and Gupta, 2015; Ha and Song, 2021; Xie et al., 2019; Schoettler et al., 2019; Sivakumar et al., 2022). James and Davison (2021); James et al. (2021) leverages a few demonstrations to increase the sample-efficiency of Q learning by focusing the learner on important aspects of the scene. Other approaches, as in locomotion, first utilize a simulator, then transfer to the real world (Tzeng et al., 2015; Akkaya et al., 2019; OpenAI et al., 2018; Irpan et al., 2020). Our work focuses on single-robot environments where the agent must learn through a small amount of interaction with the world. Meanwhile, the Google Arm Farm line of work by Levine et al. leverages over $5 8 0 \mathrm { k }$ grasp attempts gathered by 7 robots and collected over 4 months. We believe that a method such as Dreamer could benefit greatly from this scale of training data, however it is unlikely that works such as MT-OPT/QT-OPT Kalashnikov et al. (2018; 2021) would work well in the low data regime that Dreamer excels in.
228
+
229
+ Model-based RL Due to its higher sample-efficiency over model-free methods, model-based RL is a promising approach to learning on real world robots (Deisenroth et al., 2013). A model based method first learns a dynamics model, which can then be used to plan actions (Nagabandi et al., 2019; Hafner et al., 2018; Chua et al., 2018; Nagabandi et al., 2017; Becker-Ehmck et al., 2020), or be used as a simulator to learn a policy network as in Dreamer (Hafner et al., 2019; 2020). One approach to tackle the high visual complexity of the world is to learn an action conditioned video prediction model (Finn and Levine, 2017; Ebert et al., 2018; Finn et al., 2016). One downside of this approach is the need to directly predict high dimensional observations, which can be computationally inefficient and easily drift. Dreamer learns a dynamics model in a latent space, allowing more efficient rollouts and avoids relying on high quality visual reconstructions for the policy. Another line of work proposes to learn latent dynamics models without having to reconstruct inputs (Deng et al., 2021; Okada and Taniguchi, 2021; Bharadhwaj et al., 2022; Paster et al., 2021), which we see as a promising approach for supporting moving view points in cluttered environments.
230
+
231
+ # D Hyperparameters
232
+
233
+ <table><tr><td rowspan=1 colspan=1>Name</td><td rowspan=1 colspan=1>Symbol</td><td rowspan=1 colspan=1>Value</td></tr><tr><td rowspan=1 colspan=3>General</td></tr><tr><td rowspan=1 colspan=1>Replay capacity (FIFO)Start learningBatch sizeBatch lengthMLP sizeActivation</td><td rowspan=1 colspan=1>BT</td><td rowspan=1 colspan=1>10610432324× 512LayerNorm+ELU</td></tr><tr><td rowspan=1 colspan=3>World Model</td></tr><tr><td rowspan=1 colspan=1>RSSM sizeNumber of latentsClasses per latentKL balancing</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>51232320.8</td></tr><tr><td rowspan=1 colspan=3>Actor Critic</td></tr><tr><td rowspan=1 colspan=1>Imagination horizonDiscountReturn lambdaTarget update interval</td><td rowspan=1 colspan=1>H?</td><td rowspan=1 colspan=1>150.950.95100</td></tr><tr><td rowspan=1 colspan=3>All Optimizers</td></tr><tr><td rowspan=1 colspan=1>Gradient clippingLearning rateAdam epsilon</td><td rowspan=1 colspan=1>E</td><td rowspan=1 colspan=1>10010-410-6</td></tr></table>
234
+
235
+ # E Environment and Hardware Details
236
+
237
+ For every robot setup that involved vision (UR5, XArm, Sphero), we used a RealSense D435 camera positioned to offer a fixed 3rd person view of the scene.
238
+
239
+ A1 We used the A1 quadrupedal robot by Unitree. The RL policy outputs actions at a frequency that is too high for the PD controller to track, which we overcome by lowpass filtering the action sequence. The joint range allows the legs to self-collide with the body, which can be damaging to the motors and increase battery consumption. We limited the joint range to decrease self-collisions. Finally, the EKF velocity estimator relies on foot-ground contact events to prevent significant drift in the estimates, so we employ a curriculum reward function that does not reward the robot for forward velocity until the robot is upright with extended legs. We also designed a shell which we 3D printed in order to better protect the cables and hardware and provide a smoother rolling over.
240
+
241
+ XArm & UR5 We utilized slanted bins to prevent objects from leaving the work area during the long-running pick and place experiments on the UR5, which is common practice Levine et al. (2018); Kalashnikov et al. (2018). We also added a partition behind the setup to keep the background constant. It would be interesting to study how a gripper-mounted camera would impact policy performance Hsu et al. (2022), however we report strong results without this design choice. For the XArm we use the uFactory xArm Gripper. For the UR5, we use the Robotiq 2F-85 parallel jaw gripper. The bin locations are predetermined and provided as part of the environment to prevent the robot from colliding with the bin. In addition, movement in the $\textsf { Z }$ axis is only enabled while holding an object and the gripper automatically opens once above the other bin.
242
+
243
+ Sphero We used a rectangular enclosure of $0 . 8 \times 0 . 8 \mathrm { { m ^ { 2 } } }$ to keep the sphero robot within the camera view. We used a simple OpenCV script to estimate the L2 distance between the Sphero and the goal position to provide a dense reward for policy optimization. This positional information was not provided to the agent, which it had to learn from the raw top-down images.
md/dev/83LJRUzXWj/83LJRUzXWj.md ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Convolutions Die Hard: Open-Vocabulary Segmentation with Single Frozen Convolutional CLIP
2
+
3
+ Qihang $\mathbf { V } \mathbf { u } ^ { 1 }$ , $\mathbf { J u H e } ^ { 2 }$ , Xueqing Deng1, Xiaohui Shen1, Liang-Chieh Chen1 1 ByteDance 2 The Johns Hopkins University
4
+
5
+ # Abstract
6
+
7
+ Open-vocabulary segmentation is a challenging task requiring segmenting and recognizing objects from an open set of categories in diverse environments. One way to address this challenge is to leverage multi-modal models, such as CLIP, to provide image and text features in a shared embedding space, which effectively bridges the gap between closed-vocabulary and open-vocabulary recognition. Hence, existing methods often adopt a two-stage framework to tackle the problem, where the inputs first go through a mask generator and then through the CLIP model along with the predicted masks. This process involves extracting features from raw images multiple times, which can be ineffective and inefficient. By contrast, we propose to build everything into a single-stage framework using a shared Frozen Convolutional CLIP backbone, which not only significantly simplifies the current two-stage pipeline, but also remarkably yields a better accuracy-cost trade-off. The resulting single-stage system, called FC-CLIP, benefits from the following observations: the frozen CLIP backbone maintains the ability of open-vocabulary classification and can also serve as a strong mask generator, and the convolutional CLIP generalizes well to a larger input resolution than the one used during contrastive image-text pretraining. Surprisingly, FC-CLIP advances state-of-the-art results on various benchmarks, while running practically fast. Specifically, when training on COCO panoptic data only and testing in a zero-shot manner, FC-CLIP achieve 26.8 PQ, 16.8 AP, and 34.1 mIoU on ADE20K, 18.2 PQ, 27.9 mIoU on Mapillary Vistas, 44.0 PQ, 26.8 AP, 56.2 mIoU on Cityscapes, outperforming the prior art under the same setting by $+ 4 . 2$ PQ, $+ 2 . 4$ AP, $+ 4 . 2$ mIoU on ADE20K, $+ 4 . 0$ PQ on Mapillary Vistas and $+ 2 0 . 1$ PQ on Cityscapes, respectively. Additionally, the training and testing time of FC-CLIP is $7 . 5 \times$ and $6 . 6 \times$ significantly faster than the same prior art, while using $5 . 9 \times$ fewer total model parameters. Meanwhile, FC-CLIP also sets a new state-of-the-art performance across various open-vocabulary semantic segmentation datasets. Code and models are available at https://github.com/bytedance/fc-clip.
8
+
9
+ # 1 Introduction
10
+
11
+ Panoptic segmentation [44] is a complex computer vision task that aims to predict a set of nonoverlapping masks, each with its corresponding class label. It combines the tasks of semantic segmentation [37] and instance segmentation [34], making it a challenging problem to solve. Many methods [43, 87, 18, 83, 51, 93, 20, 94, 53] have been proposed to tackle this problem, and a significant progress has been made in terms of panoptic quality (PQ). However, due to the high cost of annotating such a fine-grained dataset [54, 22], the number of semantic classes is typically limited to a few dozens or hundreds. This restriction hinders the further application of existing approaches to real-world settings, where the number of possible semantic classes is unlimited.
12
+
13
+ ![](images/421dc1efec208feccec5a8ed08ca72dba279c8c5a4e7d13967936f14f48ba000.jpg)
14
+ Figure 1: $k$ -means visualization on top of frozen CLIP backbone features w.r.t. different input resolutions. Both ViT-based and CNN-based CLIP produces semantic-meaningful features. However, when scaling up the input resolutions, we note that ViT-based CLIP features turn noisier, while CNN-based ones are smoother and generalize better. The smoother feature map is preferable for mask-pooling modules in our design.
15
+
16
+ To overcome the limitations of closed-vocabulary segmentation, open-vocabulary segmentation [48, 90, 29, 25] has been proposed. These approaches uses text embeddings of category names [97], represented in natural language, as label embeddings, instead of learning them from the training dataset. By doing so, models can classify objects from a wider vocabulary, which improves their ability to handle a broader range of categories. To ensure that meaningful embeddings are provided, a pretrained text encoder [23, 70, 57, 69] is typically used. This encoder can effectively capture the semantic meaning of words and phrases, which is critical for open-vocabulary segmentation.
17
+
18
+ Multi-modal models, such as CLIP [69] and ALIGN [40], have shown promise for open-vocabulary segmentation due to their ability to learn aligned image-text feature representations from large-scale Internet data [74]. SimBaseline [90] and OVSeg [52] are two recent methods that use a two-stage framework to adapt CLIP for open-vocabulary segmentation. In these methods, images are first processed by a heavy mask generator [36, 20] to obtain mask proposals, and then each masked image crop is generated and fed into a frozen CLIP model for classification. MaskCLIP [25] extends this approach to open-vocabulary panoptic segmentation, but additionally leverages mask proposals as attention masks in the CLIP backbone to efficiently avoid multiple forwarding processes for the masked crops. More recently, ODISE [89] employs a stable diffusion UNet [72, 71] as a frozen backbone for mask generator, which significantly boosts the state-of-the-art performance. However, despite these advances, they still rely on a two-stage framework, where the mask generator and CLIP classifier extract features from raw images separately, resulting in inefficiency and ineffectiveness.
19
+
20
+ A natural question thus arises as to whether it is possible to unify the mask generator and CLIP classifier into a single-stage framework for open-vocabulary segmentation. Sharing the feature extractor between them is a straightforward solution, but it poses two challenges. First, fine-tuning CLIP backbone can disrupt the alignment between image and text features, resulting in a much worse performance on out-of-vocabulary categories. Existing methods [90, 52, 25, 89] rely on another separate backbone for mask generator, increasing model size and computational costs. Second, CLIP models are typically pretrained on relatively lower-resolution inputs, while dense prediction tasks require a much higher resolution for optimal performance. This makes it difficult to directly apply CLIP-pretrained backbones to downstream dense prediction tasks, particularly ViT-based CLIP models [26], where careful treatments are required (e.g., side adapter [17, 91], or cost aggregation [101, 21]). Consequently, existing methods [25, 89] perform mask segmentation and CLIP classification at different input scales, leading to sub-optimal performance.
21
+
22
+ To alleviate the two challenges, we propose to build both mask generator and CLIP classifier on top of a shared Frozen Convolutional CLIP backbone, resulting in a single-stage framework FC-CLIP. Its design is based on the following observations. The frozen CLIP backbone ensures that the pretrained image-text feature alignment is intact, allowing out-of-vocabulary classification. It can also serve as a strong mask generator by appending a lightweight pixel decoder and mask decoder [20, 94]. The convolutional CLIP, based on a Convolutional Neural Network (CNN) [47], empirically shows a better generalization ability compared to ViT-based CLIP [26], when the input size scales up. This echoes the success of fully convolutional networks [60] in dense prediction tasks. Both observations are critical for developing a single-stage framework, but they have been overlooked and undiscovered by existing two-stage pipelines [25, 89]. In Fig. 1, we visualize the learned visual representation of ViT-based and CNN-based CLIP via $k$ -means clustering [59]. As shown in the figure, the features learned by CNN-based CLIP are more robust across different input sizes.
23
+
24
+ Surprisingly, the adoption of a single frozen convolutional CLIP as the shared feature extractor results in an extremely simple yet effective design. Specifically, the single-stage FC-CLIP consists of three modules built upon a shared frozen convolutional CLIP backbone: a class-agnostic mask generator, an in-vocabulary classifier, and an out-of-vocabulary classifier (see Fig. 2 for comparison between pipelines). The proposed method not only enjoys a simple design, but also comes with a very low cost for both training and testing. As a comparison, our model has only 238M frozen parameters and 21M trainable parameters, against the state-of-the-art work ODISE [89] that has 1494M frozen and 28M trainable parameters. Furthermore, our model training only takes 25.6 V100 GPU days, which is $7 . 5 \times$ faster compared to ODISE’s 192 V100 GPU days. During inference, our model also runs $6 . 6 \times$ faster. Although FC-CLIP enjoys a simple design, it still outperforms previous methods across multiple datasets. Trained on COCO panoptic dataset only, FC-CLIP surpasses prior state-of-the-art ODISE [89] significantly in a zero-shot manner. Specifically, FC-CLIP achieves 26.8 PQ $( + 3 . 4 )$ , 18.2 PQ $( + 4 . 0 ) $ , and 44.0 PQ $( + 2 0 . 1 )$ on ADE20K, Mapillary Vistas, and Cityscapes, respectively.
25
+
26
+ As panoptic segmentation unifies semantic and instance segmentation, FC-CLIP naturally extends to open-vocabulary semantic and instance segmentation. With the same model trained on COCO panoptic data only (i.e., no task-specific fine-tuning), FC-CLIP achieves state-of-the-art performance on open-vocabulary instance and semantic segmentation. Specifically, FC-CLIP achieves $1 6 . 8 \mathrm { A P }$ on ADE20K, surpassing the state-of-art ODISE [89] by $+ 2 . 4$ . FC-CLIP also outperforms the state-of-art specialized open-vocabulary semantic segmentation model SAN [91] by $+ 1 . 1$ and $+ 1 . 1$ mIoU on the challenging ADE20K-847 (A-847) and PASCAL-Context-459 (PC-459) benchmarks, respectively.
27
+
28
+ In summary, through the lens of a careful re-design of existing two-stage open-vocabulary segmentation models, we establish a simple, strong, and fast baseline for the community. The proposed FC-CLIP adopts a single-stage framework by exploiting a shared frozen convolutional CLIP, which not only advances the state-of-the-art performances on multiple benchmarks, but also enjoys a practically fast training and inference speed. We hope our study will inspire future research on efficient single-stage open-vocabulary segmentation models.
29
+
30
+ # 2 Related Work
31
+
32
+ Vision-language models target at encoding vision and language jointly in a fusion model. Early works [78, 16, 98] extract visual representations by pretrained object detectors and fine-tune on downstream tasks with language supervision. Recently, with the breakthrough of large language models [23, 3], rapid progress has been made in this field. CLIP [69] and ALIGN [40] demonstrate that pretraining dual-encoder models with contrastive objectives on large-scale noisy image-text pairs can learn representation with cross-modal alignment ability and show strong performance in zero-shot downstream tasks. The following works [95, 1, 92] further confirm these points and achieve impressive results in zero-shot transfer learning such as open-vocabulary image recognition.
33
+
34
+ Closed-vocabulary segmentation can be divided into three types according to the semantics of the grouping pixels, i.e. semantic, instance and panoptic segmentation. Semantic segmentation interprets high-level category semantic concepts. Prior works [9, 72, 10, 11, 13, 28, 96, 86, 99, 30] mainly treat this task as a per-pixel classification problem and build their models on top of the idea of FCN [60]. Instance segmentation groups foreground pixels into different object instances. Starting from Mask RCNN [36], prior works [42, 56, 12, 6, 2, 8, 80, 84, 66] mainly address this task with mask classification, where a set of bounding boxes and binary masks are predicted. Panoptic segmentation seeks for holistic scene understanding including both stuff and things. The pioneering work [44] and prevalent ones [55, 43, 87, 18, 50, 82, 14, 67] decompose the problem into various proxy tasks and merge the results in the end. Recently, following DETR [7], most works [83, 76, 19, 20, 51, 93, 94, 39, 49, 77] present end-to-end solutions based on the idea of mask classification. Standing on their shoulders, our proposed method builds on top of the pixel decoder and mask decoder of Mask2Former [20] by additionally exploiting the open-vocabulary recognition ability from CLIP [69].
35
+
36
+ ![](images/145e50b35132b4f6bbd418a7573e6d7f442c94af26cb54a19820007c343c33db.jpg)
37
+ Figure 2: Comparisons between open-vocabulary panoptic segmentation pipelines. Left: Existing methods [25, 89] adopt a two-stage pipeline, where the first stage employs a high-resolution image to generate class-agnostic masks, and the second stage feeds both the low-resolution image and predicted masks to a frozen CLIP backbone for open-vocabulary recognition. This incurs heavy computation, as image features are extracted multiple times. Middle: A naïve single-stage framework builds everything together and fine-tunes the CLIP backbone, breaking the pretrained alignment between images and texts. Right: Our single-stage framework FC-CLIP employs a shared frozen convolutional CLIP, where "frozen CLIP" maintains the open-vocabulary recognition and can serve as a strong mask generator, and "convolutional CLIP" generalizes well to large input sizes. Note that the predicted masks are used for CLIP recognition in all three schemes (not shown for simplicity).
38
+
39
+ Open-vocabulary segmentation aims at segmenting arbitrary classes including those that can not be accessed during the training procedure. Priors works [48, 29, 90, 52, 24, 88, 101, 91, 104, 62, 102, 32] perform open-vocabulary semantic segmentation through leveraging large pretrained vision-language models [69, 40, 71]. Recently, MaskCLIP [25] presents a two-stage pipeline, which consists of a class-agnostic mask generator and a frozen CLIP [69] encoder for cross-modal alignment, and thus expands the scope of the CLIP models into open-vocabulary panoptic segmentation. ODISE [89] digs out the innate potential of pretrained text-image diffusion models [71] in terms of the ability to present open concepts in the representation space for performing strong open-vocabulary panoptic segmentation. FreeSeg [68] encodes multi-granularity concepts into a compact textural abstraction, enabling generalizability to arbitrary text description. Unlike those methods, we propose a singlestage framework by exploiting a single frozen convolutional CLIP backbone, resulting in a simpler, faster, and stronger model than existing works.
40
+
41
+ We also note that the pioneering work F-VLM [46] builds an open-vocabulary detection framework on top of a frozen CLIP backbone. However, FC-CLIP differs from it with a totally different observation and motivation. Specifically, our work was initially motivated by the state-of-art open-vocabulary segmentation model ODISE [89], which found that the CLIP backbone extracts noisier features than diffusion models (Figure B. 1. in [89]), leading to inferior segmentation results (which justifies their adoption of diffusion models). Their observation motivated us to look deeply into the problem. Interestingly, our discoveries show that both ViT-based (used by ODISE [89]) and CNN-based CLIP can produce semantic-meaningful features. However, when scaling up the input resolutions, we discover that ViT-based CLIP features turn noisier, while CNN-based ones are smoother and generalize better across input sizes. F-VLM [46] also empirically found that a frozen CLIP can provide meaningful features for object detection. However, they did not choose CNN-based CLIP on purpose and thus did not compare carefully between ViT-based and CNN-based CLIP backbones. On the other hand, in our paper, we have provided careful ablation studies on ViT-based and CNNbased CLIP, where we observe that even though both ViT-based and CNN-based CLIP initially have comparable performance at resolution 224, CNN-based CLIP shows better and more robust performance when input resolution scales up.
42
+
43
+ ![](images/4bc84f63ef1e86053e84eacd0a6406a0b8cf125a36e19bd9f9f34ee8ca8d3001.jpg)
44
+ Figure 3: Overview of FC-CLIP, which contains three main components: mask generator, an in-vocabulary (in-vocab) classifier, and an out-of-vocabulary (out-vocab) classifier. All components build on top of a shared frozen covolutional CLIP backbone. The pixel decoder and mask decoder follow the design of Mask2Former, and generate class-agnostic masks. The in-vocabulary classifier yields the class embeddings by mask-pooling over final pixel features from pixel decoder. During testing, FC-CLIP additionally exploits the out-of-vocabulary classifier by mask-pooling over frozen CLIP backbone features, and the final class prediction is obtained by geometric ensembling both classifiers. Note that the text embeddings are obtained by feeding category names into a CLIP text encoder, which are done beforehand and cached in memory, thus causing no additional costs. Also, the class-agnostic mask proposals are fed to the mask pooling modules (not shown for simplicity).
45
+
46
+ # 3 Method
47
+
48
+ In this section, we first define the problem of open-vocabulary segmentation. We then introduce the existing two-stage pipeline, followed by our proposed single-stage framework FC-CLIP.
49
+
50
+ Problem Definition Open-vocabulary segmentation aims to segment the image $\mathbf { I } \in \mathbb { R } ^ { H \times W \times 3 }$ into a set of masks with associated semantic labels:
51
+
52
+ $$
53
+ \{ y _ { i } \} _ { i = 1 } ^ { K } = \{ ( m _ { i } , c _ { i } ) \} _ { i = 1 } ^ { K } .
54
+ $$
55
+
56
+ The K ground truth masks mi ∈ {0, 1}H×W contain the corresponding ground truth class label $c _ { i }$ . During training, a fixed set of class labels $C _ { t r a i n }$ is used, while during inference, another set of categories $C _ { t e s t }$ is used. In the open-vocabulary setting, $C _ { t e s t }$ may contain novel categories unseen during training, i.e., $C _ { t r a i n } \neq C _ { t e s t }$ . We follow previous works [25, 89] and assume the availability of the category names of $C _ { t e s t }$ (represented in natural language) during testing.
57
+
58
+ Two-Stage Open-Vocabulary Segmentation Existing works [90, 52, 25, 89] adopt a two-stage pipeline for open-vocabulary segmentation. The first stage contains a class-agnostic mask generator $\mathcal { M }$ with parameters $\theta _ { \mathcal { M } }$ that generates a set of $N$ mask proposals $\{ \hat { m } _ { i } \} _ { i = 1 } ^ { N } \stackrel { \smile } { \in } \mathbb { R } ^ { N \times H \times W }$ , given the input image $\mathbf { I }$ :
59
+
60
+ $$
61
+ \{ \hat { m } _ { i } \} _ { i = 1 } ^ { N } = \mathcal { M } ( \mathbf { I } ; \boldsymbol { \theta } _ { \mathcal { M } } ) .
62
+ $$
63
+
64
+ In the second stage, a CLIP adapter $\mathcal { P }$ takes both image $\mathbf { I }$ and mask proposals $\{ \hat { m } _ { i } \} _ { i = 1 } ^ { N }$ as inputs, where the latter input is used to guide the frozen CLIP model $C L I P ^ { * }$ ( $^ *$ denotes frozen). The adapter performs mask classification through forwarding processes with either masked crops [90, 52] or masked attention [25, 89]:
65
+
66
+ $$
67
+ \{ \hat { c } _ { i } \} _ { i = 1 } ^ { N } = \mathcal { P } ( \mathbf { I } , \{ \hat { m } _ { i } \} _ { i = 1 } ^ { N } ; C L I P ^ { * } ) ,
68
+ $$
69
+
70
+ where $\{ \hat { c } _ { i } \} _ { i = 1 } ^ { N } \in \mathbb { R } ^ { N \times | C | }$ refers to the predicted class probabilities for the $N$ predicted masks, $C \in \{ C _ { t r a i n } , C _ { t e s t } \}$ depending on training or testing phase, and $| C |$ is the category size.
71
+
72
+ Although this framework has achieved impressive open-vocabulary segmentation performance, it has two limitations. First, the image features are extracted twice, once for mask generation and the other for mask classification. The double feature extractions incur heavy computation, making it costly to scale up backbone parameters. Second, the mask generator often requires high-resolution inputs (e.g., $1 0 2 4 \times 1 0 2 4 )$ , whereas the CLIP model is usually pretrained with lower-resolution images (e.g.,
73
+
74
+ $2 2 4 \times 2 2 4 )$ . The two-stage pipeline thus needs to feed high-resolution images into the mask generator and low-resolution images into the CLIP classifier, making the model inefficient.
75
+
76
+ Naïve Single-Stage Open-Vocabulary Segmentation To avoid increasing the model size and computational cost of duplicate feature extractions, one may naïvely formulate everything together into a single-stage framework $\mathcal { F }$ , where both mask generator and mask classifier share the same CLIP-pretrained backbone $C L I P$ (not frozen) for extracting features from an input image I:
77
+
78
+ $$
79
+ \{ \hat { m } _ { i } , \hat { c } _ { i } \} _ { i = 1 } ^ { N } = \mathcal { F } ( \mathbf { I } ; C L I P , \theta _ { M } ) .
80
+ $$
81
+
82
+ However, we empirically discover that fine-tuning this naïve single-stage framework causes a misalignment between image and text features in the pretrained CLIP model, leading to sub-optimal performance, especially for novel unseen classes. It also increases the training costs by $2 . 1 \times$ to 52.8 GPU days. Interestingly, our experiments also show that a frozen CLIP backbone can provide sufficient features for mask generation, while preserving the image-text aligned representation. Nevertheless, we still face another challenge, where CLIP models are usually pretrained on lowresolution images (e.g., $2 2 4 \times 2 2 4 )$ ), whereas segmentation models prefer higher-resolution inputs (e.g., $8 0 0 \times 1 3 3 3$ for COCO, or $1 0 2 4 \times 2 0 4 8$ for Cityscapes). This discrepancy results in the significant performance degradation, when applying a frozen CLIP on large input images. Digging into the details, we found that it is related to the popular ViT [26] backbone used in CLIP that does not transfer well to different input sizes, which could be alleviated by extra careful designs (e.g., side adapter [17, 91], or cost aggregation [101, 21]). On the other hand, CNN-based CLIP models (such as ResNet [35] and ConvNeXt [58]) exhibit better generalization ability to different input sizes, due to their fully convolutional nature [60]. Additionally, the CNN-based CLIP backbone, extracting multi-scale feature maps, can be used as a simple plug-in module into modern closed-vocabulary segmentation models [20, 94]. Motivated by the observations, we thus propose FC-CLIP, a simple yet effective single-stage open-vocabulary segmentation framework built entirely on a single frozen convolutional CLIP backbone $C L I P _ { C N N } ^ { * }$ :
83
+
84
+ $$
85
+ \{ \hat { m } _ { i } , \hat { c } _ { i } \} _ { i = 1 } ^ { N } = \mathcal { F } ( \mathbf { I } ; C L I P _ { C N N } ^ { * } , \boldsymbol { \theta } _ { M } ) .
86
+ $$
87
+
88
+ FC-CLIP The proposed FC-CLIP leverages the semantic features of a frozen CNN-based CLIP backbone for both mask generation and CLIP classification. Unlike previous works [90, 52, 25, 89], which often train a separate mask generator and ignore the potential reuse of CLIP’s semantic features, we incorporate the CNN-based CLIP backbone into the state-of-the-art segmentation method Mask2Former [20]. We note that FC-CLIP is a general meta-architecture that can build on top of several modern segmentation methods [20, 94]. Our approach offers several advantages. By freezing and sharing the backbone features, our model is significantly more efficient during both training and testing (i.e., avoiding feature duplication). The CNN-based CLIP backbone not only transfers well to different input resolutions (from its pretrained image size), but also generates multi-scale feature maps, seamlessly compatible with modern segmentation methods [20, 94]. At a high level, FC-CLIP consists of three components: class-agnostic mask generator, in-vocabulary classifier, and out-of-vocabulary classifier. We detail each component below.
89
+
90
+ Class-Agnostic Mask Generator Following Mask2Former [20], we use a pixel decoder enhanced with multi-scale deformable attention [103] to improve the features extracted from the frozen CNNbased CLIP backbone. The enhanced pixel features, together with a set of object queries [7, 83], are then passed through a series of mask decoders, where each consists of masked cross-attention [20], self-attention [81], and a feed-forward network. The resulting segmentation logits are obtained by performing a matrix multiplication between the object query and pixel features. The predicted masks are matched with ground-truth masks in a one-to-one manner through Hungarian matching [45] and are supervised accordingly. Moreover, as the number of object queries is often greater than the number of labeled masks, only a subset of predicted masks are optimized through this matching process. We apply no penalty to the remaining unmatched proposals, which ensures that more mask proposals are obtained.
91
+
92
+ In-Vocabulary Classifier Once the mask proposals are predicted, they are classified with category text embedding in a contrastive manner, where the class embeddings for each mask and category text embeddings are projected into a common embedding space. That is, the predicted class probability by in-vocabulary classifier is defined as follows: $\forall i = 1 , \ldots , N$
93
+
94
+ $$
95
+ \hat { c } _ { i , i n } = s o f t m a x ( \frac { 1 } { T } \left[ c o s ( { \bf v } _ { i } , { \bf t } _ { 1 } ) , c o s ( { \bf v } _ { i } , { \bf t } _ { 2 } ) , \cdots , c o s ( { \bf v } _ { i } , { \bf t } _ { | C | } ) \right] ) ,
96
+ $$
97
+
98
+ where $T$ is a learnable temperature parameter with initialization of 0.07 to control the sharpness of the distribution, cos is cosine distance measurement, $\mathbf { v } _ { i }$ is the class embeddings for $i$ -th predicted mask, which is obtained by mask pooling over the final pixel features from pixel decoder, similar to [29]. $\mathbf { t } _ { j }$ is the category name’s text embeddings of class $j$ , which is obtained by feeding the category name to a CLIP-pretrained text encoder. Note that these category text embeddings only need to be generated once. They are then kept in memory to serve as text classifiers, and thus it incurs negligible additional cost during training. This forms our in-vocabulary classifier.
99
+
100
+ Out-of-Vocabulary Classifier During inference, however, we notice that using the in-vocabulary classifier alone fails to generalize to completely novel unseen classes, as the model is only trained on a finite set of categories and thus could not recognize diverse novel concepts. To address this issue, we introduce an out-of-vocabulary classifier, which applies mask pooling to the frozen CLIP backbone features, aiming to borrow the pretrained (intact) open-vocabulary recognition ability from CLIP. Unlike the other two-stage methods [90, 52, 25, 89], where one or multiple forward processes of CLIP are needed, the adopted out-of-vocabulary classifier introduces marginal additional costs, since the backbone features are already extracted (and only lightweight mask-pooling is performed). The predicted class probability by out-of-vocabulary classifier $\hat { c } _ { i , o u t }$ is then obtained in a manner similar to Eq. (6) by replacing $\mathbf { v } _ { i }$ with the mask-pooled features over frozen CLIP backbone features. This classifier strictly maintains the original CLIP feature distribution, allowing us to better recognize brand new categories. Note that the out-of-vocabulary classifier is only performed during testing.
101
+
102
+ Combining In- and Out-of-Vocabulary Classifiers Following prior works [31, 29, 46, 89], we employ geometric ensemble to fuse the classification scores between in-vocabulary and out-ofvocabulary classifiers. That is, $\forall j = 1 , \ldots , | C |$
103
+
104
+ $$
105
+ \hat { c } _ { i } ( j ) = \left\{ \begin{array} { l l } { ( \hat { c } _ { i , i n } ( j ) ) ^ { ( 1 - \alpha ) } \cdot ( \hat { c } _ { i , o u t } ( j ) ) ^ { \alpha } , } & { \mathrm { i f ~ } j \in C _ { t r a i n } } \\ { ( \hat { c } _ { i , i n } ( j ) ) ^ { ( 1 - \beta ) } \cdot ( \hat { c } _ { i , o u t } ( j ) ) ^ { \beta } , } & { \mathrm { o t h e r w i s e } } \end{array} \right.
106
+ $$
107
+
108
+ where $\hat { c } _ { i } ( j )$ denotes the $j$ -th element of $\hat { c } _ { i }$ , and the underscripts $_ { i n }$ and out refer to in-vocabulary and out-of-vocabulary classifier, respectively. $\alpha , \beta \in [ 0 , 1 ]$ balance the predictions between in- and out-of-vocabulary classifiers for seen and novel unseen categories.
109
+
110
+ # 4 Experimental Results
111
+
112
+ Herein, we provide implementation details of FC-CLIP in Sec. 4.1. After setting the stage, we introduce our main results, compared with state-of-the-art methods and ablations studies in Sec. 4.2.
113
+
114
+ # 4.1 Implementation Details
115
+
116
+ Architecture We use ConvNeXt-Large CLIP [58, 69] backbones from OpenCLIP [38]1 pretrained on LAION-2B [74] dataset. On top of the CLIP backbone, we build the mask generator, following Mask2Former [20]. Nine mask decoders are employed to generate the class-agnostic masks by taking as inputs the enhanced pixel features and a set of object queries. For in-vocabulary classification, following [29], the class embeddings are obtained by mask-pooling the pixel features from the pixel decoder’s final output. Afterwards, the classification logits (before softmax) is obtained by matrix multiplication between the predicted class embeddings and categories’ text embeddings.
117
+
118
+ Training Strategy We follow [20] and adopt the same training recipe and losses without any special design. The training is optimized with AdamW [41, 61] optimizer and weight decay 0.05. We use a crop size of $1 0 2 4 \times 1 0 2 4$ . We employ the learning rate $1 ^ { ^ { \bullet } \times 1 0 ^ { - 4 } }$ and a multi-step decay schedule. The training batch size is 16, and the model is trained for 50 epochs on COCO panoptic training set [54].
119
+
120
+ Inference Strategy During inference, the shorted side of input images will be resized to 800 while ensuring longer side not exceeds 1333. For Cityscapes and Mapillary Vistas, we increase the shorter side size to 1024. We adopt mask-wise merging scheme [20] for the mask predictions. The out-of-vocabulary classifier is only performed during inference by mask-pooling over the frozen CLIP backbone features. The final classification results are then obtained by geometric ensembling in- and out-of-vocabulary classifiers [31, 29, 46, 89], as in Eq. (7), where we default $\alpha = 0 . 4$ and $\beta = 0 . 8$ . Following prior arts, we also adopt prompt engineering from [29, 89] and prompt templates from [31, 52]. If not specified, FC-CLIP is only trained on COCO panoptic dataset [54]. Following prior works [29, 89], we zero-shot evaluate the model on ADE20K [100], Cityscapes [22], and Mapillary Vistas [64] for open-vocabulary panoptic segmentation. We also report open-vocabulary semantic segmentation results on those datasets along with PASCAL datasets [27, 63]. The panoptic segmentation results are evaluated with the panoptic quality (PQ) [44], Average Precision (AP), and mean intersection-over-union (mIoU), and semantic segmentation is evaluated with mIoU [27]. Note that all results are obtained with the same single checkpoint trained on COCO panoptic data only.
121
+
122
+ Table 1: Open-vocabulary panoptic segmentation performance on ADE20K. The proposed FCCLIP demonstrates better performances than prior arts, while using much fewer frozen parameters. We provide more results in the supplementary material
123
+
124
+ <table><tr><td></td><td>params (M)</td><td>zero-shot test dataset</td><td>ADE20K</td><td>training dataset COCO</td><td></td></tr><tr><td>method</td><td>frozen</td><td>trainable PQ</td><td>AP mIoU</td><td>PQ</td><td>AP mIoU</td></tr><tr><td>MaskCLIP[25]</td><td>304 63</td><td>15.1</td><td>6.0 23.7</td><td>1 -</td><td>-</td></tr><tr><td>FreeSeg [68]</td><td>- 1</td><td>16.3</td><td>6.5 24.6</td><td>1 =</td><td>-</td></tr><tr><td>ODISE [89]</td><td>1494 28 28</td><td>22.6 14.4 13.9</td><td>29.9</td><td>55.4 46.0</td><td>65.2</td></tr><tr><td>ODISE [89] (caption)</td><td>1494</td><td>23.4</td><td>28.7</td><td>45.6 38.4</td><td>52.4</td></tr><tr><td>FC-CLIP (ours)</td><td>200</td><td>21 26.8</td><td>16.8 34.1</td><td>54.4 44.6</td><td>63.7</td></tr></table>
125
+
126
+ Table 2: Open-vocabulary panoptic segmentation performance on street-view datasets. The proposed FC-CLIP demonstrates better transferability to street-view dataset
127
+
128
+ <table><tr><td rowspan="2"></td><td colspan="8">zero-shot test dataset</td></tr><tr><td colspan="3">Mapillary Vistas</td><td colspan="4">Cityscapes</td></tr><tr><td>method</td><td>PQ</td><td>SQ</td><td>RQ</td><td>mIoU</td><td>PQ SQ</td><td>RQ</td><td>AP</td><td>mIoU</td></tr><tr><td>ODISE [89]</td><td>14.2</td><td>61.0</td><td>17.2</td><td>-</td><td>23.9 75.3</td><td>29.0</td><td>1</td><td>-</td></tr><tr><td>FC-CLIP (ours)</td><td>18.2</td><td>57.7</td><td>22.9</td><td>27.9</td><td>44.0 75.4</td><td>53.6</td><td>26.8</td><td>56.2</td></tr></table>
129
+
130
+ # 4.2 Results
131
+
132
+ We summarize the main results for open-vocabulary panoptic segmentation and semantic segmentation in Tab. 1, Tab. 2 and Tab. 3, where we train FC-CLIP on COCO train set with panoptic annotation and evaluate it on various datasets in a zero-shot manner.
133
+
134
+ Open-Vocabulary Panoptic Segmentation Evaluation on ADE20K In Tab. 1, we compare our FC-CLIP with other state-of-the-art methods on ADE20K [100], the main test-bed of zero-shot open-vocabulary panoptic segmentation. As shown in the table, our method achieves significantly better performance compared to MaskCLIP [25], with $+ 1 1 . 7$ PQ, $+ 1 0 . 8$ AP and $+ 1 0 . 4$ mIoU, even though we use fewer frozen $\left( - 6 6 \mathbf { M } \right)$ and trainable $\left( { - 4 2 \mathbf { M } } \right)$ parameters. When compared to the concurrent methods FreeSeg [68] and ODISE [89], the advantage of FC-CLIP persists. FC-CLIP is $+ 1 0 . 5$ PQ, $+ 1 0 . 3$ AP, and $+ 9 . 5$ mIoU better than FreeSeg without using COCO-Stuff annotations [5] (which contains more semantic classes than COCO-Panoptic). Our PQ, AP, mIoU score are also $+ 4 . 2$ , $+ 2 . 4$ , $+ 4 . 2$ higher than ODISE under the same training settings. Compared to ODISE with caption [15] for supervision, our model still outperforms it by $+ 3 . 4 \mathrm { P Q }$ , setting a new state-of-the-art record. Meanwhile, it is noticeable that our model has $6 . 3 \times ( 5 . 9 \times )$ significantly fewer frozen (total) parameters compared to ODISE, which utilizes a strong large backbone from stable diffusion [71] for feature extraction.
135
+
136
+ Open-Vocabulary Panoptic Segmentation Evaluation on Street-View Datasets In Tab. 2, we evaluate on Cityscapes and Mapillary Vistas, which focus on street driving scenes. Compared to state-of-the-art method ODISE, FC-CLIP achieves better performances on both datasets. Specifically, it outperforms ODISE by $+ 4 . 0$ PQ and $+ 2 0 . 1$ PQ on Mapillary Vistas and Cityscapes, respectively. Notably, FC-CLIP has a slightly lower SQ, which indicates our mask generator is actually weaker than the one in ODISE, which utilizes a much larger backbone.
137
+
138
+ Open-Vocabulary Semantic Segmentation Evaluation Although our model was trained on COCO panoptic data only, it also performs well on open-vocabulary semantic segmentation. In Tab. 3, we report our model’s performance on various benchmarks against other open-vocabulary segmentation models, where FC-CLIP shows an overall superior performance. Specifically, with the same training annotations used, FC-CLIP outperforms MaskCLIP by $+ 6 . 6$ , $+ 8 . 2$ , $+ 1 0 . 4$ , $+ 1 2 . 5$ mIoU across A-847, PC-459, A-150, and PC-59, respectively. Compared to methods with caption annotations, FC-CLIP persists its advantages, where it outperforms ODISE (caption) by $+ 3 . 8$ , $+ 4 . 4$ , $+ 5 . 4$ , $+ 3 . 1$ mIoU across datasets A-847, PC-459, A-150, PC-59 respectively. Against other open-vocabulary semantic segmentation methods, our model maintains its advantages across different datasets, despite being trained solely with panoptic annotations. Furthermore, it demonstrates comparable performance to state-of-the-art open-vocabulary semantic segmentation methods, which utilize the COCO-Stuff dataset as their training set. The COCO-Stuff dataset comprises 171 classes, 38 more classes than COCO-Panoptic, and offers highly desirable annotations for semantic segmentation tasks. It is worth mentioning that these methods build their approach on top of ViT-L (with extra designs [91]), resulting in a significantly larger model size compared to our deployed ConvNeXt-L (304M vs. 198M). Despite the disparity in model size, FC-CLIP remains competitive in terms of performance. Specifially, FC-CLIP outperforms state-of-the-art open-vocabulary semantic segmentation method SAN [91] by 1.1 and 1.1 mIoU on the challenging A-847 and PC-459 datasets.
139
+
140
+ Table 3: Open-vocabulary semantic segmentation performance. The proposed FC-CLIP also demonstrates state-of-the-art performances on open-vocabulary semantic segmentation
141
+
142
+ <table><tr><td rowspan="2">method</td><td rowspan="2">training dataset</td><td colspan="5">mIoU</td></tr><tr><td>A-847 PC-459 A-150 PC-59</td><td></td><td></td><td></td><td>PAS-21 PAS-20</td></tr><tr><td>SPNet [85]</td><td>Pascal VOC[27]</td><td>-</td><td>-</td><td>1</td><td>24.3</td><td>18.3</td><td>-</td></tr><tr><td>ZS3Net [4]</td><td>Pascal VOC [27]</td><td>-</td><td></td><td></td><td>19.4</td><td>38.3</td><td>-</td></tr><tr><td>LSeg [48]</td><td>Pascal VOC[27]</td><td>-</td><td>-</td><td>1</td><td>-</td><td>47.4</td><td>-</td></tr><tr><td>GroupViT[88]</td><td>GCC[75]+YFCC[79]</td><td>4.3</td><td>4.9</td><td>10.6</td><td>25.9</td><td>50.7</td><td>52.3</td></tr><tr><td>SimBaseline [90]</td><td>COCO Stuff [5]</td><td>-</td><td>-</td><td>15.3</td><td>-</td><td>74.5</td><td>-</td></tr><tr><td>ZegFormer [24]</td><td>COCO Stuff [5]</td><td>1</td><td>1</td><td>16.4</td><td>1</td><td>73.3</td><td>=</td></tr><tr><td>LSeg+ [48, 29]</td><td>COCO Stuff [5]</td><td>3.8</td><td>7.8</td><td>18.0</td><td>46.5</td><td>-</td><td></td></tr><tr><td>OVSeg [52]</td><td>COCO Stuff [5]</td><td>9.0</td><td>12.4</td><td>29.6</td><td>55.7</td><td>=</td><td>94.5</td></tr><tr><td>SAN [91]</td><td>COCO Stuff [5]</td><td>13.7</td><td>17.1</td><td>33.3</td><td>60.2</td><td>-</td><td>95.5</td></tr><tr><td>OpenSeg [29]</td><td>COCO Panoptic + COCO Caption</td><td>6.3</td><td>9.0</td><td>21.1</td><td>42.1</td><td>-</td><td>-</td></tr><tr><td>ODISE [89] (caption)</td><td>COCO Panoptic + COCO Caption</td><td>11.0</td><td>13.8</td><td>28.7</td><td>55.3</td><td>82.7</td><td>-</td></tr><tr><td>MaskCLIP[25]</td><td>COCO Panoptic</td><td>8.2</td><td>10.0</td><td>23.7</td><td>45.9</td><td>-</td><td>-</td></tr><tr><td>ODISE [89]</td><td>COCO Panoptic</td><td>11.1</td><td>14.5</td><td>29.9</td><td>57.3</td><td>84.6</td><td>-</td></tr><tr><td>FC-CLIP (ours)</td><td>COCO Panoptic</td><td>14.8</td><td>18.2</td><td>34.1</td><td>58.4</td><td>81.8</td><td>95.4</td></tr></table>
143
+
144
+ Table 4: FPS comparison. All results are obtained with one V100 GPU, CUDA 11.6 and PyTorch 1.13, by taking the average runtime on the entire validation set, including post-processing time
145
+
146
+ <table><tr><td>method</td><td>ADE20K</td><td>COCO</td></tr><tr><td>ODISE[89]</td><td>0.41</td><td>0.39</td></tr><tr><td>FC-CLIP (ours)</td><td>2.71 (6.61×)</td><td>2.76 (7.08×)</td></tr></table>
147
+
148
+ Inference Speed We provide a comparison of FPS (frames per second) in Tab. 4. The proposed FC-CLIP not only demonstrates superior performances, but also enjoys a significant fast inference time: FC-CLIP runs $6 . 6 1 \times$ and $7 . 0 8 \times$ faster than ODISE evaluated on ADE20K and COCO datasets, respectively.
149
+
150
+ Training on ADE20K and Evaluating on COCO We further validate the effectiveness of FC-CLIP by using a different training dataset. Specifically, we follow [68, 89] to train our model on ADE20K dataset with panoptic annotation, and evaluate it on COCO panoptic dataset. As shown in Tab. 5, FC-CLIP outperforms FreeSeg [68] by $+ 1 0 . 5$ PQ, and ODISE [89] by $+ 2 . 0$ PQ on COCO dataset. Notably, our model actually has a lower SQ $( - 1 . 4 )$ compared to ODISE, which utilizes a much larger backbone and thus has a stronger mask generator. Nevertheless, FC-CLIP still outperforms ODISE significantly with a simple yet effective design.
151
+
152
+ Fine-tuning CLIP Backbone Harms Performance on Novel Vocabularies We validate the necessity of freezing CLIP backbone to ensure a better generalization to novel vocabularies. We compare the performance of trainable CLIP variant and frozen CLIP variant in Fig. 4, where we use the same mask proposals to ensure a fair comparison. Specifically, we compare the performance on
153
+
154
+ Table 5: Results of training on ADE20K panoptic and evaluating on COCO panoptic val set. The proposed FC-CLIP performs better than prior arts, even in the different setting (i.e., trained on ADE20K and zero-shot evaluated on COCO)
155
+
156
+ <table><tr><td rowspan="2">method</td><td colspan="2">zero-shot test dataset</td><td colspan="2">training dataset ADE20K</td></tr><tr><td>COCO PQ SQ</td><td>RQ</td><td>PQ SQ</td><td>RQ</td></tr><tr><td>FreeSeg [68]</td><td>16.5 72.0</td><td>21.6</td><td>- -</td><td>-</td></tr><tr><td>ODISE [89]</td><td>25.0 79.4</td><td>30.4</td><td>31.4 77.9</td><td>36.9</td></tr><tr><td>FC-CLIP (ours)</td><td>27.0 78.0</td><td>32.9</td><td>41.9 78.2</td><td>50.2</td></tr></table>
157
+
158
+ ![](images/4c173f274a4b226910b94b406e37d2bfd7e857b78f04f471eb13149fd2af5166.jpg)
159
+ Figure 4: Trainable CLIP vs. Frozen CLIP, with per-class PQ analysis. We show 10 common classes (labeled in green) shared by COCO and ADE20K, and 10 novel classes (labeled in red) that are only in ADE20K. The frozen CLIP demonstrates a much better recognition ability for novel classes, while performing similarly for the seen classes.
160
+
161
+ 10 seen classes, which are shared by both COCO and ADE20K (e.g., person, sky), and 10 unseen classes, which are only included in ADE20K dataset (e.g., arcade machine, dishwasher). As shown in the figure, tuning CLIP backbone leads to a worse performance on unseen concepts, which breaks the CLIP feature alignment and thus loses its recognition ability on a much wider vocabulary.
162
+
163
+ # 5 Conclusion
164
+
165
+ In this work, we have presented FC-CLIP, a simple yet effective single-stage framework for openvocabulary segmentation. FC-CLIP shows great potential by building everything on top of a shared frozen convolutional CLIP backbone, which not only significantly reduces training and testing costs, but also establishes a strong baseline on multiple benchmarks. Our study demonstrates how to better adapt a pretrained CLIP model for downstream dense prediction tasks, which we hope will shed the light on unleashing CLIP’s potential for other various downstream tasks.
166
+
167
+ Limitations FC-CLIP presents a simple single-stage open-vocabulary segmentation framework with state-of-the-art performance. We note that there exist some interesting research topics to be explored in the near future, such as better unleashing CLIP’s potential in both mask segmentation and classification, how to deal with conflict or overlapping vocabularies (e.g., cat vs. cat head), etc.
168
+
169
+ Broader Impact FC-CLIP shows great potential for segmenting and naming every object in the scene, which could facilitate many applications including intelligent home assistants, robots, selfdriving, etc. Yet it relies on CLIP model pre-trained on the Internet data that may be biased, which calls for future research for calibration to avoid misuse.
170
+
171
+ # References
172
+
173
+ [1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. In NeurIPS, 2022.
174
+ [2] Daniel Bolya, Chong Zhou, Fanyi Xiao, and Yong Jae Lee. Yolact: Real-time instance segmentation. In ICCV, 2019.
175
+ [3] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. In NeurIPS, 2020.
176
+ [4] Maxime Bucher, Tuan-Hung Vu, Matthieu Cord, and Patrick Pérez. Zero-shot semantic segmentation. In NeurIPS, 2019.
177
+ [5] Holger Caesar, Jasper Uijlings, and Vittorio Ferrari. Coco-stuff: Thing and stuff classes in context. In CVPR, 2018.
178
+ [6] Zhaowei Cai and Nuno Vasconcelos. Cascade r-cnn: Delving into high quality object detection. In CVPR, 2018.
179
+ [7] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In ECCV, 2020.
180
+ [8] Kai Chen, Jiangmiao Pang, Jiaqi Wang, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jianping Shi, Wanli Ouyang, et al. Hybrid task cascade for instance segmentation. In CVPR, 2019.
181
+ [9] Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. Semantic image segmentation with deep convolutional nets and fully connected crfs. In ICLR, 2015.
182
+ [10] 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. IEEE TPAMI, 2017.
183
+ [11] Liang-Chieh Chen, George Papandreou, Florian Schroff, and Hartwig Adam. Rethinking atrous convolution for semantic image segmentation. arXiv:1706.05587, 2017.
184
+ [12] Liang-Chieh Chen, Alexander Hermans, George Papandreou, Florian Schroff, Peng Wang, and Hartwig Adam. Masklab: Instance segmentation by refining object detection with semantic and direction features. In CVPR, 2018.
185
+ [13] Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam. Encoderdecoder with atrous separable convolution for semantic image segmentation. In ECCV, 2018.
186
+ [14] Liang-Chieh Chen, Huiyu Wang, and Siyuan Qiao. Scaling wide residual networks for panoptic segmentation. arXiv:2011.11675, 2020.
187
+ [15] Xinlei Chen, Hao Fang, Tsung-Yi Lin, Ramakrishna Vedantam, Saurabh Gupta, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco captions: Data collection and evaluation server. arXiv:1504.00325, 2015.
188
+ [16] Yen-Chun Chen, Linjie Li, Licheng Yu, Ahmed El Kholy, Faisal Ahmed, Zhe Gan, Yu Cheng, and Jingjing Liu. Uniter: Universal image-text representation learning. In ECCV, 2020.
189
+ [17] Zhe Chen, Yuchen Duan, Wenhai Wang, Junjun He, Tong Lu, Jifeng Dai, and Yu Qiao. Vision transformer adapter for dense predictions. In ICLR, 2023.
190
+ [18] Bowen Cheng, Maxwell D Collins, Yukun Zhu, Ting Liu, Thomas S Huang, Hartwig Adam, and Liang-Chieh Chen. Panoptic-DeepLab: A Simple, Strong, and Fast Baseline for Bottom-Up Panoptic Segmentation. In CVPR, 2020.
191
+ [19] Bowen Cheng, Alexander G Schwing, and Alexander Kirillov. Per-pixel classification is not all you need for semantic segmentation. In NeurIPS, 2021.
192
+ [20] Bowen Cheng, Ishan Misra, Alexander G Schwing, Alexander Kirillov, and Rohit Girdhar. Maskedattention mask transformer for universal image segmentation. In CVPR, 2022.
193
+ [21] Seokju Cho, Heeseong Shin, Sunghwan Hong, Seungjun An, Seungjun Lee, Anurag Arnab, Paul Hongsuck Seo, and Seungryong Kim. Cat-seg: Cost aggregation for open-vocabulary semantic segmentation. arXiv:2303.11797, 2023.
194
+ [22] 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.
195
+ [23] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL, 2019.
196
+ [24] Jian Ding, Nan Xue, Gui-Song Xia, and Dengxin Dai. Decoupling zero-shot semantic segmentation. In CVPR, 2022.
197
+ [25] Zheng Ding, Jieke Wang, and Zhuowen Tu. Open-vocabulary universal image segmentation with maskclip. In ICML, 2023.
198
+ [26] 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.
199
+ [27] Mark Everingham, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman. The pascal visual object classes (voc) challenge. IJCV, 88:303–338, 2010.
200
+ [28] Jun Fu, Jing Liu, Haijie Tian, Yong Li, Yongjun Bao, Zhiwei Fang, and Hanqing Lu. Dual attention network for scene segmentation. In CVPR, 2019.
201
+ [29] Golnaz Ghiasi, Xiuye Gu, Yin Cui, and Tsung-Yi Lin. Scaling open-vocabulary image segmentation with image-level labels. In ECCV, 2022.
202
+ [30] Jiaqi Gu, Hyoukjun Kwon, Dilin Wang, Wei Ye, Meng Li, Yu-Hsin Chen, Liangzhen Lai, Vikas Chandra, and David Z Pan. Multi-scale high-resolution vision transformer for semantic segmentation. In CVPR, 2022.
203
+ [31] Xiuye Gu, Tsung-Yi Lin, Weicheng Kuo, and Yin Cui. Open-vocabulary object detection via vision and language knowledge distillation. In ICLR, 2022.
204
+ [32] Xiuye Gu, Yin Cui, Jonathan Huang, Abdullah Rashwan, Xuan Yang, Xingyi Zhou, Golnaz Ghiasi, Weicheng Kuo, Huizhong Chen, Liang-Chieh Chen, and David A Ross. Dataseg: Taming a universal multi-dataset multi-task segmentation model. NeurIPS, 2023.
205
+ [33] Tanmay Gupta, Arash Vahdat, Gal Chechik, Xiaodong Yang, Jan Kautz, and Derek Hoiem. Contrastive learning for weakly supervised phrase grounding. In ECCV, 2020.
206
+ [34] Bharath Hariharan, Pablo Arbeláez, Ross Girshick, and Jitendra Malik. Simultaneous detection and segmentation. In ECCV, 2014.
207
+ [35] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
208
+ [36] Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask r-cnn. In ICCV, 2017.
209
+ [37] Xuming He, Richard S Zemel, and Miguel Á Carreira-Perpiñán. Multiscale conditional random fields for image labeling. In CVPR, 2004.
210
+ [38] Gabriel Ilharco, Mitchell Wortsman, Ross Wightman, Cade Gordon, Nicholas Carlini, Rohan Taori, Achal Dave, Vaishaal Shankar, Hongseok Namkoong, John Miller, Hannaneh Hajishirzi, Ali Farhadi, and Ludwig Schmidt. Openclip, July 2021. URL https://doi.org/10.5281/zenodo.5143773.
211
+ [39] Jitesh Jain, Jiachen Li, MangTik Chiu, Ali Hassani, Nikita Orlov, and Humphrey Shi. Oneformer: One transformer to rule universal image segmentation. In CVPR, 2023.
212
+ [40] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In ICML, 2021.
213
+ [41] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
214
+ [42] Alexander Kirillov, Evgeny Levinkov, Bjoern Andres, Bogdan Savchynskyy, and Carsten Rother. Instancecut: from edges to instances with multicut. In CVPR, 2017.
215
+ [43] Alexander Kirillov, Ross Girshick, Kaiming He, and Piotr Dollár. Panoptic feature pyramid networks. In CVPR, 2019.
216
+ [44] Alexander Kirillov, Kaiming He, Ross Girshick, Carsten Rother, and Piotr Dollár. Panoptic segmentation. In CVPR, 2019.
217
+ [45] Harold W Kuhn. The hungarian method for the assignment problem. Naval research logistics quarterly, 2(1-2):83–97, 1955.
218
+ [46] Weicheng Kuo, Yin Cui, Xiuye Gu, AJ Piergiovanni, and Anelia Angelova. F-vlm: Open-vocabulary object detection upon frozen vision and language models. In ICLR, 2023.
219
+ [47] 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.
220
+ [48] Boyi Li, Kilian Q Weinberger, Serge Belongie, Vladlen Koltun, and René Ranftl. Language-driven semantic segmentation. In ICLR, 2022.
221
+ [49] Feng Li, Hao Zhang, Shilong Liu, Lei Zhang, Lionel M Ni, Heung-Yeung Shum, et al. Mask dino: Towards a unified transformer-based framework for object detection and segmentation. In CVPR, 2023.
222
+ [50] Qizhu Li, Xiaojuan Qi, and Philip HS Torr. Unifying training and inference for panoptic segmentation. In CVPR, 2020.
223
+ [51] Zhiqi Li, Wenhai Wang, Enze Xie, Zhiding Yu, Anima Anandkumar, Jose M Alvarez, Tong Lu, and Ping Luo. Panoptic segformer. In CVPR, 2022.
224
+ [52] Feng Liang, Bichen Wu, Xiaoliang Dai, Kunpeng Li, Yinan Zhao, Hang Zhang, Peizhao Zhang, Peter Vajda, and Diana Marculescu. Open-vocabulary semantic segmentation with mask-adapted clip. In CVPR, 2023.
225
+ [53] James Liang, Tianfei Zhou, Dongfang Liu, and Wenguan Wang. Clustseg: Clustering for universal segmentation. In ICML, 2023.
226
+ [54] 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.
227
+ [55] Huanyu Liu, Chao Peng, Changqian Yu, Jingbo Wang, Xu Liu, Gang Yu, and Wei Jiang. An end-to-end network for panoptic segmentation. In CVPR, 2019.
228
+ [56] Shu Liu, Lu Qi, Haifang Qin, Jianping Shi, and Jiaya Jia. Path aggregation network for instance segmentation. In CVPR, 2018.
229
+ [57] Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. arXiv:1907.11692, 2019.
230
+ [58] Zhuang Liu, Hanzi Mao, Chao-Yuan Wu, Christoph Feichtenhofer, Trevor Darrell, and Saining Xie. A convnet for the 2020s. In CVPR, 2022.
231
+ [59] Stuart Lloyd. Least squares quantization in pcm. IEEE transactions on information theory, 28(2):129–137, 1982.
232
+ [60] Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In CVPR, 2015.
233
+ [61] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR, 2019.
234
+ [62] Chaofan Ma, Yuhuan Yang, Yanfeng Wang, Ya Zhang, and Weidi Xie. Open-vocabulary semantic segmentation with frozen vision-language models. In BMVC, 2022.
235
+ [63] Roozbeh Mottaghi, Xianjie Chen, Xiaobai Liu, Nam-Gyu Cho, Seong-Whan Lee, Sanja Fidler, Raquel Urtasun, and Alan Yuille. The role of context for object detection and semantic segmentation in the wild. In CVPR, 2014.
236
+ [64] Gerhard Neuhold, Tobias Ollmann, Samuel Rota Bulo, and Peter Kontschieder. The mapillary vistas dataset for semantic understanding of street scenes. In ICCV, 2017.
237
+ [65] Jordi Pont-Tuset, Jasper Uijlings, Soravit Changpinyo, Radu Soricut, and Vittorio Ferrari. Connecting vision and language with localized narratives. In ECCV, 2020.
238
+ [66] Siyuan Qiao, Liang-Chieh Chen, and Alan Yuille. Detectors: Detecting objects with recursive feature pyramid and switchable atrous convolution. In CVPR, 2021.
239
+ [67] Siyuan Qiao, Yukun Zhu, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen. Vip-deeplab: Learning visual perception with depth-aware video panoptic segmentation. In CVPR, 2021.
240
+ [68] Jie Qin, Jie Wu, Pengxiang Yan, Ming Li, Ren Yuxi, Xuefeng Xiao, Yitong Wang, Rui Wang, Shilei Wen, Xin Pan, et al. Freeseg: Unified, universal and open-vocabulary image segmentation. In CVPR, 2023.
241
+ [69] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In ICML, 2021.
242
+ [70] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. TMLR, 21(1):5485–5551, 2020.
243
+ [71] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. In CVPR, 2022.
244
+ [72] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In MICCAI, 2015.
245
+ [73] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael S. Bernstein, Alexander C. Berg, and Li Fei-Fei. Imagenet large scale visual recognition challenge. IJCV, 115:211–252, 2015.
246
+ [74] Christoph Schuhmann, Romain Beaumont, Richard Vencu, Cade Gordon, Ross Wightman, Mehdi Cherti, Theo Coombes, Aarush Katta, Clayton Mullis, Mitchell Wortsman, et al. Laion-5b: An open large-scale dataset for training next generation image-text models. In NeurIPS, 2022.
247
+ [75] Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 2556–2565, 2018.
248
+ [76] Robin Strudel, Ricardo Garcia, Ivan Laptev, and Cordelia Schmid. Segmenter: Transformer for semantic segmentation. In ICCV, 2021.
249
+ [77] Shuyang Sun, Weijun Wang, Qihang Yu, Andrew Howard, Philip Torr, and Liang-Chieh Chen. Remax: Relaxing for better training on efficient panoptic segmentation. NeurIPS, 2023.
250
+ [78] Hao Tan and Mohit Bansal. Lxmert: Learning cross-modality encoder representations from transformers. In EMNLP, 2019.
251
+ [79] Bart Thomee, David A Shamma, Gerald Friedland, Benjamin Elizalde, Karl Ni, Douglas Poland, Damian Borth, and Li-Jia Li. Yfcc100m: The new data in multimedia research. Communications of the ACM, 59 (2):64–73, 2016.
252
+ [80] Zhi Tian, Chunhua Shen, and Hao Chen. Conditional convolutions for instance segmentation. In ECCV, 2020.
253
+ [81] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
254
+ [82] Huiyu Wang, Yukun Zhu, Bradley Green, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen. AxialDeepLab: Stand-Alone Axial-Attention for Panoptic Segmentation. In ECCV, 2020.
255
+ [83] 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.
256
+ [84] Xinlong Wang, Rufeng Zhang, Tao Kong, Lei Li, and Chunhua Shen. SOLOv2: Dynamic and fast instance segmentation. In NeurIPS, 2020.
257
+ [85] Yongqin Xian, Subhabrata Choudhury, Yang He, Bernt Schiele, and Zeynep Akata. Semantic projection network for zero-and few-label semantic segmentation. In CVPR, 2019.
258
+ [86] Enze Xie, Wenhai Wang, Zhiding Yu, Anima Anandkumar, Jose M Alvarez, and Ping Luo. Segformer: Simple and efficient design for semantic segmentation with transformers. In NeurIPS, 2021.
259
+ [87] Yuwen Xiong, Renjie Liao, Hengshuang Zhao, Rui Hu, Min Bai, Ersin Yumer, and Raquel Urtasun. Upsnet: A unified panoptic segmentation network. In CVPR, 2019.
260
+ [88] Jiarui Xu, Shalini De Mello, Sifei Liu, Wonmin Byeon, Thomas Breuel, Jan Kautz, and Xiaolong Wang. Groupvit: Semantic segmentation emerges from text supervision. In CVPR, 2022.
261
+ [89] Jiarui Xu, Sifei Liu, Arash Vahdat, Wonmin Byeon, Xiaolong Wang, and Shalini De Mello. Openvocabulary panoptic segmentation with text-to-image diffusion models. In CVPR, 2023.
262
+ [90] Mengde Xu, Zheng Zhang, Fangyun Wei, Yutong Lin, Yue Cao, Han Hu, and Xiang Bai. A simple baseline for zero-shot semantic segmentation with pre-trained vision-language model. In ECCV, 2022.
263
+ [91] Mengde Xu, Zheng Zhang, Fangyun Wei, Han Hu, and Xiang Bai. Side adapter network for openvocabulary semantic segmentation. In CVPR, 2023.
264
+ [92] Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models. TMLR, 2022.
265
+ [93] Qihang Yu, Huiyu Wang, Dahun Kim, Siyuan Qiao, Maxwell Collins, Yukun Zhu, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen. Cmt-deeplab: Clustering mask transformers for panoptic segmentation. In CVPR, 2022.
266
+ [94] Qihang Yu, Huiyu Wang, Siyuan Qiao, Maxwell Collins, Yukun Zhu, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen. k-means Mask Transformer. In ECCV, 2022.
267
+ [95] Lu Yuan, Dongdong Chen, Yi-Ling Chen, Noel Codella, Xiyang Dai, Jianfeng Gao, Houdong Hu, Xuedong Huang, Boxin Li, Chunyuan Li, et al. Florence: A new foundation model for computer vision. arXiv:2111.11432, 2021.
268
+ [96] Yuhui Yuan, Xilin Chen, and Jingdong Wang. Object-contextual representations for semantic segmentation. In ECCV, 2020.
269
+ [97] Alireza Zareian, Kevin Dela Rosa, Derek Hao Hu, and Shih-Fu Chang. Open-vocabulary object detection using captions. In CVPR, 2021.
270
+ [98] Pengchuan Zhang, Xiujun Li, Xiaowei Hu, Jianwei Yang, Lei Zhang, Lijuan Wang, Yejin Choi, and Jianfeng Gao. Vinvl: Revisiting visual representations in vision-language models. In CVPR, 2021.
271
+ [99] 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.
272
+ [100] Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In CVPR, 2017.
273
+ [101] Chong Zhou, Chen Change Loy, and Bo Dai. Extract free dense labels from clip. In ECCV, 2022.
274
+ [102] Ziqin Zhou, Yinjie Lei, Bowen Zhang, Lingqiao Liu, and Yifan Liu. Zegclip: Towards adapting clip for zero-shot semantic segmentation. In CVPR, 2023.
275
+ [103] Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable detr: Deformable transformers for end-to-end object detection. In ICLR, 2021.
276
+ [104] Xueyan Zou, Zi-Yi Dou, Jianwei Yang, Zhe Gan, Linjie Li, Chunyuan Li, Xiyang Dai, Jianfeng Wang, Lu Yuan, Nanyun Peng, Lijuan Wang, Yong Jae Lee, and Jianfeng Gao. Generalized decoding for pixel, image, and language. In CVPR, 2023.
277
+
278
+ Appendix In the following supplementary materials, we present additional experimental results pertaining to the design of FC-CLIP. Our supplementary analysis also includes comparisons against other methods that specifically address open-vocabulary semantic segmentation, ensemble methods, and hyperparameter tuning. Furthermore, we provide a quantitative comparison between ViT-based CLIP and CNN-based CLIP across varying input sizes, along with additional visualizations and comprehensive dataset details.
279
+
280
+ # 6 Additional Experimental Results
281
+
282
+ Fine-tuning or Freezing CLIP Backbone in FC-CLIP In this study, we provide a comprehensive analysis of the impact of fine-tuning or freezing the CLIP backbone in our framework. We specifically focus on the $\mathrm { P Q } ^ { \mathrm { s e e n } }$ and $\mathrm { P Q } ^ { \mathrm { u n s e e n } }$ metrics, which evaluate the performance for classes that overlap and do not overlap between the training and testing datasets, respectively. To determine whether a class is seen or unseen, we adopt the prompt engineering technique described in [29], which provides synonyms or subcategories of classes. Specifically, if any category name in test dataset overlaps with a category name in training dataset, we consider it as a seen class; otherwise unseen. As discussed in the main paper, the proposed FC-CLIP contains three components: a class-agnostic mask generator, an in-vocabulary classifier, and an out-of-vocabulary classifier. We thus explore using frozen or trainable CLIP for each component, and summarize the results in Tab. 6. To ensure a fair comparison, all "trainable" modules utilize the same weights, resulting in identical mask proposals and in-vocabulary classification results. Moreover, we note that the first row in Tab. 6 with trainable mask generator and in-vocabulary classifier, can be considered as an approximation to OpenSeg [29] in our framework. Our findings reveal that an in-vocabulary classifier built upon a trainable CLIP backbone achieves a higher $\mathrm { P Q } ^ { \mathrm { s e e n } }$ score (37.9 compared to 32.4), but experiences a decrease in PQunseen (2.6 compared to 12.6) compared to a frozen out-of-vocabulary classifier. Consequently, a model that incorporates a trainable CLIP backbone for all components yields a PQ of 24.1, which is 2.7 lower than our final model (last row) that relies on a single frozen CLIP backbone. Using a trainable mask generator and in-vocabulary classifier, along with a frozen out-of-vocabulary classifier boosts the performance but requires maintaining one trainable and one frozen CLIP weights, resulting in $2 \times$ more backbone parameters. In summary, our observations demonstrate that building the entire framework upon a frozen CLIP backbone is not only effective but also efficient, providing a better balance between $\mathrm { P Q } ^ { \mathrm { s e e n } }$ and $\mathrm { P Q } ^ { \mathrm { u n s e e n } }$ metrics.
283
+
284
+ Table 6: Effects of fine-tuning or freezing the CLIP backbone for each module in FC-CLIP. Building all three modules upon a single frozen CLIP backbone attains best performance. Note that our mask generator and in-vocabulary classifier use the same backbone following [20, 29, 94], and thus it is infeasible (denoted as N/A) for the setting in the 2nd last row. Our final setting is labeled in gray
285
+
286
+ <table><tr><td>mask generator</td><td>in-vocabulary classifier</td><td>out-of-vocabulary classifier</td><td>PQ</td><td>PQseen</td><td>PQunseen</td></tr><tr><td>trainable</td><td>trainable</td><td>1</td><td>17.7</td><td>37.9</td><td>2.6</td></tr><tr><td>trainable</td><td>-</td><td>frozen</td><td>21.1</td><td>32.4</td><td>12.6</td></tr><tr><td>trainable</td><td>trainable</td><td>trainable</td><td>24.1</td><td>38.9</td><td>13.1</td></tr><tr><td>trainable</td><td>trainable</td><td>frozen</td><td>25.4</td><td>40.0</td><td>14.6</td></tr><tr><td>trainable</td><td>frozen</td><td>frozen</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>frozen</td><td>frozen</td><td>frozen</td><td>26.8</td><td>39.5</td><td>17.3</td></tr></table>
287
+
288
+ Evaluation with Grounding PQ and Grounding mIoU It is worth emphasizing that despite the absence of grounding loss [33, 97, 29, 89] during training, our model exhibits exceptional grounding segmentation capabilities. Tab. 7 presents the grounding PQ and grounding mIoU scores of FCCLIP, following the evaluation methodology outlined in [29]. In this evaluation, we exclusively employ ground-truth classes as text query inputs to assess the effectiveness of concept grounding. Compared to OpenSeg [29], FC-CLIP achieves a substantial performance improvement, with notable enhancements of $+ 1 1 . 6$ , $+ 9 . 1$ , $+ 1 3 . 1$ , and $+ 1 7 . 7$ on A-847, PC-459, A-150, and PC-59, respectively. Even when compared to OpenSeg trained with the Localized Narrative dataset [65], which enables training on a significantly larger vocabulary, FC-CLIP still surpasses it with improvements of $+ 8 . 0$ , $+ 2 . 2 , + 8 . 6$ and $+ 1 3 . 4$ on A-847, PC-459, A-150 and PC-59, respectively, underscoring the grounding proficiency of FC-CLIP.
289
+
290
+ Table 7: Grounding segmentation performance. The proposed FC-CLIP also demonstrates stateof-the-art performances on grounding segmentation. MV: Mapillary Vistas
291
+
292
+ <table><tr><td></td><td>grounding PQ</td><td colspan="5">grounding mloU</td></tr><tr><td>method</td><td>ADE20K Cityscapes MV</td><td colspan="5">|A-847 PC-459 A-150 PC-59 PAS-21 PAS-20</td></tr><tr><td>ALIGN [40, 29]</td><td>- =</td><td>17.8 1</td><td>21.8</td><td>25.7 34.2</td><td>1</td><td>-</td></tr><tr><td>ALIGN w/ proposal [40, 29]</td><td></td><td>17.3</td><td>19.7 25.3</td><td>32.0</td><td></td><td></td></tr><tr><td>LSeg+ [48,29]</td><td></td><td>10.5</td><td>17.1 30.8</td><td>56.7</td><td></td><td></td></tr><tr><td>OpenSeg [29]</td><td></td><td>21.8</td><td>32.1 41.0</td><td>57.2</td><td>-</td><td></td></tr><tr><td>OpenSeg [29] w/L. Narr</td><td>- -</td><td>- 25.4</td><td>39.0</td><td>45.5 61.5</td><td>-</td><td>-</td></tr><tr><td>FC-CLIP (ours)</td><td>38.4 48.1</td><td>21.5 33.4</td><td>41.2</td><td>54.1 74.9</td><td>88.7</td><td>98.5</td></tr></table>
293
+
294
+ Table 8: Ensemble methods comparison with zero-shot evaluation (PQ) on ADE20K. Our method is robust to different ensemble methods (arithmetic and geometric). The results show that it is preferable to bias towards using the in-vocabulary classifier for seen classes and the out-of-vocabulary classifier for unseen classes. Our final setting $( \alpha = 0 . 4 , \beta = 0 . 8 )$ is labeled in gray
295
+
296
+ <table><tr><td>method</td><td>arithmetic</td><td>geometric</td></tr><tr><td>(a=0.0,β=0.0)</td><td>17.8</td><td>17.8</td></tr><tr><td>(α = 1.0,β = 1.0)</td><td>21.9</td><td>21.9</td></tr><tr><td>(α = 0.0,β = 1.0)</td><td>25.3</td><td>25.3</td></tr><tr><td>(α = 1.0,β = 0.0)</td><td>17.5</td><td>17.5</td></tr><tr><td>(a = 0.5,β = 0.5)</td><td>25.0</td><td>25.3</td></tr><tr><td>(α = 0.5, β = 0.6)</td><td>25.6</td><td>26.4</td></tr><tr><td>(α = 0.5,β = 0.7)</td><td>25.5</td><td>26.7</td></tr><tr><td>(α = 0.5,β = 0.8)</td><td>25.4</td><td>26.6</td></tr><tr><td>(α = 0.4,β = 0.6)</td><td>25.1</td><td>25.6</td></tr><tr><td>(α = 0.4,β = 0.7)</td><td>25.6</td><td>26.4</td></tr><tr><td>(α = 0.4,β = 0.8)</td><td>25.6</td><td>26.8</td></tr><tr><td>(α = 0.4, β = 0.9)</td><td>25.4</td><td>25.8</td></tr></table>
297
+
298
+ Table 9: Quantitative results of ViT-based CLIP and CNN-based CLIP when input size (denoted as "res") varies for panoptic segmentation on COCO and ADE20K. All results are obtained by applying CLIP directly as a mask classifier with the same mask proposals from ODISE [89]
299
+
300
+ <table><tr><td>CLIP backbone</td><td>COCO PQ @res 224 448 672 896 1120</td><td>ADE20K PQ @res 224 448 672 896 1120</td></tr><tr><td>ViT-L/14</td><td>19.3 22.5 20.6 18.5 14.9</td><td>11.9 13.7 12.6 11.6 9.1</td></tr><tr><td>ConvNeXt-L</td><td></td><td></td></tr><tr><td></td><td>17.3 23.5 27.0 28.6 29.3</td><td>9.3 12.8 14.8 16.0 15.9</td></tr></table>
301
+
302
+ Ensemble In-Vocabulary and Out-of-Vocabulary Classifiers In Tab. 8, we present experiments conducted to evaluate the impact of ensemble methods and ensemble parameters on the performance of the in-vocabulary and out-of-vocabulary classifiers. Specifically, we examine two ensemble methods: arithmetic and geometric. The arithmetic method involves a linear combination of the in-vocabulary classifier and the out-of-vocabulary classifier, while the geometric method is defined as shown in Equation (7) of main paper. It is worth noting that FC-CLIP exhibits robustness to different ensemble methods, with both methods displaying a consistent trend within the explored hyper-parameter ranges. However, the geometric ensemble consistently outperforms the arithmetic ensemble by a slight margin. Additionally, we observe that preference is given to values of $\alpha \leq 0 . 5$ and $\beta \geq 0 . 5$ , which biases the model towards using the in-vocabulary classifier for seen classes and the out-of-vocabulary classifier for unseen classes. We also explore extreme cases, including $\alpha = 0 . 0$ and $\beta = 0 . 0$ (i.e., exclusively utilizing the in-vocabulary classifier for every class), $\alpha = 1 . 0$ and $\beta = 1 . 0$ (i.e., exclusively utilizing the out-of-vocabulary classifier for every class), $\alpha = 0 . 0$ and $\beta = 1 . 0$ (i.e., using the in-vocabulary classifier for seen classes and the out-of-vocabulary classifier for unseen classes), and $\alpha = 1 . 0$ and $\beta = 0 . 0$ (i.e., using the out-of-vocabulary classifier for seen classes and the in-vocabulary classifier for unseen classes). The results align with our observations that it is preferable to bias towards the in-vocabulary classifier for seen classes and the out-of-vocabulary classifier for unseen classes.
303
+
304
+ Table 10: Quantitative results of ViT-based CLIP and CNN-based CLIP when input size (denoted as "res") varies for ImageNet-1k classification.
305
+
306
+ <table><tr><td>CLIP backbone</td><td>Accuracy ( @res 224336 448 560 672 784896</td></tr><tr><td>ViT-L/14</td><td>75.3 74.3 71.3 67.5 63.1 58.5 53.9</td></tr><tr><td>ConvNeXt-L</td><td>75.1 77.1 76.8 74.2 69.8 65.6 58.4</td></tr></table>
307
+
308
+ Table 11: Open-vocabulary segmentation performance with different backbones and segmentation frameworks. All models are trained on COCO and tested on the other datasets in a zero-shot manner. MV: Mapillary Vistas. $^ *$ : kMaX-DeepLab with multi-scale deformable attention [103]
309
+
310
+ <table><tr><td rowspan="2">method</td><td rowspan="2">backbone</td><td colspan="3"> panoptic datasets (PQ)</td><td rowspan="2"></td><td colspan="3">semantic datasets (mIoU)</td></tr><tr><td>ADE</td><td>Cityscapes MV</td><td>A-847</td><td>PC-459</td><td>PC-59</td><td>PAS-21</td></tr><tr><td>FC-CLIP</td><td>R50 [35, 69]</td><td>17.9</td><td>40.3</td><td>15.9</td><td>7.1</td><td>12.9</td><td>50.5</td><td>75.9</td></tr><tr><td>FC-CLIP</td><td>R101 [35,69]</td><td>19.1</td><td>40.9</td><td>16.7</td><td>7.7</td><td>12.3</td><td>48.9</td><td>77.6</td></tr><tr><td>FC-CLIP</td><td>R50×4[69]</td><td>21.8</td><td>42.2</td><td>17.4</td><td>8.7</td><td>13.1</td><td>54.0</td><td>79.0</td></tr><tr><td>FC-CLIP</td><td>R50×16 [69]</td><td>22.5</td><td>42.0</td><td>17.8</td><td>10.3</td><td>15.7</td><td>56.4</td><td>80.7</td></tr><tr><td>FC-CLIP</td><td>R50×64 [69]</td><td>22.8</td><td>42.7</td><td>18.2</td><td>10.8</td><td>16.2</td><td>55.7</td><td>80.3</td></tr><tr><td>FC-CLIP w/ kMaX</td><td>ConvNeXt-L [58,38]</td><td>24.5</td><td>43.0</td><td>17.0</td><td>11.4</td><td>15.0</td><td>57.4</td><td>84.7</td></tr><tr><td>FC-CLIP w/ kMaX*</td><td>ConvNeXt-L [58, 38]</td><td>26.4</td><td>40.2</td><td>17.4</td><td>13.6</td><td>17.5</td><td>57.1</td><td>81.2</td></tr><tr><td>FC-CLIP</td><td>ConvNeXt-L [58,38]</td><td>26.8</td><td>44.0</td><td>18.2</td><td>14.8</td><td>18.2</td><td>58.4</td><td>81.8</td></tr></table>
311
+
312
+ Quantitative ViT-based CLIP vs. CNN-based CLIP when Input Size Scales Training our model solely with ViT-based CLIP, without any additional modifications [101, 17, 91, 21], is infeasible. Furthermore, applying ViT to large input sizes is computationally expensive. Therefore, to evaluate the effects of using ViT- or CNN-based CLIP in our framework, we incorporate them into our out-ofvocabulary classifier, which is performed only during inference. To ensure a fair comparison, we use the same mask proposals and disable the geometric ensemble scheme. We also perform experiment on the ImageNet [73] benchmark to ensure a comprehensive comaprison. In Tab. 9 and Tab. 10, we conduct an ablation study to analyze the impact of different input resolutions for CLIP models. We consider both ViT-based (ViT-L/14) and CNN-based (ConvNeXt-L) CLIP models. By employing them as zero-shot classifiers and varying the input resolutions, we observe that CNN-based CLIP demonstrates superior generalization ability as the input size scales up. Specifically, we observe that the ViT-L/14 CLIP has a higher PQ and Accuracy at a lower resolution (i.e., input size 224), but suffers from a higher resolution, which leads existing two-stage methods [90, 52, 25, 91, 89] to adopt different input resolutions for mask generator and classifier branches. On the contrary, FC-CLIP provides a simple solution by adopting a CNN-based CLIP that generalizes well to different input sizes.
313
+
314
+ FC-CLIP with Different Backbones and Different Segmentation Frameworks Though we majorly report FC-CLIP results with ConvNeXt-L [58, 69] backbone in Mask2Former [20] framework. We note that FC-CLIP can be easily incorporated with different backbones and segmentation frameworks. Specifically, we experiment FC-CLIP with different backbones (e.g., ResNet [35]) and different segmentation architecture (e.g., kMaX-DeepLab [94]). As shown in Tab. 11, FC-CLIP demonstrates superior performance across different backbones and frameworks.
315
+
316
+ Visualization We provide visualization on ADE20K val set in Fig. 5.
317
+
318
+ # 7 Datasets Information and Licenses
319
+
320
+ The datasets we used for training and/or testing FC-CLIP are described as follows.
321
+
322
+ COCO: We train FC-CLIP on COCO data with panoptic annotation [54]. We follow the 2017 splits which include $1 1 8 k$ images for train split and $5 k$ images for val split. If not specified, we train our model on the COCO train split and report results on val set of various datasets.
323
+
324
+ License: Creative Commons Attribution 4.0 License
325
+
326
+ URL: https://cocodataset.org/#home
327
+
328
+ ![](images/6d945a983934e5f4e46d3f6c8d08c51a60561977f3204409808abcc4583cf137.jpg)
329
+ Figure 5: Visualization examples of FC-CLIP on ADE20K val set. FC-CLIP is trained on COCO panoptic training set and zero-shot evaluated on ADE20K validation set.
330
+
331
+ ADE20k: ADE20k [100] covers a wide range of indoor and outdoor scenes, with $2 k$ val images. We evaluate FC-CLIP on both the version with 847 classes (A-847) and the more widely-used version with 150 frequent categories (A-150).
332
+
333
+ License: Creative Commons BSD-3 License
334
+
335
+ URL: https://groups.csail.mit.edu/vision/datasets/ADE20K/
336
+
337
+ Cityscapes: Cityscapes [22] focuses on semantic understanding of urban street scenes. We use the fine data includes 500 images for validation set.
338
+
339
+ License: This dataset is made freely available to academic and non-academic entities for noncommercial purposes such as academic research, teaching, scientific publications, or personal experimentation.
340
+
341
+ URL: https://www.cityscapes-dataset.com/
342
+
343
+ Mapillary Vistas: Mapillary Vistas [64] is a large-scale traffic-related dataset, including $2 k$ images for validation purposes.
344
+
345
+ License: Creative Commons Attribution NonCommercial Share Alike (CC BY-NC-SA) license
346
+
347
+ URL: https://www.mapillary.com/dataset/vistas
348
+
349
+ Pascal Context: Pascal Context [63] covers a wide variety of indoor and outdoor scenes and includes $5 k$ val images. We evaluate FC-CLIP on both its full version (PC-459) with 459 classes and the more common version (PC-59) with 59 classes.
350
+
351
+ URL: https://www.cs.stanford.edu/\~roozbeh/pascal-context/
352
+
353
+ Pascal VOC: Pascal VOC [27] contains $1 . 5 k$ val images with 20 foreground classes and 1 background class. Due to the ambiguity in definition of “background", we assign the background class to the pixels predicted as PC-59 categories that are not in Pascal VOC following [29], which leads to PAS-21. We also evaluate the model with background class excluded, which leads to PAS-20.
354
+
355
+ URL: http://host.robots.ox.ac.uk/pascal/VOC/
md/dev/9Vrb9D0WI4/9Vrb9D0WI4.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/9XFSbDPmdW/9XFSbDPmdW.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/9rKTy4oZAQt/9rKTy4oZAQt.md ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A RISK-SENSITIVE POLICY GRADIENT METHOD
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Standard deep reinforcement learning (DRL) agents aim to maximize expected reward, considering collected experiences equally in formulating a policy. This differs from human decision-making, where gains and losses are valued differently and outlying outcomes are given increased consideration. It also wastes an opportunity for the agent to modulate behavior based on distributional context. Several approaches to distributional DRL have been investigated, with one popular strategy being to evaluate the projected distribution of returns for possible actions. We propose a more direct approach, whereby the distribution of full-episode outcomes is optimized to maximize a chosen function of its cumulative distribution function (CDF). This technique allows for outcomes to be weighed based on relative quality, does not require modification of the reward function to modulate agent behavior, and may be used for both continuous and discrete action spaces. We show how to achieve an asymptotically consistent estimate of the policy gradient for a broad class of CDF-based objectives via sampling, subsequently incorporating variance reduction measures to facilitate effective on-policy learning. We use the resulting algorithm to train agents with different “risk profiles” in penalty-based formulations of six OpenAI Safety Gym environments, observing that moderate emphasis on improvement in training scenarios where the agent performs poorly both increases the accumulation of positive rewards and decreases the frequency of incurred penalties. We found that, in all environments tested, the same risk profile can be used to produce both stronger overall performance than standard Proximal Policy Optimization (PPO) and higher levels of positive reward than PPO constrained by Lagrangians to maintain the same cost levels.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ While deep reinforcement learning (DRL) has been used to master an impressive array of simulated tasks in controlled settings, it has not yet been widely adopted for high-stakes, real-world applications. One reason for this gap is the lack of distributional perspective in standard artificial agents. Endowing agents with such perspective could make their decision-making more robust, potentially leading to increased safety, increased trust from humans, and more widespread real-world adoption.
12
+
13
+ In reinforcement learning (RL), risk arises due to uncertainty around the possible outcomes of an agent’s future actions. It is a result of randomness in the operating environment, mismatch between training and test conditions, and the inherent randomness of a stochastic policy. Risk-sensitive policies, or those that consider more than a mean over the distribution of possible outcomes, offer the potential for added robustness under uncertain and dynamic conditions. There is an evolving landscape of algorithmic paradigms for handling risk in RL, from constraint-based approaches adapted from optimal control (Achiam et al., 2017; Chow et al., 2019; Ray et al., 2019; Zhong et al., 2020) to adversarial approaches emerging from AI Safety (Garc´ıa & Fernandez, 2015; Amodei et al., 2016). ´ Within this landscape, learning approaches that optimize distributional measures offer the ability to express design preferences over the full distribution of potential outcomes, through the specification of a risk-sensitivity criterion.
14
+
15
+ Distributional RL has been studied for value-based methods, with a popular strategy being to use the distributional Bellman equation to estimate the distribution of Q-values for each member of a discrete set of potential actions (Bellemare et al., 2017; Dabney et al., 2018a;b). However, distributional RL has not been widely explored for policy gradient methods, which could permit direct optimization of risk-sensitive measures and naturally accommodate both discrete and continuous action spaces.
16
+
17
+ In the following, we introduce a novel framework for risk-sensitive learning using policy gradients. Our approach allows agents to be trained with different risk profiles through design-time specification of both utility and weight functions, with the latter being defined over the estimated distribution of full-episode rewards. This framework enables agent-based learning that captures aspects of human decision-making, such as overemphasis of rare occurrences and diminishing marginal utility relative to a reference outcome (Kahneman & Tversky, 1979). It also allows implementation of another key strategy of human learning: emphasizing improvement on tasks where one is deficient. We demonstrate the ability of our algorithm to use this strategy to improve performance relative to both unconstrained and constrained methods in six OpenAI Safety Gym environments (Ray et al., 2019).
18
+
19
+ # 2 RELATED WORK
20
+
21
+ Constrained RL offers a set of approaches to safe exploration (Garc´ıa & Fernandez (2015)) that aim ´ to enforce explicit constraints throughout the learning process via methods including Lagrangian constraints (Ray et al. (2019)) and constraint coefficients (Achiam et al. (2017)). Differing from the safe exploration scenario, we here consider problems with distinct training and test phases where agent performance is to be evaluated. Our experiments indicate that risk-sensitive learning can offer performance improvements over constrained learning in scenarios where safety constraints need not be enforced during training.
22
+
23
+ Distributional approaches to risk-sensitive RL have primarily been explored in the value-based setting. Therein, the value distribution has been explicitly modeled through categorical techniques (Bellemare et al., 2017) or quantile regression (Dabney et al., 2018a) and used to improve both value predictions and overall performance. Recent works utilize distributional modeling in the actor-critic setting to enable application to continuous action spaces, again demonstrating improved performance over baseline approaches (Ma et al., 2020; Zhang et al., 2021; Duan et al., 2021). In value-based approaches, risk-sensitivity criteria are applied at run time as a nonlinear warping of the estimated value distribution.
24
+
25
+ Policy gradient approaches offer additional promise for risk-sensitive RL, but require direct optimization of a parameterized policy with respect to a distributional objective. Some existing methods are limited to a specific class of learning objective, such as the set of concave risk measures that allow a globally-optimal solution (Tamar et al., 2015; Zhong et al., 2020). Others allow a broader class of measures but are more restrictive in the class of policies that can be represented (Prashanth et al., 2016). We aim for a risk-sensitive policy gradient approach that both offers significant flexibility in the choice of learning objective and can learn policies parameterized by a deep neural network.
26
+
27
+ Various measures have been considered in the context of risk-sensitive RL, including exponential utility (Pratt, 1964), percentile performance criteria (Wu & Lin, 1999), value-at-risk (Leavens, 1945), conditional value-at-risk (Rockafellar & Uryasev, 2000), and prospect theory (Kahneman & Tversky, 1979). In this work, we consider a class of risk-sensitivity measures motivated by Cumulative Prospect Theory (CPT) (Tversky & Kahneman, 1992). CPT uniquely models two key aspects of human decision-making: (1) a utility function $u$ , computed relative to a reference point that induces more risk-averse behavior in the presence of gains than losses and (2) a weight function $w$ that prioritizes outlying events. Specific forms of $u$ and $w$ are given in Tversky & Kahneman (1992) (and in Appendix A.4), but the general form of CPT admits a wide variety of risk-sensitive objectives.
28
+
29
+ Here we show how to train agents to optimize this class of objectives through sampling-based estimation of their policy gradients and requisite variance reduction. The final algorithm resembles well-known on-policy approaches such as Proximal Policy Optimization (Schulman et al., 2017b) and is similarly widely applicable. Although we do not explore it here, the incorporation of an appropriate risk-sensitivity criterion could additionally enable risk-aware exploration and adversarial training for increased robustness (Pinto et al., 2017; Parisi et al., 2019; Zhang et al., 2020).
30
+
31
+ # 3 RISK-SENSITIVE POLICY OPTIMIZATION
32
+
33
+ In this section we formalize the class of distributional objectives to be considered, derive a samplingbased approximation of its policy gradient, enact variance reduction on this estimate, and use the result to produce a practical learning algorithm.
34
+
35
+ # 3.1 PRELIMINARIES: PROBLEM AND NOTATION
36
+
37
+ Standard deep reinforcement learning seeks to maximize the expected reward of an agent over encountered trajectories; that is, it maximizes the objective
38
+
39
+ $$
40
+ J ( \theta ) = E _ { \tau \sim p _ { \theta } ( \tau ) } \Big [ \sum _ { t } r ( \mathbf { s } _ { t } , \mathbf { a } _ { t } ) \Big ] .
41
+ $$
42
+
43
+ Here $p _ { \theta } ( \tau )$ is the distribution over trajectories $\tau \equiv \mathbf { s } _ { 1 } , \mathbf { a } _ { 1 } , \dots , \mathbf { s } _ { T } , \mathbf { a } _ { T }$ induced by a policy parameterized by $\theta$ ; $\mathbf { s } _ { t } , \mathbf { a } _ { t }$ , and $r ( \mathbf { s } _ { t } , \mathbf { a } _ { t } )$ denote the state, action, and reward at time $t$ , respectively. To enable the incorporation of distributional context, we instead consider the objective
44
+
45
+ $$
46
+ J ( \theta ) = \int _ { - \infty } ^ { + \infty } u ( r ( \tau ) ) \frac { d } { d r ( \tau ) } \biggl ( w ( P _ { \theta } ( r ( \tau ) ) \biggr ) d r ( \tau ) ,
47
+ $$
48
+
49
+ where $u ( r ( \tau ) )$ is the utility associated with full-trajectory reward $\begin{array} { r } { r ( \tau ) \equiv \sum _ { t } r ( \mathbf { s } _ { t } , \mathbf { a } _ { t } ) } \end{array}$ and $w$ is a piecewise differentiable weighting function of the CDF of trajectory reward $P _ { \theta } ( r ( \tau ) ) ~ =$ $\int _ { - \infty } ^ { r ( \tau ) } p _ { \theta } ( r ^ { \prime } ) d r ^ { \prime }$ .
50
+
51
+ Equation 2 is inspired by CPT (Tversky & Kahneman, 1992), which includes a pair of integrals of this form. It was chosen for its generality; by using different utility functions $u$ and weight functions $w$ one may represent all of the risk measures mentioned in Section 2 and all of the risk measures evaluated by Dabney et al. (2018a). The form (2) reduces to (1) when $u$ and $w$ are both the identity mapping. While designed for the episodic setting, the objective (2) may be considered for infinite horizons through the choice of appropriately long windows.
52
+
53
+ # 3.2 RISK-SENSITIVE POLICY GRADIENT
54
+
55
+ To optimize the objective (2), we first derive an approximation to its gradient with respect to the policy parameters $\theta$ . Working toward a representation that can be sampled, we assert the independence of the reward on $\theta$ and use the chain rule to write
56
+
57
+ $$
58
+ \nabla _ { \theta } J ( \theta ) = \int _ { - \infty } ^ { \infty } u ( r ( \tau ) ) \frac { d } { d r ( \tau ) } \biggl ( w ^ { \prime } ( P _ { \theta } ( r ( \tau ) ) ) \nabla _ { \theta } P _ { \theta } ( r ( \tau ) ) \biggr ) d r ( \tau ) ,
59
+ $$
60
+
61
+ where $w ^ { \prime }$ is the derivative of $w$ with respect to $P _ { \theta } ( r ( \tau ) )$ . The gradient of the CDF may be written as follows:
62
+
63
+ $$
64
+ \begin{array} { l } { \displaystyle \nabla _ { \theta } P _ { \theta } ( r ( \tau ) ) = \nabla _ { \theta } \int _ { - \infty } ^ { r ( \tau ) } p _ { \theta } ( r ^ { \prime } ) d r ^ { \prime } = \nabla _ { \theta } \int _ { \tau ^ { \prime } } H ( r ( \tau ) - r ( \tau ^ { \prime } ) ) p _ { \theta } ( \tau ^ { \prime } ) d \tau ^ { \prime } } \\ { \displaystyle = \int _ { \tau ^ { \prime } } H ( r ( \tau ) - r ( \tau ^ { \prime } ) ) \nabla _ { \theta } p _ { \theta } ( \tau ^ { \prime } ) d \tau ^ { \prime } = \int _ { \tau ^ { \prime } } H ( r ( \tau ) - r ( \tau ^ { \prime } ) ) p _ { \theta } ( \tau ^ { \prime } ) \nabla _ { \theta } \log p _ { \theta } ( \tau ^ { \prime } ) d \tau ^ { \prime } . } \end{array}
65
+ $$
66
+
67
+ Here the first equality is the integral representation of $P _ { \theta } ( r ( \tau ) )$ , the second uses the Heaviside step function to select all trajectories with total reward $\leq r ( \tau )$ , the third follows from the independence of reward on $\theta$ , and the fourth follows from the expression for the derivative of the natural logarithm. In the following, we also use the complementary expression
68
+
69
+ $$
70
+ \nabla _ { \theta } P _ { \theta } ( r ( \tau ) ) = \nabla _ { \theta } \bigg ( 1 - \int _ { r ( \tau ) } ^ { \infty } p _ { \theta } ( r ^ { \prime } ) d r ^ { \prime } \bigg ) = - \int _ { \tau ^ { \prime } } H ( r ( \tau ^ { \prime } ) - r ( \tau ) ) p _ { \theta } ( \tau ^ { \prime } ) \nabla _ { \theta } \log p _ { \theta } ( \tau ^ { \prime } ) d \tau ^ { \prime } .
71
+ $$
72
+
73
+ Either form, or a combination of the two, may be substituted into (3) and the result sampled over $N$ trajectories by first ordering trajectories $i = 1 \ldots N$ by increasing reward $r ( \tau )$ . Then
74
+
75
+ $$
76
+ \nabla _ { \theta } J ( \theta ) \approx \sum _ { i = 1 } ^ { N } u ( r ( \tau _ { i } ) ) \bigg ( w ^ { \prime } \bigg ( \frac { i } { N } \bigg ) \nabla _ { \theta } P _ { \theta } ( r ( \tau _ { i } ) ) - w ^ { \prime } \bigg ( \frac { i - 1 } { N } \bigg ) \nabla _ { \theta } P _ { \theta } ( r ( \tau _ { i - 1 } ) ) \bigg ) ,
77
+ $$
78
+
79
+ where the term $w ^ { \prime } ( 0 ) \nabla _ { \theta } P _ { \theta } \big ( r ( \tau _ { 0 } ) \big ) \equiv 0$ . This ordering scheme produces an asymptotically consistent estimate, as shown in the context of CPT value estimation by Prashanth et al. (2016). $\nabla _ { \theta } P _ { \theta } ( r ( \tau _ { i } ) )$ may be sampled in one of two ways, based on either (4) or (5):
80
+
81
+ $$
82
+ \nabla _ { \theta } P _ { \theta } ( r ( \tau _ { i } ) ) \approx \frac { 1 } { N } \sum _ { j = 1 } ^ { i } \sum _ { t = 1 } ^ { T _ { j } } \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) \approx - \frac { 1 } { N } \sum _ { j = i + 1 } ^ { N } \sum _ { t = 1 } ^ { T _ { j } } \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) .
83
+ $$
84
+
85
+ The expression (6) may be used to train a policy that optimizes the distributional objective (2) in a manner similar to REINFORCE (Williams, 1992).
86
+
87
+ # 3.3 VARIANCE REDUCTION
88
+
89
+ Reducing the variance of sample-based gradient estimates enables faster learning. Here we take several steps to reduce the variance of (6), as has been done with the policy gradient estimate of REINFORCE (Williams, 1992).
90
+
91
+ First, note that cross-trajectory terms of the form $f ( \tau _ { i } , \mathbf { a } _ { j , t } , \mathbf { s } _ { j , t } ) \stackrel { } { = } u ( r ( \tau _ { i } ) ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } )$ while nonzero, do not contribute to the gradient estimate in expectation when $i \neq j$ . A proof of this assertion is given in Appendix A.1. Using (4) for the first term of (6) and (5) for the second allows us to write
92
+
93
+ $$
94
+ \begin{array} { r l r } { { \nabla _ { \theta } J ( \theta ) \approx \sum _ { i = 1 } ^ { N } u ( r ( \tau _ { i } ) ) \bigg ( w ^ { \prime } \bigg ( \frac { i } { N } \bigg ) \frac { 1 } { N } \sum _ { j = 1 } ^ { i } \sum _ { t = 1 } ^ { T _ { j } } \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) } } \\ & { } & { \qquad + w ^ { \prime } \bigg ( \frac { i - 1 } { N } \bigg ) \frac { 1 } { N } \sum _ { j = i } ^ { N } \sum _ { t = 1 } ^ { T _ { j } } \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) \bigg ) . } \end{array}
95
+ $$
96
+
97
+ Removing cross-trajectory terms gives
98
+
99
+ $$
100
+ \overline { { \nabla _ { \theta } J ( \theta ) } } \approx \frac { 1 } { N } \sum _ { i = 1 } ^ { N } u ( r ( \tau _ { i } ) ) \bigg ( \bigg ( w ^ { \prime } \bigg ( \frac { i } { N } \bigg ) + w ^ { \prime } \bigg ( \frac { i - 1 } { N } \bigg ) \bigg ) \sum _ { t = 1 } ^ { T _ { i } } \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) .
101
+ $$
102
+
103
+ Note that the weight coefficients $\begin{array} { r } { ( w ^ { \prime } ( \frac { i } { N } ) + w ^ { \prime } ( \frac { i - 1 } { N } ) ) } \end{array}$ should be normalized over each batch. The expression (9) is equivalent to (6) in expectation, but with reduced variance (see Appendix A.1 for justification). It has a clear intuition – trajectories are assigned utilities based on their rewards and their contributions to the gradient are scaled by the derivative of the weight function, just as they are in Cumulative Prospect Theory (Tversky & Kahneman, 1992).
104
+
105
+ Standard variance reduction techniques may be applied to this simplified form. Without further assumption or introduction of additional bias, a static baseline $b$ can be employed:
106
+
107
+ $$
108
+ \nabla _ { \theta } J ( \theta ) \approx \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \left( u ( r ( \tau _ { i } ) ) - b \right) \left( w ^ { \prime } \left( \frac { i } { N } \right) + w ^ { \prime } \left( \frac { i - 1 } { N } \right) \right) \sum _ { t = 1 } ^ { T _ { i } } \nabla _ { \theta } \log \pi _ { \theta } \big ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } \big )
109
+ $$
110
+
111
+ Justification for this assertion is given in Appendix A.2. Learning may be further improved if we additionally assume that utility may be allocated on a per-step basis. In this case, per-step utilities are computed as the difference between what the full-episode utility would be if the episode were to end at a given time step and what it would have been had the episode ended at the previous time step. While not applicable in cases where episode utility is adjusted based on final outcome, this assumption has the significant benefit of modeling the temporal allocation of rewards and aligns with the standard formulation of RL. With it, the variance of (9) may be further reduced through the incorporation of utility-to-go and a state-dependent baseline $V _ { \phi } ( \mathbf { s } _ { i , t } )$ :
112
+
113
+ $$
114
+ \nabla _ { \theta } J ( \theta ) \approx \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \left[ w ^ { \prime } \left( \frac { i } { N } \right) + w ^ { \prime } \left( \frac { i - 1 } { N } \right) \right] \sum _ { t = 1 } ^ { T _ { i } } \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) \left[ \sum _ { t ^ { \prime } = t } ^ { T _ { i } } u ( \mathbf { s } _ { i , t ^ { \prime } } , \mathbf { a } _ { i , t ^ { \prime } } ) - V _ { \phi } ( \mathbf { s } _ { i , t } ) \right] .
115
+ $$
116
+
117
+ Here $u ( \mathbf { s } _ { i , t ^ { \prime } } , \mathbf { a } _ { i , t ^ { \prime } } )$ is the per-step utility. The value function $V _ { \phi } ( \mathbf { s } _ { i , t } )$ is parameterized by $\phi$ and trained via regression to minimize
118
+
119
+ $$
120
+ \mathcal { L } ( \phi ) = \sum _ { i , t } \bigg ( V _ { \phi } ( \mathbf { s } _ { i , t } ) - \sum _ { t ^ { \prime } = t } ^ { T _ { i } } u ( \mathbf { s } _ { i , t ^ { \prime } } , \mathbf { a } _ { i , t ^ { \prime } } ) \bigg ) ^ { 2 } .
121
+ $$
122
+
123
+ A standard argument, similar to the approach taken in (Achiam, 2018), can be used to show that the incorporation of utility-to-go does not change the expected value of (9). The addition of a state-dependent baseline also does not introduce additional bias, as justified in Appendix A.2.
124
+
125
+ Finally, discount factors, bootstrapping, and trust regions may be used to provide additional variance reduction, just as they are in conventional on-policy learning (Appendix A.2). These measures may introduce additional bias to the policy gradient estimate, but typically lead to more sampleefficient learning. In our experiments, we evaluate the use of generalized advantage estimation (GAE; (Schulman et al., 2016)) based on the utility-to-go as well as the clipping-based trust regions of Proximal Policy Optimization (PPO; (Schulman et al., 2017b)). Incorporating these in the policy gradient yields
126
+
127
+ $$
128
+ \nabla _ { \theta } J ( \theta ) \approx \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \left( w ^ { \prime } \left( \frac { i } { N } \right) + w ^ { \prime } \left( \frac { i - 1 } { N } \right) \right) \sum _ { t = 1 } ^ { T _ { i } } \nabla _ { \theta } L _ { \mathrm { c l i p } } \bigg ( \log \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) , A _ { u } ^ { \pi } ( \mathbf { s } _ { i , t } , \mathbf { a } _ { i , t } ) \bigg ) ,
129
+ $$
130
+
131
+ where $A _ { u } ^ { \pi } ( \mathbf { s } _ { i , t } , \mathbf { a } _ { i , t } )$ is the standard GAE except with per-step utilities in place of rewards. Trust regions are implemented similarly to PPO, pessimistically clipping policy updates to be within a multiplicative factor of $1 \pm \epsilon$ of the existing policy:
132
+
133
+ $$
134
+ \begin{array} { r l } & { L _ { \mathrm { c l i p } } = \operatorname* { m i n } \Bigg ( \log \pi _ { \boldsymbol \theta } \big ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } \big ) A _ { u } ^ { \pi } \big ( \mathbf { s } _ { i , t } , \mathbf { a } _ { i , t } \big ) , } \\ & { \qquad \log \bigg ( \mathrm { c l i p } \bigg ( \frac { \pi _ { \boldsymbol \theta } \big ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } \big ) } { \pi _ { \theta _ { \mathrm { o l d } } } \big ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } \big ) } , 1 \pm \epsilon \bigg ) \pi _ { \theta _ { \mathrm { o l d } } } \big ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } \big ) \Bigg ) A _ { u } ^ { \pi } \big ( \mathbf { s } _ { i , t } , \mathbf { a } _ { i , t } \big ) \Bigg ) . } \end{array}
135
+ $$
136
+
137
+ They are used to perform multiple policy updates using the same batch of data, providing learning that is no longer strictly on-policy but that can be significantly more sample efficient. When following this route, we apply the same early stopping mechanism, based on the Kullback-Leibler divergence $( D _ { \mathrm { K L } } )$ between old and new policies, as was used by Ray et al. (2019).
138
+
139
+ # 3.4 LEARNING ALGORITHM
140
+
141
+ The above sample-based estimate of the policy gradient may be used to train agents to maximize distributional objectives of the form (2). The resulting method, Cumulative Prospect Proximal Policy Optimization (C3PO), is given in Algorithm 1 and mirrors standard on-policy learning.
142
+
143
+ <table><tr><td>Algorithm 1 Cumulative Prospect Proximal Policy Optimization (C3PO)</td></tr><tr><td>Require: Policy: initial parameters 0o,learning rate αθ,updates per batch Mθ</td></tr><tr><td>Require: Value: initial parameters o,learning rate α𝜙,updates per batch MΦ Require:Early stopping threshold DKL,stop, discount factor y</td></tr><tr><td>for k = 1,2,... do</td></tr><tr><td>Collect set of episodes Dk = {Ti} by running policy π(0k) in the environment</td></tr><tr><td>Compute per-step utilities u(Si,t, ai,t)</td></tr><tr><td>Fit value function by regression:</td></tr><tr><td>for m=1,...M do</td></tr><tr><td>(v(i)-∑()) ←Φ+aV∑T∑it(</td></tr><tr><td>end for</td></tr><tr><td></td></tr><tr><td>Update utility-based advantage estimates A&quot;(s,a), using new V(s)</td></tr><tr><td>Compute weight coefficients based on ordered episode outcomes and normalize</td></tr><tr><td>Update policy, using KL-based early stopping:</td></tr><tr><td>for m=1,...Mθ do if DKL(πθ/πold)&lt;DkL, stop then</td></tr><tr><td>N</td></tr><tr><td>θ←θ+aθ∑1(w′()+w′(1))∑=1 VLeip(logθ(ai,tlsi,t),A((sit,ai,t)) else</td></tr></table>
144
+
145
+ ![](images/77aa2a8e4e8903a0e8c73d9178f7e58cb69c1b08ab6f8e6fde7356f5b778ee51.jpg)
146
+ Figure 1: Example weight functions and their resulting coefficients in the policy gradient estimate (9). In these plots, outcomes increase in quality from left to right. As in CPT (Tversky & Kahneman, 1992), weight coefficients are proportional to the derivative of the weight function.
147
+
148
+ Beyond the utility and weight components, Algorithm 1 differs from conventional methods in the requirement to collect full episodes of data in each batch. This requirement can be removed if outcomes can be defined over partial rather than full episodes, an assumption that is often viable and matches human decision-making. For instance, while out of scope for this work, our approach could be applied to the Atari suite (Bellemare et al., 2013) by considering the outcomes of fixed-length windows and restructuring Algorithm 1 to mimic minibatch PPO (Schulman et al., 2017b).
149
+
150
+ # 4 EXPERIMENTS
151
+
152
+ To evaluate our approach, we sought to both establish that it can effectively optimize different distributional objectives and explore the impact of using different objectives on agent outcomes. We found the OpenAI Safety Gym (Ray et al., 2019) to be suitable for these purposes. Safety Gym is a configurable suite of continuous, multidimensional control tasks wherein different types of robots must navigate through obstacles with different dynamics to perform different tasks. By including both positive and negative events in each training scenario, it allowed us to evaluate how our various agents handled risk. Safety Gym is also highly stochastic: the locations of the goals and obstacles are randomized, leading to outcome variability and forcing the agent to learn a generalized navigation strategy.
153
+
154
+ Safety Gym logs adverse events but does not incorporate them into the reward function. As our method relies solely on the training signal from the reward, we assigned each logged adverse event a fixed, negative reward contribution in experiments using it or other unconstrained agents. Our initial experiments were conducted with a reward contribution of $- 0 . 0 2 5$ , which was found to allow agents to prioritize reaching goals but deter them from collisions with obstacles. To further emphasize obstacle avoidance, we doubled this contribution to $- 0 . 0 5$ in our experiments using cautious weightings. These choices and the role they play are further discussed in Section 5.
155
+
156
+ To highlight distributional differences, we focused on the publicly available, obstacle-rich level 2 environments.1 Avoiding the longer compute time of the “Doggo” robot, we evaluated the “Point” and “Car” robots on each task (“Goal”, “Button”, and “Push”). Further details on these environments and our rationale for choosing them are given in Appendix A.3.
157
+
158
+ In all experiments, we evaluated five random seeds and matched the hyperparameters used in the baselines accompanying Safety Gym (Ray et al., 2019) as closely as possible. The neural networks used to model both policy and value were multilayer perceptrons (MLPs), with two hidden layers of 256 units each and tanh activations. As in Ray et al. (2019), the policy network outputs the mean values of a multivariate gaussian with diagonal covariance. The control variances are optimized but independent of state. The full complement of variance reduction measures were used throughout; see Appendix A.4 for experimental justification of this choice.
159
+
160
+ # 4.1 DIFFERING OBJECTIVES
161
+
162
+ Agent performance was explored under four different distributional objectives. In addition to expected reward and CPT (configured to match the original form of Tversky & Kahneman (1992) and as given in Appendix A.4), we optimized for cautious ( $\gamma = 0 . 7 5 )$ and aggressive $( \eta = - 0 . 7 5 )$ versions of the distortion risk measure proposed in Wang (2000). This measure is defined as $w ( p ) = \Phi ( \Phi ^ { - 1 } ( p ) + \eta )$ where $\Phi$ and $\Phi ^ { - 1 }$ are the standard normal cumulative distribution function and its inverse. While we found this form to be convenient, the “Pow” metric in Dabney et al. (2018a) or any other set of similarly shaped $w$ curves should achieve a similar effect. In experiments using the objective from Tversky & Kahneman (1992), the reference point was taken to be the mean episode reward of the current batch, matching the tendency of humans to change their standards over time. The four weight functions and their resulting coefficients in (9) are shown in Figure 1.
163
+
164
+ ![](images/e0e22e1a977d26c084e5a479a42b9426590fced223729c1eece0c6e3436890d2.jpg)
165
+ Figure 2: Impact of different distributional objectives in one environment (CarButton2). The shading in the first 2 plots (and subsequent learning curves) reflects the standard deviation associated with running over 5 random seeds. Left: Net reward (positive reward minus penalty) throughout learning. Middle: Average number of cost events per episode during training (lower is better). Right: Agent outcome distribution in testing (with sampling turned off). The cautious (Wang $( \eta = 0 . 7 5 )$ ) weighting shows higher reward and lower cost once trained.
166
+
167
+ Plots of the total rewards (including penalties) in training, average cost events per episode in training, and outcome distributions in testing are shown for one environment in Figure 2 and for two additional environments in Appendix A.5. The trends were fairly consistent over the three environments evaluated in this manner. While no explicit effort was made to handle cost (agents were given only the sum of positive rewards and penalties), the cautious and aggressive weightings consistently accumulated relatively low and high costs, respectively. The cautious $( \mathrm { W a n g } ( \eta = 0 . 7 5 ) )$ ) agent typically also generated the highest positive and total rewards after 10 millions steps of training.
168
+
169
+ To generate the histograms in Figures 2, 5, 8, 9, and 13 as well as the numbers in Table 1, the trained agents were deployed on a set of 5000 test episodes – 1000 for each of the 5 networks learned using different random seeds in training. The resulting distributions therefore include contributions from both aleatoric and epistemic uncertainty. Sampling was turned off, allowing the agents to choose their perceived optimal action at each time step. In this context the benefit of emphasizing the lower part of the outcome distribution (i.e., cautious weighting) became more pronounced, in part because the methods that emphasize poor outcomes tended to maintain higher policy entropy (Appendix A.5).
170
+
171
+ # 4.2 CAUTIOUS WEIGHTINGS
172
+
173
+ To further explore the apparent benefits of cautious weightings in Safety Gym, we trained a series of variably cautious agents by tuning $\eta$ in the risk-averse weight function proposed by Wang (2000). Histograms of their episode rewards in testing are given in Appendix A.5 and summarized in Table 1. In these environments, agent performance – both in terms of improving the lower end of the reward distribution and on average – was seen to generally improve with increasing $\eta$ until the range $\eta \in [ 0 . 7 5 , 1 . 2 5 ]$ , subsequently degrading. Additional comparisons were made with PPO (Schulman et al., 2017b), which unsurprisingly was found to closely track performance of the “Uniform” agent. We found that naively incorporating cautious weightings into PPO improved its performance (row $\mathrm { P P O } + \mathrm { W a n g } ( 0 . 7 5 )$ in Table 1), though not to the level of the full C3PO method with $\eta = 0 . 7 5$ .
174
+
175
+ We then pursued a set of longer runs to compare C3PO with the cautious objective from Wang (2000) to both unconstrained and constrained benchmarks. Here we did not tune $\eta$ , keeping it fixed at 0.75 for all experiments. Comparisons with unconstrained methods for three environments are given in Figures 3, 4, and 5 and for the remaining three environments in Appendix A.6. In addition to PPO, we compared performance with Trust Region Policy Optimization (TRPO; Schulman et al. (2017a)) as configured in Ray et al. (2019). Since this TRPO configuration generally outperformed the PPO configuration in Ray et al. (2019) from which we derived the hyperparameters for C3PO, we would expect C3PO to be at a disadvantage compared to TRPO. However, we found C3PO had the highest
176
+
177
+ <table><tr><td rowspan="2"></td><td colspan="4">PointButton2</td><td colspan="4">CarGoal2</td><td colspan="4">CarButton2</td></tr><tr><td>Mean</td><td>Std</td><td>Q=0.5</td><td>Q=.05</td><td>Mean</td><td>Std</td><td>Q=0.5</td><td>Q=.05</td><td>Mean</td><td>Std</td><td>Q=0.5</td><td>Q=.05</td></tr><tr><td>Uniform</td><td>22.5</td><td>7.1</td><td>22.8</td><td>10.7</td><td>18.1</td><td>6.6</td><td>18.0</td><td>7.4</td><td>12.4</td><td>9.1</td><td>14.0</td><td>-6.1</td></tr><tr><td> CPT Value</td><td>16.5</td><td>7.3</td><td>16.3</td><td>4.9</td><td>13.9</td><td>7.7</td><td>14.6</td><td>-0.5</td><td>9.5</td><td>10.7</td><td>11.2</td><td>-11.0</td></tr><tr><td>Wang (-0.75)</td><td>17.5</td><td>6.1</td><td>17.6</td><td>7.6</td><td>13.5</td><td>6.9</td><td>14.0</td><td>0.9</td><td>6.4</td><td>10.7</td><td>8.9</td><td>-15.5</td></tr><tr><td>Wang (0.5)</td><td>23.3</td><td>6.3</td><td>23.3</td><td>13.1</td><td>18.5</td><td>6.0</td><td>18.8</td><td>8.2</td><td>12.9</td><td>9.0</td><td>14.4</td><td>-5.6</td></tr><tr><td>Wang (0.75)</td><td>24.2</td><td>6.7</td><td>24.4</td><td>13.7</td><td>19.0</td><td>6.4</td><td>19.3</td><td>8.2</td><td>14.3</td><td>9.5</td><td>15.8</td><td>-4.4</td></tr><tr><td>Wang (1.0)</td><td>24.7</td><td>6.0</td><td>24.9</td><td>15.1</td><td>20.3</td><td>6.9</td><td>21.3</td><td>7.2</td><td>11.4</td><td>11.0</td><td>13.8</td><td>-12.2</td></tr><tr><td>Wang (1.25)</td><td>25.4</td><td>6.1</td><td>25.4</td><td>15.9</td><td>17.3</td><td>6.7</td><td>17.8</td><td>5.6</td><td>12.7</td><td>10.4</td><td>14.8</td><td>-8.3</td></tr><tr><td>Wang (1.50)</td><td>23.6</td><td>5.9</td><td>23.7</td><td>14.1</td><td>16.6</td><td>7.5</td><td>17.2</td><td>3.1</td><td>10.1</td><td>12.0</td><td>13.3</td><td>-17.9</td></tr><tr><td>Wang (1.75)</td><td>23.4</td><td>6.2</td><td>23.5</td><td>13.5</td><td>12.5</td><td>8.0</td><td>13.0</td><td>-0.6</td><td>7.3</td><td>13.0</td><td>11.1</td><td>-22.8</td></tr><tr><td>PPO°</td><td>19.0</td><td>6.4</td><td>18.9</td><td>9.1</td><td>15.8</td><td>6.0</td><td>15.8</td><td>5.8</td><td>8.3</td><td>9.5</td><td>9.5</td><td>-9.8</td></tr><tr><td>PPO + Wang(0.75)</td><td>20.4</td><td>8.4</td><td>21.7</td><td>2.6</td><td>17.7</td><td>6.7</td><td>18.0</td><td>6.3</td><td>12.1</td><td>9.5</td><td>13.6</td><td>-6.8</td></tr></table>
178
+
179
+ Table 1: Testing statistics for episode rewards achieved by agents trained over 10 million steps with different distributional objectives. $Q = 0 . 5$ is the median and $Q = 0 . 0 5$ refers to the location of the 0.05 quantile. Blue bold-face represents the best performance for a given environment; in all cases these occur for moderately cautious weightings $( \eta \in [ 0 . 7 5 , 1 . 2 5 ] )$ .
180
+
181
+ ![](images/bb501da34dad9ffd280e1e0abf0d5aecacef9ec4aebd9042e3c91ece0f75c297.jpg)
182
+ Figure 3: Average episode reward (including penalty) over training for different learning approaches in three different environments. C3PO with Wang $\langle \eta = 0 . 7 5 \rangle$ weighting outperforms others.
183
+
184
+ average reward (including penalty) in five of the six environments and lowest average cost in five of the six environments. In addition, agents that used the cautious weightings tended to have more stable and repeatable training, as evidenced by the tight distribution of their learning curves. This tightness was found to reflect a lack of negative outlier episodes and potentially lower epistemic uncertainty throughout training. Finally, note that the use of a nonzero penalty for cost events resulted in significantly lower incurred costs than were observed with unconstrained agents trained without a penalty (Ray et al., 2019). PPO and TRPO were seen to reach similar cost levels without a penalty; these levels are indicated by red dashed lines in the cost figures.
185
+
186
+ Comparisons with versions of PPO and TRPO that use Lagrangian constraints (PPO-Lagrangian and TRPO-Lagrangian; Ray et al. (2019)) to match the cost level of C3PO are shown in Figure 6 and Appendix A.7 . We see that, given the same level of cost incurred per episode, agents trained using C3PO consistently achieve higher levels of reward than those trained with PPO-Lagrangian and TRPO-Lagrangian. As above, training is seen to be more stable and repeatable using our risksensitive method. Additional comparisons were generated with Constrained Policy Optimization (CPO; Achiam et al. (2017)), but are not shown in Figure 6 because they failed to maintain the cost levels of the other methods. For completeness, they are given in Appendix A.7.
187
+
188
+ ![](images/b480abf87ed601bfa9179249c5ec3dd7d87906197280fa6f22c1a694668b308f.jpg)
189
+ Figure 4: Average number of penalty events per episode (lower is better) over training for different learning approaches in three different environments. The horizontal lines reflect the cost levels reached by both PPO and TRPO training with zero penalty in Ray et al. (2019).
190
+
191
+ ![](images/1ea98699dfc873c29da3ef3b46e960c5a5e7468be941a26dfa56083a0f5b663d.jpg)
192
+ Figure 5: Testing reward distributions (including penalty; sampling turned off) for long training runs of three Safety Gym environments.
193
+
194
+ ![](images/590e3d8733c49cdf2b37370bfa39c5fd34856e12ec257bbfea7255b8db3a9693.jpg)
195
+ Figure 6: Comparison of positive contributions to episode reward during training for our approach (yellow) and Lagrangian methods configured to have the same cost level.
196
+
197
+ # 5 DISCUSSION
198
+
199
+ The analysis above allows for sample-based policy gradient estimates of a broad class of distributional objectives. Variance reduction measures were shown to enable efficient optimization based on these estimates (Appendix A.4). However, it was not seen to be the case that a given distributional objective could be most effectively optimized directly. Instead, the best results were generally obtained through moderate emphasis on improving negative training outcomes (Table 1).
200
+
201
+ To understand this behavior, consider the interplay of optimization and exploration in the training of cautious and aggressive agents. Cautious weightings continually emphasize the lower part of the outcome distribution, pushing that part of the distribution upward and adjusting behavior the most where it is most necessary. Once a part of the state space where the agent is deficient is adequately addressed, a different part of the state space takes its place. Policy entropy remains high because of the emphasis on problematic situations, ensuring adequate exploration. This trend continues with increasing $\eta$ , until the point where the agent begins to ignore high quality training outcomes too much. Conversely, aggressive weightings continually emphasize the best outcomes in the distribution. When an already strong outcome is given increased attention, it is likely to stay at the top. Hence agents trained with aggressive weightings tend to become myopic, obsessing over a fraction of the state space while neglecting the rest of it. They tend to explore inadequately and ironically fail to attain better top-end performance than more cautious weightings.
202
+
203
+ Given the consistent performance gains observed using our method, we propose that it represents a useful option for improving the performance and stability of on-policy learners. This should be particularly true in the presence of a meaningful trade-off between positive and negative reward terms and when there is significant stochasticity. While our approach does add an additional hyperparameter – the shaping constant $\eta$ – one value for that hyperparameter was seen to provide gains across all environments tested. While our approach does not provide for a direct choice of cost limit as constrained methods do, it is simpler to implement and was consistently seen to be more performant for the cost level it reached. It is also likely possible to use cautious weightings in conjunction with constrained RL, though this has not yet been investigated.
204
+
205
+ # 6 CONCLUSIONS
206
+
207
+ In this work, we proposed a risk-sensitive learning algorithm based on a policy gradient estimate for a broad class of distributional objectives. When configured to emphasize improvement in scenarios where the agent performs poorly, we found our method to compare favorably with existing unconstrained and constrained on-policy learners.
208
+
209
+ # REFERENCES
210
+
211
+ Josh Achiam. Openai spinning up: Proof for don’t let the past distract you. http://spinningup. openai.com/en/latest/spinningup/extra_pg_proof1.html, 2018.
212
+
213
+ Joshua Achiam, David Held, Aviv Tamar, and Pieter Abbeel. Constrained policy optimization. In Proceedings of the 34th International Conference on Machine Learning (ICML), pp. 22–31, 2017.
214
+
215
+ Dario Amodei, Chris Olah, Jacob Steinhardt, Paul Christiano, John Schulman, and Dan Mane.´ Concrete problems in AI safety. arXiv:1606.06565, 2016.
216
+
217
+ 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, jun 2013.
218
+
219
+ Marc G. Bellemare, Will Dabney, and Remi Munos. A distributional perspective on reinforcement ´ learning. In Proceedings of the 34th International Conference on Machine Learning (ICML), volume 70, pp. 449–458, 2017.
220
+
221
+ Yinlam Chow, Ofir Nachum, Aleksandra Faust, Mohammad Ghavamzadeh, and Edgar A. Due´nez- ˜ Guzman. Lyapunov-based safe policy optimization for continuous control. ´ CoRR, abs/1901.10031, 2019. URL http://arxiv.org/abs/1901.10031.
222
+
223
+ Will Dabney, Georg Ostrovski, David Silver, and Remi Munos. Implicit quantile networks for ´ distributional reinforcement learning. In Proceedings of the 35th International Conference on Machine Learning (ICML), volume 80, pp. 1096–1105, 2018a.
224
+
225
+ Will Dabney, Mark Rowland, Marc G. Bellemare, and Remi Munos. Distributional reinforcement ´ learning with quantile regression. In Proceedings of the 32nd AAAI Conference on Artificial Intelligence (AAAI), pp. 2892–2901, 2018b.
226
+
227
+ Jingliang Duan, Yang Guan, Shengbo Eben Li, Yangang Ren, Qi Sun, and Bo Cheng. Distributional soft actor-critic: Off-policy reinforcement learning for addressing value estimation errors. IEEE Transactions on Neural Networks and Learning Systems, pp. 1–15, 2021.
228
+
229
+ Javier Garc´ıa and Fernando Fernandez. A comprehensive survey on safe reinforcement learning. ´ Journal of Machine Learning Research, 16(42):1437–1480, 2015.
230
+
231
+ Daniel Kahneman and Amos Tversky. Prospect theory: An analysis of decision under risk. Econometrica, 47(2):263–291, 1979.
232
+
233
+ Dickson H. Leavens. Diversification of investments. Trusts and Estates, 80:469–473, 1945.
234
+
235
+ Xiaoteng Ma, Li Xia, Zhengyuan Zhou, Jun Yang, and Qianchuan Zhao. DSAC: Distributional soft actor critic for risk-sensitive reinforcement learning. arXiv:2004.14547, June 2020.
236
+
237
+ German I. Parisi, Ronald Kemker, Jose L. Part, Christopher Kanan, and Stefan Wermter. Continual lifelong learning with neural networks: A review. Neural Networks, 113:54–71, May 2019.
238
+
239
+ Lerrel Pinto, James Davidson, Rahul Sukthankar, and Abhinav Gupta. Robust adversarial reinforcement learning. In Proceedings of the 34th International Conference on Machine Learning (ICML), 2017.
240
+
241
+ L.A. Prashanth, Cheng Jie, Michael C. Fu, Steven I. Marcus, and Csaba Szepesvari. Cumulative ´ prospect theory meets reinforcement learning: Prediction and control. In Proceedings of the 33nd International Conference on Machine Learning (ICML), pp. 1406–1415, 2016.
242
+
243
+ John W. Pratt. Risk aversion in the small and in the large. Econometrica, 32:122–136, 1964.
244
+
245
+ Alex Ray, Joshua Achiam, and Dario Amodei. Benchmarking safe exploration in deep reinforcement learning. https://cdn.openai.com/safexp-short.pdf, 2019.
246
+
247
+ R. Tyrrell Rockafellar and Stanislav Uryasev. Optimization of conditional value-at-risk. Journal of Risk, 2:21–41, 2000.
248
+
249
+ John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel. High-dimensional continuous control using generalized advantage estimation. In Proceedings of the International Conference on Learning Representations (ICLR), 2016.
250
+
251
+ John Schulman, Sergey Levine, Philipp Moritz, Michael I. Jordan, and Pieter Abbeel. Trust region policy optimization. In Proceedings of the 32nd International Conference on Machine Learning (ICML), 2017a.
252
+
253
+ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv:1707.06347, 2017b.
254
+
255
+ Aviv Tamar, Yinlam Chow, Mohammad Ghavamzadeh, and Shie Mannor. Policy gradient for coherent risk measures. In Proceedings of the 28th International Conference on Neural Information Processing Systems (NeurIPS), pp. 1468–1476, 2015.
256
+
257
+ Amos Tversky and Daniel Kahneman. Advances in prospect theory: Cumulative representation of uncertainty. Journal of Risk and Uncertainty, 5(4):297–323, 1992.
258
+
259
+ Shaun S. Wang. A class of distortion operators for pricing financial and insurance risks. The Journal of Risk and Insurance, 67(1):15, March 2000.
260
+
261
+ Ronald J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning, 8(3):229–256, May 1992.
262
+
263
+ Congbin Wu and Yuanlie Lin. Minimizing risk models in Markov decision processes with policies depending on target values. Journal of Mathematical Analysis and Applications, 231:47–67, 1999.
264
+
265
+ Huan Zhang, Hongge Chen, Chaowei Xiao, Bo Li, Mingyan Liu, Duane Boning, and Cho-Jui Hsieh. Robust deep reinforcement learning against adversarial perturbations on state observations. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Proceedings of the 34th International Conference on Neural Information Processing Systems (NeurIPS), volume 33, pp. 21024–21037, 2020.
266
+
267
+ Junyu Zhang, Amrit Singh Bedi, Mengdi Wang, and Alec Koppel. Cautious reinforcement learning via distributional risk in the dual domain. IEEE Journal on Selected Areas in Information Theory, 2(2):611–626, 2021.
268
+
269
+ Han Zhong, Ethan X. Fang, Zhuoran Yang, and Zhaoran Wang. Risk-sensitive deep RL: Varianceconstrained actor-critic provably finds globally optimal policy. arXiv:2012.14098, 2020.
270
+
271
+ # A APPENDIX
272
+
273
+ # A.1 EVALUATION OF CROSS-TRAJECTORY TERMS IN POLICY GRADIENT
274
+
275
+ In this section, we first show that the cross-trajectory terms in our policy gradient estimate (6) have an expectation value of 0. We then argue that their removal leads to a policy gradient estimate with reduced variance.
276
+
277
+ Lemma 1. Cross-trajectory terms of the form $f ( \tau _ { i } , \mathbf { a } _ { j , t } , \mathbf { s } _ { j , t } ) = u ( r ( \tau _ { i } ) ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } )$ , where $i \neq j$ , do not contribute to the gradient estimate (6) in expectation.
278
+
279
+ Proof. First, note that
280
+
281
+ $$
282
+ \begin{array} { r l } & { E _ { \tau _ { i } \sim p _ { \theta } ( \tau ) , \tau _ { j } \sim p _ { \theta } ( \tau ) } f ( \tau _ { i } , \mathbf { a } _ { j , t } , \mathbf { s } _ { j , t } ) = E _ { \tau _ { i } \sim p _ { \theta } ( \tau ) , \tau _ { j } \sim p _ { \theta } ( \tau ) } u ( r ( \tau _ { i } ) ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) } \\ & { \qquad = E _ { \tau _ { i } \sim p _ { \theta } ( \tau ) } \Bigg [ u ( r ( \tau _ { i } ) ) E _ { \tau _ { j } \sim p _ { \theta } ( \tau ) } \Bigg [ \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) \Bigg | \tau _ { i } \Bigg ] \Bigg ] } \end{array}
283
+ $$
284
+
285
+ Then consider the innermost expectation:
286
+
287
+ $$
288
+ \begin{array} { r l } { \mathbb { E } _ { \tau _ { j } \sim \mathbb { P } _ { \theta } ( \tau ) } \Bigg [ \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) \Bigg | \tau _ { i } \Bigg ] = \displaystyle \int _ { \mathbf { s } _ { j , t } , \mathbf { a } _ { j , t } } p ( \mathbf { s } _ { j , t } , \mathbf { a } _ { j , t } | \tau _ { \theta } , \tau _ { j } ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) d \mathbf { a } _ { j , t } d \mathbf { s } _ { j , t } } \\ { = \displaystyle \int _ { \mathbf { s } _ { j , t } } p ( \mathbf { s } _ { j , t } | \pi _ { \theta } , \tau _ { i } ) \int _ { \mathbf { a } _ { j , t } } \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) d \mathbf { a } _ { j , t } d \mathbf { s } _ { j , t } } \\ { = \displaystyle \int _ { \mathbf { s } _ { j , t } } p ( \mathbf { s } _ { j , t } | \pi _ { \theta } , \tau _ { i } ) \int _ { \mathbf { a } _ { j , t } } \nabla _ { \theta } \pi _ { \theta } ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) d \mathbf { a } _ { j , t } d \mathbf { s } _ { j , t } } \\ { = \displaystyle \int _ { \mathbf { s } _ { j , t } } p ( \mathbf { s } _ { j , t } | \pi _ { \theta } , \tau _ { i } ) \nabla _ { \theta } \int _ { \mathbf { a } _ { j , t } } \pi ( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } ) d \mathbf { a } _ { j , t } d \mathbf { s } _ { j , t } } \\ { = \displaystyle \int _ { \mathbf { s } _ { j , t } } p ( \mathbf { s } _ { j , t } | \pi _ { \theta } , \tau _ { i } ) \nabla _ { \theta } \log \left( \mathbf { a } _ { j , t } | \mathbf { s } _ { j , t } \right) d \mathbf { a } _ { j , t } d \mathbf { s } _ { j , t } } \\ = \displaystyle \int _ { \mathbf { s } _ { j , t } , | \pi _ { \theta } , \tau _ { i } | } \end{array}
289
+ $$
290
+
291
+ To see why removal of cross-trajectory terms leads to reduced variance, consider that the full expression (6) may be written as the sum of terms of the form $\begin{array} { r l } { f ( \tau _ { i } , \mathbf { a } _ { j , t } , \mathbf { s } _ { j , t } ) } & { { } = } \end{array}$ $u ( r ( \tau _ { i } ) \bar { ) } _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { j , t } , \bar { \mathbf { s } _ { j , t } } )$ . Its variance is the sum of the total variance from terms where $i = j$ , the total variance from terms where $i \neq j$ , and a term proportional to the covariance of these two totals. However, because each term in the covariance contains at least one trajectory that differs from the rest, the above reasoning may be applied to argue that the covariance is 0. Hence, the removal of the cross-trajectory terms lowers the variance of the policy gradient estimate by the variance of the cross-trajectory terms.
292
+
293
+ A.2 INTRODUCTION OF STATIC AND STATE-DEPENDENT BASELINES
294
+
295
+ Lemma 2. A static baseline of the utility may be added to the policy gradient estimate (9) without introduction of bias.
296
+
297
+ Proof. The additional term is 0 in expectation as
298
+
299
+ $$
300
+ \begin{array} { r l } & { \mathbb { E } _ { \tau _ { \tau } \sim p _ { \theta } ( \tau ) } \left[ b \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { i } , | \mathbf { s } _ { i } , t ) \right] } \\ & { \qquad = b \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \int _ { \mathbf { s } _ { i , t } , \mathbf { a } _ { i } , t } p ( \mathbf { s } _ { i , t } , \mathbf { a } _ { i } , t | \pi _ { \theta } ) \Bigg [ \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { i } , | \mathbf { s } _ { i } , t ) \Bigg ] d \mathbf { a } _ { i , t } d \mathbf { s } _ { i , t } } \\ & { \qquad = b \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \int _ { \mathbf { s } _ { i , t } } p ( \mathbf { s } _ { i , t } | \pi _ { \theta } ) \int _ { \mathbf { a } _ { i , t } } \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i } , t ) d \mathbf { a } _ { i , t } d \mathbf { s } _ { i , t } } \\ & { \qquad = b \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \int _ { \mathbf { s } _ { i , t } } p ( \mathbf { s } _ { i , t } | \pi _ { \theta } ) \nabla _ { \theta } \int _ { \mathbf { a } _ { i , t } } \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) d \mathbf { a } _ { i , t } d \mathbf { s } _ { i , t } } \\ & \qquad = b \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \int _ { \mathbf { s } _ { i , t } } p ( \mathbf { s } _ { i , t } | \pi _ { \theta } ) \nabla _ { \theta } \mathbf { 1 } _ { i , t } d \end{array}
301
+ $$
302
+
303
+ The contribution of the weight terms $\begin{array} { r } { ( w ^ { \prime } ( \frac { i } { n } ) + w ^ { \prime } ( \frac { i - 1 } { n } ) ) } \end{array}$ may be pulled out of the integral between the first and second line because of its independence on both state and action. This term is fixed for a given trajectory by the rank of its reward amongst the rewards accumulated on all trajectories in the current batch.
304
+
305
+ In our variance reduction experiments (Appendix A.4), the “Base” agent uses $b$ equal to the mean of full-episode utility in the current batch.
306
+
307
+ As described in Section 3.3, we may further adjust the policy gradient estimate through introduction of per-step utilities. In this case, we may justify the use of a state-dependent baseline through the following.
308
+
309
+ Lemma 3. A state-dependent baseline $V _ { \phi } ( \mathbf { s } _ { i , t } )$ may be added to the policy gradient estimate (9) without introduction of bias, if per-step utilities are assumed.
310
+
311
+ Proof. The additional term is 0 in expectation as
312
+
313
+ $$
314
+ \begin{array} { r l } & { \mathbb { E } _ { \tau _ { i } \sim p _ { 0 } ( \tau ) } \Big [ \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Big ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) V _ { \phi } ( \mathbf { s } _ { i , t } ) \Big ] } \\ & { \qquad = \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \int _ { \mathbf { s } _ { i , t } , \mathbf { s } _ { i , t } } p ( \mathbf { s } _ { i , t } , \mathbf { a } _ { i , t } | \pi _ { \theta } ) V _ { \phi } ( \mathbf { s } _ { i , t } ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) d \mathbf { a } _ { i , t } d \mathbf { s } _ { i , t } } \\ & { \qquad = \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \int _ { \mathbf { s } _ { i , t } } p ( \mathbf { s } _ { i , t } | \pi _ { \theta } ) V _ { \phi } ( \mathbf { s } _ { i , t } ) \int _ { \mathbf { a } _ { i , t } } \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) \nabla _ { \theta } \log \pi _ { \theta } ( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } ) d \mathbf { a } _ { i , t } } \\ & { \qquad = \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \int _ { \mathbf { s } _ { i , t } } p ( \mathbf { s } _ { i , t } | \pi _ { \theta } ) V _ { \phi } ( \mathbf { s } _ { i , t } ) \nabla _ { \theta } \left( \mathbf { a } _ { i , t } | \mathbf { s } _ { i , t } \right) d \mathbf { a } _ { i , t } d \mathbf { s } _ { i , t } } \\ & \qquad = \Bigg ( w ^ { \prime } \left( \frac { i } { n } \right) + w ^ { \prime } \left( \frac { i - 1 } { n } \right) \Bigg ) \int _ { \mathbf { s } _ { i , t } } p ( \mathbf s \end{array}
315
+ $$
316
+
317
+ The rationale for pulling the $w ^ { \prime }$ terms out of the integral is the same as in Lemma 2.
318
+
319
+ Finally, we note that the ability to pull the contribution of the weight terms $\begin{array} { r } { ( w ^ { \prime } ( \frac { i } { n } ) + w ^ { \prime } ( \frac { i - 1 } { n } ) ) } \end{array}$ to the front of Equation 11 allows us to formulate advantage estimates based on per-step utility. Bootstrap estimates of the value function $V _ { \phi } ( \mathbf { s } _ { i , t } )$ and Generalized Advantage Estimation as in Schulman et al. (2016) can be conducted exactly as they are in standard on-policy learning, if rewards are replaced by per-step utilities.
320
+
321
+ # A.3 ADDITIONAL INFORMATION ON SAFETY GYM
322
+
323
+ As mentioned in Section 4, we chose to evaluate our approach using the OpenAI Safety Gym (Ray et al., 2019). The choice was governed by our desire to test in conditions with clear cost-benefit trade-offs, significant stochasticity, adequate complexity, and available benchmarks. While our methods are not limited to particular task types or observation/action spaces, we found Safety Gym to be suitable for exploring their potential.
324
+
325
+ The six environments chosen were the most obstacle-rich of the publicly available environments that used the “Point” and “Car” robots. The Point robot is constrained to the 2D plane and has two control dimensions: one for moving forward/backward and one for turning. The Car robot also has two control dimensions, corresponding to independently actuated parallel wheels. It has a freely rotating wheel and, while it is not constrained to the 2D plane, typically remains in it. While we expect our results to extend to the remaining default robot, “Doggo”, we did not experiment with it because of the order of magnitude longer training times it exhibited in Ray et al. (2019).
326
+
327
+ Several types of obstacles and tasks were present in the environments we evaluated. In all cases, the robot is given a fixed amount of time (1000 steps) to complete the prescribed task as many times as possible and is motivated by both sparse and dense reward contributions. In the “Goal” environments, the robot must navigate to a series of randomly-assigned goal positions, with a new target being assigned as soon as a goal is reached. In the “Button” environments, the robot must reach and press a sequence of goal buttons while avoiding other buttons. In the “Push” task, the robot must push a box to a series of goal positions. The set of obstacles are different for each task; among the three environments there are a total of five different constraint elements (hazards, vases, incorrect buttons, pillars, and gremlins), each with different dynamics. See Ray et al. (2019) for further details.
328
+
329
+ # A.4 EMPIRICAL PERFORMANCE OF VARIANCE REDUCTION MEASURES
330
+
331
+ To gauge the impact of the variance reduction techniques outlined in Section 3.3, we evaluated their performance in maximizing the value function of Cumulative Prospect Theory (Tversky & Kahneman, 1992). As mentioned in Section 3.1, this function has two integrals of the form (2):
332
+
333
+ ![](images/e4fc7555f5d13748a1481c4e76a2449b69e4d2ae8e481a159d249b1af8716792.jpg)
334
+ Figure 7: Impact of variance reduction measures on optimization of the CPT value function. Here “Base” refers to the risk-sensitive policy gradient estimate (10), “UTG” adds utility-to-go and a neural network baseline (11), “GAE” incorporates generalized advantage estimation, and “TR” implements trust regions via clipping. Shading represents the variation over five random seeds.
335
+
336
+ $$
337
+ \begin{array} { l } { \displaystyle { J ( \theta ) = - \int _ { - \infty } ^ { \infty } u ^ { - } ( r ( \tau ) ) \frac { d } { d r ( \tau ) } \bigg ( w ^ { - } ( P _ { \theta } ( r ( \tau ) ) ) \bigg ) d r ( \tau ) } } \\ { \displaystyle { + \int _ { - \infty } ^ { \infty } u ^ { + } ( r ( \tau ) ) \frac { d } { d r ( \tau ) } \bigg ( - w ^ { + } ( 1 - P _ { \theta } ( r ( \tau ) ) ) \bigg ) d r ( \tau ) } } \end{array}
338
+ $$
339
+
340
+ In Tversky & Kahneman (1992), the utility functions are computed relative to a reference point and reflect the tendency of humans to be more risk-averse in the presence of gains than in the presence of losses. The weight functions $\{ w ^ { + } , w ^ { - } \}$ model our inclination to emphasize the best and worst possible outcomes in our decision-making.
341
+
342
+ More specifically, in these experiments we used the piecewise utility functions $u ^ { + } ( r ) = H ( r -$ $r _ { 0 } ) ( r - r _ { 0 } ) ^ { \sigma }$ and $u ^ { - } = \lambda H ( r _ { 0 } - r ) ( r _ { 0 } - r ) ^ { \sigma }$ with static reference $r _ { 0 } = 1 0$ , $\sigma = 0 . 8 8$ , and $\lambda = 2 . 2 5$ . The weight function $\begin{array} { r } { w ( p ) = \frac { p ^ { \eta } } { ( p ^ { \eta } + ( 1 - p ) ^ { \eta } ) ^ { \frac { 1 } { \eta } } } } \end{array}$ was used, where $\eta = 0 . 6 1$ for $r < r _ { 0 }$ and $\eta = 0 . 6 9$ for $r \geq r _ { 0 }$ . Four methods were evaluated, incorporating progressive amounts of variance reduction:
343
+
344
+ • Base: Risk-sensitive policy gradient with a static baseline (10)
345
+
346
+ • UTG: Base with utility-to-go and a neural network baseline (11)
347
+
348
+ • GAE: UTG with generalized advantage estimation ((13) without clipping)
349
+
350
+ • TR: GAE with trust regions ((13) with clipping (14))
351
+
352
+ As shown in Figure 7, the incorporation of these techniques increased the sample efficiency of the CPT value optimization significantly. Consequently, we used the full complement (TR) in all other experiments.
353
+
354
+ # A.5 DIFFERING OBJECTIVES: ADDITIONAL RESULTS
355
+
356
+ Below we include results for all environments for the experiments described in Section 4.1.
357
+
358
+ ![](images/81ec3e345b1af717ace27eb04a70b8099728900fe08a0cfddaef39054e279403.jpg)
359
+ Figure 8: Impact of different distributional objectives in remaining two environments of initial trials. The shading reflects the standard deviation associated with running over 5 random seeds. Left: Net reward (positive reward minus penalty) throughout learning. Middle: Average number of cost events per episode during training (lower is better). Right: Agent outcome distribution in testing (i.e., with sampling turned off).
360
+
361
+ ![](images/59f9e15291612540513e9a339525bfe082627947977ab0f09ef0a60afb6db7e4.jpg)
362
+ Figure 9: Agent outcome distributions across trials run over increasingly cautious ( $\dot { \eta }$ increasing) objectives. Distributions correspond to results shown in Table 1.
363
+
364
+ In addition, we note the trend of policy entropies with different distributional objectives. In general, more cautious weightings maintain higher entropy for longer than more aggressive weightings. Note that these plots represent an upper bound because they do not account for action clipping by the environment; see Ray et al. (2019) for details.
365
+
366
+ ![](images/00ab35e3a5313b6d13471e09bf379ea0297414422ff0001e0a1ee8e3d079506d.jpg)
367
+ Figure 10: Policy entropy progression during training for three environments. Shading reflects the observed variation over 5 random seeds.
368
+
369
+ # A.6 ADDITIONAL COMPARISONS WITH UNCONSTRAINED METHODS
370
+
371
+ Below are plots of average episode reward and average number of episode cost events throughout training for the remainder of the environments on which we conducted long runs (Section 4.2). Also included are histograms of testing performance for those runs.
372
+
373
+ ![](images/4e0bde6c535c84b3123dd3fcc102743d54ee7eb04ce8ee2c18002eb2e37c1a66.jpg)
374
+ Figure 11: Average episode reward (including penalty) over training for different unconstrained learning approaches in remaining three environments.
375
+
376
+ ![](images/d1c2fdfe7eb2dab990a76db14e17c5a4577c034dc9ac5e533dc1af2133f48d77.jpg)
377
+ Figure 12: Average number of cost events per episode (lower is better) over training for different unconstrained learning approaches in remaining three environments. As above, the “zero-penalty” line refers to the level reached by PPO and TRPO trained with no penalty in the reward (Ray et al., 2019).
378
+
379
+ ![](images/92c7a36dbcab49314f44bc5df77ef04e277e3258109d0f0552b1bdccdf5113e3.jpg)
380
+ Figure 13: Testing reward distributions (including penalty; sampling turned off) for long training runs in the remaining three Safety Gym environments. In five of the six environments, C3PO with $\eta = 0 . 7 5$ provides tangible benefit. A smaller $\eta$ is likely required to improve performance on CarPush2.
381
+
382
+ # A.7 ADDITIONAL COMPARISONS WITH CONSTRAINED METHODS
383
+
384
+ As mentioned in Section 4.2, we compared the performance of C3PO with constrained methods by setting the cost limit of the constrained methods to match the cost level attained by C3PO. Here we provide
385
+
386
+ • the positive reward plots for the remaining three Safety Gym environments studied, • the cost plots for each of the six environments, and
387
+
388
+ • all plots for Constrained Policy Optimization (CPO; Achiam et al. (2017)).
389
+
390
+ The intent of the cost plots of Figure 15 is to show rough consistency between the cost levels of our approach and Lagrangian methods configured to have the same cost limit. This is verified, but other trends should be noted. First, while the Lagrangian-based methods typically follow the cost constraint well, they cannot satisfy it in each batch. Second, our approach tends to have comparable or lower cost rates throughout training. This safe exploration metric, defined in Ray et al. (2019), refers to the average cost per episode over all of training up to a given point.
391
+
392
+ Results related to Constrained Policy Optimization (CPO; Achiam et al. (2017)) are included here but not in the main text because, consistent with (Ray et al., 2019), we were not able to configure CPO to respect the cost levels of the other constrained methods. Here we show the cost levels reached by CPO compared with C3PO (Figure 16) as well as a comparison of the average episode rewards of the two (Figure 17). For the latter, we employed the penalty scaling used by C3PO to enable a fair comparison.
393
+
394
+ ![](images/24de7d6235c5be2e5e1dc0b014bc5127dafbe58f7faa61aa080822bd5d15716a.jpg)
395
+ Figure 14: Comparison of positive contributions to episode reward during training for our approach (yellow) and Lagrangian methods configured to have the same cost level. The plots for the other three environments are shown in Figure 6.
396
+
397
+ ![](images/0a1c8a5e024f2f99938d54a3a75070e0d0ca8e8cf1be356e2020459e46f946b6.jpg)
398
+ Figure 15: Comparison of cost incurred (lower is better) during training for our approach and Lagrangian methods configured to have the same cost level. As intended, cost levels are consistently matched between the methods. As above, the “zero-penalty” line refers to the level reached by PPO and TRPO trained with no penalty in the reward (Ray et al., 2019).
399
+
400
+ ![](images/6423517191387cafba4cc4f1f5f46b465712c3f21dbd55084697f87212ff8ad3.jpg)
401
+ Figure 16: Comparison of cost incurred (lower is better) during training for our method and Constrained Policy Optimization (Achiam et al., 2017) configured to have a matching cost limit. Results are consistent with Ray et al. (2019). As above, the “zero-penalty” line refers to the level reached by unconstrained PPO and TRPO trained with no penalty in the reward (Ray et al., 2019).
402
+
403
+ ![](images/c52be513072a68cb4cd41cf8eaae3878b94349cfe8d6349a99d42264d32f3dfd.jpg)
404
+ Figure 17: Comparison of average episode reward (including penalty) for C3PO and CPO.
405
+
406
+ # A.8 SUPPLEMENTARY MATERIALS
407
+
408
+ The code used to produce these results is included in our Supplementary Materials.
md/dev/AXDNM76T1nc/AXDNM76T1nc.md ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Video PreTraining (VPT): Learning to Act by Watching Unlabeled Online Videos
2
+
3
+ Bowen Baker⇤† bowen@openai.com
4
+
5
+ Ilge Akkaya⇤† ilge@openai.com
6
+
7
+ Peter Zhokhov⇤† peterz@openai.com
8
+
9
+ Joost Huizinga⇤† joost@openai.com
10
+
11
+ Jie Tang⇤† jietang@openai.com
12
+
13
+ Adrien Ecoffet⇤† adrien@openai.com
14
+
15
+ Brandon Houghton⇤† brandon@openai.com
16
+
17
+ Raul Sampedro⇤† raulsamg@gmail.com
18
+
19
+ Jeff Clune⇤†‡ jclune@gmail.com
20
+
21
+ # Abstract
22
+
23
+ Pretraining on noisy, internet-scale datasets has been heavily studied as a technique for training models with broad, general capabilities for text, images, and other modalities. 1–6 However, for many sequential decision domains such as robotics, video games, and computer use, publicly available data does not contain the labels required to train behavioral priors in the same way. We extend the internet-scale pretraining paradigm to sequential decision domains through semi-supervised imitation learning wherein agents learn to act by watching online unlabeled videos. Specifically, we show that with a small amount of labeled data we can train an inverse dynamics model accurate enough to label a huge unlabeled source of online data – here, online videos of people playing Minecraft – from which we can then train a general behavioral prior. Despite using the native human interface (mouse and keyboard at $2 0 \mathrm { H z }$ ), we show that this behavioral prior has nontrivial zeroshot capabilities and that it can be fine-tuned, with both imitation learning and reinforcement learning, to hard-exploration tasks that are impossible to learn from scratch via reinforcement learning. For many tasks our models exhibit humanlevel performance, and we are the first to report computer agents that can craft diamond tools, which can take proficient humans upwards of 20 minutes (24,000 environment actions) of gameplay to accomplish.
24
+
25
+ # 1 Introduction
26
+
27
+ Work in recent years has demonstrated the efficacy of pretraining large and general foundation models 7 on noisy internet-scale datasets for use in downstream tasks in natural language 1–4, computer vision, 5,6,8 and multi-task models. 9 For sequential decision domains (e.g. robotics, game playing, and computer usage) where agents must repeatedly act within an environment, a wealth of data also exists on the web; however, most of this data is in the form of unlabeled video (i.e. without the actions taken at each frame), making it much less straightforward to train a behavioral prior in these domains than it is in e.g. natural language. In a few rare settings, such as Chess, Go, and StarCraft, there already exist large datasets with action labels from various online platforms that researchers have used for imitation learning. 10,11 When large labeled datasets do not exist, the canonical strategy for training capable agents is reinforcement learning (RL), 12 which can be sample inefficient and expensive for hard-exploration problems. 13–19 Many virtual tasks, e.g. navigating websites, using Photoshop, booking flights, etc., can be very hard to learn with RL and do not have large, commonly available sources of labeled data. 20,21 In this paper, we seek to extend the paradigm of training large, general-purpose foundation models to sequential decision domains by utilizing freely available internet-scale unlabeled video datasets with a simple semi-supervised imitation learning method. We call this method Video PreTraining (VPT) and demonstrate its efficacy in the domain of Minecraft.
28
+
29
+ Existing semi-supervised imitation learning methods aim to learn with few or no explicit action labels; however, they generally rely on the policy’s ability to explore the environment throughout training, making them susceptible to exploration bottlenecks. 22–26 Furthermore, most prior semi-supervised imitation learning work was tested in the relatively low data regime; because we experiment with far more data ( $\mathord { \sim } 7 0 \mathrm { k }$ hours of unlabeled video), we hypothesize that we can achieve good performance with a much simpler method, a trend that has proven true for pretraining in other modalities such as text. 1 In particular, given a large but unlabeled dataset, we propose generating pseudo-labels by gathering a small amount of labeled data to train an inverse dynamics model (IDM) that predicts the action taken at each timestep in a video. Behavioral cloning (BC) can require a large amount of data because the model must learn to infer intent and the distribution over future behaviors from only past observations. In contrast, the inverse dynamics modeling task is simpler because it is non-causal, meaning it can look at both past and future frames to infer actions. In most settings, environment mechanics are far simpler than the breadth of human behavior that can take place within the environment, suggesting that non-causal IDMs could require far less data to train than causal BC models. Using pseudo-labels generated from the IDM, we then train a model to mimic the distribution of behavior in the previously unlabeled dataset with standard behavioral cloning at scale, which does not require any model rollouts and thus does not suffer from any potential exploration bottlenecks in the environment. Finally, we show we can fine-tune this model to downstream tasks with either behavioral cloning or reinforcement learning.
30
+
31
+ We chose to test our method in Minecraft because it (a) is one of the most actively played games in the world27 and thus has a wealth of online video data, (b) is an open-ended sandbox game with an extremely wide variety of potential things to do, build, and collect, making our results more applicable to real-world applications such as computer usage, which also tends to be varied and open-ended, and (c) has already garnered interest by the RL community as a research domain due to its complexity and correspondingly difficult exploration challenges. 28–32 In this work we use the native human interface for Minecraft so that we can (1) most accurately model the human behavior distribution and reduce domain shift between video data and the environment, (2) make data collection easier by allowing our human contractors to play the game without modification, and (3) eliminate the need to hand-engineer a custom interface for models to interact with the environment. This choice means that our models play at 20 frames per second and must use a mouse and keyboard interface to interact with human GUIs for crafting, smelting, trading, etc., including dragging items to specific slots or navigating the recipe book with the mouse cursor (Fig. 1). Compared to prior work in Minecraft that uses a lower frame rate and constructs crafting and attacking macros, 31,33–35 using the native human interface drastically increases the environment’s exploration difficulty, making most simple tasks near impossible with RL from scratch. Even the simple task of gathering a single wooden log while already facing a tree takes 60 consecutive attack actions with the human interface, meaning the chance for a naive random policy to succeed is $1 / 2 ^ { 6 0 }$ . While this paper shows results in Minecraft only, the VPT method is general and could be applied to any domain.
32
+
33
+ ![](images/9ecaae8777654a20f20ae479e79fd1eb563c824f512fc612e394f000c310a23c.jpg)
34
+ Figure 1: Example Minecraft crafting GUI. Agents use the mouse and keyboard to navigate menus and drag and drop items.
35
+
36
+ In Section 4 we show that the VPT foundation model has nontrivial zero-shot performance, accomplishing tasks impossible to learn with RL alone, such as crafting planks and crafting tables (tasks requiring a human proficient in Minecraft a median of 50 seconds or ${ \sim } 9 7 0 $ consecutive actions). Through fine-tuning with behavioral cloning to smaller datasets that target more specific behavior distributions, our agent is able to push even further into the technology tree, crafting stone tools (taking a human a median of 2.3 minutes or ${ \sim } 2 7 9 0$ actions). Finally, fine-tuning via RL produces the most dramatic improvements: our agent is able to craft diamond tools, an unprecedented result in Minecraft made even more challenging by using the native human interface. This task requires a proficient human a median upwards of 20 minutes or ${ \sim } 2 4 0 0 0$ actions. The main contributions of this work are (1) we are the first to show promising results applying semi-supervised imitation learning to extremely large, noisy, and freely available video datasets for sequential decision domains, (2) we show that such pretraining plus fine-tuning enables agents to solve tasks that were otherwise impossible to learn, (3) we show that labeled contractor data is far more efficiently used within the VPT method than it would be by directly training a foundation model from it and (4) we open source our contractor data, trained model weights, and Minecraft environment for future research into learning to act via semi-supervised imitation learning at scale.
37
+
38
+ # 2 Preliminaries and Related Work
39
+
40
+ Imitation learning methods 36–39 seek to construct a policy that accurately models the distribution of behavior in some dataset $D = \{ ( o _ { i } , a _ { i } ) \}$ , $i \in \{ 1 . . . N \}$ of action-observation pairs. In order to roll out these policies in an environment, they must be causal, meaning they condition on observations from the current timestep $t$ and past timesteps only, i.e. $\pi \sim p ( \bar { a } _ { t } | o _ { 1 } . . . o _ { t } )$ . Imitation learning is simplest when demonstrations are labeled with corresponding actions. Imitating labeled trajectories has seen success in aerial vehicles, 40,41 self-driving cars, 42,43 board games, 10,44 and video games. 11,45
41
+
42
+ When labeled demonstrations are not available, standard behavioral cloning will not work; however, there is a large body of work in imitating behavior from unlabeled demonstrations. 23 For instance, GAIL24 constructs an adversarial objective incentivizing the trained policy to exhibit behaviors indistinguishable from those in the target dataset. Edwards et al. 46 propose to first learn a latent policy using unlabeled demonstrations and then map the learned latent actions to real actions using environment interaction. Peng et al. 47 use motion-capture methods to track agent positions in videos and then train RL agents to match these waypoints. Similarly, Behbahani et al. 48 and Aytar et al. 49 task a RL agent to match waypoints; however, their waypoints are embeddings from unsupervised feature learning models. Pathak et al. 50 and Nair et al. 51 train goal conditioned policies to take actions that move towards expert-provided goal states expressed as high dimensional visual waypoints. Most similar to our own work, Torabi et al. 25 simultaneously train (1) an inverse dynamics model (IDM), 52 which aims to uncover the underlying action between timesteps given observations of past and future timesteps, e.g. $p _ { \mathrm { I D M } } ( a _ { t } | o _ { t } , o _ { t + 1 } )$ , and (2) a behavioral cloning (BC) model on trajectories of observations labeled with the IDM. Data to train the IDM is collected by rolling out the BC model in the target environment such that both models improve in tandem. However, at any point in training if there are sequences in the dataset that the IDM performs poorly on, it requires that the BC model perform those or similar sequences in order for the IDM to improve and correctly label them. Therefore, if the BC model does not explore efficiently, it could severely slow down learning. In order to avoid this potential issue we opted for a simpler two-stage approach: we first train an IDM on a small number of labeled trajectories collected from human contractors (they play the game as would normally as we record their keypresses and mouse movements). Because human contractors reach most relevant parts of the state space, we can hold the IDM fixed throughout BC training.
43
+
44
+ Compared to most previous work in semi-supervised imitation learning, we experiment in the much more complex and open-ended environment of Minecraft. Minecraft is a voxel-based 3D video game that, due its popularity and wide variety of mechanics, has attracted a vast amount of RL research. 28,29,31–35,53–61 A large body of work focuses on small, custom-made Minecraft worlds with tasks such as navigation, 54,61 block placing, 55,56 instruction following, 59,60 combat, 57 and others. 29,32,58 Work operating in the massive, randomly generated environments of Minecraft itself has included hill climbing, 53 automated curriculum learning31 and, most closely related to the RL experiments presented in Sec. 4.4, diamond mining. 28,33–35 However, to the best of our knowledge, there is no published work that operates in the full, unmodified human action space, which includes drag-and-drop inventory management and item crafting.
45
+
46
+ # 3 Methods
47
+
48
+ Inverse Dynamics Models (IDM) VPT, illustrated in Figure 2, requires we first collect a small amount of labeled contractor data with which to train an inverse dynamics model $p _ { \mathrm { I D M } } ( a _ { t } | o _ { 1 \ldots T } )$
49
+
50
+ ![](images/064a1527f9fa1ec271241672e70e73bab60b52c51f73a35ec94e5f1f718ad9c6.jpg)
51
+ Figure 2: Video Pretraining (VPT) Method Overview.
52
+
53
+ which seeks to minimize the negative log-likelihood of an action at timestep $t$ given a trajectory of $T$ observations $o _ { t } ~ : ~ t \in [ 1 . . . T ]$ . In contrast to an imitation learning policy, the IDM can be non-causal, meaning its prediction for $a _ { t }$ can be a function of both past and future events, i.e. $o _ { t ^ { \prime } > t }$ . Compared to the behavioral cloning objective of modeling the distribution of human intent given past frames only, we hypothesize that inverting environment dynamics is easier and more data efficient to learn. Indeed, Sec. 4.1 will show that the IDM objective is much easier to learn, and furthermore Sec. 4.6 will show that with very little labeled data (as few as 100 hours) we can train a fairly accurate IDM. This IDM can be used to label online videos, providing the large amount of data required for the harder task of behavioral cloning. See appendices D and B for IDM training and data collection details.
54
+
55
+ Data Filtering We gather a large dataset of Minecraft videos by searching the web for related keywords (Appendix A). Online videos often (1) include overlaid artifacts, such as a video feed of the player’s face, channel logos, watermarks, etc., (2) are collected from platforms other than a computer with different gameplay, or (3) are from different game modes, e.g. in Minecraft we only want "survival mode" where players start from scratch and must gather or craft all their items. We call data “clean” if it does not contain visual artifacts and is from survival mode, and call all other data “unclean.” With enough data, a large enough model, and enough training compute, a BC model trained on both unclean and clean videos would likely still perform well in a clean Minecraft environment. However, for simplicity and training compute efficiency, we choose to filter out unclean segments of video (note that a video may contain both clean and unclean segments). We do this by training a model to filter out unclean segments using a small dataset (8800) of images sampled from online videos labeled by contractors as clean or unclean. We did not tune this process as it is fairly standard; see Appendix A.2 for more details and ablations showing data cleaning is beneficial.
56
+
57
+ VPT Foundation Model We train a foundation model with standard behavioral cloning, i.e. minimizing the negative log-likelihood of actions predicted by the IDM on clean data. For a particular trajectory of length $T$ we minimize
58
+
59
+ $$
60
+ \operatorname* { m i n } _ { \theta } \sum _ { t \in [ 1 \ldots T ] } - \log \pi _ { \theta } ( a _ { t } | o _ { 1 } , \ldots , o _ { t } ) , { \mathrm { w h e r e ~ } } a _ { t } \sim p _ { \mathrm { I D M } } ( a _ { t } | o _ { 1 } , \ldots , o _ { t } , \ldots , o _ { T } )
61
+ $$
62
+
63
+ As we will see in the following sections, this model exhibits nontrivial zero-shot behavior and can be fine-tuned with both imitation learning and RL to perform even more complex skills.
64
+
65
+ # 4 Results
66
+
67
+ # 4.1 Performance of the Inverse Dynamics Model
68
+
69
+ The IDM architecture is comprised primarily of a temporal convolution layer, a ResNet 63 image processing stack, and residual unmasked attention layers, from which the IDM simultaneously predicts keypresses and mouse movements (see Appendix D for IDM architecture and training details). A key hypothesis behind our work is that IDMs can be trained with a relatively small amount of labeled data. While more data improves both mouse movement and keypress predictions, our best IDM trains on only 1962 hours of data (compared to the $\mathrm { \sim } 7 0 \mathrm { k }$ hours of clean data we collected from the internet) and achieves $9 0 . 6 \%$ keypress accuracy and a $0 . 9 7 ~ R ^ { 2 }$ for mouse movements evaluated on a held-out validation set of contractor-labeled data (Figure 3 left).
70
+
71
+ ![](images/4b3ea22386575829558b307187db5f20ebab1ca9a8165026d52849f357087422.jpg)
72
+ Figure 3: (Left) IDM keypress accuracy and mouse movement $R ^ { 2 }$ (explained variance 62) as a function of dataset size. (Right) IDM vs. behavioral cloning data efficiency.
73
+
74
+ Figure 3 (right) validates our hypothesis that IDMs are far more data efficient than BC models, likely because inverting environment mechanics is far easier than modeling the entire distribution of human behavior. The IDM is two orders of magnitude more data efficient than a BC model trained on the same data and improves more quickly with more data. This evidence supports our hypothesis that it is more effective to use contractor data within the VPT pipeline by training an IDM than it is to train a foundation model from contractor data directly (Sections 4.5 and 4.6 provide additional evidence). Due to their data efficiency, training an IDM uses a negligible fraction of the overall compute needed to train a VPT model.
75
+
76
+ # 4.2 VPT Foundation Model Training and Zero-Shot Performance
77
+
78
+ ![](images/34a95ee247846f0d6edcf6bdccdb1ad4fe749757d92015a2c7b77655f520b49f.jpg)
79
+ Figure 4: (Left) Training and validation loss on the web_clean internet dataset with IDM pseudolabels, and loss on the main IDM contractor dataset, which has ground-truth labels but is out-ofdistribution (see text). (Right) Amount a given item was collected per episode averaged over 2500 60-minute survival episodes as a function of training epoch, shaded with the standard error of the mean. Basic mining refers to collection of dirt, gravel, or sand (all materials that can be gathered without tools). Logs are obtained by repeatedly hitting trees for three seconds, a difficult feat for an RL agent to achieve as we show in Sec. 4.4. Planks can be crafted from logs, and crafting tables crafted from planks. Crafting requires using in-game crafting GUIs, and proficient humans take a median of 50 seconds (970 consecutive actions) to make a crafting table.
80
+
81
+ We now explore the emergent behavior learned by a behavioral cloning policy trained on an extremely large, but noisy, internet dataset labeled with our IDM. To collect the unlabeled internet dataset, we searched for publicly available videos of Minecraft play with search terms such as “minecraft survival for beginners.” These searches resulted in ${ \sim } 2 7 0 \mathrm { k }$ hours of video, which we filtered down to “clean” video segments yielding an unlabeled dataset of $\mathrm { \sim } 7 0 \mathrm { k }$ hours, which we refer to as web_clean (Appendix A has further details on data scraping and filtering). We then generated pseudo-labels for web_clean with our best IDM (Section 3) and then trained the VPT foundation model with behavioral cloning. Preliminary model scaling experiments suggested that our model could benefit from 30 epochs of training and that a 0.5 billion parameter model was required to stay in the efficient learning regime 64 for that training duration (Appendix H shows results comparing model size and the benefit of scaling to 0.5B parameters), which took ${ \sim } 9$ days on 720 V100 GPUs.
82
+
83
+ We evaluate our models by measuring validation loss (Fig. 4, left) and rolling them out in the Minecraft environment. Unless otherwise noted, in all environment evaluations we spawn agents in a standard survival mode game where they play for 60 minutes, i.e. 72000 consecutive actions, and we plot the mean and shade the standard error of the mean for various game statistics such as crafting and collection rates (Fig. 4, right). The VPT foundation model quickly learns to chop down trees to collect logs, a task we found near impossible for an RL agent to achieve with the native human interface (Sec. 4.4). It also learns to craft those logs into wooden planks and then use those planks to craft a crafting table, which are required to unlock most other technology in the game and take a human proficient in Minecraft approximately 50 seconds (970 consecutive actions) to collect. While these behaviors are fairly complex in the native human action space, the VPT foundation model crafts these items at a rate far below that of our proficient contractors, e.g. on average our contractors craft 5.44 crafting tables in 60 minutes of play versus 0.19 for the foundation model. The model also crafts a non-negligible amount of wooden sticks, which are required to make wooden tools; collects various flowers and crafts dyes from them; kills zombies that appear during the night; hunts wild animals; collects various berries and mushrooms and eats them; and finds game-generated villages from which to collect various rare items from chests. The model also learned to navigate uneven terrain, swim, and pillar jump, which involves the agent repeatedly jumping and quickly placing a block below itself such that it climbs upward by making a pillar.(iv)
84
+
85
+ While training and validation loss decrease healthily over training (Fig. 4, left), loss on our contractor dataset (which the VPT model does not train on) begins increasing after 7 epochs. Contractor data could be out-of-distribution because our contractors may have a different distribution of play or because there is some impactful visual domain shift compared to videos from the web, and we provide some evidence for this phenomenon in Appendix H. While one could have expected this would be predictive of declining evaluation performance, we do not see notable game statistics from the VPT foundation model rollouts (Figure 4, right) decrease over training, and in the next section we show that BC fine-tuning performance continually improves as the VPT foundation model trains.
86
+
87
+ # 4.3 Fine-Tuning with Behavioral Cloning
88
+
89
+ Foundation models are designed to have a broad behavior profile and be generally capable across a wide variety of tasks. To incorporate new knowledge or allow them to specialize on a narrower task distribution, it is common practice to fine-tune these models to smaller, more specific datasets. 1 The VPT foundation model trained on the broad web_clean dataset had nontrivial zero-shot performance; it was able to craft a crafting table yet unable to go past this in the technology tree. As a case study into BC fine-tuning, we attempt to improve the VPT foundation model’s ability to collect and craft these “early game” items by fine-tuning to two narrower datasets targeted at Minecraft behavior within the first few minutes of players starting in a fresh world. In the first dataset, contractor_house, contractors have 10 minutes to build a basic house from scratch using primarily wood, sand, and dirt. Collecting contractor data can be difficult and expensive, so we also construct a dataset earlygame_keyword by searching for videos online with descriptions that match keywords such as “new world”, “let’s play episode 1”, etc.; this is a subset of web_clean and is labeled with the IDM. See Appendix B.4 and A.3 for full descriptions of both datasets.
90
+
91
+ ![](images/6de54e50401bab8c4182be82806eb8a59bcf1d9c74a1f831f1c8e532f5d5450c.jpg)
92
+ Figure 5: (Left) Collection and crafting rates for three policies: the zero-shot VPT foundation model, and the VPT foundation model BC fine-tuned to the earlygame_keyword or contractor_house datasets. BC fine-tuning to either dataset improves performance, including (for the contractor_house dataset) yielding wooden and stone tools. Proficient Minecraft players take a median of 1.2 minutes (1390 actions) to construct wooden tools and 2.3 minutes (2790 actions) to construct stone tools. (Right) Collection and crafting rates for VPT foundation model snapshots throughout training after they are BC fine-tuned to the contractor_house dataset. In general, crafting-related behaviors increase throughout foundation model training. Fig. 4 defines the other task terms (logs, planks, crafting tables, and total crafting).
93
+
94
+ Fine-tuning to earlygame_keyword results in a large boost compared to the zero-shot foundation model: $2 . 5 \mathrm { x }$ more crafting tables, 6.1x more planks, $4 . 3 \mathbf { x }$ more logs, and $5 . 5 \mathrm { x }$ more crafting overall (Fig. 5). However, when fine-tuning to this dataset we did not see any new behaviors emerge, only a refinement of existing skills. We saw an even bigger improvement when fine-tuning to the contractor_house dataset: $2 1 3 \mathrm { x }$ more crafting tables, $5 9 \mathrm { x }$ more wooden planks, $7 \mathbf { x }$ more logs, and $5 9 \mathrm { x }$ more crafting over all. In addition, we saw the emergence of crafting wooden tools, which requires placing a crafting table on the ground, opening it to reveal a new crafting interface, and then using it to craft wooden tools. This entire sequence takes a proficient human player a median of 1.2 minutes (1390 consecutive actions) to accomplish. The model goes further and collects cobblestone, which requires a wooden pickaxe to mine, and crafts stone tools, requiring it to again use a crafting table; this takes a proficient human player a median of 2.3 minutes (2790 consecutive actions). We also saw this model more frequently raiding villages that randomly spawn in the game, hunting animals for food, in addition to many behaviors we saw performed by the foundation model.(v)
95
+
96
+ Despite the foundation model’s zero-shot rollout performance plateauing 1/3 into training (Fig. 4, right), fine-tuning performance does continue to increase throughout foundation model training (Fig. 5, right). Additionally, there is a stark difference in performance when training from scratch vs. fine-tuning from the VPT foundation model (Fig. 5 right, comparing the left and rightmost points).
97
+
98
+ # 4.4 Fine-Tuning with Reinforcement Learning
99
+
100
+ ![](images/cba0e6b9fd67795bb3b4d12861ce77a9904cf7d4c4cee89a406ab396ae3a0429.jpg)
101
+ Figure 6: Typical sequence of items for obtaining a diamond pickaxe. Below each item is the median time and number of actions contractors required to obtain that item and the percentage of contractors that got the item within 10 minutes. The median time to obtain a diamond pickaxe is unknown (except that it is $> 2 0 \mathrm { m } ,$ ) because contractors obtained this item in less than $5 0 \%$ of 20-minute episodes.
102
+
103
+ To demonstrate the efficacy of RL fine-tuning, we chose the challenging goal of obtaining a diamond pickaxe within 10 minutes starting from a fresh Minecraft survival world. Doing so involves acquiring a sequence of difficult-to-obtain items that require complex skills like mining, inventory management, crafting with and without a crafting table, tool use, operating a furnace, and mining at the lowest depths, where many hazards like enemies and lava exist (Fig. 6). Adding to the difficulty, progress can be easily lost by dropping items, destroying items, or dying. Obtaining a diamond pickaxe more often than not takes a proficient human over 20 minutes (24,000 actions).
104
+
105
+ Agents are rewarded for each item obtained in the sequence, with lower rewards for items that have to be collected in bulk and higher rewards for items near the end of the sequence. Agents are optimized with the phasic policy gradient 65 RL algorithm for ${ \sim } 1 . 3$ million episodes (roughly $1 . 4 \times 1 0 ^ { 1 0 }$ frames). Episodes last for 10 minutes. See Appendix G.1 for reward function and RL training details. Due to computational constraints, RL experiments use a $\sim 2 4 8$ million parameter VPT model (Appendix H).
106
+
107
+ A major problem when fine-tuning with RL is catastrophic forgetting66,67 because previously learned skills can be lost before their value is realized. For instance, while our VPT foundation model never exhibits the entire sequence of behaviors required to smelt iron zero-shot, it did train on examples of players smelting with furnaces. It therefore may have some latent ability to smelt iron once the many prerequisites to do so have been performed. To combat the catastrophic forgetting of latent skills such that they can continually improve exploration throughout RL fine-tuning, we add an auxiliary Kullback-Leibler (KL) divergence loss between the RL model and the frozen pretrained policy. 11
108
+
109
+ Training from a randomly initialized policy fails to achieve almost any reward, underscoring how hard an exploration challenge the diamond pickaxe task is for RL in the native human action space (Fig. 7a). The model never learns to reliably collect logs, typically the first of many steps to obtaining a diamond pickaxe (Fig. 7b). RL fine-tuning from the VPT foundation model does substantially better (Fig. 7a), learning everything up to mining iron ore and crafting furnaces. (Fig. 7c). However, this agent fails at smelting an iron ingot, the next item required to get further into the tech tree, likely because the zero-shot probability that the VPT foundation model smelts an iron ingot is too low, even when given the prerequisite materials.
110
+
111
+ ![](images/3465129888555f408ab610b7e6a3dbdf535575989fd849fe8c5dda363f075cfd.jpg)
112
+ Figure 7: RL Fine-tuning results. (a) RL from a randomly initialized model fails to get almost any reward, RL fine-tuning from the VPT foundation model performs substantially better with a reward near 13, and RL fine-tuning from the early-game model performs best with a reward of 25. When training the early-game model without a KL loss to the original policy (No KL-loss) progress stalls after 100,000 episodes, suggesting that the skills necessary to make further progress have been catastrophically forgotten. (b) RL from a randomly initialized model occasionally collects sticks by breaking leaves (an easy but inefficient method of getting sticks that does not require logs or planks) and never learns to reliably collect logs. (c) RL fine-tuning from the VPT Foundation model learns everything in the curriculum up to iron ore and making furnaces, but fails to learn to use the furnace to smelt iron ingots. (d) RL fine-tuning from the early-game model learns to obtain (at human-level) all items in the sequence towards a diamond pickaxe and crafts a diamond pickaxe in $2 . 5 \%$ of episodes.
113
+
114
+ Results further improve by first BC fine-tuning the VPT Foundation Model to the earlygame_keyword dataset (the early-game model, Sec. 4.3) and then fine-tuning with RL (Fig. 7a), which in preliminary experiments we found to perform better than first fine-tuning to contractor_house followed by fine-tuning with RL (Appendix G.2). The three-phase training (pretraining, BC fine-tuning, and then RL fine-tuning) succeeds in learning extremely difficult tasks: it achieves over $8 0 \%$ reliability on iron pickaxes, almost $2 0 \%$ reliability on collecting diamonds, and $2 . 5 \%$ reliability on obtaining a diamond pickaxe (Fig. 7d). For comparison, human players given the objective of obtaining a diamond pickaxe collect these items in $5 7 \%$ , $1 5 \%$ , and $1 2 \%$ of episodes, respectively, meaning our model is human-level for crafting iron pickaxes and mining diamonds. Others have managed to obtain diamonds with $\sim 0 . 1 \%$ reliability in 15 minutes 33,34 but always with a simplified action space designed to ease exploration. To the best of our knowledge, we are the first to report non-zero success rates on crafting a diamond pickaxe. Qualitatively, the model developed useful skills for diamond mining, such as efficient mining patterns, cave exploration, returning to previously placed objects like crafting tables, and advanced techniques like using wooden pickaxes as fuel when moving on to iron tools.(vi)
115
+
116
+ Finally, we validated the importance of the KL loss to the pretrained model during RL fine-tuning. The treatment without a KL loss obtains only items early in the sequence (logs, planks, sticks, and crafting tables) limiting its reward (Fig. 7a). This failure to progress further into the sequence is likely because, while the initial skills of chopping logs and crafting planks are being learned with RL, subsequent skills like crafting a wooden pickaxe are lost due to catastrophic forgetting.
117
+
118
+ # 4.5 Data Scaling Properties of the Foundation Model
119
+
120
+ In this section we validate a core hypothesis behind this work: that it is far more effective to use labeled contractor data to train an IDM within the VPT method than it is to directly train a BC foundation model from that same small contractor dataset. If we could cheaply collect a labeled contractor dataset of a similar order of magnitude as web_clean, then this would not be important; however, collecting that scale of data would have cost millions of dollars. Figure 8 compares foundation models trained on increasing orders of magnitude of data from 1 hour up to the full ${ \sim } 7 0 \mathrm { k }$ web_clean dataset. Foundation models trained up to and including 1k hours are trained on the IDM contractor data, and those trained on 5k hours and above are trained on subsets of web_clean, which does not contain any IDM contractor data. Scaling training data increases log collection, mining, and crafting capabilities. The zero-shot model only begins to start crafting crafting tables at over 5000 hours of training data. When fine-tuning each foundation model to contractor_house, we see that crafting rates for crafting tables and wooden tools increase by orders of magnitude when using the entire ${ \sim } 7 0 \mathrm { k }$ hour web_clean dataset. We furthermore only see the emergence of crafting stone tools at the largest data scale.
121
+
122
+ ![](images/a4e776f01b9e9a1ad25c549eef4298ddfee753b2cc183af6b0d9ea8fde1fc6bf.jpg)
123
+ Figure 8: (Left) Zero-shot rollout performance of foundation models trained on varying amounts of data. Models to the left of the dashed black line (points $\leq 1 \mathrm { k }$ hours) were trained on contractor data (ground-truth labels), and models to the right were trained on IDM pseudo-labeled subsets of web_clean. Due to compute limitations, this analysis was performed with smaller (71 million parameter) models except for the final point, which is the 0.5 billion parameter VPT foundation model. (Right) The corresponding performance of each model after BC fine-tuning each model to the contractor_house dataset.
124
+
125
+ # 4.6 Effect of Inverse Dynamics Model Quality on Behavioral Cloning
126
+
127
+ This section investigates how downstream BC performance is affected by IDM quality. We train IDMs on increasingly larger datasets and use each to independently label the earlygame_keyword dataset (this smaller dataset was chosen due to a limited compute budget). We then train a BC model from scratch on each dataset and report game statistics for each model as a function of IDM contractor dataset size (Fig. 9).
128
+
129
+ IDMs trained on at least 10 hours of data are required for any crafting, and the crafting rate increases quickly up until 100 hours of data,
130
+
131
+ ![](images/555a4d47272fd3d0f24896ab4bc7825e8002ccc73861b6de1f09a96cbfe40ed5.jpg)
132
+ Figure 9: Zero-shot performance of BC models trained from scratch on the earlygame_keyword dataset labeled with IDMs that were trained on increasing amounts of contractor data.
133
+
134
+ after which there are few to no gains and differences are likely due to noise. Similarly, crafting tables are only crafted after 50 or more hours of IDM data, and again gains plateau after 100 hours. While in all previous experiments we use our best IDM trained on 1962 hours of data, these results suggest we could reduce that number to as low as 100 hours.
135
+
136
+ # 5 Discussion and Conclusion
137
+
138
+ The results presented in this paper help pave the path to utilizing the wealth of unlabeled data on the web for many sequential decision domains. Compared to representation learning methods, e.g. generative video modeling, VPT offers the exciting possibility of directly learning to act during pretraining and using these learned behavioral priors as extremely effective exploration priors for RL. VPT could even be an effective representation learning method for downstream tasks that do not require acting, e.g. video captioning, because arguably the most important information in any given scene would be present in features trained to correctly predict the distribution over future human actions. We leave this intriguing direction to future work.
139
+
140
+ Future work could improve results with more data (we estimate we could collect ${ \bf \Lambda } > 1 { \bf M }$ hours) and larger, better-tuned models. Our internet data was fairly noisy and varied (players choose their own graphics settings); we hope future work will investigate even noisier sources of data, as well as how to use both first and third person demonstrations. Furthermore, all models in this work condition on past observations only; we cannot ask the model to perform specific tasks. Appendix I presents preliminary experiments on conditioning our models on closed captions (text transcripts of speech in videos), showing they become weakly steerable; we believe this a rich direction for future research. By definition behavioral priors must predict actions, and in this work we found this objective sufficient to train capable agents; however, a fruitful direction could be incorporating auxiliary representation learning objectives (e.g. contrastive losses, environment dynamics modeling, etc.) to reduce the sample complexity of both the IDM and foundation models. Similarly, it would be interesting to see if VPT could benefit from pretraining its attention layers with a language modeling task as in Li et al. 68 and Reid et al. 69 Loss was not consistently correlated with downstream evaluation metrics (Sec. 4.2), which often made progress slow. Another worthwhile future direction would be to investigate the correlation between various training metrics and downstream evaluations.
141
+
142
+ For RL fine-tuning we only experimented with a standard policy gradient based RL algorithm (PPG); an interesting future direction would be to investigate how well VPT can be combined with other RL algorithms, e.g. off-policy or model based. Furthermore, we showed the efficacy of fine-tuning VPT with RL using a very difficult, albeit handcrafted, reward function aimed at crafting diamond tools. We hope future work will combine VPT with methods that can generate more generic reward functions, e.g. natural language based reward functions as proposed in MineDojo70 (released after this paper). Finally, while we do not anticipate any direct negative societal impacts from the models trained in this work, as VPT improves and expands to other domains it will be important to assess and mitigate harms that emerge with other forms of pretraining on internet datasets, such as emulating inappropriate behavior. 71
143
+
144
+ In conclusion, VPT extends the paradigm of training large and general purpose behavioral priors to sequential decision domains that have commonly available unlabeled internet data. Our models exhibited impressive zero-shot behavior and, when fine-tuned with RL, achieved an unprecedented result of crafting a diamond pickaxe in Minecraft (all the more difficult given the human interface). We further showed that contractor data is far better used within the VPT pipeline than to train a foundation model directly and that only a small amount of contractor data (about $\$ 2000$ USD) was required to unlock massive amounts of unlabeled online data for use in BC. Finally, learning with the human keyboard and mouse interface is highly general and allows losslessly modeling the entire distribution of human behavior. While we only experiment in Minecraft, we believe that VPT provides a general recipe for training behavioral priors in hard, yet generic, action spaces in any domain that has a large amount of freely available unlabeled data, such as computer usage.
145
+
146
+ # Acknowledgements
147
+
148
+ We thank the following people for helpful discussions and support: Bob McGrew, Ken Stanley, Joel Lehman, Ilya Sutskever, Wojciech Zaremba, Ingmar Kanitscheider, David Farhi, Glenn Powell, Jonathan Gordon, and the OpenAI supercomputing team, especially Christian Gibson, Ben Chess, and Christopher Berner.
149
+
150
+ # References
151
+
152
+ [1] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
153
+ [2] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
154
+ [3] Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
155
+
156
+ [4] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.
157
+
158
+ [5] Dhruv Mahajan, Ross Girshick, Vignesh Ramanathan, Kaiming He, Manohar Paluri, Yixuan Li, Ashwin Bharambe, and Laurens Van Der Maaten. Exploring the limits of weakly supervised pretraining. In Proceedings of the European conference on computer vision (ECCV), pages 181–196, 2018.
159
+
160
+ [6] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748–8763. PMLR, 2021.
161
+
162
+ [7] Rishi Bommasani, Drew A Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, et al. On the opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258, 2021.
163
+
164
+ [8] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. CoRR, abs/2106.04560, 2021. URL https://arxiv.org/abs/2106.04560.
165
+
166
+ [9] Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, et al. A generalist agent. arXiv preprint arXiv:2205.06175, 2022.
167
+
168
+ [10] 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.
169
+
170
+ [11] Oriol Vinyals, Igor Babuschkin, Wojciech M Czarnecki, Michaël Mathieu, Andrew Dudzik, Junyoung Chung, David H Choi, Richard Powell, Timo Ewalds, Petko Georgiev, et al. Grandmaster level in starcraft ii using multi-agent reinforcement learning. Nature, 575(7782):350–354, 2019.
171
+
172
+ [12] Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018.
173
+
174
+ [13] Christopher Berner, Greg Brockman, Brooke Chan, Vicki Cheung, Przemysław D˛ebiak, Christy Dennison, David Farhi, Quirin Fischer, Shariq Hashme, Chris Hesse, et al. Dota 2 with large scale deep reinforcement learning. arXiv preprint arXiv:1912.06680, 2019.
175
+
176
+ [14] Bowen Baker, Ingmar Kanitscheider, Todor Markov, Yi Wu, Glenn Powell, Bob McGrew, and Igor Mordatch. Emergent tool use from multi-agent autocurricula. arXiv preprint arXiv:1909.07528, 2019.
177
+
178
+ [15] Max Jaderberg, Wojciech M Czarnecki, Iain Dunning, Luke Marris, Guy Lever, Antonio Garcia Castaneda, Charles Beattie, Neil C Rabinowitz, Ari S Morcos, Avraham Ruderman, et al. Human-level performance in 3d multiplayer games with population-based reinforcement learning. Science, 364(6443):859–865, 2019.
179
+
180
+ [16] Adrià Puigdomènech Badia, Bilal Piot, Steven Kapturowski, Pablo Sprechmann, Alex Vitvitskyi, Zhaohan Daniel Guo, and Charles Blundell. Agent57: Outperforming the atari human benchmark. In International Conference on Machine Learning, pages 507–517. PMLR, 2020.
181
+
182
+ [17] Marc Bellemare, Sriram Srinivasan, Georg Ostrovski, Tom Schaul, David Saxton, and Remi Munos. Unifying count-based exploration and intrinsic motivation. Advances in neural information processing systems, 29, 2016.
183
+
184
+ [18] Yuri Burda, Harrison Edwards, Amos Storkey, and Oleg Klimov. Exploration by random network distillation. arXiv preprint arXiv:1810.12894, 2018.
185
+
186
+ [19] Adrien Ecoffet, Joost Huizinga, Joel Lehman, Kenneth O Stanley, and Jeff Clune. First return, then explore. Nature, 590(7847):580–586, 2021.
187
+
188
+ [20] Peter C Humphreys, David Raposo, Toby Pohlen, Gregory Thornton, Rachita Chhaparia, Alistair Muldal, Josh Abramson, Petko Georgiev, Alex Goldin, Adam Santoro, et al. A data-driven approach for learning to control computers. arXiv preprint arXiv:2202.08137, 2022.
189
+
190
+ [21] Tianlin Shi, Andrej Karpathy, Linxi Fan, Jonathan Hernandez, and Percy Liang. World of bits: An open-domain platform for web-based agents. In Doina Precup and Yee Whye Teh, editors, Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 3135–3144. PMLR, 06–11 Aug 2017. URL https://proceedings.mlr.press/v70/shi17a.html.
191
+
192
+ [22] Andrew Y Ng, Stuart J Russell, et al. Algorithms for inverse reinforcement learning. In Icml, volume 1, page 2, 2000.
193
+
194
+ [23] Faraz Torabi, Garrett Warnell, and Peter Stone. Recent advances in imitation learning from observation. arXiv preprint arXiv:1905.13566, 2019.
195
+
196
+ [24] Jonathan Ho and Stefano Ermon. Generative adversarial imitation learning. Advances in neural information processing systems, 29, 2016.
197
+
198
+ [25] Faraz Torabi, Garrett Warnell, and Peter Stone. Behavioral cloning from observation. arXiv preprint arXiv:1805.01954, 2018.
199
+
200
+ [26] YuXuan Liu, Abhishek Gupta, Pieter Abbeel, and Sergey Levine. Imitation from observation: Learning to imitate behaviors from raw video via context translation. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pages 1118–1125. IEEE, 2018.
201
+
202
+ [27] Twinfinite Staff. Most played games in 2021, ranked by peak concurrent players. Twinfinite. URL https://twinfinite.net/2021/12/ most-played-games-in-2020-ranked-by-peak-concurrent-players/.
203
+
204
+ [28] William H Guss, Brandon Houghton, Nicholay Topin, Phillip Wang, Cayden Codel, Manuela Veloso, and Ruslan Salakhutdinov. Minerl: A large-scale dataset of minecraft demonstrations. arXiv preprint arXiv:1907.13440, 2019.
205
+
206
+ [29] Chen Tessler, Shahar Givony, Tom Zahavy, Daniel Mankowitz, and Shie Mannor. A deep hierarchical approach to lifelong learning in minecraft. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 31, 2017.
207
+
208
+ [30] Christian Scheller, Yanick Schraner, and Manfred Vogel. Sample efficient reinforcement learning through learning from demonstrations in minecraft. In NeurIPS 2019 Competition and Demonstration Track, pages 67–76. PMLR, 2020.
209
+
210
+ [31] Ingmar Kanitscheider, Joost Huizinga, David Farhi, William Hebgen Guss, Brandon Houghton, Raul Sampedro, Peter Zhokhov, Bowen Baker, Adrien Ecoffet, Jie Tang, et al. Multi-task curriculum learning in a complex, visual, hard-exploration domain: Minecraft. arXiv preprint arXiv:2106.14876, 2021.
211
+
212
+ [32] Junhyuk Oh, Valliappa Chockalingam, Honglak Lee, et al. Control of memory, active perception, and action in minecraft. In International Conference on Machine Learning, pages 2790–2799. PMLR, 2016.
213
+
214
+ [33] Vihang P Patil, Markus Hofmarcher, Marius-Constantin Dinu, Matthias Dorfer, Patrick M Blies, Johannes Brandstetter, Jose A Arjona-Medina, and Sepp Hochreiter. Align-rudder: Learning from few demonstrations by reward redistribution. arXiv preprint arXiv:2009.14108, 2020.
215
+
216
+ [34] Alexey Skrynnik, Aleksey Staroverov, Ermek Aitygulov, Kirill Aksenov, Vasilii Davydov, and Aleksandr I Panov. Forgetful experience replay in hierarchical reinforcement learning from demonstrations. arXiv preprint arXiv:2006.09939, 2020.
217
+
218
+ [35] Zichuan Lin, Junyou Li, Jianing Shi, Deheng Ye, Qiang Fu, and Wei Yang. Juewu-mc: Playing minecraft with sample-efficient hierarchical reinforcement learning. arXiv preprint arXiv:2112.04907, 2021.
219
+
220
+ [36] Dean A Pomerleau. Alvinn: An autonomous land vehicle in a neural network. Advances in neural information processing systems, 1, 1988.
221
+
222
+ [37] Stefan Schaal. Is imitation learning the route to humanoid robots? Trends in cognitive sciences, 3(6):233–242, 1999.
223
+
224
+ [38] Brenna D Argall, Sonia Chernova, Manuela Veloso, and Brett Browning. A survey of robot learning from demonstration. Robotics and autonomous systems, 57(5):469–483, 2009.
225
+
226
+ [39] Ahmed Hussein, Mohamed Medhat Gaber, Eyad Elyan, and Chrisina Jayne. Imitation learning: A survey of learning methods. ACM Computing Surveys (CSUR), 50(2):1–35, 2017.
227
+
228
+ [40] Claude Sammut, Scott Hurst, Dana Kedzier, and Donald Michie. Learning to fly. In Machine Learning Proceedings 1992, pages 385–393. Elsevier, 1992.
229
+
230
+ [42] Mariusz Bojarski, Davide Del Testa, Daniel Dworakowski, Bernhard Firner, Beat Flepp, Prasoon Goyal, Lawrence D Jackel, Mathew Monfort, Urs Muller, Jiakai Zhang, et al. End to end learning for self-driving cars. arXiv preprint arXiv:1604.07316, 2016.
231
+
232
+ [43] Felipe Codevilla, Matthias Müller, Antonio López, Vladlen Koltun, and Alexey Dosovitskiy. End-to-end driving via conditional imitation learning. In 2018 IEEE international conference on robotics and automation (ICRA), pages 4693–4700. IEEE, 2018.
233
+
234
+ [44] Rémi Coulom. Computing “elo ratings” of move patterns in the game of go. ICGA journal, 30 (4):198–208, 2007.
235
+
236
+ [45] Todd Hester, Matej Vecerik, Olivier Pietquin, Marc Lanctot, Tom Schaul, Bilal Piot, Dan Horgan, John Quan, Andrew Sendonaris, Ian Osband, et al. Deep q-learning from demonstrations. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
237
+
238
+ [46] Ashley Edwards, Himanshu Sahni, Yannick Schroecker, and Charles Isbell. Imitating latent policies from observation. In International conference on machine learning, pages 1755–1763. PMLR, 2019.
239
+
240
+ [47] Xue Bin Peng, Angjoo Kanazawa, Jitendra Malik, Pieter Abbeel, and Sergey Levine. Sfv: Reinforcement learning of physical skills from videos. ACM Transactions On Graphics (TOG), 37(6):1–14, 2018.
241
+
242
+ [48] Feryal Behbahani, Kyriacos Shiarlis, Xi Chen, Vitaly Kurin, Sudhanshu Kasewa, Ciprian Stirbu, Joao Gomes, Supratik Paul, Frans A Oliehoek, Joao Messias, et al. Learning from demonstration in the wild. In 2019 International Conference on Robotics and Automation (ICRA), pages 775–781. IEEE, 2019.
243
+
244
+ [49] Yusuf Aytar, Tobias Pfaff, David Budden, Thomas Paine, Ziyu Wang, and Nando De Freitas. Playing hard exploration games by watching youtube. Advances in neural information processing systems, 31, 2018.
245
+
246
+ [50] Deepak Pathak, Parsa Mahmoudieh, Guanghao Luo, Pulkit Agrawal, Dian Chen, Yide Shentu, Evan Shelhamer, Jitendra Malik, Alexei A. Efros, and Trevor Darrell. Zero-shot visual imitation. In ICLR, 2018.
247
+
248
+ [51] Ashvin Nair, Dian Chen, Pulkit Agrawal, Phillip Isola, Pieter Abbeel, Jitendra Malik, and Sergey Levine. Combining self-supervised learning and imitation for vision-based rope manipulation. pages 2146–2153, 05 2017. doi: 10.1109/ICRA.2017.7989247.
249
+
250
+ [52] Duy Nguyen-Tuong, Jan Peters, Matthias Seeger, and Bernhard Schölkopf. Learning inverse dynamics: a comparison. In European symposium on artificial neural networks, number CONF, 2008.
251
+
252
+ [53] David Abel, Alekh Agarwal, Fernando Diaz, Akshay Krishnamurthy, and Robert E Schapire. Exploratory gradient boosting for reinforcement learning in complex domains. arXiv preprint arXiv:1603.04119, 2016.
253
+
254
+ [54] Dilip Arumugam, Jun Ki Lee, Sophie Saskin, and Michael L Littman. Deep reinforcement learning from policy-dependent human feedback. arXiv preprint arXiv:1902.04257, 2019.
255
+
256
+ [55] Alexander Trott, Stephan Zheng, Caiming Xiong, and Richard Socher. Keeping your distance: Solving sparse reward tasks using self-balancing shaped rewards. Advances in Neural Information Processing Systems, 32, 2019.
257
+
258
+ [56] Stephan Alaniz. Deep reinforcement learning with model learning and monte carlo tree search in minecraft. arXiv preprint arXiv:1803.08456, 2018.
259
+
260
+ [57] Hiroto Udagawa, Tarun Narasimhan, and Shim-Young Lee. Fighting zombies in minecraft with deep reinforcement learning. Technical report, Technical report, Technical report, Stanford University, 2016.
261
+
262
+ [58] Tianmin Shu, Caiming Xiong, and Richard Socher. Hierarchical and interpretable skill acquisition in multi-task reinforcement learning. arXiv preprint arXiv:1712.07294, 2017.
263
+
264
+ [59] Junhyuk Oh, Satinder Singh, Honglak Lee, and Pushmeet Kohli. Zero-shot task generalization with multi-task deep reinforcement learning. In International Conference on Machine Learning, pages 2661–2670. PMLR, 2017.
265
+
266
+ [60] Zhengxiang Shi, Yue Feng, and Aldo Lipani. Learning to execute or ask clarification questions. arXiv preprint arXiv:2204.08373, 2022.
267
+
268
+ [61] Tambet Matiisen, Avital Oliver, Taco Cohen, and John Schulman. Teacher–student curriculum learning. IEEE transactions on neural networks and learning systems, 31(9):3732–3740, 2019.
269
+
270
+ [62] Robert George Douglas Steel, James Hiram Torrie, et al. Principles and procedures of statistics. Principles and procedures of statistics., 1960.
271
+
272
+ [63] 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.
273
+
274
+ [64] 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. arXiv preprint arXiv:2001.08361, 2020.
275
+
276
+ [65] Karl W Cobbe, Jacob Hilton, Oleg Klimov, and John Schulman. Phasic policy gradient. 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 2020– 2027. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr.press/v139/cobbe21a. html.
277
+
278
+ [66] Dhireesha Kudithipudi, Mario Aguilar-Simon, Jonathan Babb, Maxim Bazhenov, Douglas Blackiston, Josh Bongard, Andrew P Brna, Suraj Chakravarthi Raja, Nick Cheney, Jeff Clune, et al. Biological underpinnings for lifelong learning machines. Nature Machine Intelligence, 4 (3):196–210, 2022.
279
+
280
+ [67] James Kirkpatrick, Razvan Pascanu, Neil Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka Grabska-Barwinska, et al. Overcoming catastrophic forgetting in neural networks. Proceedings of the national academy of sciences, 114(13):3521–3526, 2017.
281
+
282
+ [68] Shuang Li, Xavier Puig, Yilun Du, Clinton Wang, Ekin Akyurek, Antonio Torralba, Jacob Andreas, and Igor Mordatch. Pre-trained language models for interactive decision-making. arXiv preprint arXiv:2202.01771, 2022.
283
+
284
+ [69] Machel Reid, Yutaro Yamada, and Shixiang Shane Gu. Can wikipedia help offline reinforcement learning? arXiv preprint arXiv:2201.12122, 2022.
285
+
286
+ [70] Linxi Fan, Guanzhi Wang, Yunfan Jiang, Ajay Mandlekar, Yuncong Yang, Haoyi Zhu, Andrew Tang, De-An Huang, Yuke Zhu, and Anima Anandkumar. Minedojo: Building open-ended embodied agents with internet-scale knowledge. arXiv preprint arXiv:2206.08853, 2022.
287
+
288
+ [71] Emily M Bender, Timnit Gebru, Angelina McMillan-Major, and Shmargaret Shmitchell. On the dangers of stochastic parrots: Can language models be too big???. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, pages 610–623, 2021.
289
+
290
+ [72] Fabian Pedregosa, Gaël Varoquaux, Alexandre Gramfort, Vincent Michel, Bertrand Thirion, Olivier Grisel, Mathieu Blondel, Peter Prettenhofer, Ron Weiss, Vincent Dubourg, et al. Scikitlearn: Machine learning in python. the Journal of machine Learning research, 12:2825–2830, 2011.
291
+
292
+ [73] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
293
+
294
+ [74] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
295
+
296
+ [75] Yann A LeCun, Léon Bottou, Genevieve B Orr, and Klaus-Robert Müller. Efficient backprop. In Neural networks: Tricks of the trade, pages 9–48. Springer, 2012.
297
+
298
+ [76] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
299
+
300
+ [77] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, highperformance deep learning library. 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 8024–8035. Curran Associates, Inc., 2019. URL http://papers.neurips.cc/paper/ 9015-pytorch-an-imperative-style-high-performance-deep-learning-library. pdf.
301
+
302
+ [78] Yann N Dauphin, Razvan Pascanu, Caglar Gulcehre, Kyunghyun Cho, Surya Ganguli, and Yoshua Bengio. Identifying and attacking the saddle point problem in high-dimensional nonconvex optimization. Advances in neural information processing systems, 27, 2014.
303
+
304
+ [79] Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? Advances in neural information processing systems, 27, 2014.
305
+
306
+ [80] Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc V Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. arXiv preprint arXiv:1901.02860, 2019.
307
+
308
+ [81] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
309
+
310
+ [82] John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel. Highdimensional continuous control using generalized advantage estimation. arXiv preprint arXiv:1506.02438, 2015.
311
+
312
+ [83] Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3):229–256, 1992.
313
+
314
+ [84] Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International conference on machine learning, pages 1928–1937. PMLR, 2016.
315
+
316
+ [85] Marcin Andrychowicz, Filip Wolski, Alex Ray, Jonas Schneider, Rachel Fong, Peter Welinder, Bob McGrew, Josh Tobin, OpenAI Pieter Abbeel, and Wojciech Zaremba. Hindsight experience replay. Advances in neural information processing systems, 30, 2017.
317
+ [86] Tom Schaul, Daniel Horgan, Karol Gregor, and David Silver. Universal value function approximators. In International conference on machine learning, pages 1312–1320. PMLR, 2015.
318
+ [87] Open Ended Learning Team, Adam Stooke, Anuj Mahajan, Catarina Barros, Charlie Deck, Jakob Bauer, Jakub Sygnowski, Maja Trebacz, Max Jaderberg, Michael Mathieu, et al. Openended learning leads to generally capable agents. arXiv preprint arXiv:2107.12808, 2021.
319
+ [88] Jelena Luketina, Nantas Nardelli, Gregory Farquhar, Jakob Foerster, Jacob Andreas, Edward Grefenstette, Shimon Whiteson, and Tim Rocktäschel. A survey of reinforcement learning informed by natural language. In Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence, IJCAI-19, pages 6309–6317. International Joint Conferences on Artificial Intelligence Organization, 7 2019. doi: 10.24963/ijcai.2019/880. URL https://doi.org/10.24963/ijcai.2019/880.
320
+ [89] DeepMind Interactive Agents Team, Josh Abramson, Arun Ahuja, Arthur Brussee, Federico Carnevale, Mary Cassin, Felix Fischer, Petko Georgiev, Alex Goldin, Tim Harley, et al. Creating multimodal interactive agents with imitation and self-supervised learning. arXiv preprint arXiv:2112.03763, 2021.
321
+ [90] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
322
+ [91] Dong Yu and Li Deng. Automatic speech recognition, volume 1. Springer, 2016.
323
+ [92] Daulet Nurmanbetov. rpunct, May 25 2021. URL https://github.com/Felflare/rpunct. accessed 2022-04-22.
324
+ [93] Arvind Neelakantan, Tao Xu, Raul Puri, Alec Radford, Jesse Michael Han, Jerry Tworek, Qiming Yuan, Nikolas Tezak, Jong Wook Kim, Chris Hallacy, et al. Text and code embeddings by contrastive pre-training. arXiv preprint arXiv:2201.10005, 2022.
md/dev/BT03V9Re9a/BT03V9Re9a.md ADDED
@@ -0,0 +1,491 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EmbedDistill: A Geometric Knowledge Distillation for Information Retrieval
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Large neural models (such as Transformers) achieve state-of-the-art performance
11
+ 2 for information retrieval (IR). In this paper, we aim to improve distillation methods
12
+ 3 that pave the way for the resource-efficient deployment of such models in practice.
13
+ 4 Inspired by our theoretical analysis of the teacher-student generalization gap for
14
+ 5 IR models, we propose a novel distillation approach that leverages the relative
15
+ 6 geometry among queries and documents learned by the large teacher model. Unlike
16
+ 7 existing teacher score-based distillation methods, our proposed approach employs
17
+ 8 embedding matching tasks to provide a stronger signal to align the representations
18
+ 9 of the teacher and student models. In addition, it utilizes query generation to
19
+ 10 explore the data manifold to reduce the discrepancies between the student and the
20
+ 11 teacher where training data is sparse. Furthermore, our analysis also motivates
21
+ 12 novel asymmetric architectures for student models which realizes better embedding
22
+ 13 alignment without increasing online inference cost. On standard benchmarks like
23
+ 14 MSMARCO, we show that our approach successfully distills from both dual
24
+ 15 encoder (DE) and cross-encoder (CE) teacher models to 1/10th size asymmetric
25
+ 16 students that can retain $9 5 . 9 7 \%$ of the teacher performance.
26
+
27
+ # 17 1 Introduction
28
+
29
+ 18 Neural models for information retrieval (IR) are increasingly used to model the true ranking function
30
+ 19 in various applications, including web search [38], recommendation [65], and question-answering
31
+ 20 (QA) [6]. Notably, the recent success of Transformers [59]-based pre-trained language models [11,
32
+ 21 30, 49] on a wide range of natural language understanding tasks has also prompted their utilization in
33
+ 22 IR to capture query-document relevance [see, e.g., 10, 34, 43, 26, 20].
34
+ 23 A typical IR system comprises two stages: (1) A retriever first selects a small subset of potentially
35
+ 24 relevant candidate documents (out of a large collection) for a given query; and (2) A re-ranker then
36
+ 25 identifies a precise ranking among the candidates provided by the retriever. Dual-encoder (DE)
37
+ 26 models are the de-facto architecture for retrievers [26, 20]. Such models independently embed queries
38
+ 27 and documents into a common space, and capture their relevance by simple operations on these
39
+ 28 embeddings such as the inner product. This enables offline creation of a document index and supports
40
+ 29 fast retrieval during inference via efficient maximum inner product search implementations [12, 19],
41
+ 30 with online query embedding generation primarily dictating the inference latency. Cross-encoder (CE)
42
+ 31 models, on the other hand, are preferred as re-rankers, owing to their excellent performance [43, 9, 62].
43
+ 32 A CE model jointly encodes a query-document pair while enabling early interaction among query
44
+ 33 and document features. Employing a CE model for retrieval is often infeasible, as it would require
45
+ 34 processing a given query with every document in the collection at inference time. In fact, even in
46
+ 35 the re-ranking stage, the inference cost of CE models is high enough [22] to warrant exploration of
47
+ 36 efficient alternatives [14, 22, 37]. Across both architectures, scaling to larger models brings improved
48
+ 37 performance at increased computational cost [41, 39].
49
+ 38 Knowledge distillation [5, 13] provides a general strategy to address the prohibitive inference cost
50
+ 39 associated with high-quality large neural models. In the IR literature, most existing distillation
51
+ 40 methods only rely on the teacher’s query-document relevance scores [see, e.g., 31, 14, 8, 51, 56] or
52
+ 41 their proxies [16]. However, given that neural IR models are inherently embedding-based, it is natural
53
+ 42 to ask: Is it useful to go beyond matching of the teacher and student models’ scores, and directly aim
54
+ 43 to align their embedding spaces?
55
+ 44 With this in mind, we propose a novel distillation method for IR models that utilizes an embedding
56
+ 45 matching task to train student models. The proposed method is inspired by our rigorous treatment
57
+ 46 of the generalization gap between the teacher and student models in IR settings. Our theoretical
58
+ 47 analysis of the teacher-student generalization gap further suggests novel design choices involving
59
+ 48 asymmetric configurations for student DE models, intending to further reduce the gap by better
60
+ 49 aligning teacher and student embedding spaces. Notably, our proposed distillation method supports
61
+ 50 cross-architecture distillation and improves upon existing (score-based) distillation methods for both
62
+ 51 retriever and re-ranker models. When distilling a large teacher DE model into a smaller student DE
63
+ 52 model, for a given query (document), one can minimize the distance between the query (document)
64
+ 53 embeddings of the teacher and student (after compatible projection layers to account for dimension
65
+ 54 mismatch, if any). In contrast, a teacher CE model doesn’t directly provide document and query
66
+ 55 embeddings, and so to effectively employ embedding matching-based distillation requires modifying
67
+ 56 the scoring layer with dual-pooling [61] and adding various regularizers. Both of these changes
68
+ 57 improve geometry of teacher embeddings and facilitate effective knowledge transfer to the student
69
+ 58 DE model via embedding matching-based distillation.
70
+
71
+ 59 Our key contributions toward improving IR models via distillation are:
72
+
73
+ • We provide the first rigorous analysis of the teacher-student generalization gap for IR settings which captures the role of alignment of embedding spaces of the teacher and student towards reducing the gap (Sec. 3). Inspired by our analysis, we propose a novel distillation approach for neural IR models, namely EmbedDistill, that goes beyond score matching and aligns the embedding spaces of the teacher and student models (Sec. 4). We also show that EmbedDistill can leverage synthetic data to improve a student by further aligning the embedding spaces of the teacher and student (Sec. 4.3). Our analysis motivates novel distillation setups. Specifically, we consider a student DE model with an asymmetric configuration, consisting of a small query encoder and a frozen document encoder inherited from the teacher. This significantly reduces inference latency of query embedding generation, while leveraging the teachers’ high-quality document index (Sec. 4.1). We provide a comprehensive empirical evaluation of EmbedDistill (Sec. 5) on two standard IR benchmarks – Natural Questions [23] and MSMARCO [40]. We also evaluate EmbedDistill on BEIR benchmark [57] which is used to measure the zero-shot performance of an IR model.
74
+
75
+ 74 Note that prior works have utilized embedding alignment during distillation for non-IR setting [see,
76
+ 75 e.g., 52, 55, 18, 1, 64, 7]. However, to the best of our knowledge, our work is the first to study
77
+ 76 embedding matching-based distillation method for IR settings which requires addressing multiple
78
+ 77 IR-specific challenges such as cross-architecture distillation, partial representation alignment, and en
79
+ 78 abling novel asymmetric student configurations. Furthermore, unlike these prior works, our proposed
80
+ 79 method is theoretically justified to reduce the teacher-student performance gap.
81
+
82
+ # 80 2 Background
83
+
84
+ 81 Let Q and $\mathrm { \Phi _ { \mathrm { ~ \mathcal { D } ~ } } }$ denote the query and document spaces, respectively. An IR model is equivalent to
85
+ 82 a scorer $s : \Omega \times \mathcal { D } \mathbb { R }$ , i.e., it assigns a (relevance) score $s ( q , d )$ for a query-document pair
86
+ 83 $( \boldsymbol { q } , \boldsymbol { d } ) \in \Omega \times \mathcal { D }$ . Ideally, we want to learn a scorer such that $s ( q , d ) > s ( q , d ^ { \prime } )$ iff the document $d$ is
87
+ 84 more relevant to the query $q$ than document $d ^ { \prime }$ . We assume access to $n$ labeled training examples
88
+ 85 $\mathcal { S } _ { n } = \{ ( q _ { i } , \mathbf { d } _ { i } , \mathbf { y } _ { i } ) \} _ { i \in [ n ] } .$ . Here, $\mathbf { d } _ { i } = ( d _ { i , 1 } , \dots , d _ { i , L } ) \in \mathcal { D } ^ { L } , \forall i \in [ n ]$ , denotes a list of $L$ documents
89
+ 86 and $\mathbf { y } _ { i } = ( y _ { i , 1 } , \ldots , y _ { i , L } ) \in \{ 0 , 1 \} ^ { L }$ denotes the corresponding labels such that $y _ { i , j } = 1$ iff the
90
+ 87 document $d _ { i , j }$ is relevant to the query $q _ { i }$ . Given $\mathcal { S } _ { n }$ , we learn an IR model by minimizing
91
+
92
+ $$
93
+ R ( s ; \mathbb { S } _ { n } ) : = { \frac { 1 } { n } } \sum _ { i \in [ n ] } \ell { \bigl ( } s _ { q _ { i } , \mathbf { d } _ { i } } , \mathbf { y } _ { i } { \bigr ) } ,
94
+ $$
95
+
96
+ 88 where $s _ { q _ { i } , \mathbf { d } _ { i } } : = ( s ( q _ { i } , d _ { 1 , i } ) , \ldots , s ( q _ { i } , d _ { 1 , L } ) )$ and $\ell \left( s _ { q _ { i } , \mathbf { d } _ { i } } , \mathbf { y } _ { i } \right)$ denotes the loss $s$ incurs on $\left( q _ { i } , \mathbf { d } _ { i } , \mathbf { y } _ { i } \right)$ .
97
+ 89 Due to space constraint, we defer concrete choices for the loss function $\ell$ to Appendix A.
98
+ 90 While this learning framework is general enough to work with any IR models, next, we formally
99
+ 91 introduce two families of Transformer-based IR models that are prevalent in the recent literature.
100
+
101
+ # 92 2.1 Transformer-based IR models: Cross-encoders and Dual-encoders
102
+
103
+ Let query $q = \left( q ^ { 1 } , \ldots , q ^ { m _ { 1 } } \right)$ and document $d = ( d ^ { 1 } , \ldots , d ^ { m _ { 2 } } )$ consist of $m _ { 1 }$ and $m _ { 2 }$ tokens, respectively. We now discuss how Transformers-based CE and DE models process the $( q , d )$ pair.
104
+
105
+ 95 Cross-encoder model. Let $p = [ q ; d ]$ be the sequence obtained by concatenating $q$ and $d$ . Further,
106
+ 96 let $\tilde { p }$ be the sequence obtained by adding special tokens such [CLS] and [SEP] to $p$ . Given an
107
+ 97 encoder-only Transformer model Enc, the relevance score for the $( q , d )$ pair is
108
+
109
+ $$
110
+ s ( q , d ) = \langle w , \mathrm { p o o l } \bigl ( \mathrm { E n c } ( \tilde { p } ) \bigr ) \rangle = \langle w , \mathrm { e m b } _ { q , d } \rangle ,
111
+ $$
112
+
113
+ 98 where $w$ is a $d$ -dimensional classification vector, and $\mathrm { p o o l } ( \cdot )$ denotes a pooling operation that
114
+ 99 transforms the contextualized token embeddings $\operatorname { E n c } ( \tilde { p } )$ to a joint embedding vector $\mathtt { e m b } _ { q , d }$ . [CLS]-
115
+ 100 pooling is a common operation that simply outputs the embedding of the [CLS] token as $\mathtt { e m b } _ { q , d }$ .
116
+
117
+ Dual-encoder model. Let $\tilde { q }$ and $\tilde { d }$ be the sequences obtained by adding appropriate special tokens to $q$ and $d$ , respectively. A DE model comprises two (encoder-only) Transformers $\operatorname { E n c } _ { Q }$ and $\mathrm { E n c } _ { D }$ , which we call query and document encoders, respectively.1 Let $\mathsf { e m b } _ { q } = \mathrm { p o o l } \big ( \mathrm { E n c } _ { Q } ( \tilde { q } ) \big )$ and $\mathsf { e m b } _ { d }$ $= \mathrm { p o o l } \big ( \mathrm { E n c } _ { D } ( \tilde { d } ) \big )$ denote the query and document embeddings, respectively. Now, one can define $s ( q , d ) = \langle \mathbf { e m b } _ { q } , \mathbf { e m b } _ { d } \rangle$ to be the relevance score assigned to the $( q , d )$ pair by the DE model.
118
+
119
+ # 2.2 Score-based distillation for IR models
120
+
121
+ Most distillation schemes for IR [e.g., 31, 14, 8] rely on teacher relevance scores. Given a training set $\mathcal { S } _ { n }$ and a teacher with scorer $s ^ { \mathrm { t } }$ , one learns a student with scorer $s ^ { \mathrm { s } }$ by minimizing
122
+
123
+ $$
124
+ R ( s ^ { \mathrm { s } } , s ^ { \mathrm { t } } ; \mathcal { S } _ { n } ) = \frac { 1 } { n } \sum _ { i \in [ n ] } \ell _ { \mathrm { d } } \big ( s _ { q , \mathbf { d } _ { i } } ^ { \mathrm { s } } , s _ { q , \mathbf { d } _ { i } } ^ { \mathrm { t } } \big ) ,
125
+ $$
126
+
127
+ where $\ell _ { \mathrm { d } }$ captures the discrepancy between $s ^ { \mathrm { s } }$ and $s ^ { \mathrm { t } }$ . See Appendix A for common choices for $\ell _ { \mathrm { d } }$
128
+
129
+ # 10 3 Teacher-student generalization gap: Inspiration for embedding alignment
130
+
131
+ 111 Our main objective is to devise novel distillation methods to realize high-performing student DE
132
+ 112 models. As a first step in this direction, we rigorously study the teacher-student generalization
133
+ 113 gap as realized by standard (score-based) distillation in IR settings. Informed by our analysis, we
134
+ 114 subsequently identify novel ways to improve the student model’s performance. In particular, our
135
+ 115 analysis suggests two natural directions to reduce the teacher-student generalization gap: 1) enforcing
136
+ 116 tighter alignment between embedding spaces of teacher and student models; and 2) exploring novel
137
+ 117 asymmetric configuration for student DE model.
138
+ 118 Let $R ( s ) = \mathbb { E } \left[ \ell \left( s _ { q , \mathbf { d } } , \mathbf { y } \right) \right]$ be the population version of the empirical risk in Eq. 1, which measures
139
+ 119 the test time performance of the IR model defined by the scorer $s$ . Thus, $R ( s ^ { \mathrm { s } } ) - R ( s ^ { \mathrm { t } } )$ denotes the
140
+ 120 teacher-student generalization gap. In the following result, we bound this quantity (see Appendix C.1
141
+ 121 for a formal statement and proof). We focus on distilling a teacher DE model to a student DE model
142
+ 122 and $L = 1$ (cf. Sec. 2) as it leads to easier exposition without changing the main takeaways. Our
143
+ 123 analysis can be extended to $L > 1$ or CE to DE distillation with more complex notation.
144
+ 124 Theorem 3.1 (Teacher-student generalization gap (informal)). Let $\mathcal { F }$ and G denote the function
145
+ 125 classes for the query and document encoders for the student model, respectively. Suppose that the
146
+ 126 score-based distillation loss $\ell _ { \mathrm { d } }$ in Eq. 3 is based on binary cross entropy loss (Eq. 12 in Appendix A).
147
+ 127 Let one-hot (label-dependent) loss \` in Eq. 1 be the binary cross entropy loss (Eq. 10 in Appendix $A$ ).
148
+ 128 Further, assume that all encoders have the same output dimension and embeddings have their $\ell _ { 2 }$ -norm
149
+ 129 bounded by $K$ . Then, we have
150
+
151
+ $$
152
+ \begin{array} { r l } & { R ( s ^ { \mathrm { s } } ) - R ( s ^ { \mathrm { t } } ) \leq \displaystyle \mathcal { E } _ { n } ( \mathcal { F } , \mathfrak { G } ) + 2 K R _ { \mathrm { E m b } , Q } ( \mathfrak { t } , { \mathrm { s } } ; \mathcal { S } _ { n } ) + 2 K R _ { \mathrm { E m b } , D } ( \mathfrak { t } , { \mathrm { s } } ; \mathcal { S } _ { n } ) } \\ & { \qquad + \Delta ( s ^ { \mathrm { t } } ; \mathcal { S } _ { n } ) + K ^ { 2 } \bigl ( \mathbb { E } \left[ \left. \sigma ( s _ { q , d } ^ { \mathrm { t } } ) - y \right. \right] + \displaystyle \frac { 1 } { n } \sum _ { i \in [ n ] } \big \vert \sigma ( s _ { q , d _ { i } } ^ { \mathrm { t } } ) - y _ { i } \big \vert \big ) , } \end{array}
153
+ $$
154
+
155
+ 1 It is common to employ dual-encoder models where query and document encoders are shared.
156
+
157
+ ![](images/9e8e766c8265c2e75b6fcdbafd8432533c6448ff8ac70fa51c8e0ab6a64802df.jpg)
158
+ Figure 1: Proposed distillation method with query embedding matching. Left: The setting where student employs an asymmetric DE configuration with a small query encoder and a large (non-trainable) document encoder inherited from the teacher DE model. The smaller query encoder ensures small latency for encoding query during inference, and large document encoder leads to a good quality document index. Right: Similarly the setting of CE to DE distillation using EmbedDistill, with teacher CE model employing dual pooling.
159
+
160
+ where 130 $\begin{array} { r } { \mathcal { E } _ { n } ( \mathcal { F } , \mathcal { G } ) : = \operatorname* { s u p } _ { s ^ { \mathrm { s } } \in \mathcal { F } \times \mathcal { G } } \big | R ( s ^ { \mathrm { s } } , s ^ { \mathrm { t } } ; \mathbb { S } _ { n } ) - \mathbb { E } \ell _ { \mathrm { d } } \big ( s _ { q , d } ^ { \mathrm { s } } , s _ { q , d } ^ { \mathrm { t } } \big ) \big | , } \end{array}$ ; $\sigma$ denotes the sigmoid function; and 131 $\Delta ( s ^ { \mathrm { t } } ; \mathcal { S } _ { n } )$ denotes the deviation between the empirical risk (on $\mathcal { S } _ { n }$ ) and population risk of the 132 teacher $s ^ { \mathrm { t } }$ . Here, $R _ { \mathrm { E m b } , Q } ( \mathrm { t } , \mathrm { s } ; \mathcal { S } _ { n } )$ and $R _ { \mathrm { E m b } , D } ( \mathrm { t } , \mathrm { s } ; \mathcal { S } _ { n } )$ measure misalignment between teacher and 133 student embeddings by focusing on queries and documents, respectively (cf. Eq. 7 & 8 in Sec. 4.1).
161
+
162
+ 134 The last three quantities in the bound in Thm. 3.1, namely $\Delta ( s ^ { \mathrm { t } } ; \mathbb { S } _ { n } ) , \mathbb { E } [ | \sigma ( s _ { q , d } ^ { \mathrm { t } } ) - y | ]$ , and
163
+ 135 $\begin{array} { r } { \frac { 1 } { n } \sum _ { i \in [ n ] } | \sigma ( s _ { q _ { i } , d _ { i } } ^ { \mathrm { t } } ) - y _ { i } | } \end{array}$ , are independent of the underlying student model. These terms solely
164
+ 136 depend on the quality of the underlying teacher model $s ^ { \mathrm { t } }$ . That said, the teacher-student gap can be
165
+ 137 made small by reducing the following three terms: 1) uniform deviation of the student’s empirical
166
+ 138 distillation risk from its population version $\mathcal { E } _ { n } ( \mathcal { F } , \mathcal { G } ) ; 2 )$ misalignment between teacher student query
167
+ 139 embeddings $R _ { \mathrm { E m b } , Q } ( \mathrm { t } , \mathrm { s } ; \mathcal { S } _ { n } )$ ; and 3) misalignment between teacher student document embeddings
168
+ 140 $R _ { \mathrm { E m b } , D } ( \mathrm { t } , \mathrm { s } ; \mathcal { S } _ { n } )$ .
169
+ 141 The last two terms motivate us to propose an embedding matching-based distillation that explicitly
170
+ 142 aims to minimize these terms during student training. Even more interestingly, these terms also
171
+ 143 inspire an asymmetric $D E$ configuration for the student which strikes a balance between the goals of
172
+ 144 reducing the misalignment between the embeddings of teacher and student (by inheriting teacher’s
173
+ 145 document encoder) and ensuring serving efficiency (small inference latency) by employing a small
174
+ 146 query encoder. Before discussing these proposals in detail in Sec. 4 and Fig. 1, we explore the first
175
+ 147 term $\textstyle { \mathcal { E } } _ { n } ( { \mathcal { F } } , { \mathcal { G } } )$ and highlight how our proposals also have implications for reducing this term. Towards
176
+ 148 this, the following result bounds $\mathcal { E } _ { n } ( \mathcal { F } , \mathcal { G } )$ . Due to space constraints, we present an informal statement
177
+ 149 of the result (see Appendix C.2 for a more precise statement and proof).
178
+ 150 Proposition 3.2. Let $\ell _ { \mathrm { d } }$ be a distillation loss which is $L _ { \ell _ { \mathrm { d } } }$ -Lipschitz in its first argument. Let $\mathcal { F }$ and G
179
+ 151 denote the function classes for the query and document encoders, respectively. Further assume that,
180
+ 152 for each query and document encoder in our function class, the query and document embeddings
181
+ 153 have their $\ell _ { 2 }$ -norm bounded by $K$ . Then,
182
+
183
+ $$
184
+ { \mathcal E } _ { n } ( \mathcal F , \mathcal G ) \leq { \mathbb E } _ { \mathcal S _ { n } } \frac { 4 8 K L _ { \ell _ { \mathrm { d } } } } { \sqrt { n } } \int _ { 0 } ^ { \infty } \sqrt { \log \left( N ( u , \mathcal F ) N ( u , \mathcal G ) \right) } d u .
185
+ $$
186
+
187
+ Furthermore, with a fixed document encoder, i.e., 154 $\mathcal { G } = \{ g ^ { * } \}$ ,
188
+
189
+ $$
190
+ \mathcal { E } _ { n } ( \mathcal { F } , \{ g * \} ) \leq \mathbb { E } _ { \mathcal { S } _ { n } } \frac { 4 8 K L _ { \ell _ { \mathrm { d } } } } { \sqrt { n } } \int _ { 0 } ^ { \infty } \sqrt { \log N ( u , \mathcal { F } ) } d u .
191
+ $$
192
+
193
+ 155 Here, $N ( u , \cdot )$ is the $u$ -covering number of a function class.
194
+
195
+ 156 Note that Eq. 5 and Eq. 6 correspond to uniform deviation when we train without and with a frozen
196
+ 157 document encoder, respectively. It is clear that the bound in Eq. 6 is less than or equal to that in
197
+ 158 Eq. 5 (because $N ( u , \mathcal { G } ) \ge 1$ for any $u ^ { \cdot }$ ), which alludes to desirable impact of employing a frozen
198
+ 159 document encoder as one of our proposal seeks to do via inheriting teacher’s document encoder (for
199
+ 160 instance in an asymmetric DE configuration). Furthermore, our proposal of employing an embedding
200
+ 161 matching task will regularize the function class of query encoders; effectively reducing it to ${ \mathcal { F } } ^ { \prime }$ with
201
+ 162 $| \mathcal { F } ^ { \prime } | \leq | \bar { \mathcal { F } } |$ . The same holds true for document encoder function class when document encoder is
202
+ 163 trainable (as in Eq. 5), leading to an effective function class ${ \mathcal { G } } ^ { \prime }$ with $| \mathcal { G } ^ { \prime } | \leq | \mathcal { G } |$ . Since we would have
203
+ 164 $N ( u , \mathcal { F } ^ { \prime } ) \leq N ( u , \mathcal { F } )$ and $N ( u , \mathcal { G } ^ { \prime } ) \leq N ( u , \mathcal { G } )$ , this suggests desirable implications of embedding
204
+ 165 matching for reducing the uniform deviation bound.
205
+
206
+ # 166 4 Embedding-matching based distillation
207
+
208
+ 7 Informed by our analysis of teacher-student generalization gap in Sec. 3, we propose EmbedDistill – a
209
+ 68 novel distillation method that explicitly focuses on aligning the embedding spaces of the teacher and
210
+ 69 student. Our proposal goes beyond existing distillation methods in the IR literature that only use the
211
+ 70 teacher scores. Next, we introduce EmbedDistill for two prevalent settings: (1) distilling a large DE
212
+ 71 model to a smaller DE model; 2 and (2) distilling a CE model to a DE model.
213
+
214
+ # 172 4.1 DE to DE distillation
215
+
216
+ 173 Given a $( q , d )$ pair, let $\mathsf { e m b } _ { q } ^ { \mathrm { t } }$ and $\mathtt { e m b } _ { d } ^ { \mathrm { t } }$ be the query and document embeddings produced by the
217
+ 174 query encoder $\mathrm { E n c } _ { Q } ^ { \mathrm { t } }$ and document encoder $\mathrm { E n c } _ { D } ^ { \mathrm { t } }$ of the teacher DE model, respectively. Similarly,
218
+ 175 let $\mathsf { e m b } _ { q } ^ { \mathrm { s } }$ and $\mathsf { e m b } _ { d } ^ { \mathrm { s } }$ denote the query and document embeddings produced by a student DE model
219
+ 176 with $( \dot { \mathrm { E n c } } _ { Q } ^ { \mathrm { s } } , \mathrm { E n c } _ { D } ^ { \mathrm { s } } )$ as its query and document encoders. Now, EmbedDistill optimizes the following
220
+ 177 embedding alignment losses in addition to the score-matching loss from Sec. 2.2 to align query and
221
+ 178 document embeddings of the teacher and student:
222
+
223
+ $$
224
+ \begin{array} { r l } & { R _ { \mathrm { E m b } , Q } ( \mathrm { t } , \mathrm { s } ; \mathbb { S } _ { n } ) = \displaystyle \frac { 1 } { n } \sum _ { q \in \mathcal { S } _ { n } } \| \mathbf { e m b } _ { q } ^ { \mathrm { t } } - \mathrm { p r o j } \big ( \mathbf { e m b } _ { q } ^ { \mathrm { s } } \big ) \| ; } \\ & { R _ { \mathrm { E m b } , D } ( \mathrm { t } , \mathrm { s } ; \mathbb { S } _ { n } ) = \displaystyle \frac { 1 } { n } \sum _ { d \in \mathcal { S } _ { n } } \| \mathbf { e m b } _ { d } ^ { \mathrm { t } } - \mathrm { p r o j } \big ( \mathbf { e m b } _ { d } ^ { \mathrm { s } } \big ) \| . } \end{array}
225
+ $$
226
+
227
+ 179 Asymmetric DE. We also propose a novel student DE configuration where the student employs the
228
+ 180 teacher’s document encoder (i.e., $\mathrm { E n c } _ { D } ^ { \mathrm { s } } = \mathrm { E n c } _ { D } ^ { \mathrm { t } } ,$ ) and only train its query encoder, which is much
229
+ 181 smaller compared to the teacher’s query encoder. For such a setting, it is natural to only employ the
230
+ 182 embedding matching loss in Eq. 7 as the document embeddings are aligned by design (cf. Fig. 1a).
231
+ 183 Note that this asymmetric student DE does not incur an increase in latency despite the use of a
232
+ 184 large teacher document encoder. This is because the large document encoder is only needed to
233
+ 185 create a good quality document index offline, and only the query encoder is evaluated at inference
234
+ 186 time. Also, the similarity search cost is not increased as the projection layer ensures the same small
235
+ 187 embedding dimension as in the symmetric DE student. Thus, for DE to DE distillation, we prescribe
236
+ 188 the asymmetric DE configuration universally. Our theoretical analysis (cf. Sec. 3) and experimental
237
+ 189 results (cf. Sec. 5) suggest that the ability to inherit the document tower from the teacher DE model
238
+ 190 can drastically improve the final performance, especially when combined with query embedding
239
+ 191 matching task (cf. Eq. 7).
240
+
241
+ # 4.2 CE to DE distillation
242
+
243
+ 193 Given that CE models jointly encode query-document pairs, individual query and document embed
244
+ 94 dings are not readily available to implement embedding matching losses as per Eq. 7 and 8. This
245
+ 95 makes it challenging to employ EmbedDistill for CE to DE distillation.
246
+
247
+ As a naïve solution, for a $( q , d )$ pair, one can simply match a joint transformation of the student’s query embedding $\mathsf { e m b } _ { q } ^ { \mathrm { s } }$ and document embedding $\mathsf { e m b } _ { d } ^ { \mathrm { s } }$ to the teacher’s joint embedding $\mathtt { e m b } _ { q , d } ^ { \mathrm { t } }$ , produced by (single) teacher encoder $\operatorname { E n c } ^ { t }$ . However, we observed that including such an embedding matching task often leads to severe over-fitting, and results in a poor student. Since $s ^ { \mathrm { t } } ( q , d ) = \langle \bar { w } , \mathtt { e m b } _ { q , d } ^ { \mathrm { t } } \rangle$ , during CE model training, the joint embeddings $\mathtt { e m b } _ { q , d } ^ { \mathrm { t } }$ for relevant and irrelevant $( q , d )$ pairs are encouraged to be aligned with $w$ and $- w$ , respectively. This produces degenerate embeddings that do not capture semantic query-to-document relationships. We notice that even the final query and document token embeddings lose such semantic structure (cf. Appendix G.2). Thus, a teacher CE model with $s ^ { \mathrm { t } } ( q , d ) = \langle w , \mathsf { e m b } _ { q , d } ^ { \mathrm { t } } \rangle$ does not add value for distillation beyond score-matching; in fact, it hurts to include naïve embedding matching. Next, we propose a modified CE model training strategy that facilitates EmbedDistill.
248
+
249
+ CE models with dual pooling. A dual pooling scheme is employed in the scoring layer to produce two embeddings $\mathsf { e m b } _ { q \gets ( q , d ) } ^ { \mathrm { t } }$ and $\mathsf { e m b } _ { d ( q , d ) } ^ { \mathrm { t } }$ from a CE model that serve as the proxy query and document embeddings, respectively. Accordingly, we define the relevance score as $s ^ { \mathrm { t } } ( q , d ) \ =$ $\langle \mathbf { e m b } _ { q ( q , d ) } ^ { \mathrm { t } } , \mathbf { e m b } _ { d ( q , d ) } ^ { \mathrm { t } } \rangle$ . We explore two variants of dual pooling: (1) special token-based pooling that pools from [CLS] and [SEP]; and (2) segment-based weighted mean pooling that separately
250
+
251
+ Table 1: Full recall performance of various student DE models on NQ dev set, including symmetric DE student model (67.5M or 11.3M transformer for both encoders), and asymmetric DE student model (67.5M or 11.3M transformer as query encoder and document embeddings inherited from the teacher). All distilled students used the same teacher (110.1M parameter BERT-base models as both encoders), with the full Recall $\textcircled { \omega } 5 = 7 2 . 3 $ , Recall $\textcircled { \omega } 2 0 = 8 6 . 1 $ , and Recall $\textcircled { a } 1 0 0 = 9 3 . 6 $ .
252
+
253
+ <table><tr><td rowspan="2">Method</td><td colspan="3">6-Layer (67.5M)</td><td colspan="3">4-Layer (11.3M)</td></tr><tr><td></td><td>R@5 R@20R@100</td><td></td><td></td><td>R@5 R@20R@100</td><td></td></tr><tr><td>Train student directly</td><td>36.2</td><td>59.7</td><td>80.0</td><td>24.8</td><td>44.7</td><td>67.5</td></tr><tr><td>+ Distill from teacher</td><td>65.3</td><td>81.6</td><td>91.2</td><td>44.3</td><td>64.9</td><td>81.0</td></tr><tr><td>+ Inherit doc embeddings</td><td>69.9</td><td>83.9</td><td>92.3</td><td>56.3</td><td>70.9</td><td>82.5</td></tr><tr><td>+ Query embedding matching</td><td>72.7</td><td>86.5</td><td>93.9</td><td>61.2</td><td>75.2</td><td>85.1</td></tr><tr><td>+ Query generation</td><td>73.4</td><td>86.3</td><td>93.8</td><td>64.3</td><td>77.8</td><td>87.9</td></tr><tr><td>Train student using only embedding matching and</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>inherit doc embeddings</td><td>71.4</td><td>84.9</td><td>92.6</td><td>64.6</td><td>50.2</td><td>76.8</td></tr><tr><td>+ Query generation</td><td>71.8</td><td>85.0</td><td>93.0</td><td>54.2</td><td>68.9</td><td>80.8</td></tr></table>
254
+
255
+ Table 2: Performance of EmbedDistill for DE to DE distillation on NQ test set. While prior works listed in the table rely on techniques such as negative mining and multistage training, we explore the orthogonal direction of embedding-matching that improves single-stage distillation, which can be combined with them.
256
+
257
+ <table><tr><td>Method</td><td>#Layers</td><td>R@20</td><td>R@100</td></tr><tr><td>DPR [20]</td><td>12</td><td>78.4</td><td>85.4</td></tr><tr><td>DPR + PAQ[47]</td><td>12</td><td>84.0</td><td>89.2</td></tr><tr><td>DPR + PAQ[47]</td><td>24</td><td>84.7</td><td>89.2</td></tr><tr><td>ACNE [60]</td><td>12</td><td>81.9</td><td>87.5</td></tr><tr><td>RocketQA [48]</td><td>12</td><td>82.7</td><td>88.5</td></tr><tr><td>MSS-DPR[53]</td><td>12</td><td>84.0</td><td>89.2</td></tr><tr><td>MSS-DPR[53]</td><td>24</td><td>84.8</td><td>89.8</td></tr><tr><td>Our teacher [63]</td><td>12 (220.2M)</td><td>85.4</td><td>90.0</td></tr><tr><td>EmbedDistill</td><td>6 (67.5M)</td><td>85.1</td><td>89.8</td></tr><tr><td>EmbedDistill</td><td>4 (11.3M)</td><td>81.2</td><td>87.4</td></tr></table>
258
+
259
+ 12 performs weighted averaging on the query and document segments of the final token embeddings.
260
+ 13 See Appendix B for details.
261
+
262
+ In addition to dual pooling, we also utilize a reconstruction loss during the CE training, which measures the likelihood of predicting each token of the original input from the final token embeddings. This loss encourages reconstruction of query and document tokens based on the final token embeddings and prevents the degeneration of the token embeddings during training. Given proxy embeddings from the teacher CE, we can perform EmbedDistill with the embedding matching loss defined in Eq. 7 and Eq. 8 (cf. Fig. 1b).
263
+
264
+ # 4.3 Task-specific online data generation
265
+
266
+ Data augmentation as a general technique has been previously considered in the IR literature [see, e.g., 45, 47, 17], especially in data-limited, out-of-domain, or zero-shot settings. As EmbedDistill aims to align the embeddings spaces of the teacher and student, the ability to generate similar queries or documents can naturally help enforce such an alignment globally on the task-specific manifold. Given a set of unlabeled task-specific query and document pairs $\mathbb { U } _ { m }$ , we can further add the embedding matching losses $R _ { \mathrm { E m b , Q } } ( \mathrm { t } , \mathrm { s } ; \mathcal { U } _ { m } )$ or $R _ { \mathrm { E m b , D } } ( \mathrm { t } , \mathrm { s } ; \mathcal { U } _ { m } )$ to our training objective. Interestingly, for DE to DE distillation setting, our approach can even benefit from a large collection of task-specific queries $\Omega ^ { \prime }$ or documents $\mathrm { \textmathcal { D } ^ { \prime } }$ . Here, we can independently employ embedding matching losses $R _ { \mathrm { E m b , Q } } ( \mathrm { t } , \mathrm { s } ; \Omega ^ { \prime } )$ or $R _ { \mathrm { E m b , D } } ( \mathrm { t } , \mathrm { s } ; \mathcal { D } ^ { \prime } )$ that focus on queries and documents, respectively. Please refer to Appendix E describing how the task-specific data were generated.
267
+
268
+ # 5 Experiments
269
+
270
+ We now conduct a comprehensive evaluation of the proposed distillation approach. Specifically, we highlight the utility of the approach for both DE to DE and CE to DE distillation. We also showcase the benefits of combining our distillation approach with query generation methods.
271
+
272
+ # 5.1 Setup
273
+
274
+ Benchmarks and evaluation metrics. We consider two popular IR benchmarks — Natural Questions (NQ) [24] and MSMARCO [40], which focus on finding the most relevant passage/document given a question and a search query, respectively. NQ provides both standard test and dev sets, whereas MSMARCO provides only the dev set that are widely used for common benchmarks. In what follows, we use the terms query (document) and question (passages) interchangeably. For NQ, we use the standard full recall (strict) as well as the relaxed recall metric [20] to evaluate the retrieval performance. For MSMARCO, we focus on the standard metrics Mean Reciprocal Rank $( \mathbf { M } \mathbf { R } \mathbf { R } ) @ 1 0$ , and normalized Discounted Cumulative Gain $( \mathrm { n D C G } ) @ 1 0$ to evaluate both re-ranking and retrieval performance. For the re-ranking, we restrict to re-ranking only the top 1000 candidate document provided as part of the dataset to be fair, while some works use stronger methods to find better top 1000 candidates for re-ranking (resulting in higher evaluation numbers) See Appendix D for a detailed discussion on these evaluation metrics. Finally, we also evaluate EmbedDistill on the BEIR benchmark [57] in terms of nDCG $@ 1 0$ and recall $@ 1 0 0$ metrics.
275
+
276
+ 9 Model architectures. We follow the standard Transformers-based IR model architectures similar to Karpukhin et al. [20], Qu et al. [48], Oguz et al. ˘ [47]. We utilized various sizes of DE models based on BERT-base [11] (12-layer, 768 dim, 110M parameters), DistilBERT [55] (6-layer, 768 dim, 67.5M parameters $- \sim 2 / 3$ of base), or BERT-mini [58] (4-layer, 256 dim, 11.3M parameters $- \sim 1 / 1 0$ of base). For query generation (cf. Sec. 4.3), we employ BART-base [27], an encoder-decoder model, to generate similar questions from each training example’s input question (query). We randomly mask $\bar { 1 } 0 \%$ of tokens and inject zero mean Gaussian noise with $\sigma = \{ 0 . 1 , 0 . 2 \}$ between the encoder and decoder. See Appendix E for more details on query generation and Appendix F.1 for hyperparameters.
277
+
278
+ # 5.2 DE to DE distillation
279
+
280
+ We employ AR2 $[ 6 3 ] ^ { 3 }$ and SentenceBERTv5 $[ 5 0 ]$ as teacher DE models for NQ and MSMARCO. Note that both models are based on BERT-base. For DE to DE distillation, we consider two kinds of configurations for the student DE model: (1) Symmetric: We use identical question and document encoders. We evaluate DistilBERT and BERT-mini on both datasets. (2) Asymmetric: The student inherits document embeddings from the teacher DE model and are not trained during the distillation. For query encoder, we use DistilBERT or BERT-mini which are smaller than document encoder.
281
+
282
+ Student DE model training. We train student DE models using a combination of (i) one-hot loss (cf. Eq. 9 in Appendix A) on training data; (ii) distillation loss in (cf. Eq. 11 in Appendix A); and (iii) em
283
+
284
+ Table 3: Performance of various DE models on MSMARCO dev set for both $r e$ -ranking and retrieval tasks (full corpus). The teacher model (110.1M parameter BERT-base models as both encoders) for re-ranking achieves MRR $@ 1 0$ of 36.8 and that for retrieval get MRR $@ 1 0$ of 37.2. The table shows performance (in MRR $@ 1 0$ ) of the symmetric DE student model (67.5M or 11.3M transformer as both encoders), and asymmetric DE student model $( 6 7 . 5 \mathrm { M }$ or $1 1 . 3 \mathbf { M }$ transformer as query encoder and document embeddings inherited from the teacher).
285
+
286
+ <table><tr><td rowspan="2">Method</td><td colspan="2">Re-ranking</td><td colspan="2">Retrieval</td></tr><tr><td>67.5M</td><td>11.3M</td><td>67.5M</td><td>11.3M</td></tr><tr><td>Train student directly</td><td>27.0</td><td>23.0</td><td>22.6</td><td>18.6</td></tr><tr><td>+ Distill from teacher</td><td>34.6</td><td>30.4</td><td>35.0</td><td>28.6</td></tr><tr><td>+ Inherit doc embeddings</td><td>35.2</td><td>32.1</td><td>35.7</td><td>30.3</td></tr><tr><td>+ Query embedding matching</td><td>36.2</td><td>35.0</td><td>35.4</td><td>40.8</td></tr><tr><td>+ Query generation</td><td>36.2</td><td>34.4</td><td>37.2</td><td>34.8</td></tr><tr><td>Train student using only embedding matching and</td><td></td><td></td><td></td><td></td></tr><tr><td>inherit doc embeddings</td><td>36.5</td><td>33.5</td><td>36.6</td><td>31.4</td></tr><tr><td>+ Query generation</td><td>36.4</td><td>34.1</td><td>36.7</td><td>32.8</td></tr></table>
287
+
288
+ bedding matching loss in Eq. 7. We used [CLS]-pooling for all student encoders. Unlike DPR [20] or AR2, we do not use hard negatives from BM25 or other models, which greatly simplifies our distillation procedure.
289
+
290
+ Results and discussion. To understand the impact of various proposed configurations and losses, we train models by sequentially adding components and evaluate their retrieval performance on NQ and MSMARCO dev set as shown in Table 1 and Table 3 respectively. (See Table 6 in Appendix F.2 for performance on NQ in terms of the relaxed recall and Table 7 in Appendix F.3 for MSMARCO in terms of $\mathrm { n D C G G } 1 0 .$ )
291
+
292
+ We begin by training a symmetric DE without distillation. As expected, moving to distillation brings in considerable gains. Next, we swap the student document encoder with document embeddings from the teacher (non-trainable), which leads to a good jump in the performance. Now we can introduce EmbedDistill with Eq. 7 for aligning query representations between student and teacher. The two losses are combined with weight of 1.0 (except for BERT-mini models in the presence of query generation with 5.0). This improves performance significantly, e.g.,it provides ${ \sim } 3$ and ${ \sim } 5 $ points increase in recall $\textcircled { \alpha } 5$ on NQ with students based on DistilBERT and BERT-mini, respectively (Table 1). We further explore the utility of EmbedDistill in aligning the teacher and student embedding spaces in Appendix G.1.
293
+
294
+ On top of the two losses (standard distillation and embedding matching), we also use $R _ { \mathrm { E m b , Q } } ( \mathrm { t } , \mathrm { s } ; \Omega ^ { \prime } )$ from Sec. 4.3 on 2 additional questions (per input question) generated from BART. We also try a variant where we eliminate the standard distillation loss and only employ the embedding matching loss in Eq. 7 along with inheriting teacher’s document embeddings. This configuration without the standard distillation loss leads to excellent performance (with query generation again providing additional gains in most cases.)
295
+
296
+ It is worth highlighting that DE models trained with the proposed methods (e.g., asymmetric DE with embedding matching and generation) achieve $9 9 \%$ of the performance in both NQ/MSMARCO tasks with a query encoder that is 2/3rd the size of that of the teacher. Furthermore, even with 1/10th size of the query encoder, our proposal can achieve $9 5 . 9 7 \%$ of the performance. This is particularly useful for latency critical applications with minimal impact on the final performance.
297
+
298
+ Finally, we take our best student models, i.e., one trained using with additional embedding matching loss and using data augmentation from query generation, and evaluate on test sets. We compare with various prior work and note that most prior work used considerably bigger models in terms of parameters, depth (12 or 24 layers), or width (upto 1024 dims). For NQ test set results are reported in Table 2, but as MSMARCO does not have any public test set, we instead present results for the BEIR benchmark in Table 4. Note we also provide evaluation of our SentenceBERT teacher achieving very high performance on the benchmark which can be of independent interest (please refer to Appendix F.4 for details). For both NQ and BEIR, our approach obtains competitive student model with fewer than $50 \%$ of the parameters: even with 6 layers, our student model is very close $( 9 8 - 9 9 \%$ ) to its teacher.
299
+
300
+ Table 4: Average BEIR performance of our DE teacher and EmbedDistill student models and their numbers of trainable parameters. Both models are trained on MSMARCO and evaluated on 14 other datasets (the average does not include MSMARCO). The full table is at Appendix F.4. With EmbedDistill, student materializes most of the performance of the teacher on the unforeseen datasets.
301
+
302
+ <table><tr><td>Method</td><td>#Layers</td><td>nDCG@10</td><td>R@100</td></tr><tr><td>DPR [21]</td><td>12</td><td>22.5</td><td>47.7</td></tr><tr><td>ANCE [60]</td><td>12</td><td>40.5</td><td>60.0</td></tr><tr><td>TAS-B [15]</td><td>6</td><td>42.8</td><td>64.8</td></tr><tr><td>GenQ [57]</td><td>6</td><td>42.5</td><td>64.2</td></tr><tr><td>Our teacher [50]</td><td>12 (220.2M)</td><td>45.7</td><td>65.1</td></tr><tr><td>EmbedDistill</td><td>6 (67.5M)</td><td>44.0</td><td>63.5</td></tr></table>
303
+
304
+ # 5.3 CE to DE distillation
305
+
306
+ We consider two CE teachers for MSMARCO reranking task5 : a standard [CLS]-pooled CE teacher, and the Dual-pooled CE teacher (cf. Sec. 4.2). Both teachers are based on RoBERTa-base and trained on triples in the training set for 300K steps with crossentropy loss.
307
+
308
+ Student DE model training. We considered the following distillation variants: standard score-based distillation from the [CLS]-pooled teacher, and our novel Dual-pooled CE teacher (with and without embedding matching loss). For each variant, we initialize encoders of the student DE model with two RoBERTabase models and train for 500K steps on the training triples. We performed the naïve joint embedding matching for the [CLS]-pooled teacher (cf. Sec. 4.2) and employed the query embedding matching (cf. Eq.7) for the Dual-pooled CE teacher. In either case, embedding-matching loss is added on top of the standard cross entropy loss with the weight of 1.0 (when used).
309
+
310
+ Table 5: Performance of DE models distilled from [CLS]-pooled and Dual-pooled CE models on MSMARCO re-ranking task (original top $1 0 0 0 \ \mathrm { d e v } )$ . While both teacher models perform similarly, embedding matching-based distillation only works with the Dual-pooled teacher. See Appendix F for $\mathrm { n D C G } @ 1 0$ metric.
311
+
312
+ <table><tr><td>Method</td><td>MRR@10</td></tr><tr><td>[CLS]-pooled teacher</td><td>37.1</td></tr><tr><td>Dual-pooled teacher</td><td>37.0</td></tr><tr><td>Standard distillation from [CLs]-pooled teacher</td><td>33.0</td></tr><tr><td>+Joint matching</td><td>32.4</td></tr><tr><td>Standard distillation from Dual-pooled teacher</td><td>33.3</td></tr><tr><td>+Query matching</td><td>33.7</td></tr></table>
313
+
314
+ Results and discussion. Table 5 evaluates the effectiveness of the dual pooling and the embedding matching for CE to DE distillation. As described in Sec. 4.2, the traditional [CLS]-pooled teacher did not provide any useful embedding for the embedding matching (see Appendix G.2 for the further analysis of the resulting embedding space). However, with the Dual-pooled teacher, embedding matching does boost student’s performance.
315
+
316
+ # 6 Related work
317
+
318
+ Here, we position our EmbedDistill work with respect to prior work on distillation and data augmentation for Transformers-based IR models. We also cover prior efforts on aligning representations during distillation for non-IR settings. Unlike our problem setting where the DE student is factorized, these works mainly consider distilling a single large Transformer into a smaller one.
319
+
320
+ Distillation for IR. Traditional distillation techniques have been widely applied in the IR literature, often to distill a teacher CE model to a student DE model [28, 8]. Recently, distillation from a DE
321
+
322
+ 353 model (with complex late interaction) to another DE model (with inner-product scoring) has also been
323
+ 354 considered [29, 15]. As for distilling across different model architectures, Lu et al. [31], Izacard and
324
+ 355 Grave [16] consider distillation from a teacher CE model to a student DE model. Hofstätter et al. [14]
325
+ 356 conduct an extensive study of knowledge distillation across a wide-range of model architectures. Most
326
+ 357 existing distillation schemes for IR rely on only teacher scores; by contrast, we propose a geometric
327
+ 358 approach that also utilizes the teacher embeddings. Many recent efforts [48, 51, 56] show that iterative
328
+ 359 multi-stage (self-)distillation improves upon single-stage distillation [48, 51, 56]. These approaches
329
+ 360 use a model from the previous stage to obtain labels [56] as well as mine harder-negatives [60]. We
330
+ 361 only focus on the single-stage distillation in this paper. Multi-stage procedures are complementary to
331
+ 362 our work, as one can employ our proposed embedding-matching approach in various stages of such a
332
+ 363 procedure. Interestingly, we demonstrate in Sec. 5 that our proposed EmbedDistill can successfully
333
+ 364 benefit from high quality models trained with such complex procedures [50, 63]. In particular, our
334
+ 365 single-stage distillation method can transfer almost all of their performance gains to even smaller
335
+ 366 models. Also to showcase that our method brings gain orthogonal to how teacher was trained, we
336
+ 367 conduct experiments with single-stage trained teacher in Appendix F.5.
337
+ 368 Distillation with representation alignments. Outside of the IR context, a few prior works proposed
338
+ 369 to utilize alignment between hidden layers during distillation [52, 55, 18, 1, 64]. Chen et al. [7] utilize
339
+ 370 the representation alignment to re-use teacher’s classification layer for image classification. Unlike
340
+ 371 these works, our work is grounded in a rigorous theoretical understanding of the teacher-student
341
+ 372 (generalization) gap for IR models. Further, our work differs from these as it needs to address multiple
342
+ 373 challenges presented by an IR setting: 1) cross-architecture distillation such as CE to DE distillation;
343
+ 374 2) partial representation alignment of query or document representations as opposed to aligning for
344
+ 375 the entire input, i.e., a query-documents pair; and 3) catering representation alignment approach to
345
+ 376 novel IR setups such as asymmetric DE configuration. To the best of our knowledge, our work is first
346
+ 377 in the IR literature that goes beyond simply matching scores (or its proxies) for distillation.
347
+
348
+ Semi-supervised learning for IR. Data augmentation or semi-supervised learning has been previously used to ensure data efficiency in IR [see, e.g., 35, 66]. More interestingly, data augmentation have enabled performance improvements as well. Doc2query [45, 44] performs document expansion by generating queries that are relevant to the document and appending those queries to the document. Query expansion has also been considered, e.g., for document re-ranking [67]. Notably, generating synthetic (query, passage, answer) triples from a text corpus to augment existing training data for QA systems also leads to significant gains [2, 47]. Furthermore, even zero-shot approaches, where no labeled query-document pairs are used, can also perform competitively to supervised methods [26, 17, 33, 54]. Unlike these works, we utilize query-generation capability to ensure tighter alignment between the embedding spaces of the teacher and student.
349
+
350
+ Richer transformers-based architectures for IR. Besides DE and CE models (cf. Sec. 2), intermediate configurations [36, 22, 42, 32] have been proposed. Such models independently encode query and document before applying a more complex late interaction between the two. Nogueira et al. [46] explore generative encoder-decoder style model for re-ranking. In this paper, we focus on basic DE/CE models to showcase the benefits of our proposed geometric distillation approach. Exploring embedding matching for aforementioned architectures is an interesting avenue for future work.
351
+
352
+ # 394 7 Conclusion
353
+
354
+ We propose EmbedDistill — a novel distillation method for IR that goes beyond simple score matching. En route, we provide a theoretical understanding of the teacher-student generalization gap in an IR setting which not only motivated EmbedDistill but also inspired new design choices for the student DE models: (a) reusing the teacher’s document encoder in the student and (b) aligning query embeddings of the teacher and student. This simple approach delivers consistent quality and computational gains in practical deployments and we demonstrate them on MSMARCO, NQ, and BEIR benchmarks. Finally, we found EmbedDistill retains $9 5 . 9 7 \%$ of the teacher performance to with 1/10th size students.
355
+
356
+ Limitations. As discussed in Sec. 4.2 and 5.3, EmbedDistill requires modifications in the CE scoring function to be effective. In terms of underlying IR model architectures, we only explore Transformerbased models in our experiments; primarily due to their widespread utilization. That said, we expect our results to extend to non-Transformer architectures such as MLPs. Finally, we note that our experiments only consider NLP domains, and exploring other modalities (e.g., vision) or multi-modal settings (e.g., image-to-text search) is left as an interesting avenue for future work.
357
+
358
+ 408 References [1] Gustavo Aguilar, Yuan Ling, Yu Zhang, Benjamin Yao, Xing Fan, and Chenlei Guo. Knowledge distillation from internal representations. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 7350–7357, 2020. [2] Chris Alberti, Daniel Andor, Emily Pitler, Jacob Devlin, and Michael Collins. Synthetic QA corpora generation with roundtrip consistency. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 6168–6173, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1620. URL https://aclanthology.org/P19-1620. [3] Yoshua Bengio and Jean-SÉbastien Senecal. Adaptive importance sampling to accelerate training of a neural probabilistic language model. IEEE Transactions on Neural Networks, 19 (4):713–722, 2008. doi: 10.1109/TNN.2007.912312. [4] Olivier Bousquet, Stéphane Boucheron, and Gábor Lugosi. Introduction to Statistical Learning Theory, pages 169–207. Springer Berlin Heidelberg, Berlin, Heidelberg, 2004. ISBN 978-3-540-28650-9. doi: 10.1007/978-3-540-28650-9_8. URL https://doi.org/10.1007/ 978-3-540-28650-9_8. [5] Cristian Bucila, Rich Caruana, and Alexandru Niculescu-Mizil. Model compression. In ˇ Proceedings of the 12th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD ’06, pages 535–541, New York, NY, USA, 2006. ACM. [6] Danqi Chen, Adam Fisch, Jason Weston, and Antoine Bordes. Reading Wikipedia to answer open-domain questions. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1870–1879, Vancouver, Canada, July 2017. Association for Computational Linguistics. doi: 10.18653/v1/P17-1171. URL https://aclanthology.org/P17-1171. [7] Defang Chen, Jian-Ping Mei, Hailin Zhang, Can Wang, Yan Feng, and Chun Chen. Knowledge distillation with the reused teacher classifier. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11933–11942, 2022. [8] Xuanang Chen, Ben He, Kai Hui, Le Sun, and Yingfei Sun. Simplified tinybert: Knowledge distillation for document retrieval. In Djoerd Hiemstra, Marie-Francine Moens, Josiane Mothe, Raffaele Perego, Martin Potthast, and Fabrizio Sebastiani, editors, Advances in Information Retrieval, pages 241–248, Cham, 2021. Springer International Publishing. ISBN 978-3-030- 72240-1. [9] Zhuyun Dai and Jamie Callan. Deeper text understanding for IR with contextual neural language modeling. In Benjamin Piwowarski, Max Chevalier, Éric Gaussier, Yoelle Maarek, Jian-Yun Nie, and Falk Scholer, editors, Proceedings of the 42nd International ACM SIGIR Conference on Research and Development in Information Retrieval, SIGIR 2019, Paris, France, July 21-25, 2019, pages 985–988. ACM, 2019. [10] Zhuyun Dai and Jamie Callan. Context-aware sentence/passage term importance estimation for first stage retrieval. arXiv preprint arXiv:1910.10687, 2019. [11] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. In Jill Burstein, Christy Doran, and Thamar Solorio, editors, Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACLHLT 2019, Minneapolis, MN, USA, June 2-7, 2019, Volume 1 (Long and Short Papers), pages 4171–4186. Association for Computational Linguistics, 2019.
359
+ 453 [12] Ruiqi Guo, Philip Sun, Erik Lindgren, Quan Geng, David Simcha, Felix Chern, and Sanjiv Kumar. Accelerating large-scale inference with anisotropic vector quantization. In International Conference on Machine Learning, 2020. URL https://arxiv.org/abs/1908.10396. [13] Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network, 2015.
360
+
361
+ 458 [14] Sebastian Hofstätter, Sophia Althammer, Michael Schröder, Mete Sertkan, and Allan Hanbury.
362
+ 459 Improving efficient neural ranking models with cross-architecture knowledge distillation. CoRR,
363
+ 460 abs/2010.02666, 2020. URL https://arxiv.org/abs/2010.02666.
364
+ 61 [15] Sebastian Hofstätter, Sheng-Chieh Lin, Jheng-Hong Yang, Jimmy Lin, and Allan Hanbury.
365
+ 62 Efficiently teaching an effective dense retriever with balanced topic aware sampling. In Pro
366
+ 63 ceedings of the 44th International ACM SIGIR Conference on Research and Development in
367
+ 64 Information Retrieval, SIGIR ’21, page 113–122, New York, NY, USA, 2021. Association
368
+ 65 for Computing Machinery. ISBN 9781450380379. doi: 10.1145/3404835.3462891. URL
369
+ 66 https://doi.org/10.1145/3404835.3462891.
370
+ [16] Gautier Izacard and Edouard Grave. Distilling knowledge from reader to retriever for question
371
+ 68 answering. In International Conference on Learning Representations, 2021. URL https:
372
+ 69 //openreview.net/forum?id=NTEz-6wysdb.
373
+ 70 [17] Gautier Izacard, Mathild Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand
374
+ 71 Joulin, and Edouard Grave. Unsupervised dense information retrieval with contrastive learning.
375
+ 72 arXiv preprint arXiv:2112.09118, 2021.
376
+ [18] Xiaoqi Jiao, Yichun Yin, Lifeng Shang, Xin Jiang, Xiao Chen, Linlin Li, Fang Wang, and
377
+ 74 Qun Liu. TinyBERT: Distilling BERT for natural language understanding. In Findings of the
378
+ 75 Association for Computational Linguistics: EMNLP 2020, pages 4163–4174, Online, November
379
+ 76 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.findings-emnlp.372.
380
+ 77 URL https://aclanthology.org/2020.findings-emnlp.372.
381
+ 78 [19] Jeff Johnson, Matthijs Douze, and Hervé Jégou. Billion-scale similarity search with gpus. IEEE
382
+ 79 Transactions on Big Data, 7(3):535–547, 2021. doi: 10.1109/TBDATA.2019.2921572.
383
+ 80 [20] Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis, Ledell Wu, Sergey Edunov,
384
+ 81 Danqi Chen, and Wen-tau Yih. Dense passage retrieval for open-domain question answering.
385
+ 82 In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Process
386
+ 83 ing (EMNLP), pages 6769–6781, Online, November 2020. Association for Computational
387
+ 84 Linguistics.
388
+ 85 [21] Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis, Ledell Wu, Sergey Edunov, ˘
389
+ 86 Danqi Chen, and Wen-tau Yih. Dense passage retrieval for open-domain question answering.
390
+ 87 arXiv preprint arXiv:2004.04906, 2020.
391
+ 88 [22] Omar Khattab and Matei Zaharia. ColBERT: Efficient and Effective Passage Search via
392
+ 89 Contextualized Late Interaction over BERT, page 39–48. Association for Computing Machinery,
393
+ 90 New York, NY, USA, 2020. ISBN 9781450380164.
394
+ [23] Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris
395
+ 92 Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, Kristina Toutanova, Llion
396
+ 93 Jones, Matthew Kelcey, Ming-Wei Chang, Andrew M. Dai, Jakob Uszkoreit, Quoc Le, and Slav
397
+ 94 Petrov. Natural questions: A benchmark for question answering research. Transactions of the
398
+ 95 Association for Computational Linguistics, 7:452–466, 2019. doi: 10.1162/tacl_a_00276. URL
399
+ 96 https://aclanthology.org/Q19-1026.
400
+ 97 [24] Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris
401
+ 98 Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, et al. Natural questions: a
402
+ 99 benchmark for question answering research. Transactions of the Association for Computational
403
+ 00 Linguistics, 7:453–466, 2019.
404
+ 01 [25] Michel Ledoux and Michel Talagrand. Probability in Banach spaces. Springer-Verlag, 1991.
405
+ 02 [26] Kenton Lee, Ming-Wei Chang, and Kristina Toutanova. Latent retrieval for weakly supervised
406
+ 03 open domain question answering. In Anna Korhonen, David R. Traum, and Lluís Màrquez,
407
+ 04 editors, Proceedings of the 57th Conference of the Association for Computational Linguistics,
408
+ 05 ACL 2019, Florence, Italy, July 28- August 2, 2019, Volume 1: Long Papers, pages 6086–6096.
409
+ 06 Association for Computational Linguistics, 2019.
410
+ 507 [27] Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer
411
+ 508 Levy, Veselin Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pre
412
+ 509 training for natural language generation, translation, and comprehension. In Proceedings of
413
+ 510 the 58th Annual Meeting of the Association for Computational Linguistics, pages 7871–7880,
414
+ 511 Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.
415
+ 512 703. URL https://aclanthology.org/2020.acl-main.703.
416
+ 513 [28] Canjia Li, Andrew Yates, Sean MacAvaney, Ben He, and Yingfei Sun. Parade: Passage repre
417
+ 514 sentation aggregation for document reranking. arXiv preprint arXiv:2008.09093, 2020.
418
+ 515 [29] Sheng-Chieh Lin, Jheng-Hong Yang, and Jimmy Lin. In-batch negatives for knowledge dis
419
+ 516 tillation with tightly-coupled teachers for dense retrieval. In Proceedings of the 6th Work
420
+ 517 shop on Representation Learning for NLP (RepL4NLP-2021), pages 163–173, Online, August
421
+ 518 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.repl4nlp-1.17. URL
422
+ 519 https://aclanthology.org/2021.repl4nlp-1.17.
423
+ 520 [30] Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike
424
+ 521 Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining
425
+ 522 approach. arXiv preprint arXiv:1907.11692, 2019.
426
+ 523 [31] Wenhao Lu, Jian Jiao, and Ruofei Zhang. Twinbert: Distilling knowledge to twin-structured
427
+ 524 compressed bert models for large-scale retrieval. In Proceedings of the 29th ACM International
428
+ 525 Conference on Information & Knowledge Management, CIKM ’20, page 2645–2652, New
429
+ 526 York, NY, USA, 2020. Association for Computing Machinery. ISBN 9781450368599. doi:
430
+ 527 10.1145/3340531.3412747. URL https://doi.org/10.1145/3340531.3412747.
431
+ 528 [32] Yi Luan, Jacob Eisenstein, Kristina Toutanova, and Michael Collins. Sparse, dense, and
432
+ 529 attentional representations for text retrieval. Transactions of the Association for Computational
433
+ 530 Linguistics, 9:329–345, 2021. doi: 10.1162/tacl_a_00369. URL https://aclanthology.org/
434
+ 531 2021.tacl-1.20.
435
+ 532 [33] Ji Ma, Ivan Korotkov, Yinfei Yang, Keith Hall, and Ryan McDonald. Zero-shot neural pas
436
+ 533 sage retrieval via domain-targeted synthetic question generation. In Proceedings of the 16th
437
+ 534 Conference of the European Chapter of the Association for Computational Linguistics: Main
438
+ 535 Volume, pages 1075–1088, Online, April 2021. Association for Computational Linguistics. doi:
439
+ 536 10.18653/v1/2021.eacl-main.92. URL https://aclanthology.org/2021.eacl-main.92.
440
+ 537 [34] Sean MacAvaney, Andrew Yates, Arman Cohan, and Nazli Goharian. CEDR: Contextualized
441
+ 538 embeddings for document ranking. In Proceedings of the 42nd International ACM SIGIR
442
+ 539 Conference on Research and Development in Information Retrieval, SIGIR’19, page 1101–1104,
443
+ 540 New York, NY, USA, 2019. Association for Computing Machinery. ISBN 9781450361729. doi:
444
+ 541 10.1145/3331184.3331317. URL https://doi.org/10.1145/3331184.3331317.
445
+ 542 [35] Sean MacAvaney, Andrew Yates, Kai Hui, and Ophir Frieder. Content-based weak supervision
446
+ 543 for ad-hoc re-ranking. In Proceedings of the 42nd International ACM SIGIR Conference on
447
+ 544 Research and Development in Information Retrieval, SIGIR’19, page 993–996, New York, NY,
448
+ 545 USA, 2019. Association for Computing Machinery. ISBN 9781450361729. doi: 10.1145/
449
+ 546 3331184.3331316. URL https://doi.org/10.1145/3331184.3331316.
450
+ 547 [36] Sean MacAvaney, Franco Maria Nardini, Raffaele Perego, Nicola Tonellotto, Nazli Goharian,
451
+ 548 and Ophir Frieder. Efficient Document Re-Ranking for Transformers by Precomputing Term
452
+ 549 Representations, page 49–58. Association for Computing Machinery, New York, NY, USA,
453
+ 550 2020. ISBN 9781450380164.
454
+ 551 [37] Aditya Menon, Sadeep Jayasumana, Ankit Singh Rawat, Seungyeon Kim, Sashank Reddi,
455
+ 552 and Sanjiv Kumar. In defense of dual-encoders for neural ranking. In Kamalika Chaudhuri,
456
+ 553 Stefanie Jegelka, Le Song, Csaba Szepesvari, Gang Niu, and Sivan Sabato, editors, Proceedings
457
+ 554 of the 39th International Conference on Machine Learning, volume 162 of Proceedings of
458
+ 555 Machine Learning Research, pages 15376–15400. PMLR, 17–23 Jul 2022. URL https:
459
+ 556 //proceedings.mlr.press/v162/menon22a.html.
460
+
461
+ [38] Bhaskar Mitra and Nick Craswell. An introduction to neural information retrieval. Foundations and Trends® in Information Retrieval, 13(1):1–126, 2018. ISSN 1554-0669. doi: 10.1561/ 1500000061. URL http://dx.doi.org/10.1561/1500000061. 560 [39] Arvind Neelakantan, Tao Xu, Raul Puri, Alec Radford, Jesse Michael Han, Jerry Tworek, Qiming Yuan, Nikolas Tezak, Jong Wook Kim, Chris Hallacy, et al. Text and code embeddings by contrastive pre-training. arXiv preprint arXiv:2201.10005, 2022. [40] Tri Nguyen, Mir Rosenberg, Xia Song, Jianfeng Gao, Saurabh Tiwary, Rangan Majumder, and Li Deng. MS MARCO: A human generated machine reading comprehension dataset. In Tarek Richard Besold, Antoine Bordes, Artur S. d’Avila Garcez, and Greg Wayne, editors, Proceedings of the Workshop on Cognitive Computation: Integrating neural and symbolic approaches 2016, volume 1773 of CEUR Workshop Proceedings. CEUR-WS.org, 2016. [41] Jianmo Ni, Chen Qu, Jing Lu, Zhuyun Dai, Gustavo Hernandez Abrego, Ji Ma, Vincent Zhao, Yi Luan, Keith Hall, Ming-Wei Chang, and Yinfei Yang. Large dual encoders are generalizable retrievers. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 9844–9855, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics. URL https://aclanthology.org/2022.emnlp-main.669. [42] Ping Nie, Yuyu Zhang, Xiubo Geng, Arun Ramamurthy, Le Song, and Daxin Jiang. DC-BERT: decoupling question and document for efficient contextual encoding. In Jimmy Huang, Yi Chang, Xueqi Cheng, Jaap Kamps, Vanessa Murdock, Ji-Rong Wen, and Yiqun Liu, editors, Proceedings of the 43rd International ACM SIGIR conference on research and development in Information Retrieval, SIGIR 2020, Virtual Event, China, July 25-30, 2020, pages 1829–1832. ACM, 2020. doi: 10.1145/3397271.3401271. URL https://doi.org/10.1145/3397271.3401271. [43] Rodrigo Nogueira and Kyunghyun Cho. Passage re-ranking with BERT. CoRR, abs/1901.04085, 2019. URL http://arxiv.org/abs/1901.04085. [44] Rodrigo Nogueira, Jimmy Lin, and AI Epistemic. From doc2query to doctttttquery. Online preprint, 6, 2019. [45] Rodrigo Nogueira, Wei Yang, Jimmy Lin, and Kyunghyun Cho. Document expansion by query prediction. arXiv preprint arXiv:1904.08375, 2019. [46] Rodrigo Nogueira, Zhiying Jiang, Ronak Pradeep, and Jimmy Lin. Document ranking with a pretrained sequence-to-sequence model. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 708–718, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.findings-emnlp.63. URL https: //aclanthology.org/2020.findings-emnlp.63. [47] Barlas Oguz, Kushal Lakhotia, Anchit Gupta, Patrick Lewis, Vladimir Karpukhin, Aleksandra ˘ Piktus, Xilun Chen, Sebastian Riedel, Wen-tau Yih, Sonal Gupta, et al. Domain-matched pre-training tasks for dense retrieval. arXiv preprint arXiv:2107.13602, 2021. [48] Yingqi Qu, Yuchen Ding, Jing Liu, Kai Liu, Ruiyang Ren, Wayne Xin Zhao, Daxiang Dong, Hua Wu, and Haifeng Wang. RocketQA: An optimized training approach to dense passage retrieval for open-domain question answering. In Kristina Toutanova, Anna Rumshisky, Luke Zettlemoyer, Dilek Hakkani-Tür, Iz Beltagy, Steven Bethard, Ryan Cotterell, Tanmoy Chakraborty, and Yichao Zhou, editors, Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2021, Online, June 6-11, 2021, pages 5835–5847. Association for Computational Linguistics, 2021. [49] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21(140):1–67, 2020. URL http://jmlr.org/papers/v21/20-074.html. [50] Nils Reimers, Iryna Gurevych, and Iryna Gurevych. Sentence-BERT: Sentence embeddings using siamese bert-networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing. Association for Computational Linguistics, 11 2019. URL http://arxiv.org/abs/1908.10084.
462
+
463
+ [51] Ruiyang Ren, Yingqi Qu, Jing Liu, Wayne Xin Zhao, Qiaoqiao She, Hua Wu, Haifeng Wang, and Ji-Rong Wen. Rocketqav2: A joint training method for dense passage retrieval and passage re-ranking. In Proceedings of EMNLP, 2021.
464
+ [52] 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.
465
+ [53] Devendra Sachan, Mostofa Patwary, Mohammad Shoeybi, Neel Kant, Wei Ping, William L. Hamilton, and Bryan Catanzaro. End-to-end training of neural retrievers for open-domain question answering. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 6648–6662, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.519. URL https: //aclanthology.org/2021.acl-long.519.
466
+ [54] Devendra Singh Sachan, Mike Lewis, Mandar Joshi, Armen Aghajanyan, Wen-tau Yih, Joelle Pineau, and Luke Zettlemoyer. Improving passage retrieval with zero-shot question generation. arXiv preprint arXiv:2204.07496, 2022.
467
+ [55] Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108, 2019.
468
+ [56] Keshav Santhanam, Omar Khattab, Jon Saad-Falcon, Christopher Potts, and Matei Zaharia. Colbertv2: Effective and efficient retrieval via lightweight late interaction. CoRR, abs/2112.01488, 2021.
469
+ [57] Nandan Thakur, Nils Reimers, Andreas Rücklé, Abhishek Srivastava, and Iryna Gurevych. BEIR: A heterogeneous benchmark for zero-shot evaluation of information retrieval models. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 2), 2021. URL https://openreview.net/forum?id=wCu6T5xFjeJ.
470
+ [58] Iulia Turc, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Well-read students learn better: On the importance of pre-training compact models. arXiv preprint arXiv:1908.08962, 2019.
471
+ [59] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS’17, page 6000–6010, Red Hook, NY, USA, 2017. Curran Associates Inc. ISBN 9781510860964.
472
+ [60] Lee Xiong, Chenyan Xiong, Ye Li, Kwok-Fung Tang, Jialin Liu, Paul N. Bennett, Junaid Ahmed, and Arnold Overwijk. Approximate nearest neighbor negative contrastive learning for dense text retrieval. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $=$ zeFrfgyZln.
473
+ [61] Nishant Yadav, Nicholas Monath, Rico Angell, Manzil Zaheer, and Andrew McCallum. Efficient nearest neighbor search for cross-encoder models using matrix factorization. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 2171–2194, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics. URL https://aclanthology.org/2022.emnlp-main.140.
474
+ [62] Zeynep Akkalyoncu Yilmaz, Wei Yang, Haotian Zhang, and Jimmy Lin. Cross-domain modeling of sentence-level evidence for document retrieval. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 3490–3496, Hong Kong, China, November 2019. Association for Computational Linguistics.
475
+ [63] Hang Zhang, Yeyun Gong, Yelong Shen, Jiancheng Lv, Nan Duan, and Weizhu Chen. Adversarial retriever-ranker for dense text retrieval. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=MR7XubKUFB.
476
+ [64] Linfeng Zhang and Kaisheng Ma. Improve object detection with feature-based knowledge distillation: Towards accurate and efficient detectors. In International Conference on Learning Representations, 2020.
477
+
478
+ 660 [65] Shuai Zhang, Lina Yao, Aixin Sun, and Yi Tay. Deep learning based recommender system:
479
+ 661 A survey and new perspectives. ACM Comput. Surv., 52(1), feb 2019. ISSN 0360-0300. doi:
480
+ 662 10.1145/3285029. URL https://doi.org/10.1145/3285029.
481
+ 663 [66] Chen Zhao, Chenyan Xiong, Jordan Boyd-Graber, and Hal Daumé III. Distantly-supervised
482
+ 664 dense retrieval enables open-domain question answering without evidence annotation. In
483
+ 665 Proceedings of the 2021 Conference on Empirical Methods in Natural Language Process
484
+ 666 ing, pages 9612–9622, Online and Punta Cana, Dominican Republic, November 2021. As
485
+ 667 sociation for Computational Linguistics. doi: 10.18653/v1/2021.emnlp-main.756. URL
486
+ 668 https://aclanthology.org/2021.emnlp-main.756.
487
+ 669 [67] Zhi Zheng, Kai Hui, Ben He, Xianpei Han, Le Sun, and Andrew Yates. BERT-QE: Con
488
+ 670 textualized Query Expansion for Document Re-ranking. In Findings of the Association for
489
+ 671 Computational Linguistics: EMNLP 2020, pages 4718–4728, Online, November 2020. As
490
+ 672 sociation for Computational Linguistics. doi: 10.18653/v1/2020.findings-emnlp.424. URL
491
+ 673 https://aclanthology.org/2020.findings-emnlp.424.
md/dev/CAjxVodl_v/CAjxVodl_v.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/CZZFRxbOLC/CZZFRxbOLC.md ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Patching open-vocabulary models by interpolating weights
2
+
3
+ Gabriel Ilharco∗1 Mitchell Wortsman∗1 Samir Yitzhak Gadre∗2 Shuran Song2 Hannaneh Hajishirzi1,3 Simon Kornblith4 Ali Farhadi1 Ludwig Schmidt1,3 1University of Washington 2Columbia University 3AI2 4Google Research, Brain Team
4
+
5
+ # Abstract
6
+
7
+ Open-vocabulary models like CLIP achieve high accuracy across many image classification tasks. However, there are still settings where their zero-shot performance is far from optimal. We study model patching, where the goal is to improve accuracy on specific tasks without degrading accuracy on tasks where performance is already adequate. Towards this goal, we introduce PAINT, a patching method that uses interpolations between the weights of a model before fine-tuning and the weights after fine-tuning on a task to be patched. On nine tasks where zeroshot CLIP performs poorly, PAINT increases accuracy by 15 to 60 percentage points while preserving accuracy on ImageNet within one percentage point of the zero-shot model. PAINT also allows a single model to be patched on multiple tasks and improves with model scale. Furthermore, we identify cases of broad transfer, where patching on one task increases accuracy on other tasks even when the tasks have disjoint classes. Finally, we investigate applications beyond common benchmarks such as counting or reducing the impact of typographic attacks on CLIP. Our findings demonstrate that it is possible to expand the set of tasks on which open-vocabulary models achieve high accuracy without re-training them from scratch.
8
+
9
+ # 1 Introduction
10
+
11
+ Open-vocabulary models are characterized by their ability to perform any image classification task based on text descriptions of the classes [56]. Thanks to advances in large-scale pre-training, recent examples of open-vocabulary models such as CLIP and BASIC have reached parity with or surpassed important task-specific baselines, even when the open-vocabulary models are not fine-tuned on task-specific data (i.e., in a zero-shot setting) [57, 31, 56, 88, 1, 86]. For instance, the largest CLIP model from Radford et al. [57] used in a zero-shot setting matches the ImageNet accuracy of a ResNet-50 trained on 1.2 million ImageNet images [14, 24].
12
+
13
+ Nevertheless, current open-vocabulary models still face challenges. The same CLIP model that matches a ResNet-50 on ImageNet has lower MNIST accuracy than simple logistic regression in pixel space [57]. Moreover, even when zero-shot models achieve good performance, they are usually still worse than models trained or fine-tuned on specific downstream tasks.
14
+
15
+ To address these issues, several authors have proposed methods for adapting zero-shot models to a task of interest using labeled data [82, 91, 21, 89, 37, 73]. A common practice is to fine-tune the zero-shot model on the task of interest [82, 56]. However, fine-tuned models can suffer from catastrophic forgetting [48, 76, 20, 33], performing poorly on tasks where the zero-shot model initially performed well [2, 82, 56]. Additionally, fine-tuning typically produces a task-specific classification head, sacrificing the flexible text-based API that makes open-vocabulary models so appealing. Whereas an open-vocabulary model can perform any classification task in a zero-shot fashion, a fine-tuned model with a task-specific head can only process the specific task that it was fine-tuned on. This specialization can prevent knowledge obtained by fine-tuning on one task from transferring to other related tasks with different classes.
16
+
17
+ ![](images/27454f67282ad59a0cde948bc9974465c3d8f122323b75d055c62f58685f01e7.jpg)
18
+ Figure 1: Patching open-vocabulary models by linearly interpolating weights. We wish to improve accuracy on tasks where a model performs poorly (patching tasks), without degrading performance on tasks where accuracy is already adequate (supported tasks). When interpolating weights of fine-tuned models and zeroshot (unpatched) models, there are intermediate solutions where accuracy improves on the patching task without reducing accuracy on supported tasks. Results are shown for CLIP models [57], averaged over nine patching tasks (Stanford Cars, DTD, EuroSAT, GTSRB, KITTI distance, MNIST, RESISC45, SUN397 and SVHN [35, 11, 25, 71, 22, 39, 7, 12, 84, 53]) and five supported tasks (ImageNet, CIFAR-10, CIFAR-100, STL-10 and Food101 [14, 36, 12, 5]). We apply PAINT separately on each patching task and average results across experiments. The dashed lines illustrate vertical movement from the unpatched models and horizontal movement from the fine-tuned models.
19
+
20
+ Another approach to adapting zero-shot models would be to add data from the downstream task to the pre-training dataset and train a new open-vocabulary model from scratch. The resulting model could still perform any classification task, and zero-shot performance may improve on related tasks. However, training large image-text models from scratch can require hundreds of thousands of GPU hours [57, 56, 86], which makes this approach practically infeasible in most settings.
21
+
22
+ In this paper, we study patching open-vocabulary models, where the goal is to increase accuracy on new target tasks while maintaining the flexibility of the model and its accuracy on other tasks.1 Patching aims to combine the benefits of fine-tuning and re-training from scratch: improved performance on the task of interest, maintaining the flexibility of an open vocabulary, transfer between tasks, and fast adaptation time. Motivated by these goals, we extend existing fine-tuning techniques [82] to open-vocabulary settings, where the class space is not fixed. We introduce Patching with Interpolation (PAINT), a simple, two-step procedure for patching models: first, fine-tune the model on the patching task without introducing any task-specific parameters; then, linearly interpolate between the weights of the model before and after fine-tuning. Linearly interpolating neural network weights [52, 19, 54] has been previously used to improve accuracy on a single task [28, 81] or robustness to distribution shift [82]. Indeed, averaging network weights has been explored in continual learning contexts, although for closed-vocabulary models [40].
23
+
24
+ With PAINT, accuracy can improve on new tasks without degrading accuracy on unrelated tasks, as illustrated in Figure 1. For instance, applying PAINT to a CLIP ViT-L/14 [57] independently on nine image classification tasks [35, 11, 25, 71, 22, 39, 7, 84, 53] improves accuracy by 15 to 60 percentage points compared to the unpatched model, while accuracy on ImageNet [14] decreases by less than one percentage point. We also observe a promising trend: patching becomes more effective with model scale (Section 4.1).
25
+
26
+ Beyond single tasks, we show that models can be patched on multiple tasks (Section 5). When patching on nine image classification tasks simultaneously, a single CLIP ViT-L/14 model is competitive with using one specialized model for each task—the average accuracy difference is less than 0.5 percentage points.
27
+
28
+ Moreover, PAINT enables broad transfer (Section 6): accuracy on related tasks can increase, even when the class space changes. For instance, we partition EuroSAT [25], a satellite image dataset, into two halves with disjoint labels. Patching a ViT-L/14 model on the first half improves accuracy on the second half by 7.3 percentage points, even though the classes are unseen during patching.
29
+
30
+ Finally, we investigate PAINT on case studies including typographic attacks [23], counting [32], and visual question answering [4] (Section 7). For instance, applying PAINT using synthetic typographic attacks leads to a model that is less susceptible to typographic attacks in the real world, improving its accuracy by 41 percentage points.
31
+
32
+ In summary:
33
+
34
+ • Even the best pre-trained models are not perfect. We introduce PAINT, a method designed to improve accuracy on new tasks without harming accuracy elsewhere.
35
+ • PAINT incurs no extra computational cost compared to standard fine-tuning, neither during fine-tuning itself nor at inference time.
36
+ • PAINT can also be applied with multiple tasks, providing a single model that is competitive with many specialized models.
37
+ • Applying PAINT with one task can improve accuracy on a related task, even when they do not share the same classes.
38
+ • PAINT improves with model scale, indicating a promising trend for future models.
39
+
40
+ # 2 Patching with interpolation (PAINT)
41
+
42
+ This section details our method for patching models on a single and multiple tasks.
43
+
44
+ Patching on a single task. Given an open-vocabulary model with weights $\theta _ { \mathrm { z s } }$ and a patching task $\mathcal { D } _ { \mathrm { p a t c h } }$ , our goal is to produce a new model $\theta _ { \mathrm { p a t c h } }$ which achieves high accuracy on $\mathcal { D } _ { \mathrm { { p a t c h } } }$ without decreasing model performance on tasks where accuracy is already acceptable. We let $\mathcal { D } _ { \mathrm { s u p p } }$ denote a representative supported task where model performance is adequate, and later show that the method is stable under different choices of $\mathcal { D } _ { \mathrm { s u p p } }$ (Section 4.2). The two-step procedure we explore for producing $\theta _ { \mathrm { p a t c h } }$ is given below.
45
+
46
+ Step 1. Fine-tune $\theta _ { \mathrm { z s } }$ on training data from $\mathcal { D } _ { \mathrm { p a t c h } }$ to produce a model with weights $\theta _ { \mathrm { f t } }$ . Step 2. For mixing coefficient $\alpha \in [ 0 , 1 ]$ , linearly interpolate between $\theta _ { \mathrm { z s } }$ and $\theta _ { \mathrm { f t } }$ to produce $\theta _ { \mathrm { p a t c h } } = ( 1 - \alpha ) \cdot \theta _ { \mathrm { z s } } + \alpha \cdot \theta _ { \mathrm { f t } }$ . The mixing coefficient is determined via held-out validation sets for $\mathcal { D } _ { \mathrm { s u p p } }$ and $\mathcal { D } _ { \mathrm { p a t c h } }$ . We refer to the resulting model as $\theta _ { \mathrm { p a t c h } }$ .
47
+
48
+ In our experiments, we do not introduce any additional task-specific parameters when fine-tuning, as discussed in Section 3 and Appendices B and $\textrm { C }$ .
49
+
50
+ Patching on a multiple tasks. In practice, we often want to improve model accuracy on multiple patching tasks D(1)patch $\mathcal { D } _ { \mathrm { p a t c h } } ^ { ( 1 ) } , . . . , \mathcal { D } _ { \mathrm { p a t c h } } ^ { ( k ) }$ D(k)patch, which can be accomplished with straightforward modifications to the procedure above. We explore three alternatives and examine their relative trade-offs in Section 5:
51
+
52
+ • Joint patching, where we merge all the patching tasks $\mathcal { D } _ { \mathtt { p a t c h } } ^ { ( i ) }$ into a single task $\mathcal { D } _ { \mathrm { p a t c h } }$ before running the patching procedure;
53
+ • Sequential patching, where we iteratively repeat the patching procedure above on each new task
54
+ D(i) and let $\theta _ { \mathrm { z s } } \theta _ { \mathrm { p a t c h } }$ after each completed iteration;
55
+ • Parallel patching, where we apply the first step on each task in parallel to produce fine-tuned $\theta _ { \mathrm { f t } } ^ { ( 1 ) } , . . . , \bar { \theta _ { \mathrm { f t } } ^ { ( k ) } }$ e search for mixing coefficients . $\alpha _ { i }$ to produce $\begin{array} { r } { \theta _ { \mathrm { p a t c h } } = \big ( 1 - \sum _ { i = 1 } ^ { k } \alpha _ { i } \big ) \cdot \theta _ { \mathrm { z s } } + \sum _ { i = 1 } ^ { k } \alpha _ { i } \cdot \theta _ { \mathrm { f t } } ^ { ( i ) } } \end{array}$
56
+
57
+ For joint and parallel patching we assume access to held-out validation sets for all tasks, while in sequential patching we only assume access to held-out validation sets from the tasks seen so far. Unless mentioned otherwise, we pick the mixing coefficient $\alpha$ that optimizes average accuracy on the held-out validation sets from the supported and patching tasks.
58
+
59
+ # 3 Experimental setup
60
+
61
+ Tasks. We consider a diverse set of image classification tasks from Radford et al. [57]. In most experiments, we use ImageNet [14] as a representative supported task, although we explore other supported tasks in Section 4.2. We categorize tasks into patching tasks or supported tasks based on the accuracy difference between the zero-shot model and a model specialized to the task. A large accuracy difference indicates that the task is a relevant target for patching because the zero-shot model is still far from optimal. Specifically, we consider a subset tasks from Radford et al. [57], categorizing tasks where the linear probes outperform the zero-shot model by over 10 percentage points as patching tasks: Cars [35], DTD [11], EuroSAT [25], GTSRB [71], KITTI [22], MNIST [39], RESISC45 [7], SUN397 [84], and SVHN [53]. We use the remaining tasks as supported tasks: CIFAR10 [36], CIFAR100 [36], Food101 [5], ImageNet [14], and STL10 [12]. We investigate additional patching tasks as case studies in Section 7 and provide further details in Appendix A.
62
+
63
+ Models. We primarily use CLIP [57] pre-trained vision transformer (ViT) models [15]. Unless otherwise mentioned our experiments are with the ViT-L/14 model, while Section 4.2 studies ResNets [24].
64
+
65
+ Fine-tuning on patching tasks. Unless otherwise mentioned, we fine-tune with a batch size of 128 for 2000 iterations using learning rate 1e-5 with 200 warm-up steps with a cosine annealing learning rate schedule and the AdamW optimizer [43, 55] (weight decay 0.1). When fine-tuning, we use the frozen final classification layer output by CLIP’s text tower so that we do not introduce additional learnable parameters. This design decision keeps the model open-vocabulary and does not harm accuracy, as discussed in in Appendices B and C.
66
+
67
+ Evaluation. We use accuracy as the evaluation metric unless otherwise stated. We refer to the average of the mean accuracy on the patching tasks and the mean accuracy on the supported tasks as combined accuracy.2
68
+
69
+ # 4 Patching models on a single new task
70
+
71
+ As shown in Figure 1, when patching a model on a single task, we interpolate the weights of the zero-shot and fine-tuned model, producing a model that achieves high accuracy on both the patching task and the supported task. On the nine tasks, PAINT improves the accuracy of ViT-L/14 by 15 to 60 percentage points, while accuracy on ImageNet decreases by less than one percentage point. PAINT also allows practitioners to control the accuracy trade-off on the patching and supported tasks without re-training a new model, by varying the mixing coefficient $\alpha$ .
72
+
73
+ # 4.1 The effect of scale
74
+
75
+ We consistently observe that PAINT is more effective for larger models. Our findings are aligned with those of Ramasesh et al. [59], who observed that larger models are less susceptible to catastrophic forgetting. This section formalizes and provides insights for these observations.
76
+
77
+ Measuring the effectiveness of patching. We measure the effectiveness of patching via the accuracy difference between the single patched model and two specialized models with the same architecture and initialization. For both the supported task and patching task, we take specialized models that maximize performance on the task, considering the set of all interpolations between the zero-shot and fine-tuned models. We refer to this measure as accuracy distance to optimal. Formally, accuracy distance to optimal is given by
78
+
79
+ $$
80
+ \frac { 1 } { 2 } \left[ \operatorname* { m a x } _ { \alpha } \mathsf { A c c } ( \theta _ { \alpha } , { \mathcal D } _ { \mathrm { s u p p } } ) + \operatorname* { m a x } _ { \alpha } \mathsf { A c c } ( \theta _ { \alpha } , { \mathcal D } _ { \mathrm { p a t c h } } ) \right] - \frac { 1 } { 2 } \operatorname* { m a x } _ { \alpha } \left[ \mathsf { A c c } ( \theta _ { \alpha } , { \mathcal D } _ { \mathrm { s u p p } } ) + \mathsf { A c c } ( \theta _ { \alpha } , { \mathcal D } _ { \mathrm { p a t c h } } ) \right] ,
81
+ $$
82
+
83
+ where $\operatorname { A c c } ( \theta , { \mathcal { D } } )$ represents the accuracy of model $\theta$ on task $\mathcal { D }$ . In Figure 2 (left), we show that accuracy distance to optimal decreases with scale, indicating that patching becomes more effective for larger models.
84
+
85
+ Model similarity. Fine-tuning modifies overparameterized models less [9], which provides insights on why larger models are easier to patch: less movement is required to fit new data. We demonstrate this by evaluating representational similarity using Centered Kernel Alignment (CKA) [34] (see Appendix $\mathrm { D }$ for details). As shown in Figure 2 (center), the representations of the unpatched and fine-tuned models become more similar as models grow larger, indicated by larger CKA values. Moreover, Figure 2 (right) shows that the cosine similarity between the weights of the unpatched and fine-tuned models, $\mathrm { c o s } \bar { ( \theta _ { \mathrm { z s } } , \theta _ { \mathrm { f t } } ) } = { \langle \theta _ { \mathrm { z s } } , \theta _ { \mathrm { f t } } \rangle } / ( { | | \theta _ { \mathrm { z s } } | } { | | \theta _ { \mathrm { f t } } | } { | | } )$ , increases with scale.
86
+
87
+ ![](images/b72c4fb36424a430ec0f1a0abae638b6b4155247529a5a5b91ced0b946da30bc.jpg)
88
+ Figure 2: Larger models are easier to patch (left). For larger models, the unpatched and fine-tuned model are more similar with respect to their representations (center) and weights (right). Model scale is measured in Giga Multiply-Accumulate operations (GMACs).
89
+
90
+ ![](images/2443ac9955361eaece32bc9fb65f1d64c8d05723641e59f827424243e6ead873.jpg)
91
+ Figure 3: The frontier of accuracy trade-offs can be recovered by linearly interpolating weights. Interpolating the unpatched and fine-tuned models recovers the accuracy trade-off of early stopping, regularization towards the initialization, and changes in hyperparameters. Additional details and comparisons can be found in Appendix E.
92
+
93
+ # 4.2 Baselines and ablations
94
+
95
+ Baselines. There are many alternatives which enable a trade-off between accuracy on the supported and patching tasks. These methods include early stopping during fine-tuning, applying a regularization term which penalizes movement from initialization, or training with different hyperparameters including a smaller learning rate. Unlike interpolation, these methods do not enable navigating the accuracy trade-off without fine-tuning the model again many times. Moreover, Figure 3 demonstrates that the accuracy trade-off frontier for early stopping, regularization, or varying hyperparameters can be recovered by interpolating weights with different mixing coefficients. Appendix $\mathrm { E }$ provides additional baselines and discussion, including EMA [74], EWC [33], LwF [41], re-training a model with data from the patching task, and mixing the pre-training and fine-tuning objectives.
96
+
97
+ Additional supported tasks. In Figure 1, we use ImageNet as a representative supported task. This section demonstrates that PAINT is stable under different choices of the supported task. Instead of ImageNet, we use CIFAR10, CIFAR100, Food101 and STL10. Figure 4 displays representative results, where performance is averaged over the nine patching tasks (see Appendix $\mathrm { F }$ for additional results). We observe consistent results across supported tasks, and that the optimal mixing coefficients are stable across different choices of supported tasks (Figure 4, right).
98
+
99
+ Additional models. In addition to the CLIP ViTs used in the majority of our experiments, we study four ResNet models [24] from Radford et al. [57] in Appendix G. We find that patching is less effective for ResNets compared to ViTs of similar size, which corroborates the findings of Ramasesh et al. [59] that ResNets are generally more susceptible to catastrophic forgetting. However, similarly to ViTs, we still observe improvements with scale. Finally, we show that patching is also effective for closed-vocabulary models in Appendix H.
100
+
101
+ ![](images/4fadd75b187a9012519acf4b3f049b196caf35139ece0e9667ceb2b469c2d014.jpg)
102
+ Figure 4: Results are consistent across supported tasks. For multiple supported tasks, we observe similar accuracy improvements on patching tasks, without substantially decreasing supported task accuracy. Additional results for the supported tasks Food101, STL10 and ImageNet are in Appendix F. Moreover, choosing the mixing coefficients using a different supported task does not substantially decrease combined accuracy on patching and supported tasks (right).
103
+
104
+ # 5 Patching models on multiple tasks
105
+
106
+ This section details experimental results for patching on multiple datasets. Recall from Section 2 that there are various strategies for extending PAINT to multiple datasets, which we briefly revisit. For joint patching we merge all the datasets into a single fine-tuning task and apply our patching procedure as before. For sequential patching we iteratively perform our procedure once per task, using the patched model at each step as the initialization for the next step.3 We also explore parallel patching, for which we have an unpatched model $\theta _ { \mathrm { z s } }$ and independently fine-tune on each of the tasks in parallel. We then search for mixing coefficients to combine the resulting models. For tasks $1 , . . . , k$ , let θ(1)ft , . $\theta _ { \mathrm { f t } } ^ { ( 1 ) } , . . . , \theta _ { \mathrm { f t } } ^ { ( k ) }$ denote the fine-tuned models for each task. Since it is impractical to exhaustively search over each $\alpha _ { i }$ , we instead search over a one-dimensional scalar $\alpha \in [ 0 , 1 ]$ , which interpolates between $\theta _ { \mathrm { z s } }$ and the average of all fine-tuned solutions $\begin{array} { r } { \frac { 1 } { k } \sum _ { i = 1 } ^ { k } \theta _ { \mathrm { f t } } ^ { ( i ) } } \end{array}$ .4 Appendix J provides further experimental details.
107
+
108
+ These methods have various trade-offs and may be applicable for different scenarios. Joint patching is only possible when data from all tasks you wish to patch is available. On the other hand, sequential patching is appropriate when the tasks are observed one after another. Finally, parallel patching can leverage distributed hardware.
109
+
110
+ Figure 5 displays experimental results when patching on all nine tasks from Section 4. We observe that joint patching is the best-performing method on average. This is perhaps unsurprising since joint patching has simultaneous access to all patching datasets, unlike other patching strategies. Nevertheless, it is still interesting that for ViT-L/14, joint patching yields a single model with only 0.5 percentage points worse combined accuracy than using multiple specialized models.5 Joint patching also achieves a 15.8 percentage points improvement over the unpatched model. Moreover, patching a ViT-B/32 model with the joint strategy achieves a combined accuracy 6.1 percentage points higher than a ViT-L/14 unpatched model, which requires $1 2 \mathbf { x }$ more GMACs.
111
+
112
+ The accuracy of sequential patching approaches that of joint patching, especially for larger models. Note that, unlike in joint patching, forgetting can compound since the patching procedure is applied multiple times in sequence. In sequential patching, weight interpolations do not completely eradicate forgetting, but greatly mitigate it. This is most noticeable for smaller models: sequentially fine-tuning a ViT-B/32 without interpolation reduces the combined accuracy by 4.6 percentage points compared to the unpatched model, as shown in Appendix J. This is compared to a combined accuracy increase of 11 percentage points when using sequential patching. Additional results, including experiments on SplitCIFAR [61], can be found in Appendix J.
113
+
114
+ Finally, parallel patching underperforms other patching strategies. Like sequential patching, parallel patching is in the challenging setting where data from all patching tasks is not available simultaneously.
115
+
116
+ ![](images/ab4c4ccd3a90497f1b687f69c948c94f7552f13a00a84ff2feb8d39fe792a1b1.jpg)
117
+ Figure 5: Contrasting various strategies for patching on multiple tasks. On all experiments, ImageNet is used as the supported task while the other nine datasets are used for patching. When data from all patching tasks is available, joint patching yields a single model that is competitive with using ten different specialized models. Weight interpolations greatly mitigate catastrophic forgetting on the sequential case, but do not completely eradicate it. Finally, parallel patching underperforms other patching strategies, but still provides improvements over the unpatched model.
118
+
119
+ <table><tr><td></td><td>Cars</td><td>DTD</td><td>EuroSAT</td><td>GTSRB</td><td>KITTI</td><td>MNIST</td><td>RESISC45</td><td>SUN397</td><td>SVHN</td></tr><tr><td>Unpatched accuracy</td><td>86.2</td><td>64.9</td><td>79.9</td><td>51.7</td><td>43.4</td><td>82.6</td><td>73.4</td><td>76.9</td><td>72.8</td></tr><tr><td>Patched accuracy</td><td>87.0 (+0.8)</td><td>66.1 (+1.2)</td><td>87.2 (+7.3)</td><td>71.1 (+19.4)</td><td>60.4 (+17.0)</td><td>91.3 (+8.7)</td><td>74.2 (+0.8)</td><td>79.3 (+2.4)</td><td>88.9 (+16.1)</td></tr></table>
120
+
121
+ Table 1: PAINT can generalize to unseen classes. We randomly partition each dataset into tasks $A$ and $B$ with disjoint class spaces of roughly equal size. This table reports how patching on task $A$ affects accuracy on task $B$ for the ViT-L/14 model. In all cases, accuracy on task $B$ improves when patching on task $A$ even though the classes are unseen during patching.
122
+
123
+ Moreover, unlike in joint or sequential patching, no model is optimized on data from all patching tasks. Using a black box optimization algorithm for finding the mixing coefficients did not yield large improvements over using the same mixing coefficient for all models. However, it is possible that more sophisticated search methods could yield better results. In Appendix J, we present additional experiments for a subset of the tasks where exhaustively searching the space of mixing coefficients is tractable, finding headroom for improvement in most cases.
124
+
125
+ # 6 Broad transfer
126
+
127
+ An alternative to our patching approach is to introduce parameters which are specific to each new task. By contrast, PAINT always maintains a single model. This section describes an additional advantage of the single model approach: patching the model on task $A$ can improve accuracy on task $B$ , even when task $A$ and $B$ do not share the same classes. We refer to this phenomenon as broad transfer. Note that we are able to study this phenomenon because the single patched model remains open-vocabulary throughout the patching procedure. This is a key advantage of PAINT compared to maintaining a collection of task-specific models.
128
+
129
+ We now describe two experiments to measure the effects on a task $B$ when patching the model on a task $A$ . First, we explore broad transfer by randomly partitioning datasets into disjoint sets with no class overlap. For a dataset $\mathcal { D }$ we partition the class space $\mathcal { V }$ into two disjoint sets of roughly equal size $\mathcal { V } _ { A }$ and $\mathcal { { V } } _ { B }$ . We build task $A$ with the examples $( x , y ) \in \mathcal { D }$ where $y$ belongs to $\mathcal { V } _ { A }$ , and task $B$ with examples $( x , y )$ where $y$ belongs to $\mathcal { { V } } _ { B }$ . Table 1 shows how patching a model on task $A$ affects the accuracy on task $B$ for nine datasets $\mathcal { D }$ . The accuracy improvements on task $B$ range from 0.8 to 19.4 percentage points, even though the classes from task $B$ are not seen during patching.
130
+
131
+ To further understand transfer, we consider additional task pairs $A$ and $B$ , which are now different datasets. While some pairs $A$ , $B$ share classes, there are still instances of broad transfer. Concretely,
132
+
133
+ Table 2: Patching on task $A$ can improve accuracy on a related task $B$ . For a pair of tasks $A$ and $B$ , we report accuracy of the ViT-L/14 on task $B$ , after patching on task $A$ , finding improvements on seven out of eight cases.
134
+
135
+ <table><tr><td>Task A Task B</td><td>MNIST SVHN SVHN</td><td>MNISTRESISC45</td><td>EuroSAT RESISC45</td><td>MNIST EuroSAT FashionMNIST</td><td>FashionMNISTGTSRB MNIST</td><td>MTSD MTSD GTSRB</td></tr><tr><td>Unpatched accuracy</td><td>58.6</td><td>76.4 71.0</td><td>60.2</td><td>67.7</td><td>76.4</td><td>19.3 50.6</td></tr><tr><td>Patched accuracy</td><td>68.9 93.2 (+10.3) ) (+16.8)</td><td>69.7 (-1.3)</td><td>70.4 (+10.2)</td><td>70.8 (+3.1)</td><td>77.5 (+1.1)</td><td>30.8 69.8 (+11.5) (+19.2)</td></tr></table>
136
+
137
+ ![](images/6e73f1e55022da3d02d7e4fcdb5448dcc6e048f006e9441361fb77781b3537fd.jpg)
138
+ Figure 6: Guarding against real-world typographic attacks by patching on synthetic data. (a) A sample from our real-world typographic attacks test set. A CLIP ViT-L/14 is “tricked” into classifying this image as a dog instead of a cat. (b) Sample of synthetic typographic attack data. (c) Performance on real-world data with unseen classes after patching on only synthetic typographic attacks (curves produced by interpolating between the unpatched and fine-tuned model). (d) Analogous curves for the test set of the synthetic data used for patching.
139
+
140
+ Table 2 examines i) MNIST and SVHN, two digit recognition tasks with shared classes; ii) EuroSAT and RESISC45, two satellite imagery recognition tasks where there are unshared classes but some overlap; iii) GTSRB and MTSD [17], two traffic sign recognition datasets where there are unshared classes but some overlap; and iv) MNIST and FashionMNIST [83], which do not share any classes but appear visually similar. In seven out of eight experiments, patching on task $A$ improves accuracy by 1.1 to 19.2 percentage points on task $B$ . The exception is when $A$ is EuroSAT and $B$ is RESISC45, where accuracy decreases by 1.3 percentage points.
141
+
142
+ In all experiments, when patching on task $A$ we choose the mixing coefficient $\alpha$ by optimizing the held-out validation accuracy on task $A$ and a supported task (in this experiment we use ImageNet). While it is possible for a method that introduces new parameters for each task to exhibit broad transfer to new data, this also requires knowing which parameters to apply for the new data. This is not necessary in the single model approach.
143
+
144
+ # 7 Case studies
145
+
146
+ We further examine the performance of PAINT in three additional settings, which highlight weaknesses of the zero-shot CLIP model and showcase broad transfer (Section 6).
147
+
148
+ Typographic attacks. Goh et al. [23] find that CLIP models are susceptible to typographic attacks, where text superimposed on an image leads to misclassification. For example, in Figure $6 ( a )$ , the text on the pink note saying “dog” leads a CLIP to misclassify the image of a cat as a dog. To fix this vulnerability, we procedurally generate typographic attack data by adding text with incorrect class names to SUN397 [84], as seen in Figure 6 $( b )$ . We then collect a test set of 110 real world images by placing notes on objects and taking photos.6 After applying PAINT using the synthetic data, we evaluate on the real-world images (Figure 6 (c)) and synthetic test set (Figure 6 (d)). We observe that while larger models are more susceptible to typographic attacks, they are also more amenable to patching. Furthermore, we see an example of broad transfer between the synthetic and real-world data: when patching ViT-L/14 on synthetic data, its accuracy on real-world typographic attacks improves 41 percentage points even though the real-world classes are unseen. The cost is a reduction of less than 1 percentage point on ImageNet. We present details on the task and data collection in Appendix K.
149
+
150
+ Counting. Radford et al. [57] find that CLIP models struggle to count the number of objects in CLEVR [32]. Here, the task is to choose an integer between 3 and 10 for each image, corresponding to the number of visible objects. While a straightforward way to patch such a task is to fine-tune on it directly, we investigate if applying PAINT using a subset of the classes allows the patched model to generalize to other numbers. Specifically, we patch on images with 4, 5, 6, 8, or 9 objects. To evaluate broad transfer, we test on images with 3, 7, and 10 objects (7 for understanding interpolation and 3 and 10 for extrapolation). We find that PAINT improves accuracy from $59 \%$ to over $9 9 \%$ o n unseen classes with less than half a percentage point decrease in ImageNet accuracy. For more details see Appendix L.
151
+
152
+ Visual question answering. As shown by Shen et al. [68], zero-shot CLIP models perform poorly on visual question answering [4]. Using CLIP for VQA typically involves additional parameters—for instance, Shen et al. [68] trains a transformer [77] on CLIP features. In contrast, our procedure for patching CLIP on VQA does not introduce new parameters. Following Shen et al. [68], we contrast images with a series of text prompts, where each prompt corresponds to an option in multiple-choice VQA, formed by both the question and a candidate answer using the following template: “Question: [question text] Answer: [answer text]”. We evaluate on multiple-choice VQA v1 [4], where each question is associated with 18 candidate answers. Our results, further detailed in Appendix M, show that patching is effective for visual question answering: PAINT improves the accuracy of a ViT-L/14 model by 18 percentage points, while accuracy drops by less than one percentage point on ImageNet.
153
+
154
+ # 8 Related work
155
+
156
+ Continual learning and catastrophic forgetting. Learning tasks sequentially remains a challenge for neural networks. When a neural network learns a new task, the accuracy on other tasks often decreases, a phenomenon known as catastrophic forgetting [48, 76, 20, 33]. While forgetting in neural networks may actually aid learning [90], researchers have proposed various approaches for alleviating catastrophic forgetting, including: i) Regularization-based approaches such as elastic weight consolidation (EWC) [33] and synaptic intelligence (SI) [87] which penalize the movement of parameters and are related to weight-interpolation by Lubana et al. [44]; ii) Replay methods [61, 69, 42, 6, 64, 50], which incorporate data or gradient information from previous tasks when learning a new task; and iii) Introducing task-specific parameters [65, 85, 46, 8, 78, 80].
157
+
158
+ In contrast to these approaches, PAINT requires no modification to the standard fine-tuning process besides the later weight interpolation step. Moreover, unlike regularization or replay based methods, PAINT requires no extra computational cost during training. In contrast to methods with task specific parameters, we maintain a single model. Having a single model is beneficial when there is new data which is similar to one of the tasks which have already been patched. Even without explicitly knowing which task the new data is similar to, we can observe accuracy improvements (see Section 6).
159
+
160
+ Similar to our work is that of Mirzadeh et al. [50], who observe high accuracy on task A on the linear path between a model which achieves high accuracy on task A and a model which is fine-tuned jointly on task A and B. Moreover, they observe high accuracy on task B on the linear path between a model fine-tuned on task B, and the jointly fine-tuned model. Therefore, there exists a path between a model which achieves good performance on task A and a model fine-tuned on task B along which accuracy is high on both tasks. However, in Mirzadeh et al. [50] this combined path can be non-linear, leading them to propose a regularization and replay based method. In our work, we find that examining models on a linear path between the unpatched model (which has high accuracy on task A) and the model fine-tuned on task B is often sufficient for obtaining a model which achieves high accuracy on both tasks (Figure 1). We speculate that this is due to scale and model architecture: in contrast to Mirzadeh et al. [50], we initialize with a model pre-trained on a large dataset consisting of 400 million images [57], and primarily use vision transformers [15]. As shown in Section 4.2, our method performs substantially worse with ResNets [24], which are used by Mirzadeh et al. [50].
161
+
162
+ Finally, Ramasesh et al. [59] and Mehta et al. [49] also observed that catastrophic forgetting is less problematic for large and pre-trained models. In addition, Ramasesh et al. [59] found—similar to our results—that vision transformers are less susceptible to forgetting than ResNets of the same size.
163
+
164
+ Linear mode connectivity and robust fine-tuning. Linearly interpolating neural network weights is a key step in PAINT. Because of the many nonlinear activations in a neural network, it is not clear a priori that linearly interpolating between two sets of weights can result in a high accuracy solution. However, researchers have observed that interpolating neural network weights can achieve high accuracy when training on MNIST from a common initialization [52] or when part of the optimization trajectory is shared [19, 28, 54, 18, 82, 47, 16, 81, 10]. The term linear mode connectivity was coined by Frankle et al. [19]: two networks exhibit linearly mode connectivity if the accuracy does not decrease when using weights on the linear path between them [52, 19]. Weight averaging for continual learning has also been studied by Lee et al. [40] for closed-vocabulary models.
165
+
166
+ While Nagarajan and Kolter [52] and Frankle et al. [19] focused on accuracy on a single task, Wortsman et al. [82] use linear mode connectivity to fine-tune models while preserving their robustness to natural distribution shifts. By interpolating the weights of a zero-shot and fine-tuned model, they find a solution which performs well both on the fine-tuning task and under distribution shift. In contrast to Wortsman et al. [82], we do not modify any task-specific parameters when fine-tuning, preserving the open-vocabulary nature of the models we patch. Unlike Wortsman et al. [82], we examine accuracy trade-offs across different tasks with little or no class overlap and adapt a model to multiple tasks.
167
+
168
+ In addition, closely related to our work is that of Matena and Raffel [47], who use Fisher-weighted averaging of language models before and after fine-tuning on downstream tasks. Unlike Fisherweighted averaging of Matena and Raffel [47], we do not use different mixing coefficients for each parameter, and thus require no extra compute when patching. Moreover, we explore new strategies for patching on multiple tasks (see Section 5), and focus on open-vocabulary image classifiers.
169
+
170
+ Interventions to change the behavior of a trained model. Several authors have studied the problem of updating a model to locally alter its behavior on certain inputs without external disruptions on other inputs [70, 13, 51, 66, 63, 62]. Previous literature uses various terms to refer to this process, including model editing, patching or debugging. A popular use case is to update trained language models to reflect changes in the world (for instance, facts like who is the current president of Brazil) [29, 45, 38, 30]. Moreover, inspired by software engineering practice, previous work explored “debugging” language models through user interaction [63, 62], including providing corrective feedback to the models via natural language [3]. Mitchell et al. [51], De Cao et al. [13] propose training auxiliary networks to perform local edits on pre-trained models. Santurkar et al. [66] introduce a method for rewriting the prediction rules of a classifier, focusing on specific failure modes such as reliance on spurious correlations. In contrast with previous literature, our work explores patching models at the task level, aiming to systemically improve accuracy on a dataset—for instance, enabling a model to recognize dozens of satellite imagery classes with a single patch.
171
+
172
+ # 9 Limitations and conclusion
173
+
174
+ Limitations. When applying PAINT, accuracy on supported tasks can still decrease, especially for smaller models. This limitation is perhaps best reflected in the case of sequential patching: patched models underperform using multiple specialized models when many tasks are added sequentially. Using larger models and weight interpolations can alleviate this issue, but do not completely resolve it. Finally, better understanding on which datasets patching is more effective is an exciting direction for future research.
175
+
176
+ Conclusion. In this work, we explore several techniques for patching open-vocabulary models with the goal of improving accuracy on new tasks without decreasing accuracy elsewhere. PAINT is effective in several scenarios, ranging from classifying digits to defending against typographic attacks. PAINT becomes more effective with scale, and can be applied on multiple tasks sequentially or simultaneously. Our findings demonstrate that in many circumstances it is possible to expand the set of tasks on which models achieve high accuracy, without introducing new parameters, without re-training them from scratch, and without catastrophic forgetting.
177
+
178
+ # Acknowledgments
179
+
180
+ We thank Akari Asai, Alex Fang, David Fleet, Huy Ha, Ari Holtzman, Pieter-Jan Kindermans, Marco Tulio Ribeiro, Ofir Press, Sarah Pratt, Sewon Min, Thao Nguyen and Tim Dettmers for helpful discussions and feedback, and Hyak at UW for computing support. This work is in part supported by the NSF AI Institute for Foundations of Machine Learning (IFML), Open Philanthropy, NSF IIS 1652052, NSF IIS 17303166, NSF IIS 2044660, NSF IIS 2132519, ONR N00014-18-1-2826, DARPA N66001-19-2-4031, DARPA W911NF-15-1-0543, the Sloan Fellowship and gifts from Allen Institute for AI.
181
+
182
+ References
183
+ [1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning, 2022. https://arxiv.org/abs/2204.14198.
184
+ [2] Anders Andreassen, Yasaman Bahri, Behnam Neyshabur, and Rebecca Roelofs. The evolution of out-of-distribution robustness throughout fine-tuning, 2021. https://arxiv.org/abs/ 2106.15831.
185
+ [3] Anonymous. Fixing model bugs with natural language patches, 2022. https://openreview. net/forum?id=blJrg3WvvDV.
186
+ [4] Stanislaw Antol, Aishwarya Agrawal, Jiasen Lu, Margaret Mitchell, Dhruv Batra, C. Lawrence Zitnick, and Devi Parikh. VQA: Visual Question Answering. In International Conference on Computer Vision (ICCV), 2015. https://arxiv.org/abs/1505.00468.
187
+ [5] Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101–mining discriminative components with random forests. In European Conference on Computer Vision (ECCV), 2014. https://link.springer.com/chapter/10.1007/978-3-319-10599-4_29.
188
+ [6] Arslan Chaudhry, Marc’Aurelio Ranzato, Marcus Rohrbach, and Mohamed Elhoseiny. Efficient lifelong learning with a-gem. In International Conference on Learning Representations (ICLR), 2019. https://arxiv.org/abs/1812.00420.
189
+ [7] Gong Cheng, Junwei Han, and Xiaoqiang Lu. Remote sensing image scene classification: Benchmark and state of the art. Proceedings of the Institute of Electrical and Electronics Engineers (IEEE), 2017. https://ieeexplore.ieee.org/abstract/document/7891544.
190
+ [8] Brian Cheung, Alexander Terekhov, Yubei Chen, Pulkit Agrawal, and Bruno Olshausen. Superposition of many models into one. In Advances in Neural Information Processing Systems (NeurIPS), 2019. https://proceedings.neurips.cc/paper/2019/file/ 4c7a167bb329bd92580a99ce422d6fa6-Paper.pdf.
191
+ [9] Lenaic Chizat, Edouard Oyallon, and Francis Bach. On lazy training in differentiable programming. Advances in Neural Information Processing Systems (NeurIPS), 2019. https://proceedings.neurips.cc/paper/2019/file/ ae614c557843b1df326cb29c57225459-Paper.pdf.
192
+ [10] Leshem Choshen, Elad Venezian, Noam Slonim, and Yoav Katz. Fusing finetuned models for better pretraining, 2022. https://arxiv.org/abs/2204.03044.
193
+ [11] Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In Conference on Computer Vision and Pattern Recognition (CVPR), 2014. https://openaccess.thecvf.com/content_cvpr_2014/html/Cimpoi_ Describing_Textures_in_2014_CVPR_paper.html.
194
+ [12] Adam Coates, Andrew Ng, and Honglak Lee. An analysis of single-layer networks in unsupervised feature learning. In International Conference on Artificial Intelligence and Statistics (AISTATS), 2011. https://proceedings.mlr.press/v15/coates11a.html.
195
+ [13] Nicola De Cao, Wilker Aziz, and Ivan Titov. Editing factual knowledge in language models. In Conference on Empirical Methods in Natural Language Processing (EMNLP), 2021. https: //arxiv.org/abs/2104.08164.
196
+ [14] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Conference on Computer Vision and Pattern Recognition (CVPR), 2009. https://ieeexplore.ieee.org/abstract/document/5206848.
197
+ [15] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=YicbFdNTTy.
198
+ [16] Rahim Entezari, Hanie Sedghi, Olga Saukh, and Behnam Neyshabur. The role of permutation invariance in linear mode connectivity of neural networks. In International Conference on Learning Representations (ICLR), 2022. https://arxiv.org/abs/2110.06296.
199
+ [17] Christian Ertler, Jerneja Mislej, Tobias Ollmann, Lorenzo Porzi, Gerhard Neuhold, and Yubin Kuang. The mapillary traffic sign dataset for detection and classification on a global scale. In European Conference on Computer Vision (ECCV), 2020. https://arxiv.org/abs/1909. 04422.
200
+ [18] Stanislav Fort, Gintare Karolina Dziugaite, Mansheej Paul, Sepideh Kharaghani, Daniel M Roy, and Surya Ganguli. Deep learning versus kernel learning: an empirical study of loss landscape geometry and the time evolution of the neural tangent kernel. In Advances in Neural Information Processing Systems (NeurIPS), 2020. https://arxiv.org/abs/2010.15110.
201
+ [19] Jonathan Frankle, Gintare Karolina Dziugaite, Daniel Roy, and Michael Carbin. Linear mode connectivity and the lottery ticket hypothesis. In International Conference on Machine Learning (ICML), 2020. https://proceedings.mlr.press/v119/frankle20a.html.
202
+ [20] Robert M French. Catastrophic forgetting in connectionist networks. Trends in Cognitive Sciences, 1999. https://www.sciencedirect.com/science/article/pii/ S1364661399012942.
203
+ [21] Peng Gao, Shijie Geng, Renrui Zhang, Teli Ma, Rongyao Fang, Yongfeng Zhang, Hongsheng Li, and Yu Qiao. Clip-adapter: Better vision-language models with feature adapters, 2021. https://arxiv.org/abs/2110.04544.
204
+ [22] Andreas Geiger, Philip Lenz, and Raquel Urtasun. Are we ready for autonomous driving? the kitti vision benchmark suite. In Conference on Computer Vision and Pattern Recognition (CVPR), 2012. https://ieeexplore.ieee.org/abstract/document/6248074.
205
+ [23] Gabriel Goh, Nick Cammarata, Chelsea Voss, Shan Carter, Michael Petrov, Ludwig Schubert, Alec Radford, and Chris Olah. Multimodal neurons in artificial neural networks. Distill, 2021. https://distill.pub/2021/multimodal-neurons.
206
+ [24] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Conference on Computer Vision and Pattern Recognition (CVPR), 2016. https: //arxiv.org/abs/1512.03385.
207
+ [25] Patrick Helber, Benjamin Bischke, Andreas Dengel, and Damian Borth. Eurosat: A novel dataset and deep learning benchmark for land use and land cover classification. Journal of Selected Topics in Applied Earth Observations and Remote Sensing, 2019. https://arxiv. org/abs/1709.00029.
208
+ [26] Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network, 2015. https://arxiv.org/abs/1503.02531.
209
+ [27] Gabriel Ilharco, Mitchell Wortsman, Ross Wightman, Cade Gordon, Nicholas Carlini, Rohan Taori, Achal Dave, Vaishaal Shankar, Hongseok Namkoong, John Miller, Hannaneh Hajishirzi, Ali Farhadi, and Ludwig Schmidt. Openclip, 2021. https://github.com/mlfoundations/ open_clip.
210
+ [28] Pavel Izmailov, Dmitrii Podoprikhin, Timur Garipov, Dmitry Vetrov, and Andrew Gordon Wilson. Averaging weights leads to wider optima and better generalization. In Conference on Uncertainty in Artificial Intelligence (UAI), 2018. https://arxiv.org/abs/1803.05407.
211
+ [29] Joel Jang, Seonghyeon Ye, Changho Lee, Sohee Yang, Joongbo Shin, Janghoon Han, Gyeonghun Kim, and Minjoon Seo. Temporalwiki: A lifelong benchmark for training and evaluating ever-evolving language models, 2022. https://arxiv.org/abs/2204.14211.
212
+ [30] Joel Jang, Seonghyeon Ye, Sohee Yang, Joongbo Shin, Janghoon Han, Gyeonghun Kim, Stanley Jungkyu Choi, and Minjoon Seo. Towards continual knowledge learning of language models. In International Conference on Learning Representations (ICLR), 2022. https: //arxiv.org/abs/2110.03215.
213
+
214
+ [31] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc V Le, Yunhsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning (ICML), 2021. https://arxiv.org/abs/2102.05918.
215
+
216
+ [32] Justin Johnson, Bharath Hariharan, Laurens van der Maaten, Li Fei-Fei, C. Lawrence Zitnick, and Ross B. Girshick. CLEVR: A diagnostic dataset for compositional language and elementary visual reasoning. Conference on Computer Vision and Pattern Recognition (CVPR), 2017. https://arxiv.org/abs/1612.06890.
217
+
218
+ [33] James Kirkpatrick, Razvan Pascanu, Neil Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka Grabska-Barwinska, et al. Overcoming catastrophic forgetting in neural networks. Proceedings of the National Academy of Sciences (PNAS), 2017. https://arxiv.org/abs/1612.00796.
219
+
220
+ [34] Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey Hinton. Similarity of neural network representations revisited. In International Conference on Machine Learning (ICML), 2019. https://arxiv.org/abs/1905.00414.
221
+
222
+ [35] Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for finegrained categorization. In International Conference on Computer Vision Workshops (ICML), 2013. https://www.cv-foundation.org/openaccess/content_iccv_workshops_ 2013/W19/html/Krause_3D_Object_Representations_2013_ICCV_paper.html.
223
+
224
+ [36] Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images, 2009. https://www.cs.toronto.edu/\~kriz/learning-features-2009-TR.pdf.
225
+
226
+ [37] Ananya Kumar, Aditi Raghunathan, Robbie Jones, Tengyu Ma, and Percy Liang. Fine-tuning can distort pretrained features and underperform out-of-distribution. In International Conference on Learning Representations (ICLR), 2022. https://openreview.net/forum?id= UYneFzXSJWh.
227
+
228
+ [38] Angeliki Lazaridou, Adhi Kuncoro, Elena Gribovskaya, Devang Agrawal, Adam Liska, Tayfun Terzi, Mai Gimenez, Cyprien de Masson d’Autume, Tomas Kocisky, Sebastian Ruder, et al. Mind the gap: Assessing temporal generalization in neural language models. Advances in Neural Information Processing Systems (NeurIPS), 2021. https://arxiv.org/abs/2102.01951.
229
+
230
+ [39] Yann LeCun. The mnist database of handwritten digits, 1998. http://yann.lecun.com/ exdb/mnist/.
231
+
232
+ [40] Sang-Woo Lee, Jin-Hwa Kim, Jaehyun Jun, Jung-Woo Ha, and Byoung-Tak Zhang. Overcoming catastrophic forgetting by incremental moment matching. In Advances in Neural Information Processing Systems (NeurIPS), 2017. https://arxiv.org/abs/1703.08475.
233
+
234
+ [41] Zhizhong Li and Derek Hoiem. Learning without forgetting. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017. https://arxiv.org/abs/1606.09282.
235
+
236
+ [42] David Lopez-Paz and Marc’Aurelio Ranzato. Gradient episodic memory for continual learning. In Advances in Neural Information Processing Systems (NeurIPS), 2017. https://arxiv. org/abs/1706.08840.
237
+
238
+ [43] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum? id=Bkg6RiCqY7.
239
+
240
+ [44] Ekdeep Singh Lubana, Puja Trivedi, Danai Koutra, and Robert P. Dick. How do quadratic regularizers prevent catastrophic forgetting: The role of interpolation, 2021. https://arxiv. org/abs/2102.02805.
241
+
242
+ [45] Kelvin Luu, Daniel Khashabi, Suchin Gururangan, Karishma Mandyam, and Noah A Smith. Time waits for no one! analysis and challenges of temporal misalignment, 2021. https: //arxiv.org/abs/2111.07408.
243
+
244
+ [46] Arun Mallya, Dillon Davis, and Svetlana Lazebnik. Piggyback: Adapting a single network to multiple tasks by learning to mask weights. In European Conference on Computer Vision (ECCV), 2018. https://arxiv.org/abs/1801.06519.
245
+
246
+ [47] Michael Matena and Colin Raffel. Merging models with fisher-weighted averaging, 2021. https://arxiv.org/abs/2111.09832.
247
+
248
+ [48] Michael McCloskey and Neal J Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In Psychology of Learning and Motivation. Elsevier, 1989. https://www.sciencedirect.com/science/article/abs/pii/S0079742108605368.
249
+
250
+ [49] Sanket Vaibhav Mehta, Darshan Patil, Sarath Chandar, and Emma Strubell. An empirical investigation of the role of pre-training in lifelong learning, 2021. https://arxiv.org/abs/ 2112.09153.
251
+
252
+ [50] Seyed Iman Mirzadeh, Mehrdad Farajtabar, Dilan Gorur, Razvan Pascanu, and Hassan Ghasemzadeh. Linear mode connectivity in multitask and continual learning. In International Conference on Learning Representations (ICLR), 2021. https://arxiv.org/abs/ 2010.04495.
253
+
254
+ [51] Eric Mitchell, Charles Lin, Antoine Bosselut, Chelsea Finn, and Christopher D Manning. Fast model editing at scale. In International Conference on Learning Representations (ICLR), 2021. https://arxiv.org/abs/2110.11309.
255
+
256
+ [52] Vaishnavh Nagarajan and J. Zico Kolter. Uniform convergence may be unable to explain generalization in deep learning. In NeurIPS, 2019. https://proceedings.neurips.cc/ paper/2019/file/05e97c207235d63ceb1db43c60db7bbb-Paper.pdf.
257
+
258
+ [53] Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. In Advances in Neural Information Processing Systems (NeurIPS) Workshops, 2011. https://storage.googleapis. com/pub-tools-public-publication-data/pdf/37648.pdf.
259
+
260
+ [54] Behnam Neyshabur, Hanie Sedghi, and Chiyuan Zhang. What is being transferred in transfer learning? In Advances in Neural Information Processing Systems (NeurIPS), 2020. https: //arxiv.org/abs/2008.11687.
261
+
262
+ [55] 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. Advances in Neural Information Processing Systems (NeurIPS), 2019. https://arxiv.org/abs/1912.01703.
263
+
264
+ [56] Hieu Pham, Zihang Dai, Golnaz Ghiasi, Hanxiao Liu, Adams Wei Yu, Minh-Thang Luong, Mingxing Tan, and Quoc V Le. Combined scaling for zero-shot transfer learning, 2021. https://arxiv.org/abs/2111.10050.
265
+
266
+ [57] 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. In International Conference on Machine Learning (ICML), 2021. https://arxiv.org/abs/2103. 00020.
267
+
268
+ [58] Colin Raffel. A call to build models like we build opensource software, 2021. https://colinraffel.com/blog/ a-call-to-build-models-like-we-build-open-source-software.html.
269
+
270
+ [59] Vinay Venkatesh Ramasesh, Aitor Lewkowycz, and Ethan Dyer. Effect of scale on catastrophic forgetting in neural networks. In International Conference on Learning Representations (ICLR), 2021. https://openreview.net/forum?id=GhVS8_yPeEa.
271
+
272
+ [60] J. Rapin and O. Teytaud. Nevergrad - A gradient-free optimization platform. https://GitHub. com/FacebookResearch/Nevergrad, 2018.
273
+
274
+ [61] Sylvestre-Alvise Rebuffi, Alexander Kolesnikov, Georg Sperl, and Christoph H Lampert. icarl: Incremental classifier and representation learning. In Conference on Computer Vision and Pattern Recognition (CVPR), 2017. https://arxiv.org/abs/1611.07725.
275
+
276
+ [62] Marco Tulio Ribeiro and Scott Lundberg. Adaptive testing and debugging of nlp models. In Association for Computational Linguistics (ACL), 2022. https://www.microsoft.com/en-us/ research/publication/adaptive-testing-and-debugging-of-nlp-models/.
277
+
278
+ [63] Marco Tulio Ribeiro, Tongshuang Wu, Carlos Guestrin, and Sameer Singh. Beyond accuracy: Behavioral testing of NLP models with CheckList. In Association for Computational Linguistics (ACL), 2020. https://aclanthology.org/2020.acl-main.442.
279
+
280
+ [64] David Rolnick, Arun Ahuja, Jonathan Schwarz, Timothy Lillicrap, and Gregory Wayne. Experience replay for continual learning. In Advances in Neural Information Processing Systems (NeurIPS), 2019. https://arxiv.org/abs/1811.11682.
281
+
282
+ [65] Andrei A Rusu, Neil C Rabinowitz, Guillaume Desjardins, Hubert Soyer, James Kirkpatrick, Koray Kavukcuoglu, Razvan Pascanu, and Raia Hadsell. Progressive neural networks, 2016. https://arxiv.org/abs/1606.04671.
283
+
284
+ [66] Shibani Santurkar, Dimitris Tsipras, Mahalaxmi Elango, David Bau, Antonio Torralba, and Aleksander Madry. Editing a classifier by rewriting its prediction rules. In Advances in Neural Information Processing Systems (NeurIPS), 2021. https://arxiv.org/abs/2112.01008.
285
+
286
+ [67] Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki. Laion-400m: Open dataset of clip-filtered 400 million image-text pairs, 2021. https://arxiv.org/abs/2111. 02114.
287
+
288
+ [68] Sheng Shen, Liunian Harold Li, Hao Tan, Mohit Bansal, Anna Rohrbach, Kai-Wei Chang, Zhewei Yao, and Kurt Keutzer. How much can clip benefit vision-and-language tasks? In International Conference on Learning Representations (ICLR), 2022. https://arxiv.org/ abs/2107.06383.
289
+
290
+ [69] Hanul Shin, Jung Kwon Lee, Jaehong Kim, and Jiwon Kim. Continual learning with deep generative replay. In Advances in Neural Information Processing Systems (NeurIPS), 2017. https://arxiv.org/abs/1705.08690.
291
+
292
+ [70] Anton Sinitsin, Vsevolod Plokhotnyuk, Dmitriy Pyrkin, Sergei Popov, and Artem Babenko. Editable neural networks. In International Conference on Learning Representations (ICLR), 2020. https://arxiv.org/abs/2004.00345.
293
+
294
+ [71] Johannes Stallkamp, Marc Schlipsing, Jan Salmen, and Christian Igel. The german traffic sign recognition benchmark: a multi-class classification competition. In International Joint Conference on Neural Networks (IJCNN), 2011. https://ieeexplore.ieee.org/document/ 6033395.
295
+
296
+ [72] Yi-Lin Sung, Varun Nair, and Colin A Raffel. Training neural networks with fixed sparse masks. Advances in Neural Information Processing Systems (NeurIPS), 2021. https://arxiv.org/ abs/2111.09839.
297
+
298
+ [73] Yi-Lin Sung, Jaemin Cho, and Mohit Bansal. Vl-adapter: Parameter-efficient transfer learning for vision-and-language tasks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2022. https://arxiv.org/abs/2112.06825.
299
+
300
+ [74] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Conference on Computer Vision and Pattern Recognition, 2016. https://arxiv.org/abs/1512.00567v3.
301
+
302
+ [75] Bart Thomee, David A Shamma, Gerald Friedland, Benjamin Elizalde, Karl Ni, Douglas Poland, Damian Borth, and Li-Jia Li. Yfcc100m: The new data in multimedia research. Communications of the ACM, 2016. https://arxiv.org/abs/1503.01817.
303
+
304
+ [76] Sebastian Thrun. Lifelong learning algorithms. In Learning to learn, 1998. https://link. springer.com/chapter/10.1007/978-1-4615-5529-2_8.
305
+
306
+ [77] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in Neural Information Processing Systems (NeurIPS), 2017. https://arxiv.org/abs/1706.03762.
307
+
308
+ [78] Johannes von Oswald, Christian Henning, João Sacramento, and Benjamin F. Grewe. Continual learning with hypernetworks. In International Conference on Learning Representations (ICLR), 2020. https://openreview.net/forum?id=SJgwNerKvB.
309
+
310
+ [79] Ross Wightman. Pytorch image models. https://github.com/rwightman/ pytorch-image-models, 2019.
311
+
312
+ [80] Mitchell Wortsman, Vivek Ramanujan, Rosanne Liu, Aniruddha Kembhavi, Mohammad Rastegari, Jason Yosinski, and Ali Farhadi. Supermasks in superposition. In Advances in Neural Information Processing Systems (NeurIPS), 2020. https://arxiv.org/abs/2006.14769.
313
+
314
+ [81] Mitchell Wortsman, Gabriel Ilharco, Samir Yitzhak Gadre, Rebecca Roelofs, Raphael GontijoLopes, Ari S Morcos, Hongseok Namkoong, Ali Farhadi, Yair Carmon, Simon Kornblith, et al. Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time. In International Conference on Machine Learning (ICML), 2022. https://arxiv.org/abs/2203.05482.
315
+
316
+ [82] Mitchell Wortsman, Gabriel Ilharco, Mike Li, Jong Wook Kim, Hannaneh Hajishirzi, Ali Farhadi, Hongseok Namkoong, and Ludwig Schmidt. Robust fine-tuning of zero-shot models. In Conference on Computer Vision and Pattern Recognition (CVPR), 2022. https://arxiv. org/abs/2109.01903.
317
+
318
+ [83] Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms, 2017. https://arxiv.org/abs/1708.07747.
319
+
320
+ [84] Jianxiong Xiao, Krista A Ehinger, James Hays, Antonio Torralba, and Aude Oliva. Sun database: Exploring a large collection of scene categories. International Journal of Computer Vision (IJCV), 2016. https://link.springer.com/article/10.1007/s11263-014-0748-y.
321
+
322
+ [85] Jaehong Yoon, Eunho Yang, Jeongtae Lee, and Sung Ju Hwang. Lifelong learning with dynamically expandable networks. In International Conference on Learning Representations (ICLR), 2018. https://arxiv.org/abs/1708.01547.
323
+
324
+ [86] Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models, 2022. https://arxiv. org/abs/2205.01917.
325
+
326
+ [87] Friedemann Zenke, Ben Poole, and Surya Ganguli. Continual learning through synaptic intelligence. In International Conference on Machine Learning (ICML), 2017. https:// arxiv.org/abs/1703.04200.
327
+
328
+ [88] Xiaohua Zhai, Xiao Wang, Basil Mustafa, Andreas Steiner, Daniel Keysers, Alexander Kolesnikov, and Lucas Beyer. Lit: Zero-shot transfer with locked-image text tuning. In Conference on Computer Vision and Pattern Recognition (CVPR), 2022. https://arxiv. org/abs/2111.07991.
329
+
330
+ [89] Renrui Zhang, Rongyao Fang, Peng Gao, Wei Zhang, Kunchang Li, Jifeng Dai, Yu Qiao, and Hongsheng Li. Tip-adapter: Training-free clip-adapter for better vision-language modeling, 2021. https://arxiv.org/abs/2111.03930.
331
+
332
+ [90] Hattie Zhou, Ankit Vani, Hugo Larochelle, and Aaron Courville. Fortuitous forgetting in connectionist networks. In International Conference on Learning Representations (ICLR), 2022. https://arxiv.org/abs/2202.00155.
333
+
334
+ [91] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. In Conference on Computer Vision and Pattern Recognition (CVPR), 2022. https://arxiv.org/abs/2203.05557.
md/dev/D78Go4hVcxO/D78Go4hVcxO.md ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HOW DO VISION TRANSFORMERS WORK?
2
+
3
+ Namuk Park1,2, Songkuk $\mathbf { K i m ^ { 1 } }$ 1Yonsei University, 2NAVER AI Lab {namuk.park,songkuk}@yonsei.ac.kr
4
+
5
+ # ABSTRACT
6
+
7
+ The success of multi-head self-attentions (MSAs) for computer vision is now indisputable. However, little is known about how MSAs work. We present fundamental explanations to help better understand the nature of MSAs. In particular, we demonstrate the following properties of MSAs and Vision Transformers (ViTs): $\bullet$ MSAs improve not only accuracy but also generalization by flattening the loss landscapes. Such improvement is primarily attributable to their data specificity, not long-range dependency. On the other hand, ViTs suffer from non-convex losses. Large datasets and loss landscape smoothing methods alleviate this problem; $\textcircled { 2 }$ MSAs and Convs exhibit opposite behaviors. For example, MSAs are low-pass filters, but Convs are high-pass filters. Therefore, MSAs and Convs are complementary; $\bullet$ Multi-stage neural networks behave like a series connection of small individual models. In addition, MSAs at the end of a stage play a key role in prediction. Based on these insights, we propose AlterNet, a model in which Conv blocks at the end of a stage are replaced with MSA blocks. AlterNet outperforms CNNs not only in large data regimes but also in small data regimes.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ There is limited understanding of multi-head self-attentions (MSAs), although they are now ubiquitous in computer vision. The most widely accepted explanation for the success of MSAs is their weak inductive bias and capture of long-range dependencies (See, e.g., (Dosovitskiy et al., 2021; Naseer et al., 2021; Tuli et al., 2021; Yu et al., 2021a; Mao et al., 2021; Chu et al., 2021)). Yet because of their over-flexibility, Vision Transformers (ViTs)—neural networks (NNs) consisting of MSAs—have been known to have a tendency to overfit training datasets, consequently leading to poor predictive performance in small data regimes, e.g., image classification on CIFAR. However, we show that the explanation is poorly supported.
12
+
13
+ # 1.1 RELATED WORK
14
+
15
+ Self-attentions (Vaswani et al., 2017; Dosovitskiy et al., 2021) aggregate (spatial) tokens with normalized importances:
16
+
17
+ $$
18
+ z _ { j } = \sum _ { i } \mathrm { S o f t m a x } \left( \frac { Q K } { \sqrt { d } } \right) _ { i } V _ { i , j }
19
+ $$
20
+
21
+ where $Q , \kappa$ , and $V$ are query, key, and value, respectively. $d$ is the dimension of query and key, and $z _ { j }$ is the $j$ -th output token. From the perspective of convolutional neural networks (CNNs), MSAs are a transformation of all feature map points with large-sized and data-specific kernels. Therefore, MSAs are at least as expressive as convolutional layers (Convs) (Cordonnier et al., 2020), although this does not guarantee that MSAs will behave like Convs.
22
+
23
+ Is the weak inductive bias of MSA, such as modeling long-range dependencies, beneficial for the predictive performance? To the contrary, appropriate constraints may actually help a model learn strong representations. For example, local MSAs (Yang et al., 2019; Liu et al., 2021; Chu et al., 2021), which calculate self-attention only within small windows, achieve better performance than global MSAs not only on small datasets but also on large datasets, e.g., ImageNet-21K.
24
+
25
+ In addition, prior works observed that MSAs have the following intriguing properties: $\textcircled{1}$ MSAs improve the predictive performance of CNNs (Wang et al., 2018; Bello et al., 2019; Dai et al., 2021;
26
+
27
+ ![](images/6a7c10af21e7c231eebbb672587b5f2cdf840caba9cb495300f1e6ea9f2f1e2b.jpg)
28
+ Figure 1: Two different aspects consistently show that MSAs flatten loss landscapes. Left: Loss landscape visualizations show that ViT has a flatter loss $\small \mathrm { ( N L L + } \ell _ { 2 }$ regularization) than ResNet. Right: Hessian max eigenvalue spectra show that the magnitude of the Hessian eigenvalues of ViT is smaller than that of ResNet during training phases. We report the Hessian spectra at the end of the warmup phases, $1 0 0 ^ { \mathrm { t h } }$ , $2 0 0 ^ { \mathrm { t h } }$ , and $\mathrm { \bar { 3 0 0 } ^ { t h } }$ epochs. See Fig. 4 for a more detailed analysis.
29
+
30
+ Guo et al., 2021; Srinivas et al., 2021), and ViTs predict well-calibrated uncertainty (Minderer et al., 2021). $\textcircled{2}$ ViTs are robust against data corruptions, image occlusions (Naseer et al., 2021), and adversarial attacks (Shao et al., 2021; Bhojanapalli et al., 2021; Paul & Chen, 2022; Mao et al., 2021). They are particularly robust against high-frequency noises (Shao et al., 2021). $\textcircled{3}$ MSAs closer to the last layer significantly improve predictive performance (Graham et al., 2021; Dai et al., 2021).
31
+
32
+ These empirical observations raise immediate questions: $\bullet$ What properties of MSAs do we need to better optimize NNs? Do the long-range dependencies of MSAs help NNs learn? $\textcircled { \times }$ Do MSAs act like Convs? If not, how are they different? $\bullet$ How can we harmonize MSAs with Convs? Can we just leverage their advantages?
33
+
34
+ We provide an explanation of how MSAs work by addressing them as a trainable spatial smoothing of feature maps, because Eq. (1) also suggests that MSAs average feature map values with the positive importance-weights. Even non-trainable spatial smoothings, such as a small $2 \times 2$ box blur, help CNNs see better (Zhang, 2019; Park & Kim, 2021). These simple spatial smoothings not only improve accuracy but also robustness by spatially ensembling feature map points and flattening the loss landscapes (Park & Kim, 2021). Remarkably, spatial smoothings have the properties of MSAs $\textcircled{1} - \textcircled { 3 }$ . See Appendix B for detailed explanations of MSAs as a spatial smoothing.
35
+
36
+ # 1.2 CONTRIBUTION
37
+
38
+ We address the three key questions:
39
+
40
+ $\bullet$ What properties of MSAs do we need to improve optimization? We present various evidences to support that MSA is generalized spatial smoothing. It means that MSAs improve performance because their formulation—Eq. (1)—is an appropriate inductive bias. Their weak inductive bias disrupts NN training. In particular, a key feature of MSAs is their data specificity, not long-range dependency. As an extreme example, local MSAs with a $3 \times 3$ receptive field outperforms global MSA because they reduce unnecessary degrees of freedom.
41
+
42
+ How do MSAs improve performance? MSAs have their advantages and disadvantages. On the one hand, they flatten loss landscapes as shown in Fig. 1. The flatter the loss landscape, the better the performance and generalization (Li et al., 2018; Keskar et al., 2017; Santurkar et al., 2018; Foret et al., 2021; Chen et al., 2022). Thus, they improve not only accuracy but also robustness in large data regimes. On the other hand, MSAs allow negative Hessian eigenvalues in small data regimes. This means that the loss landscapes of MSAs are non-convex, and this non-convexity disturbs NN optimization (Dauphin et al., 2014). Large amounts of training data suppress negative eigenvalues and convexify losses.
43
+
44
+ ![](images/56be45fa0b2c8123606967a9d277b23dce2565d4cbe503f52a54d75f1147b242.jpg)
45
+ Figure 2: The Fourier analysis shows that MSAs do not act like Convs. Left: Relative log amplitudes of Fourier transformed feature map show that ViT tends to reduce high-frequency signals, while ResNet amplifies them. $\Delta$ Log amplitude is the difference between the log amplitude at normalized frequency $0 . 0 \pi$ (center) and at $1 . 0 \pi$ (boundary). See Fig. 8 for more detailed analysis. Right: We measure the decrease in accuracy against frequency-based random noise. ResNet is vulnerable to high-frequency noise, while ViT is robust against them. We use frequency window size of $0 . 1 \pi$ .
46
+
47
+ $\textcircled { 2 }$ Do MSAs act like Convs? We show that MSAs and Convs exhibit opposite behaviors. MSAs aggregate feature maps, but Convs diversify them. Moreover, as shown in Fig. 2a, the Fourier analysis of feature maps shows that MSAs reduce high-frequency signals, while Convs, conversely, amplifies high-frequency components. In other words, MSAs are low-pass filters, but Convs are high-pass filters. In addition, Fig. 2b indicates that Convs are vulnerable to high-frequency noise but that MSAs are not. Therefore, MSAs and Convs are complementary.
48
+
49
+ $\bullet$ How can we harmonize MSAs with Convs? We reveal that multi-stage NNs behave like a series connection of small individual models. Thus, applying spatial smoothing at the end of a stage improves accuracy by ensembling transformed feature map outputs from each stage (Park & Kim, 2021) as shown in Fig. 3a. Based on this finding, we propose an alternating pattern of Convs and MSAs. NN stages using this design pattern consists of a number of CNN blocks and one (or a few) MSA block as shown in Fig. 3c. The design pattern naturally derives the structure of canonical Transformer, which has one MSA block per MLP block as shown in Fig. 3b. It also provides an explanation of how adding Convs to Transformer’s MLP block improves accuracy and robustness (Yuan et al., 2021; Guo et al., 2021; Mao et al., 2021).
50
+
51
+ Surprisingly, models using this alternating pattern of Convs and MSAs outperform CNNs not only on large datasets but also on small datasets, such as CIFAR. This contrasts with canonical ViTs, models that perform poorly on small amount of data. It implies that MSAs are generalized spatial smoothings that complement Convs, not simply generalized Convs.
52
+
53
+ # 2 WHAT PROPERTIES OF MSAS DO WE NEED TO IMPROVE OPTIMIZATION?
54
+
55
+ To understand the underlying nature of MSAs, we investigate the properties of the ViT family: e.g., vanilla ViT (Dosovitskiy et al., 2021); PiT (Heo et al., 2021), which is “ViT $^ +$ multi-stage”; and Swin (Liu et al., 2021), which is $\mathrm { ^ { 6 6 } V i T + }$ multi-stage $^ +$ local MSA”. This section shows that these additional inductive biases enable ViTs to learn strong representations. We also use ResNet (He et al., 2016a) for comparison. NNs are trained from scratch with DeiT-style data augmentation (Touvron et al., 2021) for 300 epochs. The NN training begins with a gradual warmup (Goyal et al., 2017) for 5 epochs. Appendix A provides more detailed configurations and background information for experiments.
56
+
57
+ ![](images/f354d752997e0b3a823268a60ba0d34d9e7b1b88bfc59ffb63ac41d39cb70ed6.jpg)
58
+ Figure 3: Comparison of three different repeating patterns. Left: Spatial smoothings are located at the end of CNN stages. Middle: The stages of ViTs consist of repetitions of canonical Transformers. “D” is the hidden dimension and “H” is the number of heads. Right: The stages using alternating pattern consists of a number of CNN blocks and an MSA block. For more details, see Fig. 11.
59
+
60
+ The stronger the inductive biases, the stronger the representations (not regularizations). Do models with weak inductive biases overfit training datasets? To address this question, we provide two criteria on CIFAR-100: the error of the test dataset and the cross-entropy, or the negative log-likelihood, of the training dataset $\mathrm { { N L L } _ { \mathrm { { t r a i n } } } }$ , the lower the better). See Fig. 5a for the results.
61
+
62
+ Contrary to our expectations, experimental results show that the stronger the inductive bias, the lower both the test error and the training NLL. This indicates that ViT does not overfit training datasets. In addition, appropriate inductive biases, such as locality constraints for MSAs, helps NNs learn strong representations. We also observe these phenomena on CIFAR-10 and ImageNet as shown in Fig. C.1. Figure C.2 also supports that weak inductive biases disrupt NN training. In this experiment, extremely small patch sizes for the embedding hurt the predictive performance of ViT.
63
+
64
+ ViT does not overfit small training datasets. We observe that ViT does not overfit even on smaller datasets. Figure 5b shows the test error and the training NLL of ViT on subsampled datasets. In this experiment, as the size of the dataset decreases, the error increases as expected, but surprisingly, ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ also increases. Thanks to the strong data augmentation, ViT does not overfit even on a dataset size of $2 \%$ . This suggests that ViT’s poor performance in small data regimes is not due to overfitting.
65
+
66
+ ViT’s non-convex losses lead to poor performance. How do weak inductive biases of MSAs disturb the optimization? A loss landscape perspective provides an explanation: the loss function of ViT is non-convex, while that of ResNet is strongly (near-)convex. This poor loss disrupts NN training (Dauphin et al., 2014), especially in the early phase of training (Jastrzebski et al., 2020; 2021). Figure 1b and Fig. 4 provide top-5 largest Hessian eigenvalue densities (Park & Kim, 2021) with a batch size of 16. The figures show that ViT has a number of negative Hessian eigenvalues, while ResNet only has a few.
67
+
68
+ Figure 4 also shows that large datasets suppress negative Hessian eigenvalues in the early phase of training. Therefore, large datasets tend to help ViT learn strong representations by convexifying the loss. ResNet enjoys little benefit from large datasets because its loss is convex even on small datasets.
69
+
70
+ ![](images/f5c7623c42c203631b88cf135e8afe8e18fd25c1bb76f22d4285060f9e06082b.jpg)
71
+ Figure 4: Hessian max eigenvalue spectra show that MSAs have their advantages and disadvantages. The dotted line is the spectrum of ViT using $6 \%$ dataset for training. Left: ViT has a number of negative Hessian eigenvalues, while ResNet only has a few. Right: The magnitude of ViT’s positive Hessian eigenvalues is small. See also Fig. 1b for more results.
72
+
73
+ ![](images/3cf0bbee17a8e6f763c065b1e7c18c0c559f816350fac0474a8609263da0b6d3.jpg)
74
+ Figure 5: ViT does not overfit training datasets. “R” is ResNet and “RX” is ResNeXt. Left: Weak inductive bias disturbs NN optimization. The lower the ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ , the lower the error. Right: The lack of dataset also disturbs NN optimization.
75
+
76
+ Loss landscape smoothing methods aids in ViT training. Loss landscape smoothing methods can also help ViT learn strong representations. In classification tasks, global average pooling (GAP) smoothens the loss landscape by strongly ensembling feature map points (Park & Kim, 2021). We demonstrate how the loss smoothing method can help ViT improve performance by analyzing ViT with GAP classifier instead of CLS token on CIFAR-100.
77
+
78
+ Figure 6 shows the Hessian max eigenvalue spectrum of the ViT with GAP. As expected, the result shows that GAP classifier suppresses negative Hessian max eigenvalues, suggesting that GAP convexify the loss. Since negative eigenvalues disturb NN optimization, GAP classifier improve the accuracy by $+ 2 . 7$ percent point.
79
+
80
+ ![](images/62d6a66720e1da1e9ff9efaea1d60a8097ddab84b7ab83a6f328988fe5395220.jpg)
81
+ Figure 6: GAP classifier suppresses negative Hessian max eigenvalues in an early phase of training. We present Hessian max eigenvalue spectrum of ViT with GAP classifier instead of CLS token.
82
+
83
+ Likewise, Sharpness-Aware Minimization (SAM) (Foret et al., 2021), an optimizer that relies on the local smoothness of the loss function, also helps NNs seek out smooth minima. Chen et al. (2022) showed that SAM improves the predictive performance of ViT.
84
+
85
+ MSAs flatten the loss landscape. Another property of MSAs is that they reduces the magnitude of Hessian eigenvalues. Figure 1b and Fig. 4 shows that the eigenvalues of ViT are significantly smaller than that of CNNs. While large eigenvalues impede NN training (Ghorbani et al., 2019), MSAs can help NNs learn better representations by suppressing large Hessian eigenvalues. Figure 1a also support this claim. In Fig. 1a, we visualize the loss landscapes by using filter normalization (Li et al., 2018), and the loss landscape of ViT is flatter than that of ResNet. In large data regimes, the negative Hessian eigenvalues—the disadvantage of MSAs—disappears, and only their advantages remain. As a result, ViTs outperform CNNs on large datasets, such as ImageNet and JFT (Sun et al., 2017). PiT and Swin also flatten the loss landscapes. For more details, see Fig. C.4.
86
+
87
+ A key feature of MSAs is data specificity (not long-range dependency). The two distinguishing features of MSAs are long-range dependency and data specificity, also known as data dependency, as discussed in Section 1.1. Contrary to popular belief, the long-range dependency hinders NN optimization. To demonstrate this, we analyze convolutional ViT, which consists of two-dimensional convolutional MSAs (Yang et al., 2019) instead of global MSAs. Convolutional MSAs calculates self-attention only between feature map points in convolutional receptive fields after unfolding the feature maps in the same way as convolutions.
88
+
89
+ Figure 7a shows the error and ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ of convolutional ViTs with kernel sizes of $3 \times 3 , 5 \times 5$ , and $8 \times 8$ (global MSA) on CIFAR-100. In this experiment, $5 \times 5$ kernel outperforms $8 \times 8$ kernel on both the training and the test datasets. ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ of $3 \times 3$ kernel is worse than that of $5 \times 5$ kernel, but better than that of global MSA. Although the test accuracies of $3 \times 3$ and $5 \times 5$ kernels are comparable, the robustness of $5 \times 5$ kernel is significantly better than that of $3 \times 3$ kernel on CIFAR-100-C (Hendrycks & Dietterich, 2019).
90
+
91
+ ![](images/096854e93c3a0383c758e59378a6d8bfb67c71ab19dd2703eb7d8607eac0118f.jpg)
92
+ Figure 7: Locality constraint improves the performance of ViT. We analyze the ViT with convolutional MSAs. Convolutional MSA with $8 \times 8$ kernel is global MSA. Left: Local MSAs learn stronger representations than global MSA. Right: Locality inductive bias suppresses the negative Hessian eigenvalues, i.e., local MSAs have convex losses.
93
+
94
+ Figure 7b shows that the strong locality inductive bias not only reduce computational complexity as originally proposed (Liu et al., 2021), but also aid in optimization by convexifying the loss landscape. $5 \times 5$ kernel has fewer negative eigenvalues than global MSA because it restricts unnecessary degrees of freedom. $5 \times 5$ kernel also has fewer negative eigenvalues than $3 \times 3$ kernel because it ensembles a larger number of feature map points (See also Fig. 6). The amount of negative eigenvalues is minimized when these two effects are balanced.
95
+
96
+ It is clear that data specificity improves NNs. MLP-Mixer (Tolstikhin et al., 2021; Yu et al., 2021a), a model with an MLP kernel that does not depend on input data, underperforms compared to ViTs. Data specificity without self-attention (Bello, 2021) improves performance.
97
+
98
+ # 3 DO MSAS ACT LIKE CONVS?
99
+
100
+ Convs are data-agnostic and channel-specific. In contrast, MSAs are data-specific and channelagnostic. This section shows that these differences lead to large behavioral differences. It suggests that MSAs and Convs are complementary.
101
+
102
+ MSAs are low-pass filters, but Convs are highpass filters. As explained in Section 1.1, MSAs spatially smoothen feature maps with self-attention importances. Therefore, we expect that MSAs will tend to reduce high-frequency signals. See Appendix B for a more detailed discussion.
103
+
104
+ Figure 8 shows the relative log amplitude ( $\Delta$ log amplitude) of ViT’s Fourier transformed feature map at high-frequency $( 1 . 0 \pi )$ on ImageNet. In this figure, MSAs almost always decrease the high-frequency amplitude, and MLPs—corresponding to Convs— increase it. The only exception is in the early stages of the model. In these stages, MSAs behave like Convs, i.e., they increase the amplitude. This could serve as an evidence for a hybrid model that uses Convs in early stages and MSAs in late stages (Guo et al.,
105
+
106
+ ![](images/e36f09317cd9d1ea2b15310639f19e81ecb5ff8798236e2c950aa8351070791c.jpg)
107
+ Figure 8: MSAs (gray area) generally reduce the high-frequency component of feature map, and MLPs (white area) amplify it. This figure provides $\Delta$ log amplitude of ViT at high-frequency $( 1 . 0 \pi )$ . See also Fig. 2a and Fig. D.2 for more results.
108
+
109
+ 2021; Graham et al., 2021; Dai et al., 2021; Xiao et al., 2021; Srinivas et al., 2021).
110
+
111
+ Based on this, we can infer that low-frequency signals and high-frequency signals are informative to MSAs and Convs, respectively. In support of this argument, we report the robustness of ViT and ResNet against frequency-based random noise. Following Shao et al. (2021) and Park & Kim (2021), we measure the decrease in accuracy with respect to data with frequency-based random noise $\pmb { x } _ { \mathrm { n o i s e } } = \pmb { x } _ { 0 } + \mathcal { F } ^ { - 1 } \left( \mathcal { F } ( \delta ) \odot \mathbf { M } _ { f } \right)$ , where $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ is clean data, $\mathcal F ( \cdot )$ and $\mathcal { F } ^ { - 1 } ( \cdot )$ are Fourier transform and inverse Fourier transform, $\delta$ is Gaussian random noise, and ${ \mathbf { M } } _ { f }$ is frequency mask.
112
+
113
+ ![](images/812c340b7ae5d97b9e448ca1a7f009138c4c488370ada7b05e733593356431d4.jpg)
114
+ Figure 9: MSAs (gray area) reduce the variance of feature map points, but Convs (white area) increase the variance. The blue area is subsampling layer. This result implies that MSAs ensemble feature maps, but Convs do not.
115
+
116
+ As expected, the result in Fig. 2b reveals that ViT and ResNet are vulnerable to low-frequency noise and high-frequency noise, respectively. Low-frequency signals and the high-frequency signals each correspond to the shape and the texture of images. The results thus suggests that MSAs are shape-biased (Naseer et al., 2021), whereas Convs are texture-biased (Geirhos et al., 2019).
117
+
118
+ MSAs aggregate feature maps, but Convs do not. Since MSAs average feature maps, they will reduce variance of feature map points. This suggests that MSAs ensemble feature maps (Park & Kim, 2021). To demonstrate this claim, we measure the variance of feature maps from NN layers.
119
+
120
+ Figure 9 shows the experimental results of ResNet and ViT. This figure indicates that MSAs in ViT tend to reduce the variance; conversely, Convs in ResNet and MLPs in ViT increase it. In conclusion, MSAs ensemble feature map predictions, but Convs do not. As Park & Kim (2021) figured out, reducing the feature map uncertainty helps optimization by ensembling and stabilizing the transformed feature maps. See Fig. D.1 for more results on PiT and Swin.
121
+
122
+ We observe two additional patterns for feature map variance. First, the variance accumulates in every NN layer and tends to increase as the depth increases. Second, the feature map variance in ResNet peaks at the ends of each stage. Therefore, we can improve the predictive performance of ResNet by inserting MSAs at the end of each stage. Furthermore, we also can improve the performance by using MSAs with a large number of heads in late stages.
123
+
124
+ # 4 HOW CAN WE HARMONIZE MSAS WITH CONVS?
125
+
126
+ Since MSAs and Convs are complementary, this section seeks to design a model that leverages only the advantages of the two modules. To this end, we propose the design rules described in Fig. 3c, and demonstrate that the models using these rules outperforms CNNs, not only in the large data regimes but also in the small data regimes, such as CIFAR.
127
+
128
+ # 4.1 DESIGNING ARCHITECTURE
129
+
130
+ We first investigate the properties of multi-stage NN architectures. Based on this investigation, we come to propose an alternating pattern, i.e., a principle for stacking MSAs based on CNNs.
131
+
132
+ Multi-stage NNs behave like individual models. In Fig. 9, we observe that the pattern of feature map variance repeats itself at every stages. This behavior is also observed in feature map similarities and lesion studies.
133
+
134
+ Figure 10a shows the representational similarities of ResNet and Swin on CIFAR-100. In this experiment, we use mini-batch CKA (Nguyen et al., 2021) to measure the similarities. As Nguyen et al. (2021) figured out, the feature map similarities of CNNs have a block structure. Likewise, we observe that the feature map similarities of multi-stage ViTs, such as PiT and Swin, also have a block structure. Since vanilla ViT does not have this structure (Bhojanapalli et al., 2021; Raghu et al., 2021), the structure is an intrinsic characteristic of multi-stage architectures. See Fig. D.3 for more detailed results of ViT and PiT.
135
+
136
+ ![](images/5a440b8ae8d7079711f524fabf134967e530cc92d740404ea342d513a5a596e9.jpg)
137
+ Figure 10: Multi-stage CNNs and ViTs behave like a series connection of small individual models. Left: The feature map similarities show the block structure of ResNet and Swin. “E” stands for stem/embedding and “P” for pooling (subsampling) layer. Right: We measure decrease in accuracy after removing one unit from the trained model. Accuracy changes periodically, and this period is one stage. White, gray, and blue areas are Conv/MLP, MSA, and subsampling layers, respectively.
138
+
139
+ Figure 10b shows the results of lesion study (Bhojanapalli et al., 2021), where one NN unit is removed from already trained ResNet and Swin during the testing phase. In this experiment, we remove one $3 \times 3$ Conv layer from the bottleneck block of ResNet, and one MSA or MLP block from Swin. In ResNet, removing an early stage layers hurts accuracy more than removing a late stage layers. More importantly, removing a layer at the beginning of a stage impairs accuracy more than removing a layer at the end of a stage. The case of Swin is even more interesting. At the beginning of a stage, removing an MLP hurts accuracy. At the end of a stage, removing an MSA seriously impairs the accuracy. These results are consistent with Fig. 8. See Fig. D.4 for the results on ViT and PiT.
140
+
141
+ Based on these findings, we expect MSAs closer to the end of a stage to significantly improve the predictive performance. This is contrary to the popular belief that MSAs closer to the end of a model improve the performance (Srinivas et al., 2021; d’Ascoli et al., 2021; Graham et al., 2021; Dai et al., 2021).
142
+
143
+ Build-up rule. Considering all the insights, we propose the following design rules:
144
+
145
+ • Alternately replace Conv blocks with MSA blocks from the end of a baseline CNN model. • If the added MSA block does not improve predictive performance, replace a Conv block located at the end of an earlier stage with an MSA block . • Use more heads and higher hidden dimensions for MSA blocks in late stages.
146
+
147
+ We call the model that follows these rules AlterNet. AlterNet unifies ViTs and CNNs by adjusting the ratio of MSAs and Convs as shown in Fig. 3. Figure 11 shows AlterNet based on pre-activation ResNet-50 (He et al., 2016b) for CIFAR-100 as an example. Figure D.5 shows AlterNet for ImageNet.
148
+
149
+ Figure 12a reports the accuracy of Alter-ResNet-50, which replaces the Conv blocks in ResNet-50 with local MSAs (Liu et al., 2021) according to the aforementioned rules, on CIFAR-100. As expected, MSAs in the last stage (c4) significantly improve the accuracy. Surprisingly, an MSA in $2 ^ { \mathrm { n d } }$ stage (c2) improves the accuracy, while two or more MSAs in the $3 ^ { \mathrm { { \bar { r } d } } }$ stage (c3) reduce it. In conclusion, MSAs at the end of a stage play an important role in prediction.
150
+
151
+ Figure 12c demonstrates that MSAs suppress large eigenvalues while allowing only a few negative eigenvalues. As explained in Fig. 4, large datasets compensate for the shortcomings of MSAs. Therefore, more data allows more MSAs for a models.
152
+
153
+ ![](images/5d48db79864fdce5cd0499625b113c68ec1837fec3709a6c4bad43fdd6ec7006.jpg)
154
+ Figure 11: Detailed architecture of Alter-ResNet-50 for CIFAR-100. White, gray, and blue blocks mean Conv, MSA, and subsampling blocks. All stages (except stage 1) end with MSA blocks. This model is based on pre-activation ResNet-50. Following Swin, MSAs in stages 1 to 4 have 3, 6, 12, and 24 heads, respectively.
155
+
156
+ ![](images/8be26613a4590464286b5014a9586f6e03a11bce7cf972ed2fe2dede4a707464.jpg)
157
+ (a) Accuracy of AlterNet for MSA (b) Accuracy and robustness in a (c) Hessian max eigenvalue spectra number small data regime (CIFAR-100) in an early phase of training
158
+ Figure 12: AlterNet outperforms CNNs and ViTs. Left: MSAs in the late of the stages improve accuracy. We replace Convs of ResNet with MSAs one by one according to the build-up rules. c1 to ${ \tt c 4 }$ stands for the stages. Several MSAs in c3 harm the accuracy, but the MSA at the end of c2 improves it. Center: AlterNet outperforms CNNs even in a small data regime. Robustness is mean accuracy on CIFAR-100-C. “RX” is ResNeXt. Right: MSAs in AlterNet suppress the large eigenvalues; i.e., AlterNet has a flatter loss landscape than ResNet in the early phase of training.
159
+
160
+ # 4.2 PERFORMANCE
161
+
162
+ Figure 12b shows the accuracy and corruption robustness of Alter-ResNet-50 and other baselines on CIFAR-100 and CIFAR-100-C. Since CIFAR is a small dataset, CNNs outperforms canonical ViTs. Surprisingly, Alter-ResNet—a model with MSAs following the appropriate build-up rule— outperforms CNNs even in the small data regimes. This suggests that MSAs complement Convs. In the same manner, this simple modification shows competitive performance on larger datasets, such as ImageNet. See Fig. E.1 for more details.
163
+
164
+ # 5 DISCUSSION
165
+
166
+ Our present work demonstrates that MSAs are not merely generalized Convs, but rather generalized spatial smoothings that complement Convs. MSAs help NNs learn strong representations by ensembling feature map points and flattening the loss landscape.
167
+
168
+ Since the main objective of this work is to investigate the nature of MSA for computer vision, we preserve the architectures of Conv and MSA blocks in AlterNet. Thus, AlterNet has a strong potential for future improvements. In addition, AlterNet can conveniently replace the backbone for other vision tasks such as dense prediction (Carion et al., 2020). As Park & Kim (2021) pointed out, global average pooling (GAP) for simple classification tasks has a strong tendency to ensemble feature maps, but NNs for dense prediction do not use GAP. Therefore, we believe that MSA to be able to significantly improve the results in dense prediction tasks by ensembling feature maps. Lastly, strong data augmentation for MSA training harms uncertainty calibration as shown in Fig. F.1a. We leave a detailed investigation for future work.
169
+
170
+ # ACKNOWLEDGEMENT
171
+
172
+ We thank the reviewers, Taeoh Kim, and Pilhyeon Lee for valuable feedback. This work was supported by the Samsung Science and Technology Foundation under Project Number SSTF-BA1501-52.
173
+
174
+ # REPRODUCIBILITY STATEMENT
175
+
176
+ To ensure reproducibility, we provide comprehensive resources, such as code and experimental details. The code is available at https://github.com/xxxnell/how-do-vits-work. Appendix A.1 provides the specifications of all models used in this work. Detailed experimental setup including hyperparameters and the structure of AlterNet are also available in Appendix A.1 and Appendix E. De-facto image datasets are used for all experiments as described in Appendix A.1.
177
+
178
+ # REFERENCES
179
+
180
+ Irwan Bello. Lambdanetworks: Modeling long-range interactions without attention. In International Conference on Learning Representations, 2021.
181
+
182
+ Irwan Bello, Barret Zoph, Ashish Vaswani, Jonathon Shlens, and Quoc V Le. Attention augmented convolutional networks. In International Conference on Computer Vision, 2019.
183
+
184
+ Irwan Bello, William Fedus, Xianzhi Du, Ekin Dogus Cubuk, Aravind Srinivas, Tsung-Yi Lin, Jonathon Shlens, and Barret Zoph. Revisiting resnets: Improved training and scaling strategies. In Advances in Neural Information Processing Systems, 2021.
185
+
186
+ Srinadh Bhojanapalli, Ayan Chakrabarti, Daniel Glasner, Daliang Li, Thomas Unterthiner, and Andreas Veit. Understanding robustness of transformers for image classification. In International Conference on Computer Vision, 2021.
187
+
188
+ Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, 2020.
189
+
190
+ Xiangning Chen, Cho-Jui Hsieh, and Boqing Gong. When vision transformers outperform resnets without pretraining or strong data augmentations. In International Conference on Learning Representations, 2022.
191
+
192
+ Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Twins: Revisiting the design of spatial attention in vision transformers. In Advances in Neural Information Processing Systems, 2021.
193
+
194
+ Jean-Baptiste Cordonnier, Andreas Loukas, and Martin Jaggi. On the relationship between selfattention and convolutional layers. In International Conference on Learning Representations, 2020.
195
+
196
+ Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In Advances in Neural Information Processing Systems, 2020.
197
+
198
+ Zihang Dai, Hanxiao Liu, Quoc V Le, and Mingxing Tan. Coatnet: Marrying convolution and attention for all data sizes. In Advances in Neural Information Processing Systems, 2021.
199
+
200
+ Stéphane d’Ascoli, Hugo Touvron, Matthew Leavitt, Ari Morcos, Giulio Biroli, and Levent Sagun. Convit: Improving vision transformers with soft convolutional inductive biases. In International Conference on Machine Learning, 2021.
201
+
202
+ Yann N Dauphin, Razvan Pascanu, Caglar Gulcehre, Kyunghyun Cho, Surya Ganguli, and Yoshua Bengio. Identifying and attacking the saddle point problem in high-dimensional non-convex optimization. In Advances in Neural Information Processing Systems, 2014.
203
+
204
+ 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 International Conference on Learning Representations, 2021.
205
+
206
+ Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur. Sharpness-aware minimization for efficiently improving generalization. In International Conference on Learning Representations, 2021.
207
+
208
+ Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A Wichmann, and Wieland Brendel. Imagenet-trained cnns are biased towards texture; increasing shape bias improves accuracy and robustness. In International Conference on Learning Representations, 2019.
209
+
210
+ Behrooz Ghorbani, Shankar Krishnan, and Ying Xiao. An investigation into neural net optimization via hessian eigenvalue density. In International Conference on Machine Learning, 2019.
211
+
212
+ Priya Goyal, Piotr Dollár, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, Andrew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch sgd: Training imagenet in 1 hour. arXiv preprint arXiv:1706.02677, 2017.
213
+
214
+ Ben Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Hervé Jégou, and Matthijs Douze. Levit: a vision transformer in convnet’s clothing for faster inference. In International Conference on Computer Vision, 2021.
215
+
216
+ Jianyuan Guo, Kai Han, Han Wu, Chang Xu, Yehui Tang, Chunjing Xu, and Yunhe Wang. Cmt: Convolutional neural networks meet vision transformers. arXiv preprint arXiv:2107.06263, 2021.
217
+
218
+ 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, 2016a.
219
+
220
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European Conference on Computer Vision, 2016b.
221
+
222
+ Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations, 2019.
223
+
224
+ Byeongho Heo, Sangdoo Yun, Dongyoon Han, Sanghyuk Chun, Junsuk Choe, and Seong Joon Oh. Rethinking spatial dimensions of vision transformers. In International Conference on Computer Vision, 2021.
225
+
226
+ Jiri Hron, Yasaman Bahri, Jascha Sohl-Dickstein, and Roman Novak. Infinite attention: Nngp and ntk for deep attention networks. In International Conference on Machine Learning, 2020.
227
+
228
+ Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European Conference on Computer Vision, 2016.
229
+
230
+ Arthur Jacot, Franck Gabriel, and Clément Hongler. Neural tangent kernel: Convergence and generalization in neural networks. In Advances in Neural Information Processing Systems, 2018.
231
+
232
+ Stanislaw Jastrzebski, Maciej Szymczak, Stanislav Fort, Devansh Arpit, Jacek Tabor, Kyunghyun Cho, and Krzysztof Geras. The break-even point on optimization trajectories of deep neural networks. In International Conference on Learning Representations, 2020.
233
+
234
+ Stanislaw Jastrzebski, Devansh Arpit, Oliver Astrand, Giancarlo B Kerg, Huan Wang, Caiming Xiong, Richard Socher, Kyunghyun Cho, and Krzysztof J Geras. Catastrophic fisher explosion: Early phase fisher matrix impacts generalization. In International Conference on Machine Learning, 2021.
235
+
236
+ 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.
237
+
238
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
239
+
240
+ Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein. Visualizing the loss landscape of neural nets. In Advances in Neural Information Processing Systems, 2018.
241
+
242
+ Chaoyue Liu, Libin Zhu, and Mikhail Belkin. On the linearity of large non-linear models: when and why the tangent kernel is constant. In Advances in Neural Information Processing Systems, 2020.
243
+
244
+ 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. In International Conference on Computer Vision, 2021.
245
+
246
+ Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. In International Conference on Learning Representations, 2017.
247
+
248
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019.
249
+
250
+ Xiaofeng Mao, Gege Qi, Yuefeng Chen, Xiaodan Li, Ranjie Duan, Shaokai Ye, Yuan He, and Hui Xue. Towards robust vision transformer. arXiv preprint arXiv:2105.07926, 2021.
251
+
252
+ Paul Michel, Omer Levy, and Graham Neubig. Are sixteen heads really better than one? In Advances in Neural Information Processing Systems, 2019.
253
+
254
+ Matthias Minderer, Josip Djolonga, Rob Romijnders, Frances Hubis, Xiaohua Zhai, Neil Houlsby, Dustin Tran, and Mario Lucic. Revisiting the calibration of modern neural networks. In Advances in Neural Information Processing Systems, 2021.
255
+
256
+ Muzammal Naseer, Kanchana Ranasinghe, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Ming-Hsuan Yang. Intriguing properties of vision transformers. In Advances in Neural Information Processing Systems, 2021.
257
+
258
+ Thao Nguyen, Maithra Raghu, and Simon Kornblith. Do wide and deep networks learn the same things? uncovering how neural network representations vary with width and depth. In International Conference on Learning Representations, 2021.
259
+
260
+ Namuk Park and Songkuk Kim. Blurs behave like ensembles: Spatial smoothings to improve accuracy, uncertainty, and robustness. arXiv preprint arXiv:2105.12639, 2021.
261
+
262
+ Namuk Park, Taekyu Lee, and Songkuk Kim. Vector quantized bayesian neural network inference for data streams. In Proceedings of the AAAI Conference on Artificial Intelligence, 2021.
263
+
264
+ 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. In Advances in Neural Information Processing Systems, 2019.
265
+
266
+ Sayak Paul and Pin-Yu Chen. Vision transformers are robust learners. In Proceedings of the AAAI Conference on Artificial Intelligence, 2022.
267
+
268
+ Maithra Raghu, Thomas Unterthiner, Simon Kornblith, Chiyuan Zhang, and Alexey Dosovitskiy. Do vision transformers see like convolutional neural networks? In Advances in Neural Information Processing Systems, 2021.
269
+
270
+ 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), 2015.
271
+
272
+ Shibani Santurkar, Dimitris Tsipras, Andrew Ilyas, and Aleksander M ˛adry. How does batch normalization help optimization? In Advances in Neural Information Processing Systems, 2018.
273
+
274
+ Rulin Shao, Zhouxing Shi, Jinfeng Yi, Pin-Yu Chen, and Cho-Jui Hsieh. On the adversarial robustness of visual transformers. arXiv preprint arXiv:2103.15670, 2021.
275
+
276
+ Aravind Srinivas, Tsung-Yi Lin, Niki Parmar, Jonathon Shlens, Pieter Abbeel, and Ashish Vaswani. Bottleneck transformers for visual recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2021.
277
+
278
+ Andreas Steiner, Alexander Kolesnikov, Xiaohua Zhai, Ross Wightman, Jakob Uszkoreit, and Lucas Beyer. How to train your vit? data, augmentation, and regularization in vision transformers. arXiv preprint arXiv:2106.10270, 2021.
279
+
280
+ Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In International Conference on Computer Vision, 2017.
281
+
282
+ 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, 2016.
283
+
284
+ Ilya Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Daniel Keysers, Jakob Uszkoreit, Mario Lucic, et al. Mlp-mixer: An all-mlp architecture for vision. In Advances in Neural Information Processing Systems, 2021.
285
+
286
+ Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. In International Conference on Machine Learning, 2021.
287
+
288
+ Shikhar Tuli, Ishita Dasgupta, Erin Grant, and Thomas L Griffiths. Are convolutional neural networks or transformers more like human vision? In Proceedings of the Annual Meeting of the Cognitive Science Society, 2021.
289
+
290
+ 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, 2017.
291
+
292
+ Peihao Wang, Wenqing Zheng, Tianlong Chen, and Zhangyang Wang. Scaling the depth of vision transformers via the fourier domain analysis. In International Conference on Learning Representations, 2022.
293
+
294
+ Phil Wang. Implementation of vision transformer. https://github.com/lucidrains/ vit-pytorch, 2021.
295
+
296
+ Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2018.
297
+
298
+ Yeming Wen, Ghassen Jerfel, Rafael Muller, Michael W Dusenberry, Jasper Snoek, Balaji Lakshminarayanan, and Dustin Tran. Combining ensembles and data augmentation can harm your calibration. In International Conference on Learning Representations, 2021.
299
+
300
+ Ross Wightman. Pytorch image models. https://github.com/rwightman/ pytorch-image-models, 2019.
301
+
302
+ Tete Xiao, Mannat Singh, Eric Mintun, Trevor Darrell, Piotr Dollár, and Ross Girshick. Early convolutions help transformers see better. In Advances in Neural Information Processing Systems, 2021.
303
+
304
+ Saining Xie, Ross Girshick, Piotr Dollár, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2017.
305
+
306
+ Weijian Xu, Yifan Xu, Tyler Chang, and Zhuowen Tu. Co-scale conv-attentional image transformers. In International Conference on Computer Vision, 2021.
307
+
308
+ Baosong Yang, Longyue Wang, Derek F Wong, Lidia S Chao, and Zhaopeng Tu. Convolutional self-attention networks. 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), 2019.
309
+
310
+ Zhewei Yao, Amir Gholami, Kurt Keutzer, and Michael W Mahoney. Pyhessian: Neural networks through the lens of the hessian. In 2020 IEEE International Conference on Big Data (Big Data), 2020.
311
+
312
+ Dong Yin, Raphael Gontijo Lopes, Jon Shlens, Ekin Dogus Cubuk, and Justin Gilmer. A fourier perspective on model robustness in computer vision. In Advances in Neural Information Processing Systems, 2019.
313
+
314
+ Tan Yu, Xu Li, Yunfeng Cai, Mingming Sun, and Ping Li. Rethinking token-mixing mlp for mlp-based vision backbone. In BMVC, 2021a.
315
+
316
+ Weihao Yu, Mi Luo, Pan Zhou, Chenyang Si, Yichen Zhou, Xinchao Wang, Jiashi Feng, and Shuicheng Yan. Metaformer is actually what you need for vision. arXiv preprint arXiv:2111.11418, 2021b.
317
+
318
+ Kun Yuan, Shaopeng Guo, Ziwei Liu, Aojun Zhou, Fengwei Yu, and Wei Wu. Incorporating convolution designs into visual transformers. In International Conference on Computer Vision, 2021.
319
+
320
+ 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, 2019.
321
+
322
+ Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In International Conference on Learning Representations, 2018.
323
+
324
+ Richard Zhang. Making convolutional networks shift-invariant again. In International Conference on Machine Learning, 2019.
325
+
326
+ Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random erasing data augmentation. In Proceedings of the AAAI Conference on Artificial Intelligence, 2020.
327
+
328
+ # A EXPERIMENTAL DETAILS
329
+
330
+ This section provides experimental details, e.g., setups and background information.
331
+
332
+ # A.1 SETUPS
333
+
334
+ We obtain the main experimental results from two sets of machines for CIFAR (Krizhevsky et al., 2009). The first set consists of an Intel Xeon W-2123 Processor, 32GB memory, and a single GeForce RTX 2080 Ti, and the other set of four Intel Intel Broadwell CPUs, 15GB memory, and a single NVIDIA T4. For ImageNet (Russakovsky et al., 2015), we use AMD Ryzen Threadripper 3960X 24-Core Processor, 256GB memory, and four GeForce RTX 2080 Ti. NN models are implemented in PyTorch (Paszke et al., 2019).
335
+
336
+ We train NNs using categorical cross-entropy (NLL) loss and AdamW optimizer (Loshchilov & Hutter, 2019) with initial learning rate of $\mathrm { { 1 . 2 5 \times 1 0 ^ { - 4 } } }$ and weight decay of $5 \times 1 0 ^ { - 2 }$ . We also use cosine annealing scheduler (Loshchilov & Hutter, 2017). NNs are trained for 300 epochs with a batch size of 96 on CIFAR, and a batch size of 128 on ImageNet. The learning rate is gradually increased (Goyal et al., 2017) for 5 epochs. Following Touvron et al. (2021), strong data augmentations—such as RandAugment (Cubuk et al., 2020), Random Erasing (Zhong et al., 2020), label smoothing (Szegedy et al., 2016), mixup (Zhang et al., 2018), and CutMix (Yun et al., 2019)—are used for training. Stochastic depth (Huang et al., 2016) is also used to regularize NNs. This DeiT-style configuration, which significantly improves the performance (Steiner et al., 2021; Bello et al., 2021), is the de facto standard in ViT training (See, e.g., (Heo et al., 2021; Liu et al., 2021)). Therefore, we believe the insights presented in this paper can be used widely. See source code (https://github.com/xxxnell/how-do-vits-work) for detailed configurations.
337
+
338
+ We mainly report the performances of ResNet-50, ViT-Ti, PiT-Ti, and Swin-Ti. Their training throughputs on CIFAR-100 are 320, 434, 364, and 469 image/sec, respectively, which are comparable to each other. Figures 5a and C.1a report the predictive performance of ResNeXt-50 (Xie et al., 2017), Twins-S (Chu et al., 2021), and MLP-Mixer-Ti (Tolstikhin et al., 2021). Figure E.1 additionally reports the performance of ConViT-Ti (d’Ascoli et al., 2021), LeViT-128S (Graham et al., 2021), and CoaT-Lite-Ti (Xu et al., 2021). We use a patch size of $2 \times 2$ for ViT and PiT on CIFAR; for Swin, a patch size of $1 \times 1$ and a window size of $4 \times 4$ . We use a patch size of $4 \times 4$ for ViT only in Fig. 7. We halve the depth of the ViT in Fig. C.5 and Fig. C.6 due to the memory limitation.
339
+
340
+ All models for CIFAR, and ResNet, ViT, and AlterNet for ImageNet are trained from scratch. We use pertained PiT and Swin from Wightman (2019) for ImageNet. The implementations of Vision Transformers are based on Wightman (2019) and Wang (2021).
341
+
342
+ For Hessian max eigenvalue spectrum (Park & Kim, 2021), $10 \%$ of the training dataset is used. We also use power iteration with a batch size of 16 to produce the top-5 largest eigenvalues. To this end, we use the implementation of Yao et al. (2020). We modify the algorithm to calculate the eigenvalues with respect to $\ell _ { 2 }$ regularized NLL on augmented training datasets. In the strict sense, the weight decay is not $\ell _ { 2 }$ regularization, but we neglect the difference.
343
+
344
+ For the Fourier analysis and the feature map variance experiment, the entire test dataset is used. We report the amplitudes and the variances averaged over the channels.
345
+
346
+ # A.2 BACKGROUND INFORMATION
347
+
348
+ Below are the preliminaries and terms of our experiments.
349
+
350
+ Test error and training NLL. We report test errors on clean test datasets and training NLLs on augmented training datasets in experiments, e.g., Fig. 5 and Fig. C.1. NLL is an appropriate metric for evaluating convergence on a training dataset because an NN optimizes NLL. In addition, it is the most widely used as a proper scoring rule indicating both accuracy and uncertainty. To represent predictive performance on a test dataset, we use a well-known metric: error. Although NLL can also serve the same purpose, results are consistent even when NLL is employed.
351
+
352
+ If an additional inductive bias or a learning technique improves the performance of an NN, this is either a method to help the NNs learn “strong representations”, or a method to “regularize” it.
353
+
354
+ An improved—i.e., lower—training NLL suggests that this bias or technique helps the NN learn strong representations. Conversely, a compromised training NLL indicates that the bias or technique regularizes the NN. Likewise, we say that “an NN overfits a training dataset” when a test error is compromised as the training NLL is improved.
355
+
356
+ Hessian max eigenvalue spectrum. Park & Kim (2021) proposed “Hessian max eigenvalue spectra”, a feasible method for visualizing Hessian eigenvalues of large-sized NNs for real-world problems. It calculates and gathers top- $k$ Hessian eigenvalues by using power iteration mini-batch wisely. Ghorbani et al. (2019) visualized the Hessian eigenvalue spectrum by using the Lanczos quadrature algorithm for full batch. However, this is not feasible for practical NNs because the algorithm requires a lot of memory and computing resources.
357
+
358
+ A good loss landscape is a flat and convex loss landscape. Hessian eigenvalues indicate the flatness and convexity of losses. The magnitude of Hessian eigenvalues shows sharpness, and the presence of negative Hessian eigenvalues shows non-convexity. Based on these insights, we introduce a negative max eigenvalue proportion (NEP, the lower the better) and an average of positive max eigenvalues (APE, the lower the better) to quantitatively measure the non-convexity and the sharpness, respectively. For a Hessian max eigenvalue spectrum $p ( \lambda )$ , NEP is the proportion of negative eigenvalues $\int _ { - \infty } ^ { 0 } p ( \lambda ) d \lambda$ , and APE is the expected value of positive eigenvalues $\textstyle { \int _ { 0 } ^ { \infty } \lambda p ( \lambda ) d \lambda } / { \int _ { 0 } ^ { \infty } p ( \lambda ) d \lambda }$ We use these metrics in Fig. C.5 and Fig. C.6.
359
+
360
+ Note that measuring loss landscapes and Hessian eigenvalues without considering a regularization on clean datasets would lead to incorrect results, since NN training optimizes $\ell _ { 2 }$ regularized NLL on augmented training datasets—not NLL on clean training datasets. We visualize loss landscapes and Hessian eigenvalues with respect to ${ } ^ { } \ell _ { 2 }$ regularized NLL loss” on “augmented training datasets”.
361
+
362
+ Fourier analysis of feature maps. We analyze feature maps in Fourier space to demonstrate that MSA is a low-pass filter as shown in Fig. 2, Fig. 8, and Fig. D.2. Fourier transform converts feature maps into frequency domain. We represent these converted feature maps on normalized frequency domain, so that the highest frequency components are at $f = \{ - \pi , + \pi \}$ , and the lowest frequency components are at $f = 0$ . We mainly report the amplitude ratio of high-frequency components and low-frequency components by using $\Delta$ log amplitude, the difference in log amplitude at $f = \pi$ and $f = 0$ . Yin et al. (2019) also analyzed the robustness of NNs from a Fourier perspective, but their research focused on input images—not feature maps—in Fourier spaces.
363
+
364
+ # B MSAS BEHAVE LIKE SPATIAL SMOOTHINGS
365
+
366
+ As mentioned in Section 1.1, spatial smoothings before subsampling layers help CNNs see better (Zhang, 2019; Park & Kim, 2021). Park & Kim (2021) showed that such improvement in performance is possible due to spatial ensembles of feature map points. To this end, they used the (Bayesian) ensemble average of predictions for proximate data points (Park et al., 2021), which exploits data uncertainty (i.e., a distribution of feature maps) as well as model uncertainty (i.e., a posterior probability distribution of NN weights):
367
+
368
+ $$
369
+ p ( z _ { j } | \pmb { x } _ { j } , \pmb { \mathcal { D } } ) \simeq \sum _ { i } \pi ( \pmb { x } _ { i } | \pmb { x } _ { j } ) p ( z _ { j } | \pmb { x } _ { i } , \pmb { w } _ { i } )
370
+ $$
371
+
372
+ where $\pi ( \pmb { x } _ { i } | \pmb { x } _ { j } )$ is the normalized importance weight of a feature map point $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ with respect to another feature map point $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { j } }$ , i.e., $\begin{array} { r } { \sum _ { i } \pi ( \pmb { x } _ { i } | \pmb { x } _ { j } ) = 1 } \end{array}$ . This importance is defined as the similarity between $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ and $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { j } }$ . $p ( \boldsymbol { z } _ { j } | \mathbf { x } _ { i } , \mathrm { \bar { { \boldsymbol { w } } } } _ { i } )$ and $p ( \boldsymbol { z } _ { j } | \mathbf { x } _ { j } , \mathcal { D } )$ stand for NN prediction and output predictive distribution, respectively. ${ \pmb w } _ { i }$ is the NN weight sample from the posterior $p ( \pmb { w } | \mathcal { D } )$ with respect to the training dataset $\mathcal { D }$ . Put shortly, Eq. (2) spatially complements a prediction with other predictions based on similarities between data points. For instance, a $2 \times 2$ box blur spatially ensembles four neighboring feature map points, each with $\%$ of the same importance.
373
+
374
+ We note that the formulations for self-attention and the ensemble averaging for proximate data points are identical. The Softmax term and $V$ in Eq. (1) exactly correspond to $\pi ( \pmb { x } _ { i } | \pmb { x } _ { j } )$ and $p ( \boldsymbol { z } _ { j } | \boldsymbol { x } _ { i } , \boldsymbol { w } _ { i } )$ in Eq. (2). The weight samples in Eq. (2) is correspond to the multi-heads of MSAs (See also (Hron et al., 2020)).
375
+
376
+ ![](images/93ffbf606beb389d8c7f5ff9f1eef2b93432ca79a752c145f31a0cab4d591e3d.jpg)
377
+ Figure C.1: The lower the training NLL, the lower the test error. “R” is ResNet and “RX” is ResNeXt. Left: In small data regimes, such as CIFAR-10 and CIFAR-100 (Fig. 5a), the cons of MSAs outweigh their pros; i.e., the non-convex losses disturb ViT optimization. Right: Large datasets convexify the loss functions. Therefore, the pros of MSAs outweigh their cons in large data regimes; i.e., MSAs help NNs learn strong representations by flattening the loss landscapes.
378
+
379
+ Likewise, the properties of spatial smoothing are the same as those of MSAs (Park & Kim, 2021): $\textcircled{1}$ Spatial smoothing improves the accuracy of CNNs. In addition, spatial smoothing predicts well-calibrated uncertainty. $\textcircled{2}$ Spatial smoothing is robust against MC dropout (which is equivalent to image occlusion), data corruption, and adversarial attacks, and particularly robust against highfrequency noise. $\textcircled{3}$ Spatial smoothing layers closer to the output layer significantly improves the predictive performance. In addition, concurrent works suggest that MSA blocks behave like a spatial smoothing. Wang et al. (2022) provided a proof that Softmax-normalized matrix is a low-pass filter, although this does not guarantee that MSA blocks will behave like low-pass filters. Yu et al. (2021b) demonstrated that the MSA layers of ViT can be replaced with average pooling layers.
380
+
381
+ Taking all these observations together, we provide an explanation of how MSAs work by addressing themselves as a general form of spatial smoothing or an implementation of ensemble averaging for proximate data points. Spatial smoothing improves performance in the following ways (Park & Kim, 2021): $\bullet$ Spatial smoothing helps in NN optimization by flattening the loss landscapes. Even a small $2 \times 2$ box blur filter significantly improves performance. $\textcircled { \times }$ Spatial smoothing is a low-pass filter. CNNs are vulnerable to high-frequency noises, but spatial smoothing improves the robustness against such noises by significantly reducing these noises. $\bullet$ Spatial smoothing is effective when applied at the end of a stage because it aggregates all transformed feature maps. This paper empirically shows that these mechanisms also apply to MSAs.
382
+
383
+ # C VITS FROM A LOSS LANDSCAPE PERSPECTIVE
384
+
385
+ This section provides further explanations of the analysis in Section 2.
386
+
387
+ The lower the NLL on the training dataset, the lower the error on the test dataset. Figure 5a demonstrates that low training NLLs result in low test errors on CIFAR-100. The same pattern can be observed on CIFAR-10 and ImageNet as shown in Fig. C.1.
388
+
389
+ In small data regimes, such as CIFAR-10 (Fig. C.1a) and CIFAR-100 (Fig. 5a), both the error and the ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ of ViTs are inferior to those of CNNs. This suggests that the cons of MSAs outweigh their pros. As discussed in Fig. 4, ViTs suffers from the non-convex losses, and these non-convex losses disturb ViT optimization.
390
+
391
+ In large data regimes, such as ImageNet (Fig. C.1b), both the error and the ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ of ViTs with local MSAs are superior to those of CNNs. Since large datasets convexify the loss functions as discussed in Fig. 4, the pros of MSAs outweigh their cons. Therefore, MSAs help NNs learn strong representations by flattening the loss landscapes.
392
+
393
+ Rigorous discussion on the regularization of CNN’s inductive bias. In Fig. 5a, we compare models of similar sizes, such as ResNet-50 and ViT-Ti. Through such comparison, we show that a weak inductive bias hinders NN training, and that inductive biases of CNNs—inductive bias of Convs and multi-stage architecture—help NNs learn strong representations. However, inductive biases of
394
+
395
+ ![](images/87ccf81fc7a522e4e2bd543ce48ae17a4f60e1b6551be8d5c8175b7b22c9f576.jpg)
396
+ Figure C.2: A small patch size does not guarantee better performance. We analyze ViTs with three embedded patch sizes: $2 \times 2$ , $4 \times 4$ , and $8 \times 8$ . Note that every MSA has a global receptive fields. Left: As expected, a large patch size harms the performance, but surprisingly, the same is observed from a small patch size. Right: A small patch size, or a weak inductive bias, produces negative eigenvalues. This is another evidence that a weak inductive bias hinders NN optimization. On the other hand, MSAs with a small patch size reduce the magnitude of eigenvalues because they ensemble a large number of feature map points. Performance is optimized when these two effects are balanced.
397
+
398
+ CNNs produce better test accuracy for the same training NLL, i.e., Convs somewhat regularize NNs. We analyze two comparable models in terms of ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ on CIFAR-100. The ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ of ResNet-18, a model smaller than ResNet-50, is 2.31 with an error of $2 2 . 0 \%$ . The ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ of ViT-S, a model larger than ViT-Ti, is 2.17 with an error of $3 0 . 4 \%$ . In summary, the inductive biases of CNNs improve accuracy for similar training NLLs.
399
+
400
+ Most of the improvements come from the multi-stage architecture, not the inductive bias of Convs. The ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ of the PiT-Ti, a multi-stage ViT-Ti, is 2.29 with an error of $2 4 . 1 \ \%$ . The accuracy of PiT is only 1.9 percent point lower than that of ResNet. In addition, the small receptive field also regularizes ViT. See Fig. 7.
401
+
402
+ ViT does not overfit a small training dataset even with a large number of epochs. Figure 5b shows that ViT does not overfit small training datasets, such as CIFAR. The same phenomenon can be observed in ViT training with a large number of epochs.
403
+
404
+ In Fig. C.3, we train ViT and ResNet for 75, 150, 300, 600, and 1200 epochs. Results show that both ${ \mathrm { N L L } } _ { \mathrm { t r a i n } }$ and error decrease as the number of epochs increases. The predictive performances of ViT are inferior to those of ResNet across all ranges of epochs.
405
+
406
+ A smaller patch size does not always imply better results. ViT splits image into multiple patches. The smaller the patch size, the greater the flexibility of expression and the weaker the inductive bias. By analyzing ViT with three patch sizes— $\cdot 2 \times 2$ , $4 \times 4$ , and $8 \times 8$ —we demonstrate once again that a weak inductive bias disturbs NN optimization.
407
+
408
+ ![](images/6cb7a1e5bc44a8945f1b63f798ffe3a294f5316dff8acee2593b8b3feacc70f3.jpg)
409
+ Figure C.3: A large number of epochs does not make ViT overfit the training dataset of CIFAR. Solid line is the predictive performance of ViT and dashed line is that of ResNet.
410
+
411
+ Figure C.2a shows the error on the test dataset and the NLL on the training dataset of CIFAR-100. As expected, a large patch size harms the performance on both datasets. Surprisingly, however, a small patch size also shows the same result. As such, appropriate patch sizes help ViT learn strong representations and do not regularize ViT.
412
+
413
+ The Hessian max eigenvalue spectra in Fig. C.2b explain this observation. Results reveal that a small patch size reduces the magnitude of Hessian eigenvalues but produces negative Hessian eigenvalues. In other words, the weak inductive bias makes loss landscapes flat yet non-convex. A large patch size suppresses negative eigenvalues. On the other hand, it not only limits the model expression but also sharpens loss landscapes. Performance is optimized when these two effects are balanced.
414
+
415
+ ![](images/82ffb7b1ecd72e21a3f1e178a4968a6210c2836b7728f64a9b02aab194a12e58.jpg)
416
+ (b) Negative and positive Hessian max eigenvalue spectra in early phase (left) and late phase (right) of training
417
+ Figure C.4: A multi-stage architecture (in PiT) and a local MSA (in Swin) also flatten the loss landscapes. Top: PiT has a flatter loss landscape than ViT near the optimum. Swin has an almost perfectly smooth parabolic loss landscape, which leads to better NN optimization. Bottom: A multistage architecture in PiT suppresses negative Hessian eigenvalues. A local MSA in Swin produces negative eigenvalues, but significantly reduces the magnitude of eigenvalues.
418
+
419
+ A multi-stage architecture in PiT and a local MSA in Swin also flatten loss landscapes. As explained in Fig. 1, an MSA smoothens loss landscapes. Similarly, a multi-stage architecture in PiT and local MSA in Swin also help NN learn strong representations by smoothing the loss landscapes.
420
+
421
+ Figure C.4 provides loss landscape visualizations and Hessian eigenvalue spectra of ResNet, ViT, PiT, and Swin. Figure C.4a visualizes the global geometry of the loss functions. The loss landscapes of PiT is flatter than that of ViT near the optimum. Since Swin has more parameters than ViT and PiT, $\ell _ { 2 }$ regularization determines the loss landscapes. All the loss surfaces of ViTs are smoother than that of ResNet. Figure C.4b shows the local geometry of the loss functions by using Hessian eigenvalues. In the early phase of training, a multi-stage architecture in PiT helps training by suppressing negative Hessian eigenvalues. A local MSA in Swin produces negative eigenvalues, but significantly reduces the magnitude of eigenvalues. Moreover, the magnitude of Swin’s Hessian eigenvalue does not significantly increases in the late phase of learning.
422
+
423
+ A lack of heads may lead to non-convex losses. Neural tangent kernel (NTK) (Jacot et al., 2018) theoretically implies that the loss landscape of a ViT is convex and flat when the number of heads or the number of embedding dimensions per head goes to infinity (Hron et al., 2020; Liu et al., 2020). In particular, Liu et al. (2020) suggests that $| | \bar { H } | | \simeq \mathcal { O } ( ^ { 1 / \sqrt { m } } )$ where $\left| \left| H \right| \right|$ is the Hessian spectral norm and $m$ is the number of heads or the number of embedding dimensions per head. Therefore, in practical situations, insufficient heads may cause non-convex and sharp losses.
424
+
425
+ Fig. C.5 empirically show that a lot of heads in MSA convexify and flatten the loss landscapes (cf. Michel et al. (2019)). In this experiment, we use NEP and APE to measure the non-convexity and the sharpness as introduced in Appendix A.2. Results show that both NEP and APE decrease as the number of heads increases. Likewise, Fig. C.6 shows that high embedding dimensions per head also convexify and flatten losses. The exponents of APE are $- 0 . 5 6 2$ for the number of heads and $- 0 . 7 9 6$ for the number of embedding dimensions, which are in close agreement with the value predicted by the theory of $- 1 / 2$ .
426
+
427
+ Large models have a flat loss in the early phase of training. Figure C.7 analyzes the loss landscapes of large models, such as ResNet-101 and ViT-S. As shown in Fig. C.7a, large models explore low NLLs. This can be a surprising because loss landscapes of large models are globally sharp as shown in Fig. C.7b.
428
+
429
+ ![](images/9732ac64f786ab7745d3818d082120d30095b8c5d27683e5738d941b50d92f1d.jpg)
430
+ Figure C.5: Multi-heads convexify and flatten loss landscapes. Left: We use negative max eigenvalue proportion (NEP) and average of positive max eigenvalues (APE) to quantify, respectively, the non-convexity and sharpness of loss landscapes. As the number of heads increases, loss landscapes become more convex and flatter. Right: Hessian max eigenvalue spectra also show that multi-head suppress negative eigenvalues and reduce the magnitude of eigenvalues.
431
+
432
+ ![](images/a3a69b33a3c9b21002fefa8d96a02ab12d13ff1ad829ad59ec902cb2f4185492.jpg)
433
+ Figure C.6: High embedding dimensions per head convexify and flatten the loss landscape. Left: As the number of embedding dimensions per head increases, loss landscapes become more convex and flat. Right: Hessian max eigenvalue spectra also show that high embedding dimensions suppress negative eigenvalues and reduce the magnitude of eigenvalues as shown in Fig. C.5.
434
+
435
+ The Hessian eigenvalue spectra in Fig. C.7c provide a solution to the problem: Hessian eigenvalues of large models are smaller than those of small models in the early phase of training. This indicates that large models have flat loss functions locally.
436
+
437
+ # D VITS FROM A FEATURE MAP PERSPECTIVE
438
+
439
+ This section provides further explanations of the analysis in Section 3 and Section 4.1.
440
+
441
+ MSAs in PiT and Swin also ensemble feature maps. In Fig. 9, we show that MSAs in ViT reduce feature map variances. The same pattern can be observed in PiT and Swin. Figure D.1 demonstrates that MSAs in PiT and Swin also reduce the feature map variances, suggesting that they also ensemble feature maps. One exception is the $3 ^ { \mathrm { r d } }$ stage of Swin. MSAs suppresses the increase in variance at the beginning of the stage, but not at the end of the stage.
442
+
443
+ MSAs in PiT and Swin are also low-pass filters. As discussed in Fig. 8, MSAs in ViTs are lowpass filters, while MLPs in ViT and Convs in ResNet are high-pass filters. Likewise, we demonstrate that MSAs in PiT and Swin are also low-pass filters.
444
+
445
+ ![](images/5902ccf65d72724f26ef90686c418acad3538f87a6e0b145c7ad9585ae5d6f37.jpg)
446
+ (c) Negative and positive Hessian max eigenvalue spectra in early phase (left) and late phase (right) of training
447
+ Figure C.7: Loss landscapes of large models. ResNet-50 and ResNet-101 are comparable to ViT-Ti and ViT-S, respectively. Top: Large models explore low NLLs. Middle: Loss landscape visualizations show that the global geometry of large models is sharp. Bottom: The Hessian eigenvalues of large models are smaller than those of small models. This suggests that large models have a flat local geometry in the early phase of training, and that this flat loss helps NNs learn strong representations. In the late phase of training, large ViTs have flat minima while large ResNet has a sharp minimum.
448
+
449
+ ![](images/d86c550ce0913f71d8a8154d05b9a07fd809bcf487023dee02ca30795ff9554a.jpg)
450
+ Figure D.1: MSAs in PiT and Swin also reduce feature map variance except in $3 ^ { \mathrm { r d } }$ stage of Swin. White, gray, and blue areas are Conv/MLP, MSA, and subsampling layers, respectively.
451
+
452
+ Figure D.2 shows the relative log amplitude of Fourier transformed feature maps. As in the case of ViT, MSAs in PiT and Swin generally decrease the amplitude of high-frequency signals; in contrast, MLPs increases the amplitude.
453
+
454
+ Multi-stage ViTs have a block structures. Feature map similarities of CNNs shows a block structure (Nguyen et al., 2021). As Raghu et al. (2021) pointed out, ViTs have a uniform representations across all layers. By investigating multi-stage ViTs, we demonstrate that subsampling layers create a characteristic block structure of the representation. See Fig. D.3.
455
+
456
+ Convs at the beginning of a stage and MSAs at the end of a stage play an important role. Figure D.4 shows the results of a lesion study for ResNet and ViTs. In this experiment, we remove one $3 \times 3$ Conv layer from the bottleneck block of a ResNet, and one MSA or MLP block from ViTs. Consistent results can be observed for all models: Removing Convs at the beginning of a stage and MSAs at the end of a stage significantly harm accuracy. As a result, the accuracy varies periodically.
457
+
458
+ # E EXTENDED INFORMATION OF ALTERNET
459
+
460
+ This section provides further informations on AlterNet.
461
+
462
+ Detailed architecture of AlterNet. Section 4 introduces AlterNet to harmonize Convs with MSAs. Since most MSAs take pre-activation arrangements, pre-activation ResNet is used as a baseline for consistency. We add one CNN block to the last stage of ResNet to make the number of blocks even. A local MSA with relative positional encoding from Swin is used for AlterNet. However, for simplicity of implementation, we do not implement detailed techniques, such as a cyclic shift and layer-specific initialization. For CIFAR, the patch size of the MSA is $1 \times 1$ and the window size is $4 \times 4$ . If all Conv blocks are alternately replaced with MSA, AlterNet becomes a Swin-like model.
463
+
464
+ In order to achieve better performance, NNs should strongly aggregate feature maps at the end of models as discussed in Section 3 and Section 4. To this end, AlterNet use 3, 6, 12, 24 heads for MSAs in each stage.
465
+
466
+ ![](images/64228730558ff934403c347829c23659307e449184eee46d3f4732e1fedd77b8.jpg)
467
+ Figure D.2: MSAs in PiT and Swin also reduce high-frequency signals. Left: $\Delta$ log amplitude of Fourier transformed feature map. We only provide the diagonal components. Right: The highfrequency $( 1 . 0 \pi ) \Delta$ log amplitude. White, gray, and blue areas are Conv/MLP, MSA, and subsampling layers, respectively.
468
+
469
+ ![](images/19c5b84e65812066b89f1e039ee1c68288ef975b1336b36db577be3a4b4dd919.jpg)
470
+ Figure D.3: Multi-stage ViTs have block structures in representational similarities. Block structures can be observed in all multi-stage NNs, namely, ResNet, PiT, and Swin. “E” is the stem/embedding and “P” is the pooling (subsampling) layer.
471
+
472
+ ![](images/9b725c23e2849279a552b75de075b4fb40c3a072f09bb055f3b8d90036309f2b.jpg)
473
+ Figure D.4: Lesion study shows that Convs at the beginning of a stage and MSAs at the end of a stage are important for prediction. We measure the decrease in accuracy after removing one unit from the trained model. In this experiment, we can observe that accuracy changes periodically. The white, gray, and blue areas are Convs/MLPs, MSAs, and subsampling layers, respectively.
474
+
475
+ ![](images/1ec915118c57a908eff1017a37f081e7827cbe58d3a358be887bf9741b9e38e9.jpg)
476
+ Figure D.5: Detailed architecture of Alter-ResNet-50 for ImageNet-1K. The white, gray, and blue blocks each represent Convs, MSAs, and subsampling blocks. This model alternately replaces Conv blocks with MSA blocks from the end of a stage. Following Swin, MSAs in stages 1 to 4 use 3, 6, 12, and 24 heads, respectively. We use 6 MSA blocks for ImageNet since large amounts of data alleviates the drawbacks of MSA. See Fig. 11 for comparison with the model for CIFAR-100, which uses 4 MSA blocks.
477
+
478
+ ![](images/ef46a16f7225e044360e6cbe12dfd0bd2fe992801d4553c1d8817ca6e27974e0.jpg)
479
+ Figure F.1: Distinctive properties of strong data augmentation. “Aug” stands for strong data augmentation. Left: Strong data augmentation makes predictions underconfident on CIFAR-100. The same phenomenon can be observed on ImageNet-1K. Right: Strong data augmentation significantly reduces the magnitude of Hessian max eigenvalues. This means that the data augmentation helps NNs converge to better optima by flattening the loss landscapes. On the other hand, strong data augmentation produces a lot of negative Hessian eigenvalues, i.e., it makes the losses non-convex.
480
+
481
+ The computational costs of Conv blocks and MSA blocks are almost identical. The training throughput of Alter-ResNet-50 is 473 image/sec on CIFAR-100, which is $20 \%$ faster than that of pre-activation ResNet-50.
482
+
483
+ The optimal number of MSAs depends on the model and dataset, so we empirically determine the number of MSAs as shown in Fig. 12a. A large dataset allows a large number of MSAs. For ImageNet, we use 6 MSAs as shown in Fig. D.5, because a large datasets alleviates the shortcomings of MSAs.
484
+
485
+ ![](images/0ea5cf8f47cb1c9c515ea256649c2bbd588e8513e33e24b935aa16b884c446b4.jpg)
486
+ Figure E.1: MSA with the appropriate build-up rules significantly improves ResNet on ImageNet. Robustness is mean accuracy on ImageNet-C. “RX” is ResNeXt.
487
+
488
+ MSAs improve the performance of CNNs on ImageNet. Since MSAs complement Convs, MSAs improve the predictive performance of CNNs when appropriate build-up rules are applied as shown in Section 4.1. Figure E.1 illustrates the accuracy and robustness—mean accuracy on ImageNet-C—of CNNs and ViTs on ImageNet-1K. Since ImageNet is a large dataset, a number of ViTs outperform CNNs. MSAs with the appropriate build-up rules significantly improves ResNet, and the predictive performance of AlterNet is on par with that of Swin in terms of accuracy without heavy modifications, e.g., the shifted windowing scheme (Liu et al., 2021). AlterNet is easy-to-implement and has a strong potential for future improvements. In addition, the build-up rules not only improve ResNet, but also other NNs, e.g., vanilla post-activation ResNet and ResNeXt; but we do not report this observation in order to keep the visualization simple.
489
+
490
+ # F DISTINCTIVE PROPERTIES OF DATA AUGMENTATION
491
+
492
+ This section empirically demonstrates that NN training with data augmentation is different from training on large datasets. We compare DeiT-style strong data augmentation with weak data augmentation, i.e., resize and crop. In this section, “a result without data augmentation” stands for “a result only with weak data augmentation”.
493
+
494
+ # F.1 DATA AUGMENTATION CAN HARM UNCERTAINTY CALIBRATION
495
+
496
+ Figure F.1a shows a reliability diagram of NNs with and without strong augmentation on CIFAR-100. Here, both ResNet and ViT without data augmentation (i.e., only with weak data augmentation) predict overconfident results. We show that strong data augmentation makes the predictive results underconfident (cf. Wen et al. (2021)). These are unexpected results because the predictions without data augmentation on large datasets, such as ImageNet, are not under-confident. A detailed investigation remains for future work.
497
+
498
+ F.2 DATA AUGMENTATION REDUCES THE MAGNITUDE OF HESSIAN EIGENVALUES
499
+
500
+ How does data augmentation help an MSA avoid overfitting on a training dataset and achieve better accuracy on a test dataset? Figure F.1b shows the Hessian max eigenvalue spectrum of NNs with and without strong data augmentation. First of all, strong data augmentation reduces the magnitude of Hessian eigenvalues, i.e., data augmentation flattens the loss landscapes in the early phase of training. These flat losses leads to better generalization. On the other hand, strong data augmentation produces a lot of negative Hessian eigenvalues, i.e., data augmentation makes the losses non-convex. This prevents NNs from converging to low losses on training datasets. It is clearly different from the effects of large datasets discussed in Fig. 4—large datasets convexify the loss landscapes. A detailed investigation remains for future work.
md/dev/DHyHRBwJUTN/DHyHRBwJUTN.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/EbMuimAbPbs/EbMuimAbPbs.md ADDED
@@ -0,0 +1,442 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Flamingo: a Visual Language Model for Few-Shot Learning
2
+
3
+ Jean-Baptiste Alayrac\*,‡ Jeff Donahue\* Pauline Luc\* Antoine Miech\*
4
+
5
+ Iain Barr† Yana Hasson† Karel Lenc† Arthur Mensch† Katie Millican†
6
+
7
+ Malcolm Reynolds† Roman Ring† Eliza Rutherford† Serkan Cabi Tengda Han
8
+
9
+ Zhitao Gong Sina Samangooei Marianne Monteiro Jacob Menick
10
+
11
+ Sebastian Borgeaud Andrew Brock Aida Nematzadeh Sahand Sharifzadeh
12
+
13
+ Mikolaj Binkowski Ricardo Barreira Oriol Vinyals Andrew Zisserman
14
+
15
+ Karen Simonyan\*,‡
16
+
17
+ \* Equal contributions, ordered alphabetically, † Equal contributions, ordered alphabetically, ‡ Equal senior contributions
18
+
19
+ # DeepMind
20
+
21
+ # Abstract
22
+
23
+ Building models that can be rapidly adapted to novel tasks using only a handful of annotated examples is an open challenge for multimodal machine learning research. We introduce Flamingo, a family of Visual Language Models (VLM) with this ability. We propose key architectural innovations to: (i) bridge powerful pretrained vision-only and language-only models, (ii) handle sequences of arbitrarily interleaved visual and textual data, and (iii) seamlessly ingest images or videos as inputs. Thanks to their flexibility, Flamingo models can be trained on large-scale multimodal web corpora containing arbitrarily interleaved text and images, which is key to endow them with in-context few-shot learning capabilities. We perform a thorough evaluation of our models, exploring and measuring their ability to rapidly adapt to a variety of image and video tasks. These include open-ended tasks such as visual question-answering, where the model is prompted with a question which it has to answer; captioning tasks, which evaluate the ability to describe a scene or an event; and close-ended tasks such as multiple-choice visual question-answering. For tasks lying anywhere on this spectrum, a single Flamingo model can achieve a new state of the art with few-shot learning, simply by prompting the model with task-specific examples. On numerous benchmarks, Flamingo outperforms models fine-tuned on thousands of times more task-specific data.
24
+
25
+ ![](images/500fea4496e438926bc70a717688f49aef7e0ec0799bbdcc53a49ceb3646c261.jpg)
26
+ Figure 1: Selected examples of inputs and outputs obtained from Flamingo-80B. Flamingo can rapidly adapt to various image/video understanding tasks with few-shot prompting (top). Out of the box, Flamingo is also capable of multi-image visual dialogue (bottom). More examples in Appendix C.
27
+
28
+ ![](images/67d3c4f598fa5f712a5a0d97a635ffbeefb2449fa69c58e60a16d12063b978e9.jpg)
29
+ Figure 2: Flamingo results overview. Left: Our largest model, dubbed Flamingo, outperforms state-of-the-art fine-tuned models on 6 of the 16 tasks we consider with no fine-tuning. For the 9 tasks with published few-shot results, Flamingo sets the new few-shot state of the art. Note: We omit RareAct, our 16th benchmark, as it is a zero-shot benchmark with no available fine-tuned results to compare to. Right: Flamingo performance improves with model size and number of shots.
30
+
31
+ # 1 Introduction
32
+
33
+ One key aspect of intelligence is the ability to quickly learn to perform a new task given a short instruction [33, 70]. While initial progress has been made towards a similar capability in computer vision, the most widely used paradigm still consists of first pretraining on a large amount of supervised data, before fine-tuning the model on the task of interest [66, 118, 143]. However, successful finetuning often requires many thousands of annotated data points. In addition, it often requires careful per-task hyperparameter tuning and is also resource intensive. Recently, multimodal vision-language models trained with a contrastive objective [50, 85] have enabled zero-shot adaptation to novel tasks, without the need for fine-tuning. However, because these models simply provide a similarity score between a text and an image, they can only address limited use cases such as classification, where a finite set of outcomes is provided beforehand. They crucially lack the ability to generate language, which makes them less suitable to more open-ended tasks such as captioning or visual questionanswering. Others have explored visually-conditioned language generation [17, 114, 119, 124, 132] but have not yet shown good performance in low-data regimes.
34
+
35
+ We introduce Flamingo, a Visual Language Model (VLM) that sets a new state of the art in few-shot learning on a wide range of open-ended vision and language tasks, simply by being prompted with a few input/output examples, as illustrated in Figure 1. Of the 16 tasks we consider, Flamingo also surpasses the fine-tuned state of the art on 6 tasks, despite using orders of magnitude less task-specific training data (see Figure 2). To achieve this, Flamingo takes inspiration from recent work on large language models (LMs) which are good few-shot learners [11, 18, 42, 86]. A single large LM can achieve strong performance on many tasks using only its text interface: a few examples of a task are provided to the model as a prompt, along with a query input, and the model generates a continuation to produce a predicted output for that query. We show that the same can be done for image and video understanding tasks such as classification, captioning, or question-answering: these can be cast as text prediction problems with visual input conditioning. The difference from a LM is that the model must be able to ingest a multimodal prompt containing images and/or videos interleaved with text. Flamingo models have this capability—they are visually-conditioned autoregressive text generation models able to ingest a sequence of text tokens interleaved with images and/or videos, and produce text as output. Flamingo models leverage two complementary pre-trained and frozen models: a vision model which can “perceive” visual scenes and a large LM which performs a basic form of reasoning. Novel architecture components are added in between these models to connect them in a way that preserves the knowledge they have accumulated during computationally intensive pre-training. Flamingo models are also able to ingest high-resolution images or videos thanks to a Perceiver-based [48] architecture that can produce a small fixed number of visual tokens per image/video, given a large and variable number of visual input features.
36
+
37
+ A crucial aspect for the performance of large LMs is that they are trained on a large amount of text data. This training provides general-purpose generation capabilities that allows these LMs to perform well when prompted with task examples. Similarly, we demonstrate that the way we train the Flamingo models is crucial for their final performance. They are trained on a carefully chosen mixture of complementary large-scale multimodal data coming only from the web, without using any data annotated for machine learning purposes. After this training, a Flamingo model can be directly adapted to vision tasks via simple few-shot learning without any task-specific tuning.
38
+
39
+ ![](images/f1607ad89c4ea7b40f8723498b439571ecfb75b7d7f622105db2d86667955992.jpg)
40
+ Figure 3: Flamingo architecture overview. Flamingo is a family of visual language models (VLMs) that take as input visual data interleaved with text and produce free-form text as output.
41
+
42
+ Contributions. In summary, our contributions are the following: (i) We introduce the Flamingo family of VLMs which can perform various multimodal tasks (such as captioning, visual dialogue, or visual question-answering) from only a few input/output examples. Thanks to architectural innovations, the Flamingo models can efficiently accept arbitrarily interleaved visual data and text as input and generate text in an open-ended manner. (ii) We quantitatively evaluate how Flamingo models can be adapted to various tasks via few-shot learning. We notably reserve a large set of heldout benchmarks which have not been used for validation of any design decisions or hyperparameters of the approach. We use these to estimate unbiased few-shot performance. (iii) Flamingo sets a new state of the art in few-shot learning on a wide array of 16 multimodal language and image/video understanding tasks. On 6 of these 16 tasks, Flamingo also outperforms the fine-tuned state of the art despite using only 32 task-specific examples, around 1000 times less task-specific training data than the current state of the art. With a larger annotation budget, Flamingo can also be effectively fine-tuned to set a new state of the art on five additional challenging benchmarks: VQAv2, VATEX, VizWiz, MSRVTTQA, and HatefulMemes.
43
+
44
+ # 2 Approach
45
+
46
+ This section describes Flamingo: a visual language model that accepts text interleaved with images/videos as input and outputs free-form text. The key architectural components shown in Figure 3 are chosen to leverage pretrained vision and language models and bridge them effectively. First, the Perceiver Resampler (Section 2.1) receives spatio-temporal features from the Vision Encoder (obtained from either an image or a video) and outputs a fixed number of visual tokens. Second, these visual tokens are used to condition the frozen LM using freshly initialised cross-attention layers (Section 2.2) that are interleaved between the pretrained LM layers. These new layers offer an expressive way for the LM to incorporate visual information for the next-token prediction task. Flamingo models the likelihood of text $y$ conditioned on interleaved images and videos $x$ as follows:
47
+
48
+ $$
49
+ p ( \boldsymbol y | \boldsymbol x ) = \prod _ { \ell = 1 } ^ { L } p ( \boldsymbol y _ { \ell } | \boldsymbol y _ { \angle \ell } , \boldsymbol x _ { \le \ell } ) ,
50
+ $$
51
+
52
+ where $y _ { \ell }$ is the $\ell$ -th language token of the input text, $y _ { < \ell }$ is the set of preceding tokens, $x _ { \le \ell }$ is the set of images/videos preceding token $y _ { \ell }$ in the interleaved sequence and $p$ is parametrized by a Flamingo model. The ability to handle interleaved text and visual sequences (Section 2.3) makes it natural to use Flamingo models for in-context few-shot learning, analogously to GPT-3 with few-shot text prompting. The model is trained on a diverse mixture of datasets as described in Section 2.4.
53
+
54
+ ![](images/88258190e789163c53cdf24613ff85d84b6075a3d7a575194ef67f24043af676.jpg)
55
+ Figure 4: GATED XATTN-DENSE layers. To condition the LM on visual inputs, we insert new cross-attention layers between existing pretrained and frozen LM layers. The keys and values in these layers are obtained from the vision features while the queries are derived from the language inputs. They are followed by dense feed-forward layers. These layers are gated so that the LM is kept intact at initialization for improved stability and performance.
56
+
57
+ # 2.1 Visual processing and the Perceiver Resampler
58
+
59
+ Vision Encoder: from pixels to features. Our vision encoder is a pretrained and frozen NormalizerFree ResNet (NFNet) [10] – we use the F6 model. We pretrain the vision encoder using a contrastive objective on our datasets of image and text pairs, using the two-term contrastive loss from Radford et al. [85]. We use the output of the final stage, a 2D spatial grid of features that is flattened to a 1D sequence. For video inputs, frames are sampled at 1 FPS and encoded independently to obtain a 3D spatio-temporal grid of features to which learned temporal embeddings are added. Features are then flattened to 1D before being fed to the Perceiver Resampler. More details on the contrastive model training and performance are given in Appendix B.1.3 and Appendix B.3.2, respectively.
60
+
61
+ Perceiver Resampler: from varying-size large feature maps to few visual tokens. This module connects the vision encoder to the frozen language model as shown in Figure 3. It takes as input a variable number of image or video features from the vision encoder and produces a fixed number of visual outputs (64), reducing the computational complexity of the vision-text cross-attention. Similar to Perceiver [48] and DETR [13], we learn a predefined number of latent input queries which are fed to a Transformer and cross-attend to the visual features. We show in our ablation studies (Section 3.3) that using such a vision-language resampler module outperforms a plain Transformer and an MLP. We provide an illustration, more architectural details, and pseudo-code in Appendix A.1.1.
62
+
63
+ # 2.2 Conditioning frozen language models on visual representations
64
+
65
+ Text generation is performed by a Transformer decoder, conditioned on the visual representations produced by the Perceiver Resampler. We interleave pretrained and frozen text-only LM blocks with blocks trained from scratch that cross-attend to the visual output from the Perceiver Resampler.
66
+
67
+ Interleaving new GATED XATTN-DENSE layers within a frozen pretrained LM. We freeze the pretrained LM blocks, and insert gated cross-attention dense blocks (Figure 4) between the original layers, trained from scratch. To ensure that at initialization, the conditioned model yields the same results as the original language model, we use a tanh-gating mechanism [41]. This multiplies the output of a newly added layer by $\operatorname { t a n h } ( \alpha )$ before adding it to the input representation from the residual connection, where $\alpha$ is a layer-specific learnable scalar initialized to 0 [4]. Thus, at initialization, the model output matches that of the pretrained LM, improving training stability and final performance. In our ablation studies (Section 3.3), we compare the proposed GATED XATTN-DENSE layers against recent alternatives [22, 68] and explore the effect of how frequently these additional layers are inserted to trade off between efficiency and expressivity. See Appendix A.1.2 for more details.
68
+
69
+ Varying model sizes. We perform experiments across three models sizes, building on the 1.4B, 7B, and 70B parameter Chinchilla models [42]; calling them respectively Flamingo-3B, Flamingo-9B and
70
+
71
+ Flamingo-80B. For brevity, we refer to the last as Flamingo throughout the paper. While increasing the parameter count of the frozen LM and the trainable vision-text GATED XATTN-DENSE modules, we maintain a fixed-size frozen vision encoder and trainable Perceiver Resampler across the different models (small relative to the full model size). See Appendix B.1.1 for further details.
72
+
73
+ # 2.3 Multi-visual input support: per-image/video attention masking
74
+
75
+ The image-causal modelling introduced in Equation (1) is obtained by masking the full text-to-image cross-attention matrix, limiting which visual tokens the model sees at each text token. At a given text token, the model attends to the visual tokens of the image that appeared just before it in the interleaved sequence, rather than to all previous images (formalized and illustrated in Appendix A.1.3). Though the model only directly attends to a single image at a time, the dependency on all previous images remains via self-attention in the LM. This single-image cross-attention scheme importantly allows the model to seamlessly generalise to any number of visual inputs, regardless of how many are used during training. In particular, we use only up to 5 images per sequence when training on our interleaved datasets, yet our model is able to benefit from sequences of up to 32 pairs (or “shots”) of images/videos and corresponding texts during evaluation. We show in Section 3.3 that this scheme is more effective than allowing the model to cross-attend to all previous images directly.
76
+
77
+ # 2.4 Training on a mixture of vision and language datasets
78
+
79
+ We train the Flamingo models on a mixture of three kinds of datasets, all scraped from the web: an interleaved image and text dataset derived from webpages, image-text pairs, and video-text pairs.
80
+
81
+ M3W: Interleaved image and text dataset. The few-shot capabilities of Flamingo models rely on training on interleaved text and image data. For this purpose, we collect the MultiModal MassiveWeb (M3W) dataset. We extract both text and images from the HTML of approximately 43 million webpages, determining the positions of images relative to the text based on the relative positions of the text and image elements in the Document Object Model (DOM). An example is then constructed by inserting <image> tags in plain text at the locations of the images on the page, and inserting a special $\mathtt { < E O C > }$ (end of chunk) token (added to the vocabulary and learnt) prior to any image and at the end of the document. From each document, we sample a random subsequence of $L = 2 5 6$ tokens and take up to the first $N = 5$ images included in the sampled sequence. Further images are discarded in order to save compute. More details are provided in Appendix A.3.
82
+
83
+ Pairs of image/video and text. For our image and text pairs we first leverage the ALIGN [50] dataset, composed of 1.8 billion images paired with alt-text. To complement this dataset, we collect our own dataset of image and text pairs targeting better quality and longer descriptions: LTIP (Long Text & Image Pairs) which consists of 312 million image and text pairs. We also collect a similar dataset but with videos instead of still images: VTP (Video & Text Pairs) consists of 27 million short videos (approximately 22 seconds on average) paired with sentence descriptions. We align the syntax of paired datasets with the syntax of M3W by prepending <image> and appending $\mathtt { < E O C > }$ to each training caption (see Appendix A.3.3 for details).
84
+
85
+ Multi-objective training and optimisation strategy. We train our models by minimizing a weighted sum of per-dataset expected negative log-likelihoods of text, given the visual inputs:
86
+
87
+ $$
88
+ \sum _ { m = 1 } ^ { M } \lambda _ { m } \cdot \mathbb { E } _ { ( x , y ) \sim \mathcal { D } _ { m } } \left[ - \sum _ { \ell = 1 } ^ { L } \log p ( y _ { \ell } | y _ { < \ell } , x _ { \le \ell } ) \right] ,
89
+ $$
90
+
91
+ where $\mathcal { D } _ { m }$ and $\lambda _ { m }$ are the $m$ -th dataset and its weighting, respectively. Tuning the per-dataset weights $\lambda _ { m }$ is key to performance. We accumulate gradients over all datasets, which we found outperforms a “round-robin” approach [17]. We provide further training details and ablations in Appendix B.1.2.
92
+
93
+ # 2.5 Task adaptation with few-shot in-context learning
94
+
95
+ Once Flamingo is trained, we use it to tackle a visual task by conditioning it on a multimodal interleaved prompt. We evaluate the ability of our models to rapidly adapt to new tasks using incontext learning, analogously to GPT-3 [11], by interleaving support example pairs in the form of $( i m a g e , t e x t )$ or (??????????, ????????), followed by the query visual input, to build a prompt (details in
96
+
97
+ Table 1: Comparison to the state of the art. A single Flamingo model reaches the state of the art on a wide array of image (I) and video (V) understanding tasks with few-shot learning, significantly outperforming previous best zero- and few-shot methods with as few as four examples. More importantly, using only 32 examples and without adapting any model weights, Flamingo outperforms the current best methods – fine-tuned on thousands of annotated examples – on seven tasks. Best few-shot numbers are in bold, best numbers overall are underlined.
98
+
99
+ <table><tr><td>Method</td><td></td><td>FTShot</td><td> OAAYA</td><td> ZAAO</td><td> Cco</td><td>(A) VOAASS</td><td>VA XIA</td><td>() ZIMZ</td><td>T3</td><td>MA ITLTTI</td><td>(A)VOA!</td><td>J oo</td><td>JS TAIY</td><td>( [PiI</td><td>[T vY</td><td></td><td> VOAXAN</td><td>R eeeeY</td></tr><tr><td rowspan="4">Zero/Few shot SOTA</td><td rowspan="4">X</td><td rowspan="4"></td><td></td><td></td><td>[124]</td><td>[58]</td><td></td><td></td><td></td><td>[58]</td><td>[135]</td><td></td><td></td><td>[79]</td><td></td><td></td><td> grrreieee</td><td></td></tr><tr><td></td><td>[34]</td><td>[114]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>[143]</td><td></td><td></td><td></td><td></td><td></td><td>[85]</td></tr><tr><td></td><td>43.3</td><td>38.2</td><td>32.2</td><td>35.2</td><td>=</td><td>-</td><td></td><td>19.2 0</td><td>12.2 0</td><td>-</td><td>39.4</td><td>11.6 0</td><td>-</td><td></td><td>[85] 66.1 (0)</td><td>40.7</td></tr><tr><td>x)</td><td>(16)</td><td>(4) 49.2</td><td>(0)</td><td>0 27.5</td><td>40.1</td><td></td><td></td><td></td><td></td><td></td><td>0</td><td></td><td></td><td></td><td></td><td></td><td>0</td></tr><tr><td rowspan="4">Flamingo-3B</td><td></td><td>0</td><td>41.2</td><td></td><td>73.0</td><td></td><td></td><td>28.9</td><td>60.6</td><td>11.0</td><td>32.7</td><td>55.8 64.6</td><td>39.6</td><td>46.1</td><td>30.1 32.7</td><td>21.3 22.4</td><td>53.7 53.6</td><td>58.4</td></tr><tr><td>X X</td><td>4 32</td><td>43.3</td><td>53.2 57.1</td><td>85.0 99.0</td><td>33.0</td><td>50.0 59.2</td><td>34.0</td><td>72.0 71.2</td><td>14.9 25.6</td><td>35.7 37.7</td><td>76.7</td><td>41.3 41.6</td><td>47.3</td><td></td><td></td><td></td><td>1</td></tr><tr><td>X</td><td></td><td>45.9 44.7</td><td>51.8</td><td>79.4</td><td>42.6 30.2</td><td>39.5</td><td>45.5 28.8</td><td>61.5</td><td>13.7</td><td>35.2</td><td>55.0</td><td>41.8</td><td>47.3 48.0</td><td>30.6 31.8</td><td>26.1 23.0</td><td>56.3 57.0</td><td>57.9 -</td></tr><tr><td>X</td><td>0 4</td><td>49.3</td><td>56.3</td><td>93.1</td><td>36.2</td><td>51.7</td><td>34.9</td><td>72.6</td><td>18.2</td><td>37.7</td><td>70.8</td><td>42.8</td><td>50.4</td><td>33.6</td><td>24.7</td><td>62.7</td><td>-</td></tr><tr><td rowspan="3">Flamingo-9B</td><td></td><td></td><td>51.0</td><td>60.4</td><td>106.3</td><td>47.2</td><td>57.4</td><td>44.0</td><td>72.8</td><td>29.4</td><td>40.7</td><td>77.3</td><td>41.2</td><td>50.4</td><td>32.6</td><td>28.4</td><td>63.5</td><td>-</td></tr><tr><td>X</td><td>32 0</td><td>50.6</td><td>56.3</td><td>84.3</td><td>35.6</td><td>46.7</td><td>31.6</td><td>67.2</td><td>17.4</td><td>40.7</td><td>60.1</td><td>39.7</td><td>52.0</td><td>35.0</td><td>26.7</td><td>46.4</td><td>60.8</td></tr><tr><td>美</td><td>4</td><td>57.4</td><td>63.1</td><td>103.2 41.7</td><td>56.0</td><td></td><td>39.6</td><td>75.1</td><td>23.9</td><td>44.1</td><td>74.5</td><td>42.4</td><td>55.6</td><td>36.5</td><td>30.8</td><td>68.6</td><td>-</td></tr><tr><td rowspan="3">Flamingo</td><td>X</td><td>32</td><td>57.8</td><td>67.6</td><td>113.8</td><td>52.3</td><td>65.1</td><td>49.8</td><td>75.4</td><td>31.0</td><td>45.3</td><td>86.8</td><td>42.2</td><td>55.6</td><td>37.9</td><td>33.5</td><td>70.0</td><td>-</td></tr><tr><td></td><td></td><td>54.4</td><td>80.2</td><td>143.3</td><td>47.9</td><td>76.3</td><td>57.2</td><td>67.4 [150]</td><td>46.8</td><td>35.4 [135]</td><td>138.7 [132]</td><td>36.7</td><td>75.2</td><td>54.7</td><td>25.2</td><td>79.1</td><td></td></tr><tr><td>√</td><td>(X)</td><td>[34] (10K)</td><td>[140] (444K)</td><td>[124] [28] (500K) (27K)</td><td>[153] (500K)</td><td></td><td>[65] (20K)</td><td>(30K)</td><td>[51] (130K)</td><td>(6K)</td><td>(10K)</td><td>[128] (46K)</td><td>[79] (123K)</td><td>[137] (20K)</td><td>[129] (38K)</td><td>[62] (9K)</td><td></td></tr></table>
100
+
101
+ Appendix A.2). We perform open-ended evaluations using beam search for decoding, and closeended evaluations using our model’s log-likelihood to score each possible answer. We explore zero-shot generalization by prompting the model with two text-only examples from the task, with no corresponding images. Evaluation hyperparameters and additional details are given in Appendix B.1.5.
102
+
103
+ # 3 Experiments
104
+
105
+ Our goal is to develop models that can rapidly adapt to diverse and challenging tasks. For this, we consider a wide array of 16 popular multimodal image/video and language benchmarks. In order to validate model design decisions during the course of the project, 5 of these benchmarks were used as part of our development (DEV) set: COCO, OKVQA, VQAv2, MSVDQA and VATEX. Performance estimates on the DEV benchmarks may be biased, as a result of model selection. We note that this is also the case for prior work which makes use of similar benchmarks to validate and ablate design decisions. To account for this, we report performance on an additional set of 11 benchmarks, spanning captioning, video question-answering, as well as some less commonly explored capabilities such as visual dialogue and multi-choice question-answering tasks. The evaluation benchmarks are described in Appendix B.1.4. We keep all evaluation hyperparameters fixed across all benchmarks. Depending on the task, we use four few-shot prompt templates we describe in more detail in Appendix B.1.5. We emphasize that we do not validate any design decisions on these 11 benchmarks and use them solely to estimate unbiased few-shot learning performance of our models.
106
+
107
+ Concretely, estimating few-shot learning performance of a model involves prompting it with a set of support samples and evaluating it on a set of query samples. For the DEV benchmarks that are used both to validate design decisions and hyperparameters, as well as to report final performance, we therefore use four subsets: validation support, validation query, test support and test query. For other benchmarks, we need only the latter two. We report in Appendix B.1.4 how we form these subsets.
108
+
109
+ We report the results of the Flamingo models on few-shot learning in Section 3.1. Section 3.2 gives Flamingo fine-tuned results. An ablation study is given in Section 3.3. Appendix B.2 provides more results including Flamingo’s performance on the ImageNet and Kinetics700 classification tasks, and on our contrastive model’s performance. Appendix C includes additional qualitative results.
110
+
111
+ # 3.1 Few-shot learning on vision-language tasks
112
+
113
+ Few-shot results. Results are given in Table 1. Flamingo outperforms by a large margin all previous zero-shot or few-shot methods on the 16 benchmarks considered. This is achieved with as few as four examples per task, demonstrating practical and efficient adaptation of vision models to new tasks. More importantly, Flamingo is often competitive with state-of-the-art methods additionally fine-tuned on up to hundreds of thousands of annotated examples. On six tasks, Flamingo even outperforms the fine-tuned SotA despite using a single set of model weights and only 32 task-specific examples. Finally, despite having only used the DEV benchmarks for design decisions, our results generalize well to the other benchmarks, confirming the generality of our approach.
114
+
115
+ Table 2: Comparison to SotA when fine-tuning Flamingo. We fine-tune Flamingo on all nine tasks where Flamingo does not achieve SotA with few-shot learning. Flamingo sets a new SotA on five of them, outperfoming methods (marked with $\dagger .$ ) that use tricks such as model ensembling or domain-specific metric optimisation (e.g., CIDEr optimisation).
116
+
117
+ <table><tr><td rowspan="2">Method</td><td colspan="2">VQAV2 test-std</td><td rowspan="2">COCO</td><td rowspan="2">VATEX test</td><td colspan="2">VizWiz</td><td rowspan="2">MSRVTTQA test</td><td colspan="2" rowspan="2">VisDial valid|test-std</td><td rowspan="2">YouCook2</td><td colspan="2" rowspan="2">TextVQA valid|test-std</td><td rowspan="2">HatefulMemes test seen</td></tr><tr><td>test-dev</td><td>test</td><td>test-dev</td><td>test-std</td><td>valid</td></tr><tr><td>32 shots</td><td>67.6</td><td>:</td><td>113.8</td><td>65.1</td><td>49.8</td><td>-</td><td>31.0</td><td>56.8</td><td>-</td><td>86.8</td><td>36.0</td><td>·</td><td>70.0</td></tr><tr><td>Fine-tuned</td><td>82.0</td><td>82.1</td><td>138.1</td><td>84.2</td><td>65.7</td><td>65.4</td><td>47.4</td><td>61.8</td><td>59.7</td><td>118.6</td><td>57.1</td><td>54.1</td><td>86.6</td></tr><tr><td rowspan="2">SotA</td><td>81.3</td><td>81.3</td><td>149.6</td><td>81.4</td><td>57.21</td><td>60.6</td><td>46.8</td><td>75.2</td><td>75.4</td><td>138.7</td><td>54.7</td><td>73.7</td><td>84.6</td></tr><tr><td>[133]</td><td>[133]</td><td>[119]</td><td>[153]</td><td>[65]</td><td>[65]</td><td>[51]</td><td>[79]</td><td>[123]</td><td>[132]</td><td>[137]</td><td>[84]</td><td>[152]</td></tr></table>
118
+
119
+ <table><tr><td>setting</td><td colspan="2">Ablated</td><td>Flamingo-3B Changed original value value</td><td></td><td>Param. Step count↓ time↓</td><td>CoCo CIDEr↑</td><td>OKVQA top1个</td><td>VQAv2 top1个</td><td>MSVDQA top1个</td><td>VATEX CIDEr↑</td><td>Overall score↑</td></tr><tr><td colspan="3"></td><td>Flamingo-3B model w/o Video-Text pairs</td><td>3.2B</td><td>1.74s</td><td>86.5 84.2</td><td>42.1 43.0</td><td>55.8 53.9</td><td>36.3 34.5</td><td>53.4 46.0</td><td>70.7 67.3</td></tr><tr><td>i</td><td>Training data</td><td>All data</td><td>w/o Image-Text pairs Image-Text pairs→LAION w/oM3W</td><td>3.2B 3.2B 3.2B 3.2B</td><td>1.42s 0.95s 1.74s</td><td>66.3 79.5</td><td>39.2 41.4</td><td>51.6 53.5</td><td>32.0 33.9</td><td>41.6 47.6</td><td>60.9 66.4</td></tr><tr><td>(ii)</td><td>Optimisation</td><td>Accumulation</td><td>Round Robin</td><td>3.2B</td><td>1.02s 1.68s</td><td>54.1 76.1</td><td>36.5 39.8</td><td>52.7 52.1</td><td>31.4 33.2</td><td>23.5 40.8</td><td>53.4 62.9</td></tr><tr><td></td><td>Tanh gating</td><td>√</td><td>X</td><td>3.2B</td><td>1.74s</td><td>78.4</td><td>40.5</td><td>52.9</td><td>35.9</td><td>47.5</td><td>66.5</td></tr><tr><td>(iv)</td><td>Cross-attention architecture</td><td>GATED XATTN-DENSE</td><td>VANILLA XATTN</td><td>2.4B</td><td>1.16s 1.74s</td><td>80.6 79.2</td><td>41.5</td><td>53.4 50.8</td><td>32.9 32.2</td><td>50.7 47.8</td><td>66.9 63.1</td></tr><tr><td></td><td>Cross-attention</td><td></td><td>GRAFTING Single in middle</td><td>3.3B 2.0B</td><td>0.87s</td><td>71.5</td><td>36.1 38.1</td><td>50.2</td><td>29.1</td><td>42.3</td><td>59.8</td></tr><tr><td>(v)</td><td>frequency</td><td>Every</td><td>Every 4th Every 2nd</td><td>2.3B 2.6B</td><td>1.02s 1.24s</td><td>82.3 83.7</td><td>42.7 41.0</td><td>55.1 55.8</td><td>34.6 34.5</td><td>50.8 49.7</td><td>68.8 68.2</td></tr><tr><td>(vi)</td><td>Resampler</td><td>Perceiver</td><td>MLP Transformer</td><td>3.2B 3.2B</td><td>1.85s 1.81s</td><td>78.6 83.2</td><td>42.2 41.7</td><td>54.7 55.6</td><td>35.2 31.5</td><td>44.7 48.3</td><td>66.6 66.7</td></tr><tr><td>(vii)</td><td>Vision encoder</td><td>NFNet-F6</td><td>CLIP ViT-L/14 NFNet-F0</td><td>3.1B</td><td>1.58s 1.45s</td><td>76.5 73.8</td><td>41.6</td><td>53.4 52.8</td><td>33.2 31.1</td><td>44.5 42.9</td><td>64.9 62.7</td></tr><tr><td>(vii)</td><td></td><td></td><td>X(random init)</td><td>2.9B 3.2B</td><td>2.42s</td><td>74.8</td><td>40.5 31.5</td><td>45.6</td><td>26.9</td><td>50.1</td><td>57.8</td></tr><tr><td></td><td>Freezing LM</td><td>√</td><td>X (pretrained)</td><td>3.2B</td><td>2.42s</td><td>81.2</td><td>33.7</td><td>47.4</td><td>31.0</td><td>53.9</td><td>62.7</td></tr></table>
120
+
121
+ Table 3: Ablation studies. Each row should be compared to the baseline Flamingo run (top row). Step time measures the time spent to perform gradient updates on all training datasets.
122
+
123
+ Scaling with respect to parameters and shots. As shown in Figure 2, the larger the model, the better the few-shot performance, similar to GPT-3 [11]. The performance also improves with the number of shots. We further find that the largest model better exploits larger numbers of shots. Interestingly, even though our Flamingo models were trained with sequences limited to only 5 images on M3W, they are still able to benefit from up to 32 images or videos during inference. This demonstrates the flexibility of the Flamingo architecture for processing a variable number of videos or images.
124
+
125
+ # 3.2 Fine-tuning Flamingo as a pretrained vision-language model
126
+
127
+ While not the main focus of our work, we verify that when given more data, Flamingo models can be adapted to a task by fine-tuning their weights. In Table 2, we explore fine-tuning our largest model, Flamingo, for a given task with no limit on the annotation budget. In short, we do so by fine-tuning the model on a short schedule with a small learning rate by additionally unfreezing the vision backbone to accommodate a higher input resolution (details in Appendix B.2.2). We find that we can improve results over our previously presented in-context few-shot learning results, setting a new state of the art on five additional tasks: VQAv2, VATEX, VizWiz, MSRVTTQA, and HatefulMemes.
128
+
129
+ # 3.3 Ablation studies
130
+
131
+ In Table 3, we report our ablation results using Flamingo-3B on the validation subsets of the five DEV benchmarks with 4 shots. Note that we use smaller batch sizes and a shorter training schedule compared to the final models. The Overall score is obtained by dividing each benchmark score by its state-of-the-art (SotA) performance from Table 1 and averaging the results. More details and results are given in Appendix B.3 and Table 10.
132
+
133
+ Importance of the training data mixture. As shown in row (i), getting the right training data plays a crucial role. In fact, removing the interleaved image-text dataset M3W leads to a decrease of more than $1 7 \%$ in performance while removing the conventional paired image-text pairs also decreases performance (by $9 . 8 \%$ ), demonstrating the need for different types of datasets. Moreover, removing our paired video-text dataset negatively affects performance on all video tasks. We ablate replacing our image-text pairs (ITP) by the publicly available LAION-400M dataset [96], which leads to a slight degradation in performance. We show in row (ii) the importance of our gradient accumulation strategy compared to using round-robin updates [17].
134
+
135
+ Visual conditioning of the frozen LM. We ablate the use of the 0-initialized tanh gating when merging the cross-attention output to the frozen LM output in row (iii). Without it, we see a drop of $4 . 2 \%$ in our overall score. Moreover, we have noticed that disabling the 0-initialized tanh gating leads to training instabilities. Next, we ablate different conditioning architectures in row (iv). VANILLA XATTN, refers to the vanilla cross-attention from the original Transformer decoder [115]. In the GRAFTING approach from [68], the frozen LM is used as is with no additional layers inserted, and a stack of interleaved self-attention and cross-attention layers that take the frozen LM output are learnt from scratch. Overall, we show that our GATED XATTN-DENSE conditioning approach works best.
136
+
137
+ Compute/Memory vs. performance trade-offs. In row (v), we ablate the frequency at which we add new GATED XATTN-DENSE blocks. Although adding them at every layer is better, it significantly increases the number of trainable parameters and time complexity of the model. Notably, inserting them every fourth block accelerates training by $6 6 \%$ while only decreasing the overall score by $1 . 9 \%$ In light of this trade-off, we maximize the number of added layers under hardware constraints and add a GATED XATTN-DENSE every fourth layer for Flamingo-9B and every seventh for Flamingo-80B. We further compare in row (vi) the Perceiver Resampler to a MLP and a vanilla Transformer given a parameter budget. Both underperform the Perceiver Resampler while also being slower.
138
+
139
+ Vision encoder. In row (vii), we compare our NFNet-F6 vision encoder pretrained with contrastive learning (details in Appendix B.1.3) to the publicly available CLIP ViT-L/14 [85] model trained at 224 resolution. Our NFNet-F6 has a $+ 5 . 8 \%$ advantage over the CLIP ViT-L/14 and $+ 8 . 0 \%$ over a smaller NFNet-F0 encoder, which highlights the importance of using a strong vision backbone.
140
+
141
+ Freezing LM components prevents catastrophic forgetting. We verify the importance of freezing the LM layers at training in row (viii). If trained from scratch, we observe a large performance decrease of $- 1 2 . 9 \%$ . Interestingly, fine-tuning our pretrained LM also leads to a drop in performance of $- 8 . 0 \%$ . This indicates an instance of “catastrophic forgetting” [71], in which the model progressively forgets its pretraining while training on a new objective. In our setting, freezing the language model is a better alternative to training with the pre-training dataset (MassiveText) in the mixture.
142
+
143
+ # 4 Related work
144
+
145
+ Language modelling and few-shot adaptation. Language modelling has recently made substantial progress following the introduction of Transformers [115]. The paradigm of first pretraining on a vast amount of data followed by an adaptation on a downstream task has become standard [11, 23, 32, 44, 52, 75, 87, 108]. In this work, we build on the 70B Chinchilla language model [42] as the base LM for Flamingo. Numerous works have explored techniques to adapt language models to novel tasks using a few examples. These include adding small adapter modules [43], fine-tuning a small part of the LM [141], showing in-context examples in the prompt [11], or optimizing the prompt [56, 60] through gradient descent. In this paper, we take inspiration from the in-context [11] few-shot learning technique instead of more involved few-shot learning approaches based on metric learning [24, 103, 112, 117] or meta-learning [6, 7, 27, 31, 91, 155].
146
+
147
+ When language meets vision. These LM breakthroughs have been influential for vision-language modelling. In particular, BERT [23] inspired a large body of vision-language work [16, 28, 29, 38, 59, 61, 66, 101, 106, 107, 109, 118, 121, 142, 143, 151]. We differ from these approaches as Flamingo models do not require fine-tuning on new tasks. Another family of vision-language models is based on contrastive learning [2, 5, 49, 50, 57, 74, 82, 85, 138, 140, 146]. Flamingo differs from contrastive models as it can generate text, although we build and rely upon them for our vision encoder. Similar to our work are VLMs able to generate text in an autoregressive manner [19, 25, 45, 67, 116]. Concurrent works [17, 58, 119, 124, 154] also propose to formulate numerous vision tasks as text generation problems. Building on top of powerful pretrained language models has been explored in several recent works. One recent line of work [26, 68, 78, 114, 136, 144] proposes to freeze the pretrained LM weights to prevent catastrophic forgetting [71]. We follow this idea by freezing the
148
+
149
+ Chinchilla LM layers [42] and adding learnable layers within the frozen LM. We differ from prior work by introducing the first LM that can ingest arbitrarily interleaved images, videos, and text.
150
+
151
+ Web-scale vision and language training datasets. Manually annotated vision and language datasets are costly to obtain and thus relatively small (10k-100k) in scale [3, 15, 69, 122, 129, 139]. To alleviate this lack of data, numerous works [14, 50, 98, 110] automatically scrape readily available paired vision-text data. In addition to such paired data, we show the importance of also training on entire multimodal webpages containing interleaved images and text as a single sequence. Concurrent work CM3 [1] proposes to generate HTML markup from pages, while we simplify the text prediction task by only generating plain text. We emphasize few-shot learning and vision tasks while CM3 [1] primarily evaluates on language-only benchmarks in a zero-shot or fine-tuned setup.
152
+
153
+ # 5 Discussion
154
+
155
+ Limitations. First, our models build on pretrained LMs, and as a side effect, directly inherit their weaknesses. For example, LM priors are generally helpful, but may play a role in occasional hallucinations and ungrounded guesses. Furthermore, LMs generalise poorly to sequences longer than the training ones. They also suffer from poor sample efficiency during training. Addressing these issues can accelerate progress in the field and enhance the abilities of VLMs like Flamingo.
156
+
157
+ Second, the classification performance of Flamingo lags behind that of state-of-the-art contrastive models [82, 85]. These models directly optimize for text-image retrieval, of which classification is a special case. In contrast, our models handle a wider range of tasks, such as open-ended ones. A unified approach to achieve the best of both worlds is an important research direction.
158
+
159
+ Third, in-context learning has significant advantages over gradient-based few-shot learning methods, but also suffers from drawbacks depending on the characteristics of the application at hand. We demonstrate the effectiveness of in-context learning when access is limited to only a few dozen examples. In-context learning also enables simple deployment, requiring only inference, generally with no hyperparameter tuning needed. However, in-context learning is known to be highly sensitive to various aspects of the demonstrations [80, 148], and its inference compute cost and absolute performance scale poorly with the number of shots beyond this low-data regime. There may be opportunities to combine few-shot learning methods to leverage their complementary benefits. We discuss the limitations of our work in more depth in Appendix D.1.
160
+
161
+ Societal impacts. In terms of societal impacts, Flamingo offers a number of benefits while carrying some risks. Its ability to rapidly adapt to a broad range of tasks have the potential to enable non-expert users to obtain good performance in data-starved regimes, lowering the barriers to both beneficial and malicious applications. Flamingo is exposed to the same risks as large language models, such as outputting offensive language, propagating social biases and stereotypes, as well as leaking private information [42, 126]. Its ability to additionally handle visual inputs poses specific risks such as gender and racial biases relating to the contents of the input images, similar to a number of visual recognition systems [12, 21, 37, 97, 147]. We refer the reader to Appendix D.2 for a more extensive discussion of the societal impacts of our work, both positive and negative; as well as mitigation strategies and early investigations of risks relating to racial or gender bias and toxic outputs. Finally we note that, following prior work focusing on language models [72, 81, 111], the few-shot capabilities of Flamingo could be useful for mitigating such risks.
162
+
163
+ Conclusion. We proposed Flamingo, a general-purpose family of models that can be applied to image and video tasks with minimal task-specific training data. We also qualitatively explored interactive abilities of Flamingo such as “chatting” with the model, demonstrating flexibility beyond traditional vision benchmarks. Our results suggest that connecting pre-trained large language models with powerful visual models is an important step towards general-purpose visual understanding.
164
+
165
+ Acknowledgments and Disclosure of Funding. This research was funded by DeepMind. We would like to thank many colleagues for useful discussions, suggestions, feedback, and advice, including: Samuel Albanie, Relja Arandjelovic, Kareem Ayoub, Lorrayne Bennett, Adria Recasens Continente, ´ Tom Eccles, Nando de Freitas, Sander Dieleman, Conor Durkan, Aleksa Gordic, Raia Hadsell, ´ Will Hawkins, Lisa Anne Hendricks, Felix Hill, Jordan Hoffmann, Geoffrey Irving, Drew Jaegle, Koray Kavukcuoglu, Agustin Dal Lago, Mateusz Malinowski, Sona Mokrá, Gaby Pearl, Toby Pohlen, ˇ Jack Rae, Laurent Sifre, Francis Song, Maria Tsimpoukelli, Gregory Wayne, and Boxi Wu.
166
+
167
+ References [1] Armen Aghajanyan, Bernie Huang, Candace Ross, Vladimir Karpukhin, Hu Xu, Naman Goyal, Dmytro Okhonko, Mandar Joshi, Gargi Ghosh, Mike Lewis, and Luke Zettlemoyer. CM3: A causal masked multimodal model of the internet. arXiv:2201.07520, 2022. [2] Jean-Baptiste Alayrac, Adria Recasens, Rosalia Schneider, Relja Arandjelovic, Jason Rama- ´ puram, Jeffrey De Fauw, Lucas Smaira, Sander Dieleman, and Andrew Zisserman. Selfsupervised multimodal versatile networks. Conference on Neural Information Processing Systems, 2020. [3] Stanislaw Antol, Aishwarya Agrawal, Jiasen Lu, Margaret Mitchell, Dhruv Batra, C. Lawrence Zitnick, and Devi Parikh. VQA: Visual question answering. In International Conference on Computer Vision, 2015. [4] Thomas Bachlechner, Bodhisattwa Prasad Majumder, Henry Mao, Gary Cottrell, and Julian McAuley. ReZero is all you need: Fast convergence at large depth. In Uncertainty in Artificial Intelligence, 2021. [5] Max Bain, Arsha Nagrani, Gül Varol, and Andrew Zisserman. Frozen in time: A joint video and image encoder for end-to-end retrieval. In International Conference on Computer Vision, 2021. [6] Luca Bertinetto, João F. Henriques, Jack Valmadre, Philip Torr, and Andrea Vedaldi. Learning feed-forward one-shot learners. Conference on Neural Information Processing Systems, 2016.
168
+ [7] Luca Bertinetto, Joao F. Henriques, Philip H. S. Torr, and Andrea Vedaldi. Meta-learning with differentiable closed-form solvers. arXiv:1805.08136, 2018. [8] James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/google/jax. [9] John S. Bridle. Probabilistic interpretation of feedforward classification network outputs, with relationships to statistical pattern recognition. In Neurocomputing, 1990.
169
+ [10] Andrew Brock, Soham De, Samuel L. Smith, and Karen Simonyan. High-performance large-scale image recognition without normalization. arXiv:2102.06171, 2021.
170
+ [11] 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. In Conference on Neural Information Processing Systems, 2020.
171
+ [12] Joy Buolamwini and Timnit Gebru. Gender shades: Intersectional accuracy disparities in commercial gender classification. In ACM Conference on Fairness, Accountability, and Transparency, 2018.
172
+ [13] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, 2020.
173
+ [14] Soravit Changpinyo, Piyush Sharma, Nan Ding, and Radu Soricut. Conceptual 12M: Pushing web-scale image-text pre-training to recognize long-tail visual concepts. In IEEE Computer Vision and Pattern Recognition, 2021.
174
+ [15] Xinlei Chen, Hao Fang, Tsung-Yi Lin, Ramakrishna Vedantam, Saurabh Gupta, Piotr Dollár, and C Lawrence Zitnick. Microsoft COCO captions: Data collection and evaluation server. arXiv:1504.00325, 2015.
175
+
176
+ [16] Yen-Chun Chen, Linjie Li, Licheng Yu, Ahmed El Kholy, Faisal Ahmed, Zhe Gan, Yu Cheng, and Jingjing Liu. UNITER: Universal image-text representation learning. In European Conference on Computer Vision, 2020.
177
+
178
+ [17] Jaemin Cho, Jie Lei, Hao Tan, and Mohit Bansal. Unifying vision-and-language tasks via text generation. In International Conference on Machine Learning, 2021.
179
+
180
+ [18] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. PaLM: Scaling language modeling with pathways. arXiv:2204.02311, 2022.
181
+
182
+ [19] Wenliang Dai, Lu Hou, Lifeng Shang, Xin Jiang, Qun Liu, and Pascale Fung. Enabling multimodal generation on clip via vision-language knowledge distillation. In ACL Findings, 2022.
183
+
184
+ [20] Abhishek Das, Satwik Kottur, Khushi Gupta, Avi Singh, Deshraj Yadav, José MF Moura, Devi Parikh, and Dhruv Batra. Visual dialog. In IEEE Computer Vision and Pattern Recognition, 2017.
185
+
186
+ [21] Terrance De Vries, Ishan Misra, Changhan Wang, and Laurens Van der Maaten. Does object recognition work for everyone? In IEEE Computer Vision and Pattern Recognition, 2019.
187
+
188
+ [22] Karan Desai and Justin Johnson. VirTex: Learning visual representations from textual annotations. In IEEE Computer Vision and Pattern Recognition, 2021.
189
+
190
+ [23] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. arXiv:1810.04805, 2018.
191
+
192
+ [24] Carl Doersch, Ankush Gupta, and Andrew Zisserman. CrossTransformers: spatially-aware few-shot transfer. Conference on Neural Information Processing Systems, 2020.
193
+
194
+ [25] Jeffrey Donahue, Lisa Anne Hendricks, Sergio Guadarrama, Marcus Rohrbach, Subhashini Venugopalan, Kate Saenko, and Trevor Darrell. Long-term recurrent convolutional networks for visual recognition and description. In IEEE Computer Vision and Pattern Recognition, 2015.
195
+
196
+ [26] Constantin Eichenberg, Sidney Black, Samuel Weinbach, Letitia Parcalabescu, and Anette Frank. MAGMA–multimodal augmentation of generative models through adapter-based finetuning. arXiv:2112.05253, 2021.
197
+
198
+ [27] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning, 2017.
199
+
200
+ [28] Tsu-Jui Fu, Linjie Li, Zhe Gan, Kevin Lin, William Yang Wang, Lijuan Wang, and Zicheng Liu. VIOLET: End-to-end video-language transformers with masked visual-token modeling. arXiv:2111.12681, 2021.
201
+
202
+ [29] Zhe Gan, Yen-Chun Chen, Linjie Li, Chen Zhu, Yu Cheng, and Jingjing Liu. Large-scale adversarial training for vision-and-language representation learning. In Conference on Neural Information Processing Systems, 2020.
203
+
204
+ [30] Timnit Gebru, Jamie Morgenstern, Briana Vecchione, Jennifer Wortman Vaughan, Hanna Wallach, Hal Daumé III, and Kate Crawford. Datasheets for datasets. Communications of the ACM, 2021.
205
+
206
+ [31] Jonathan Gordon, John Bronskill, Matthias Bauer, Sebastian Nowozin, and Richard E. Turner. Meta-learning probabilistic inference for prediction. arXiv:1805.09921, 2018.
207
+
208
+ [32] Alex Graves. Generating sequences with recurrent neural networks. arXiv:1308.0850, 2013.
209
+
210
+ [33] Thomas L. Griffiths, Frederick Callaway, Michael B. Chang, Erin Grant, Paul M. Krueger, and Falk Lieder. Doing more with less: meta-reasoning and meta-learning in humans and machines. Current Opinion in Behavioral Sciences, 2019.
211
+
212
+ [34] Liangke Gui, Borui Wang, Qiuyuan Huang, Alex Hauptmann, Yonatan Bisk, and Jianfeng Gao. KAT: A knowledge augmented transformer for vision-and-language. arXiv:2112.08614, 2021.
213
+
214
+ [35] Danna Gurari, Qing Li, Abigale J. Stangl, Anhong Guo, Chi Lin, Kristen Grauman, Jiebo Luo, and Jeffrey P. Bigham. VizWiz grand challenge: Answering visual questions from blind people. In IEEE Computer Vision and Pattern Recognition, 2018.
215
+
216
+ [36] Adi Haviv, Ori Ram, Ofir Press, Peter Izsak, and Omer Levy. Transformer language models without positional encodings still learn positional information. arXiv:2203.16634, 2022.
217
+
218
+ [37] Lisa Anne Hendricks, Kaylee Burns, Kate Saenko, Trevor Darrell, and Anna Rohrbach. Women also snowboard: Overcoming bias in captioning models. In European Conference on Computer Vision, 2018.
219
+
220
+ [38] Lisa Anne Hendricks, John Mellor, Rosalia Schneider, Jean-Baptiste Alayrac, and Aida Nematzadeh. Decoupling the role of data, attention, and losses in multimodal transformers. Annual Meeting of the Association for Computational Linguistics, 2021.
221
+
222
+ [39] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (GELUs). arXiv:1606.08415, 2016.
223
+
224
+ [40] Tom Hennigan, Trevor Cai, Tamara Norman, and Igor Babuschkin. Haiku: Sonnet for JAX, 2020. URL http://github.com/deepmind/dm-haiku.
225
+
226
+ [41] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Computation, 1997.
227
+
228
+ [42] Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, Eric Noland Tom Hennigan, Katie Millican, George van den Driessche, Bogdan Damoc, Aurelia Guy, Simon Osindero, Karen Simonyan, Erich Elsen, Jack W. Rae, Oriol Vinyals, and Laurent Sifre. Training compute-optimal large language models. arXiv:2203.15556, 2022.
229
+
230
+ [43] Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for NLP. In International Conference on Machine Learning, 2019.
231
+
232
+ [44] Jeremy Howard and Sebastian Ruder. Universal language model fine-tuning for text classification. arXiv:1801.06146, 2018.
233
+
234
+ [45] Xiaowei Hu, Zhe Gan, Jianfeng Wang, Zhengyuan Yang, Zicheng Liu, Yumao Lu, and Lijuan Wang. Scaling up vision-language pre-training for image captioning. arXiv:2111.12233, 2021.
235
+
236
+ [46] Lun Huang, Wenmin Wang, Jie Chen, and Xiao-Yong Wei. Attention on attention for image captioning. In International Conference on Computer Vision, 2019.
237
+
238
+ [47] Md Amirul Islam, Matthew Kowal, Sen Jia, Konstantinos G. Derpanis, and Neil D. B. Bruce. Global pooling, more than meets the eye: Position information is encoded channel-wise in CNNs. In International Conference on Computer Vision, 2021.
239
+
240
+ [48] Andrew Jaegle, Felix Gimeno, Andy Brock, Oriol Vinyals, Andrew Zisserman, and Joao Carreira. Perceiver: General perception with iterative attention. In International Conference on Machine Learning, 2021.
241
+
242
+ [49] Aashi Jain, Mandy Guo, Krishna Srinivasan, Ting Chen, Sneha Kudugunta, Chao Jia, Yinfei Yang, and Jason Baldridge. MURAL: multimodal, multitask retrieval across languages. arXiv:2109.05125, 2021.
243
+ [50] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc V. Le, YunHsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. arXiv:2102.05918, 2021.
244
+ [51] Alex Jinpeng Wang, Yixiao Ge, Rui Yan, Yuying Ge, Xudong Lin, Guanyu Cai, Jianping Wu, Ying Shan, Xiaohu Qie, and Mike Zheng Shou. All in one: Exploring unified video-language pre-training. arXiv:2203.07303, 2022.
245
+ [52] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring the limits of language modeling. arXiv:1602.02410, 2016.
246
+ [53] 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. arXiv:2001.08361, 2020.
247
+ [54] Douwe Kiela, Hamed Firooz, Aravind Mohan, Vedanuj Goswami, Amanpreet Singh, Pratik Ringshia, and Davide Testuggine. The Hateful Memes Challenge: Detecting hate speech in multimodal memes. Conference on Neural Information Processing Systems, 2020.
248
+ [55] Hugo Larochelle. Few-shot classification by recycling deep learning. Invited Talk at the S2D-OLAD Workshop, ICLR 2021, 2021. URL https://slideslive.com/38955350/ fewshot-classification-by-recycling-deep-learning.
249
+ [56] Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. arXiv:2104.08691, 2021.
250
+ [57] Junnan Li, Ramprasaath Selvaraju, Akhilesh Gotmare, Shafiq Joty, Caiming Xiong, and Steven Chu Hong Hoi. Align before fuse: Vision and language representation learning with momentum distillation. In Conference on Neural Information Processing Systems, 2021.
251
+ [58] Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi. BLIP: Bootstrapping language-image pre-training for unified vision-language understanding and generation. arXiv:2201.12086, 2022.
252
+ [59] Linjie Li, Yen-Chun Chen, Yu Cheng, Zhe Gan, Licheng Yu, and Jingjing Liu. HERO: Hierarchical encoder for video+language omni-representation pre-training. arXiv:2005.00200, 2020.
253
+ [60] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. arXiv:2101.00190, 2021.
254
+ [61] Xiujun Li, Xi Yin, Chunyuan Li, Pengchuan Zhang, Xiaowei Hu, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, Yejin Choi, and Jianfeng Gao. Oscar: Object-semantics aligned pre-training for vision-language tasks. In European Conference on Computer Vision, 2020.
255
+ [62] Phillip Lippe, Nithin Holla, Shantanu Chandra, Santhosh Rajamanickam, Georgios Antoniou, Ekaterina Shutova, and Helen Yannakoudakis. A multimodal framework for the detection of hateful memes. arXiv:2012.12871, 2020.
256
+ [63] Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. What makes good in-context examples for GPT-3? arXiv:2101.06804, 2021.
257
+ [64] Siqi Liu, Zhenhai Zhu, Ning Ye, Sergio Guadarrama, and Kevin Murphy. Optimization of image description metrics using policy gradient methods. In International Conference on Computer Vision, 2017.
258
+ [65] Yu Liu, Lianghua Huang, Liuyihang Song, Bin Wang, Yingya Zhang, and Pan Pan. Enhancing textual cues in multi-modal transformers for VQA. VizWiz Challenge 2021, 2021.
259
+ [66] Jiasen Lu, Dhruv Batra, Devi Parikh, and Stefan Lee. ViLBERT: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. Conference on Neural Information Processing Systems, 2019.
260
+ [67] Huaishao Luo, Lei Ji, Botian Shi, Haoyang Huang, Nan Duan, Tianrui Li, Jason Li, Taroon Bharti, and Ming Zhou. UniVL: A unified video and language pre-training model for multimodal understanding and generation. arXiv:2002.06353, 2020.
261
+ [68] Ziyang Luo, Yadong Xi, Rongsheng Zhang, and Jing Ma. VC-GPT: Visual conditioned GPT for end-to-end generative vision-and-language pre-training. arXiv:2201.12723, 2022.
262
+ [69] Kenneth Marino, Mohammad Rastegari, Ali Farhadi, and Roozbeh Mottaghi. OK-VQA: A visual question answering benchmark requiring external knowledge. In IEEE Computer Vision and Pattern Recognition, 2019.
263
+ [70] Ellen M. Markman. Categorization and naming in children: Problems of induction. MIT Press, 1989.
264
+ [71] Michael McCloskey and Neil J. Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. The Psychology of Learning and Motivation, 1989.
265
+ [72] Jacob Menick, Maja Trebacz, Vladimir Mikulik, John Aslanides, Francis Song, Martin Chadwick, Mia Glaese, Susannah Young, Lucy Campbell-Gillingham, Geoffrey Irving, and Nat McAleese. Teaching language models to support answers with verified quotes. arXiv:2203.11147, 2022.
266
+ [73] Antoine Miech, Jean-Baptiste Alayrac, Ivan Laptev, Josef Sivic, and Andrew Zisserman. RareAct: A video dataset of unusual interactions. arxiv:2008.01018, 2020.
267
+ [74] Antoine Miech, Jean-Baptiste Alayrac, Lucas Smaira, Ivan Laptev, Josef Sivic, and Andrew Zisserman. End-to-end learning of visual representations from uncurated instructional videos. In IEEE Computer Vision and Pattern Recognition, 2020.
268
+ [75] Tomas Mikolov, Martin Karafiát, Lukas Burget, Jan Cernocky, and Sanjeev Khudanpur. \` Recurrent neural network based language model. Interspeech, 2010.
269
+ [76] Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. Rethinking the role of demonstrations: What makes in-context learning work? arXiv:2202.12837, 2022.
270
+ [77] Margaret Mitchell, Simone Wu, Andrew Zaldivar, Parker Barnes, Lucy Vasserman, Ben Hutchinson, Elena Spitzer, Inioluwa Deborah Raji, and Timnit Gebru. Model cards for model reporting. In ACM Conference on Fairness, Accountability, and Transparency, 2019.
271
+ [78] Ron Mokady, Amir Hertz, and Amit H. Bermano. ClipCap: CLIP prefix for image captioning. arXiv:2111.09734, 2021.
272
+ [79] Vishvak Murahari, Dhruv Batra, Devi Parikh, and Abhishek Das. Large-scale pretraining for visual dialog: A simple state-of-the-art baseline. In European Conference on Computer Vision, 2020.
273
+ [80] Ethan Perez, Douwe Kiela, and Kyunghyun Cho. True few-shot learning with language models. Conference on Neural Information Processing Systems, 2021.
274
+ [81] Ethan Perez, Saffron Huang, Francis Song, Trevor Cai, Roman Ring, John Aslanides, Amelia Glaese, Nat McAleese, and Geoffrey Irving. Red teaming language models with language models. arXiv:2202.03286, 2022.
275
+ [82] Hieu Pham, Zihang Dai, Golnaz Ghiasi, Hanxiao Liu, Adams Wei Yu, Minh-Thang Luong, Mingxing Tan, and Quoc V. Le. Combined scaling for zero-shot transfer learning. arXiv:2111.10050, 2021.
276
+ [83] Ofir Press, Noah Smith, and Mike Lewis. Train short, test long: Attention with linear biases enables input length extrapolation. In International Conference on Learning Representations, 2022.
277
+
278
+ [84] Yixuan Qiao, Hao Chen, Jun Wang, Yihao Chen, Xianbin Ye, Ziliang Li, Xianbiao Qi, Peng Gao, and Guotong Xie. Winner team Mia at TextVQA Challenge 2021: Vision-and-language representation learning with pre-trained sequence-to-sequence model. arXiv:2106.15332, 2021.
279
+
280
+ [85] 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.
281
+
282
+ [86] Jack W. Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, Eliza Rutherford, Tom Hennigan, Jacob Menick, Albin Cassirer, Richard Powell, George van den Driessche, Lisa Anne Hendricks, Maribeth Rauh, Po-Sen Huang, Amelia Glaese, Johannes Welbl, Sumanth Dathathri, Saffron Huang, Jonathan Uesato, John Mellor, Irina Higgins, Antonia Creswell, Nat McAleese, Amy Wu, Erich Elsen, Siddhant Jayakumar, Elena Buchatskaya, David Budden, Esme Sutherland, Karen Simonyan, Michela Paganini, Laurent Sifre, Lena Martens, Xiang Lorraine Li, Adhiguna Kuncoro, Aida Nematzadeh, Elena Gribovskaya, Domenic Donato, Angeliki Lazaridou, Arthur Mensch, Jean-Baptiste Lespiau, Maria Tsimpoukelli, Nikolai Grigorev, Doug Fritz, Thibault Sottiaux, Mantas Pajarskas, Toby Pohlen, Zhitao Gong, Daniel Toyama, Cyprien de Masson d’Autume, Yujia Li, Tayfun Terzi, Vladimir Mikulik, Igor Babuschkin, Aidan Clark, Diego de Las Casas, Aurelia Guy, Chris Jones, James Bradbury, Matthew Johnson, Blake Hechtman, Laura Weidinger, Iason Gabriel, William Isaac, Ed Lockhart, Simon Osindero, Laura Rimell, Chris Dyer, Oriol Vinyals, Kareem Ayoub, Jeff Stanway, Lorrayne Bennett, Demis Hassabis, Koray Kavukcuoglu, and Geoffrey Irving. Scaling language models: Methods, analysis & insights from training Gopher. arXiv:2112.11446, 2021.
283
+
284
+ [87] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv:1910.10683, 2019.
285
+
286
+ [88] Samyam Rajbhandari, Jeff Rasley, Olatunji Ruwase, and Yuxiong He. ZeRO: Memory optimizations toward training trillion parameter models. In International Conference for High Performance Computing, Networking, Storage and Analysis, 2020.
287
+
288
+ [89] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv:2204.06125, 2022.
289
+
290
+ [90] Steven J. Rennie, Etienne Marcheret, Youssef Mroueh, Jarret Ross, and Vaibhava Goel. Self-critical sequence training for image captioning. In IEEE Computer Vision and Pattern Recognition, 2017.
291
+
292
+ [91] James Requeima, Jonathan Gordon, John Bronskill, Sebastian Nowozin, and Richard E. Turner. Fast and flexible multi-task classification using conditional neural adaptive processes. Conference on Neural Information Processing Systems, 2019.
293
+
294
+ [92] Laria Reynolds and Kyle McDonell. Prompt programming for large language models: Beyond the few-shot paradigm. In Extended Abstracts of the 2021 CHI Conference on Human Factors in Computing Systems, 2021.
295
+
296
+ [93] Rachel Rudinger, Jason Naradowsky, Brian Leonard, and Benjamin Van Durme. Gender bias in coreference resolution. arXiv:1804.09301, 2018.
297
+
298
+ [94] 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 FeiFei. ImageNet large scale visual recognition challenge. International Journal of Computer Vision, 2015.
299
+
300
+ [95] Victor Sanh, Albert Webson, Colin Raffel, Stephen H. Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, Manan Dey, M. Saiful Bari, Canwen Xu, Urmish Thakker, Shanya Sharma Sharma, Eliza Szczechla, Taewoon Kim, Gunjan
301
+
302
+ Chhablani, Nihal Nayak, Debajyoti Datta, Jonathan Chang, Mike Tian-Jian Jiang, Han Wang, Matteo Manica, Sheng Shen, Zheng Xin Yong, Harshit Pandey, Rachel Bawden, Thomas Wang, Trishala Neeraj, Jos Rozen, Abheesht Sharma, Andrea Santilli, Thibault Fevry, Jason Alan Fries, Ryan Teehan, Stella Biderman, Leo Gao, Tali Bers, Thomas Wolf, and Alexander M. Rush. Multitask Prompted Training Enables Zero-Shot Task Generalization. In International Conference on Learning Representations, 2022.
303
+ [96] Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki. Laion-400m: Open dataset of clip-filtered 400 million image-text pairs. arXiv:2111.02114, 2021.
304
+ [97] Carsten Schwemmer, Carly Knight, Emily D. Bello-Pardo, Stan Oklobdzija, Martijn Schoonvelde, and Jeffrey W. Lockhart. Diagnosing gender bias in image recognition systems. Socius, 2020.
305
+ [98] Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual Captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Annual Meeting of the Association for Computational Linguistics, 2018.
306
+ [99] Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley, Jared Casper, and Bryan Catanzaro. Megatron-LM: Training multi-billion parameter language models using model parallelism. arXiv:2104.08691, 2019.
307
+ [100] Amanpreet Singh, Vivek Natarajan, Meet Shah, Yu Jiang, Xinlei Chen, Dhruv Batra, Devi Parikh, and Marcus Rohrbach. Towards VQA models that can read. In IEEE Computer Vision and Pattern Recognition, 2019.
308
+ [101] Amanpreet Singh, Ronghang Hu, Vedanuj Goswami, Guillaume Couairon, Wojciech Galuba, Marcus Rohrbach, and Douwe Kiela. FLAVA: A foundational language and vision alignment model. arXiv:2112.04482, 2021.
309
+ [102] Lucas Smaira, João Carreira, Eric Noland, Ellen Clancy, Amy Wu, and Andrew Zisserman. A short note on the Kinetics-700-2020 human action dataset. arXiv:2010.10864, 2020.
310
+ [103] Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. Conference on Neural Information Processing Systems, 2017.
311
+ [104] David R So, Wojciech Manke, Hanxiao Liu, Zihang Dai, Noam Shazeer, and Quoc V. Le. ´ Primer: Searching for efficient transformers for language modeling. arXiv:2109.08668, 2021.
312
+ [105] Emma Strubell, Ananya Ganesh, and Andrew McCallum. Energy and policy considerations for deep learning in NLP. arXiv:1906.02243, 2019.
313
+ [106] Weijie Su, Xizhou Zhu, Yue Cao, Bin Li, Lewei Lu, Furu Wei, and Jifeng Dai. VL-BERT: Pre-training of generic visual-linguistic representations. arXiv:1908.08530, 2019.
314
+ [107] Chen Sun, Austin Myers, Carl Vondrick, Kevin Murphy, and Cordelia Schmid. VideoBERT: A joint model for video and language representation learning. In International Conference on Computer Vision, 2019.
315
+ [108] Ilya Sutskever, James Martens, and Geoffrey E. Hinton. Generating text with recurrent neural networks. In International Conference on Machine Learning, 2011.
316
+ [109] Hao Tan and Mohit Bansal. LXMERT: Learning cross-modality encoder representations from transformer. In Conference on Empirical Methods in Natural Language Processing, 2019.
317
+ [110] Bart Thomee, David A Shamma, Gerald Friedland, Benjamin Elizalde, Karl Ni, Douglas Poland, Damian Borth, and Li-Jia Li. YFCC100M: The new data in multimedia research. Communications of the ACM, 2016.
318
+ [111] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, YaGuang Li, Hongrae Lee, Huaixiu Steven Zheng, Amin Ghafouri, Marcelo Menegali, Yanping Huang, Maxim Krikun, Dmitry Lepikhin, James Qin, Dehao Chen, Yuanzhong Xu, Zhifeng Chen, Adam Roberts,
319
+
320
+ Maarten Bosma, Vincent Zhao, Yanqi Zhou, Chung-Ching Chang, Igor Krivokon, Will Rusch, Marc Pickett, Pranesh Srinivasan, Laichee Man, Kathleen Meier-Hellstern, Meredith Ringel Morris, Tulsee Doshi, Renelito Delos Santos, Toju Duke, Johnny Soraker, Ben Zevenbergen, Vinodkumar Prabhakaran, Mark Diaz, Ben Hutchinson, Kristen Olson, Alejandra Molina, Erin Hoffman-John, Josh Lee, Lora Aroyo, Ravi Rajakumar, Alena Butryna, Matthew Lamm, Viktoriya Kuzmina, Joe Fenton, Aaron Cohen, Rachel Bernstein, Ray Kurzweil, Blaise AgueraArcas, Claire Cui, Marian Croak, Ed Chi, and Quoc Le. LaMDA: Language models for dialog applications. arXiv:2201.08239, 2022.
321
+
322
+ [112] Yonglong Tian, Yue Wang, Dilip Krishnan, Joshua B. Tenenbaum, and Phillip Isola. Rethinking few-shot image classification: a good embedding is all you need? In European Conference on Computer Vision, 2020.
323
+
324
+ [113] Hugo Touvron, Andrea Vedaldi, Matthijs Douze, and Hervé Jégou. Fixing the train-test resolution discrepancy. Conference on Neural Information Processing Systems, 2019.
325
+
326
+ [114] Maria Tsimpoukelli, Jacob Menick, Serkan Cabi, SM Eslami, Oriol Vinyals, and Felix Hill. Multimodal few-shot learning with frozen language models. Conference on Neural Information Processing Systems, 2021.
327
+
328
+ [115] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Conference on Neural Information Processing Systems, 2017.
329
+
330
+ [116] Oriol Vinyals, Alexander Toshev, Samy Bengio, and Dumitru Erhan. Show and tell: A neural image caption generator. In International Conference on Computer Vision, 2015.
331
+
332
+ [117] Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. Conference on Neural Information Processing Systems, 2016.
333
+
334
+ [118] Jianfeng Wang, Xiaowei Hu, Zhe Gan, Zhengyuan Yang, Xiyang Dai, Zicheng Liu, Yumao Lu, and Lijuan Wang. UFO: A unified transformer for vision-language representation learning. arXiv:2111.10023, 2021.
335
+
336
+ [119] Peng Wang, An Yang, Rui Men, Junyang Lin, Shuai Bai, Zhikang Li, Jianxin Ma, Chang Zhou, Jingren Zhou, and Hongxia Yang. Unifying architectures, tasks, and modalities through a simple sequence-to-sequence learning framework. arXiv:2202.03052, 2022.
337
+
338
+ [120] Thomas Wang, Adam Roberts, Daniel Hesslow, Teven Le Scao, Hyung Won Chung, Iz Beltagy, Julien Launay, and Colin Raffel. What language model architecture and pretraining objective work best for zero-shot generalization? arXiv:2204.05832, 2022.
339
+
340
+ [121] Wenhui Wang, Hangbo Bao, Li Dong, and Furu Wei. VLMo: Unified vision-language pre-training with mixture-of-modality-experts. arXiv:2111.02358, 2021.
341
+
342
+ [122] Xin Wang, Jiawei Wu, Junkun Chen, Lei Li, Yuan-Fang Wang, and William Yang Wang. VATEX: A large-scale, high-quality multilingual dataset for video-and-language research. In International Conference on Computer Vision, 2019.
343
+
344
+ [123] Yue Wang, Shafiq Joty, Michael Lyu, Irwin King, Caiming Xiong, and Steven Hoi. VD-BERT: A unified vision and dialog transformer with BERT. In Conference on Empirical Methods in Natural Language Processing, 2020.
345
+
346
+ [124] Zirui Wang, Jiahui Yu, Adams Wei Yu, Zihang Dai, Yulia Tsvetkov, and Yuan Cao. SimVLM: Simple visual language model pretraining with weak supervision. arXiv:2108.10904, 2021.
347
+
348
+ [125] Jason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V. Le. Finetuned language models are zero-shot learners. arXiv:2109.01652, 2021.
349
+
350
+ [126] Laura Weidinger, John Mellor, Maribeth Rauh, Conor Griffin, Jonathan Uesato, Po-Sen Huang, Myra Cheng, Mia Glaese, Borja Balle, Atoosa Kasirzadeh, Zac Kenton, Sasha Brown, Will Hawkins, Tom Stepleton, Courtney Biles, Abeba Birhane, Julia Haas, Laura Rimell, Lisa Anne Hendricks, William Isaac, Sean Legassick, Geoffrey Irving, and Iason Gabriel. Ethical and social risks of harm from language models. arXiv:2112.04359, 2021.
351
+
352
+ [127] Mitchell Wortsman, Gabriel Ilharco, Samir Yitzhak Gadre, Rebecca Roelofs, Raphael GontijoLopes, Ari S. Morcos, Hongseok Namkoong, Ali Farhadi, Yair Carmon, Simon Kornblith, and Ludwig Schmidt. Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time. arXiv:2203.05482, 2022.
353
+
354
+ [128] Bo Wu, Shoubin Yu, Zhenfang Chen, Joshua B. Tenenbaum, and Chuang Gan. STAR: A Benchmark for Situated Reasoning in Real-World Videos. In Conference on Neural Information Processing Systems, 2021.
355
+
356
+ [129] Junbin Xiao, Xindi Shang, Angela Yao, and Tat-Seng Chua. Next-QA: Next phase of questionanswering to explaining temporal actions. In IEEE Computer Vision and Pattern Recognition, 2021.
357
+
358
+ [130] Dejing Xu, Zhou Zhao, Jun Xiao, Fei Wu, Hanwang Zhang, Xiangnan He, and Yueting Zhuang. Video question answering via gradually refined attention over appearance and motion. In ACM Multimedia, 2017.
359
+
360
+ [131] Hanwei Xu, Yujun Chen, Yulun Du, Nan Shao, Yanggang Wang, Haiyu Li, and Zhilin Yang. Zeroprompt: Scaling prompt-based pretraining to 1,000 tasks improves zero-shot generalization. arXiv:2201.06910, 2022.
361
+
362
+ [132] Hu Xu, Gargi Ghosh, Po-Yao Huang, Prahal Arora, Masoumeh Aminzadeh, Christoph Feichtenhofer, Florian Metze, and Luke Zettlemoyer. VLM: Task-agnostic video-language model pre-training for video understanding. arXiv:2105.09996, 2021.
363
+
364
+ [133] Ming Yan, Haiyang Xu, Chenliang Li, Junfeng Tian, Bin Bi, Wei Wang, Weihua Chen, Xianzhe Xu, Fan Wang, Zheng Cao, Zhicheng Zhang, Qiyu Zhang, Ji Zhang, Songfang Huang, Fei Huang, Luo Si, and Rong Jin. Achieving human parity on visual question answering. arXiv:2111.08896, 2021.
365
+
366
+ [134] Shen Yan, Xuehan Xiong, Anurag Arnab, Zhichao Lu, Mi Zhang, Chen Sun, and Cordelia Schmid. Multiview transformers for video recognition. arXiv:2201.04288, 2022.
367
+
368
+ [135] Antoine Yang, Antoine Miech, Josef Sivic, Ivan Laptev, and Cordelia Schmid. Just ask: Learning to answer questions from millions of narrated videos. In International Conference on Computer Vision, 2021.
369
+
370
+ [136] Zhengyuan Yang, Zhe Gan, Jianfeng Wang, Xiaowei Hu, Yumao Lu, Zicheng Liu, and Lijuan Wang. An empirical study of GPT-3 for few-shot knowledge-based VQA. In National Conference on Artificial Intelligence (AAAI), 2021.
371
+
372
+ [137] Zhengyuan Yang, Yijuan Lu, Jianfeng Wang, Xi Yin, Dinei Florencio, Lijuan Wang, Cha Zhang, Lei Zhang, and Jiebo Luo. TAP: Text-aware pre-training for text-VQA and text-caption. In IEEE Computer Vision and Pattern Recognition, 2021.
373
+
374
+ [138] Lewei Yao, Runhui Huang, Lu Hou, Guansong Lu, Minzhe Niu, Hang Xu, Xiaodan Liang, Zhenguo Li, Xin Jiang, and Chunjing Xu. FILIP: Fine-grained interactive language-image pre-training. arXiv:2111.07783, 2021.
375
+
376
+ [139] Peter Young, Alice Lai, Micah Hodosh, and Julia Hockenmaier. From image descriptions to visual denotations: New similarity metrics for semantic inference over event descriptions. Annual Meeting of the Association for Computational Linguistics, 2014.
377
+
378
+ [140] Lu Yuan, Dongdong Chen, Yi-Ling Chen, Noel Codella, Xiyang Dai, Jianfeng Gao, Houdong Hu, Xuedong Huang, Boxin Li, Chunyuan Li, Ce Liu, Mengchen Liu, Zicheng Liu, Yumao Lu, Yu Shi, Lijuan Wang, Jianfeng Wang, Bin Xiao, Zhen Xiao, Jianwei Yang, Michael Zeng, Luowei Zhou, and Pengchuan Zhang. Florence: A new foundation model for computer vision. arXiv:2111.11432, 2021.
379
+
380
+ [141] Elad Ben Zaken, Shauli Ravfogel, and Yoav Goldberg. BitFit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. arXiv:2106.10199, 2021.
381
+
382
+ [142] Rowan Zellers, Ximing Lu, Jack Hessel, Youngjae Yu, Jae Sung Park, Jize Cao, Ali Farhadi, and Yejin Choi. MERLOT: Multimodal neural script knowledge models. Conference on Neural Information Processing Systems, 2021.
383
+
384
+ [143] Rowan Zellers, Jiasen Lu, Ximing Lu, Youngjae Yu, Yanpeng Zhao, Mohammadreza Salehi, Aditya Kusupati, Jack Hessel, Ali Farhadi, and Yejin Choi. MERLOT reserve: Neural script knowledge through vision and language and sound. In IEEE Computer Vision and Pattern Recognition, 2022.
385
+
386
+ [144] Andy Zeng, Adrian Wong, Stefan Welker, Krzysztof Choromanski, Federico Tombari, Aveek Purohit, Michael Ryoo, Vikas Sindhwani, Johnny Lee, Vincent Vanhoucke, and Pete Florence. Socratic models: Composing zero-shot multimodal reasoning with language. arXiv:2204.00598, 2022.
387
+
388
+ [145] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. arXiv:2106.04560, 2021.
389
+
390
+ [146] Xiaohua Zhai, Xiao Wang, Basil Mustafa, Andreas Steiner, Daniel Keysers, Alexander Kolesnikov, and Lucas Beyer. LiT: Zero-shot transfer with locked-image text tuning. arXiv:2111.07991, 2021.
391
+
392
+ [147] Dora Zhao, Angelina Wang, and Olga Russakovsky. Understanding and evaluating racial biases in image captioning. In IEEE Computer Vision and Pattern Recognition, 2021.
393
+
394
+ [148] Zihao Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In International Conference on Machine Learning, 2021.
395
+
396
+ [149] Luowei Zhou, Chenliang Xu, and Jason J. Corso. Towards automatic learning of procedures from web instructional videos. In National Conference on Artificial Intelligence (AAAI), 2018.
397
+
398
+ [150] Luowei Zhou, Hamid Palangi, Lei Zhang, Houdong Hu, Jason Corso, and Jianfeng Gao. Unified vision-language pre-training for image captioning and VQA. In National Conference on Artificial Intelligence (AAAI), 2020.
399
+
400
+ [151] Linchao Zhu and Yi Yang. ActBERT: Learning global-local video-text representations. In IEEE Computer Vision and Pattern Recognition, 2020.
401
+
402
+ [152] Ron Zhu. Enhance multimodal transformer with external label and in-domain pretrain: Hateful meme challenge winning solution. arXiv:2012.08290, 2020.
403
+
404
+ [153] Xinxin Zhu, Longteng Guo, Peng Yao, Shichen Lu, Wei Liu, and Jing Liu. Vatex video captioning challenge 2020: Multi-view features and hybrid reward strategies for video captioning. arXiv:1910.11102, 2019.
405
+
406
+ [154] Xizhou Zhu, Jinguo Zhu, Hao Li, Xiaoshi Wu, Xiaogang Wang, Hongsheng Li, Xiaohua Wang, and Jifeng Dai. Uni-Perceiver: Pre-training unified architecture for generic perception for zero-shot and few-shot tasks. arXiv:2112.01522, 2021.
407
+
408
+ [155] Luisa Zintgraf, Kyriacos Shiarli, Vitaly Kurin, Katja Hofmann, and Shimon Whiteson. Fast context adaptation via meta-learning. In International Conference on Machine Learning, 2019.
409
+
410
+ # Checklist
411
+
412
+ 1. For all authors...
413
+
414
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
415
+ (b) Did you describe the limitations of your work? [Yes] See Section 5.
416
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5 for a brief discussion and Appendix D.2 for the full discussion.
417
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
418
+
419
+ 2. If you are including theoretical results...
420
+
421
+ (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]
422
+
423
+ 3. If you ran experiments...
424
+
425
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No] The code and the data are proprietary.
426
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 3 and Appendix B.
427
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We do not observe large enough variance in our training runs to justify the computation cost incurred by multiple training runs. For the largest models, it is not feasible within our compute budget.
428
+ (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 can be found in Appendix B.1.2. In short, our largest run was trained on 1536 TPU chips for 15 days.
429
+
430
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
431
+
432
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We properly cited the prior methods on which our work is based, as well as prior datasets when appropriate (e.g., ALIGN).
433
+ (b) Did you mention the license of the assets? [N/A] The assets we used are previous work for which we cited papers. We do mention the license of all visual assets we use for the figures of the paper in Appendix G.
434
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
435
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] Our data was automatically scraped from million of webpages. See Datasheets [30] in Appendix F.
436
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See Datasheets [30] in Appendix F.
437
+
438
+ 5. If you used crowdsourcing or conducted research with human subjects...
439
+
440
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
441
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
442
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/Fkckkr3ya8/Fkckkr3ya8.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/HjwK-Tc_Bc/HjwK-Tc_Bc.md ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Learn to Explain: Multimodal Reasoning via Thought Chains for Science Question Answering
2
+
3
+ Pan $\mathbf { L u ^ { 1 , 3 } }$ , Swaroop Mishra2,3, Tony $\mathbf { X i a } ^ { 1 }$ , Liang $\mathbf { Q i u } ^ { 1 }$ , Kai-Wei Chang1, Song-Chun $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 1 }$ , Oyvind Tafjord3, Peter Clark3, Ashwin Kalyan3 1University of California, Los Angeles, 2Arizona State University, 3Allen Institute for AI {lupantech, kwchang.cs}@gmail.com, sczhu@stat.ucla.edu, {oyvindt, peterc, ashwinkv}@allenai.org
4
+
5
+ # Abstract
6
+
7
+ When answering a question, humans utilize the information available across different modalities to synthesize a consistent and complete chain of thought (CoT). This process is normally a black box in the case of deep learning models like large-scale language models. Recently, science question benchmarks have been used to diagnose the multi-hop reasoning ability and interpretability of an AI system. However, existing datasets fail to provide annotations for the answers, or are restricted to the textual-only modality, small scales, and limited domain diversity. To this end, we present Science Question Answering (SCIENCEQA), a new benchmark that consists of ${ \sim } 2 1 \mathrm { k }$ multimodal multiple choice questions with diverse science topics and annotations of their answers with corresponding lectures and explanations. We further design language models to learn to generate lectures and explanations as the chain of thought (CoT) to mimic the multi-hop reasoning process when answering SCIENCEQA questions. SCIENCEQA demonstrates the utility of CoT in language models, as CoT improves the question answering performance by $1 . 2 0 \%$ in fewshot GPT-3 and $3 . 9 9 \%$ in fine-tuned UnifiedQA. We also explore the upper bound for models to leverage explanations by feeding those in the input; we observe that it improves the few-shot performance of GPT-3 by $1 8 . 9 6 \%$ . Our analysis further shows that language models, similar to humans, benefit from explanations to learn from fewer data and achieve the same performance with just $40 \%$ of the data.1
8
+
9
+ # 1 Introduction
10
+
11
+ A long-standing goal of AI systems is to act reliably and learn complex tasks efficiently like human beings. In the process of reliable decision making, humans follow an explicit chain-of-thought (CoT) reasoning process that is typically expressed as an explanation. However, machine learning models are trained mostly using a large number of input-output examples to perform a specific task. These black-box models only generate the final decision without reliably revealing the underlying reasoning process. Not surprisingly, it is unclear if they understand the task and can generalize even though they perform well on the benchmark. On the other hand, humans are able to learn from instructions or explanations from past experience and generalize them to novel and unseen problems. This helps them learn more quickly with fewer data. In this work, we explore if machines can be endowed with such reasoning abilities in the context of science-based question answering.
12
+
13
+ Recently, science problem solving benchmarks [18] have been used to diagnose the multi-hop reasoning ability and interpretability of AI systems. To answer science questions, a model needs to not only understand multimodal contents but also extract external knowledge to arrive at the correct answer. Since these tasks require domain-specific knowledge and explicit multi-hop reasoning, a model would be not interpretable if it fails to provide explanations to reveal the reasoning process. However, current science question datasets [18, 17, 52] mostly lack annotated explanations for the answers. To address this issue, other science datasets annotate the explanations, but they are restricted to the textual only modality and limited to small data scales [13, 6, 37] or a small set of topics [20, 14]. Therefore, we collect Science Question Answering (SCIENCEQA), a large-scale multi-choice dataset that contains multimodal science questions with explanations and features rich domain diversity.
14
+
15
+ ![](images/bbe5265bbdcce0ffbf85cef9fd612ed120c97964ad993f721b8ee4dda5d131a6.jpg)
16
+ Figure 1: We construct the SCIENCEQA dataset where a data example consists of multimodal question answering information and the grounded lecture and explanation. We study if QA models can generate a reasonable explanation to reveal the chain-of-thought reasoning.
17
+
18
+ SCIENCEQA is collected from elementary and high school science curricula, and contains 21,208 examples along with lectures and explanations. Different from existing datasets [17, 18, 52], SCIENCEQA has richer domain diversity from three different subjects: natural science, social science, and language science. A typical example consists of a question, multiple choices, multimodal contexts, a correct answer, as well as a lecture and an explanation. The lecture and explanation provide general external knowledge and specific reasons, respectively, for arriving at the correct answer.
19
+
20
+ Consider the thoughts one person might have when answering the question in Figure 1. One first recalls the knowledge regarding the definition of a force learned from textbooks: “A force is a push or a pull that ... The direction of a push is ... The direction of a pull is ...”, then forms a line of reasoning: “The baby’s hand applies a force to the cabinet door. This force causes the door to open. $ T h e$ direction of this force is toward the baby’s hand.”, and finally arrives at the correct answer: “This force is a pull.”. Following [41], we formulate the task to output a natural explanation alongside the predicted answer. In this paper, we train language models to generate lectures and explanations as the chain of thought (CoT) to mimic the multi-hop reasoning process to answer SCIENCEQA questions.
21
+
22
+ Our experiments show that current multimodal methods [55, 1, 21, 9, 26, 35] fail to achieve satisfactory performance on SCIENCEQA and do not generate correct explanations. Instead, we find that CoT can help large language models not only in the few-shot learning setting but also in the fine-tuning setting. When combined with CoT to generate the lecture and explanation, the fine-tuned UnifiedQA [19] achieves an improvement of $3 . 9 9 \%$ as opposed to not using CoT in the fine-tuning stage. The few-shot GPT-3 model [4] via chain-of-thought prompting can obtain $7 5 . 1 7 \%$ on SCIENCEQA with an improvement of $1 . 2 0 \%$ compared to the few-shot GPT-3 without CoT. Prompted with CoT, GPT-3 can generate reasonable explanations as evaluated by automated metrics, and promisingly, $6 5 . 2 \%$ of explanations meet the gold standard of human evaluations. We also investigate the upper bound for models to harness explanations by including them in the input. We find that doing so improves GPT-3’s few-shot performance by $1 8 . 9 6 \%$ , suggesting that explanations do aid models and are currently underutilized in the CoT framework. Further analysis shows that, like humans, language models benefit from explanations to learn with less data: UnifiedQA with CoT obtains the same results as UnifiedQA without CoT with only $40 \%$ of the training data.
23
+
24
+ To sum up, our contributions are three-fold: (a) To bridge the gap in existing datasets in the scientific domain, we build Science Question Answering (SCIENCEQA), a new dataset containing 21,208 multimodal science questions with rich domain diversity. To the best of our knowledge, SCIENCEQA is the first large-scale multimodal dataset that annotates lectures and explanations for the answers.
25
+
26
+ (b) We show that CoT benefits large language models in both few-shot and fine-tuning learning by improving model performance and reliability via generating explanations. (c) We further explore the upper bound of GPT-3 and show that CoT helps language models learn from fewer data.
27
+
28
+ # 2 Related Work
29
+
30
+ Visual question answering. Since the task of visual question answering (VQA) was first proposed in [2], there have been plenty of VQA datasets [56, 58, 23, 11, 15, 12] conducted to facilitate the research work. Although our SCIENCEQA dataset shares some features with VQA, there are several main differences between them. First, SCIENCEQA is more challenging than existing VQA datasets because it contains multimodal contexts and diverse topics in the scientific domain. In addition, most answers are annotated with lectures and explanations, which makes SCIENCEQA a suitable dataset for multi-modal question answering and multi-hop reasoning for AI systems. Inspired by the recent remarkable performance achieved for VQA [33, 32, 10, 9, 26, 7, 8], in this paper, we further extensively benchmark SCIENCEQA with a wide range of attention-based [1, 33, 21, 9] and Transformer-based [30, 26, 27, 7] methods.
31
+
32
+ Datasets for science problems. Science problem solving is a challenging task that requires an AI system not only to understand the multimodal information from the science curriculum but also to reason about how to answer the domain-specific questions. Current science problem datasets such as AI2D [17], DVQA [16], VLQA [52], and FOODWEDS [24] have contributed to multimodal reasoning in the scientific domain. For example, a portion of VLQA contains multimodal questions on science subjects. These datasets, however, lack annotated explanations for the answers to reveal the reasoning steps. Some other datasets annotate the answers in the forms of supporting facts [37, 20], entailment trees [6], explanation graphs [13], reasoning chains [14]. However, these datasets are restricted to the single text modality with small data scales and limited topics. Instead, our SCIENCEQA annotates the answers with grounded lectures and explanations. Besides, SCIENCEQA features a richer domain diversity across 3 subjects, 26 topics, 127 categories, and 379 skills.
33
+
34
+ Learning from explanations and few-shot learning. Explanations help humans understand a task better, and there have been several attempts to show the same for models. For example, the learning from instruction paradigm [40, 43, 53, 39, 45, 25], where the task level explanation is provided in the form of instruction, improves model performance significantly. An example of learning from explanations in the scientific domain is proposed in [51] where the model interprets demonstrative solutions to solve geometry problems. Recently, there has been a surge of interest in few-shot learning, where language models learn a specific task from a few examples [46, 3]. For instance, [42, 54, 34] find that explanations in the format of the chain of thought can improve language models’ reasoning ability in few-shot learning. In this paper, we show that the chain of thought boosts the performance of large language models like UnifiedQA [19] if the models generate explanations along with the answer in a fine-tuning way. Furthermore, a few-shot GPT-3 model via chain-of-thought prompting is able to improve the reasoning performance on SCIENCEQA and generate reasonable explanations.
35
+
36
+ # 3 Dataset
37
+
38
+ We collect SCIENCEQA, which is a multimodal multiple-choice science question dataset containing 21,208 examples. An example in SCIENCEQA is shown in Figure 1. Given the science question and multimodal contexts, the task is to select the correct answer from multiple options. Different from existing datasets [50, 17, 52, 31, 24], SCIENCEQA covers diverse topics across three subjects: natural science, social science, and language science. Moreover, most questions are annotated with grounded lectures and detailed explanations. The lecture provides general knowledge that introduces the background information for solving problems of a similar class. The explanation reveals a specific reason for the answer. To effectively answer the questions, a model often needs to be able to understand the multimodal content in the input and extract external knowledge, similar to how humans do. More importantly, the goal of SCIENCEQA is to aid development of a reliable model that is capable of generating a coherent chain of thought when arriving at the correct answer to reveal the multi-step reasoning process. For data collection details, see Appendix A.1.
39
+
40
+ Table 1: Main statistics in SCIENCEQA.
41
+
42
+ <table><tr><td>Statistic</td><td>Number</td></tr><tr><td>Total questions</td><td>21,208</td></tr><tr><td>Questions with text context Questions with image context</td><td>10,220 (48.2%) 10,332 (48.7%)</td></tr><tr><td>* Image of natural format</td><td>~2,960 (14.0%)</td></tr><tr><td>* Image of diagram format</td><td>~7,372 (34.8%)</td></tr><tr><td>Questions with both contexts</td><td></td></tr><tr><td></td><td>6,532 (30.8%)</td></tr><tr><td>Questions without any context</td><td>7,188 (33.9%)</td></tr><tr><td>Questions with a lecture</td><td>17,798 (83.9%)</td></tr><tr><td>Questions with a explanation</td><td>19,202 (90.5%)</td></tr><tr><td>Different questions</td><td>9,122</td></tr><tr><td>Different lectures</td><td>261</td></tr><tr><td>Topic classes</td><td>26</td></tr><tr><td>Category classes</td><td>127</td></tr><tr><td>Skill classes</td><td>379</td></tr><tr><td>Average question length</td><td>12.11</td></tr><tr><td>Average choice length</td><td>4.40</td></tr><tr><td>Average lecture length</td><td>125.06</td></tr><tr><td></td><td></td></tr><tr><td>Average explanation length</td><td>47.66</td></tr></table>
43
+
44
+ ![](images/b2b497f521cd368b69a1f31122293c104dce22ad961c7e9dfc676b45c8d7885f.jpg)
45
+ Figure 2: Question distribution in SCIENCEQA.
46
+
47
+ # 3.1 Data Analysis
48
+
49
+ Key statistics. We randomly split the dataset into training, validation, and test splits with a ratio of 60:20:20. Each split has 12,726, 4,241, and 4,241 examples, respectively. Table 1 shows the main statistics of SCIENCEQA. SCIENCEQA has a large set of different questions, totaling up to 9,122. Out of the 21,208 questions in SCIENCEQA, 10,332 $( 4 8 . 7 \% )$ have an image context, 10,220 $( 4 8 . 2 \% )$ have a text context, and 6,532 $( 3 0 . 8 \% )$ have both. $8 3 . 9 \%$ of the questions are annotated with a lecture, while $9 0 . 5 \%$ of the questions feature an explanation. The cross-combination of these information sources diversifies the problem scenario: sometimes the model is given a lot of information from multiple sources, while at other times, the only source of information is the question itself. This level of complexity is very common in grade-level science exams.
50
+
51
+ (a) Question length distribution of related datasets. SCIENCEQA is distributed more evenly in terms of the number of question words than other datasets.
52
+
53
+ ![](images/a8fc123565ea6029cb4df49cf573e7d0e325e0fd955edb451d415a2ed5f6b8d1.jpg)
54
+ Figure 3: Question length distribution (a) and context distribution in SCIENCEQA (b).
55
+
56
+ ![](images/d728d925e4b6375221b45f3f2e9d01c3b689d03fbaaa6e6abe88d77158aeac8f.jpg)
57
+ (b) Question distribution with different context formats. $6 6 . 1 1 \%$ of the questions in SCIENCEQA have either an image or text context, while $3 0 . 8 0 \%$ have both.
58
+
59
+ Question analysis. SCIENCEQA has a diverse set of science questions. Figure 2 shows a distribution of the first four words in the question text. A large number of question lengths and formats highlight the diversity of SCIENCEQA. The question lengths range from 3 words to 141 words, and the questions in SCIENCEQA have an average length of 12.11 words. The question length distribution is visualized against other VQA datasets in Figure 3 (a). As shown in the diagram, SCIENCEQA’s distribution is flatter than other datasets, spanning more evenly across different question lengths.
60
+
61
+ Context analysis. Figure 3 (b) shows the number and percentage of questions with either an image context, a text context, or both. There are a total of 7,803 unique image contexts and 4,651 unique text contexts. $6 6 . 1 1 \%$ of the questions have at least one type of context information. The image context is in the format of diagrams or natural images, which visualize the critical scenario necessary for question answering or simply illustrate the question for better understanding. Similarly, the textual context can provide either semantically rich information or a simple hint to the question. Therefore, models need to be flexible and general to understand these diverse types of contexts.
62
+
63
+ ![](images/3be2ddf228b4c036aeb745f000cd23f0863b810bbd988dd9e5d2ae35c73eee02.jpg)
64
+ Figure 4: Domain diversity in SCIENCEQA. Each color corresponds to one subject: natural science, social science, and language science. For visual clarity, only the most frequent classes are shown.
65
+
66
+ Domain diversity. Each SCIENCEQA question belongs to one of the three subjects: natural science, social science, and language science. With each subject, questions are categorized first by the topic (Biology, Physics, Chemistry, etc.), then by the category (Plants, Cells, Animals, etc.), and finally by the specific skill (Classify fruits and vegetables as plant parts, Identify countries of Africa, etc.). SCIENCEQA has a total of 26 topics, 127 categories, and 379 skills. The treemap in Figure 4 visualizes the different subjects, topics, and categories and shows that SCIENCEQA questions are very diverse, spanning a wide range of domains.
67
+
68
+ # 3.2 Comparisons with Existing Datasets
69
+
70
+ Table 2 shows a comparison of SCIENCEQA and other science problem datasets. As shown in the table, SCIENCEQA is much larger than most other datasets. SCIENCEQA also has the largest set of images, spans across all 12 grades, contains the longest questions, and has the most diverse input sources. As opposed to limiting the subject to only natural science, SCIENCEQA also includes social science and language science, largely adding to the domain diversity of the dataset. Furthermore, most of the questions in SCIENCEQA are annotated with textual lectures $( 8 3 . 9 \% )$ and explanations $( 9 0 . 5 \% )$ , which reveal the reasoning path to the correct answer. To the best of our knowledge, SCIENCEQA is the first large-scale multimodal science question dataset that annotates the answers with detailed lectures and explanations.
71
+
72
+ Table 2: Statistics for SCIENCEQA and comparisons with existing datasets. #Q: number of questions, #I: number of images, AvgQ: average question length; MaxQ: maximum question length.
73
+
74
+ <table><tr><td></td><td>#Q</td><td>#</td><td>AvgQ MaxQ Grades</td><td></td><td></td><td>Science subjects</td><td>Contexts</td><td>Images</td><td>Lecture Explanation</td><td></td></tr><tr><td>Geometry3K [31]</td><td>3,002</td><td>2,342</td><td>10.1</td><td>46</td><td>6-12</td><td>natural (geometry)</td><td>image</td><td>diagram</td><td>×</td><td>×</td></tr><tr><td>AI2D [17]</td><td>4,563</td><td>4,903</td><td>9.8</td><td>64</td><td>1-6</td><td>natural</td><td>image</td><td>diagram</td><td>×</td><td>×</td></tr><tr><td>FOODWEBS [24]</td><td>~5,000</td><td>~5,00</td><td></td><td>-</td><td>8</td><td>natural (foodweb only)</td><td>image</td><td>diagram</td><td>×</td><td>×</td></tr><tr><td>ARC [5]</td><td>7,787</td><td>0</td><td>20.4</td><td>128</td><td>3-9</td><td>natural</td><td>×</td><td>×</td><td>×</td><td>×</td></tr><tr><td>TQA [18]</td><td>26,260</td><td>3,455</td><td>9.2</td><td>57</td><td>6-8</td><td>natural</td><td>image,text</td><td>diagram</td><td>?</td><td>×</td></tr><tr><td>IconQA [35]</td><td>107,439 96,817</td><td></td><td>8.4</td><td>73</td><td>PreK-3</td><td>math</td><td>visual</td><td>diagram</td><td>×</td><td>×</td></tr><tr><td>WorldTree [13]</td><td>1,680</td><td>0</td><td>-</td><td>1</td><td>3-5</td><td>natural</td><td>×</td><td>×</td><td>×</td><td>√</td></tr><tr><td>OpenBookQA [37]</td><td>5,957</td><td>0</td><td>10.6</td><td>68</td><td>1-6</td><td>natural</td><td>×</td><td>×</td><td>×</td><td>?</td></tr><tr><td>QASC [20]</td><td>9,980</td><td>0</td><td>8.0</td><td>25</td><td>1-9</td><td>natural</td><td>X</td><td>×</td><td>×</td><td>L</td></tr><tr><td>SCIENCEQA (ours)</td><td>21,208</td><td>10,332</td><td>12.1</td><td>141</td><td>1-12</td><td>natural, social,language image,text natural,diagram</td><td></td><td></td><td>√</td><td></td></tr></table>
75
+
76
+ # 4 Baselines and Chain-of-Thought Models
77
+
78
+ In this section, we establish baselines and develop two chain-of-thought models on SCIENCEQA.
79
+
80
+ # 4.1 Baselines
81
+
82
+ Heuristic baselines. The first heuristic baseline is random chance: we randomly select one from the multiple options. Each trial is completed on the whole test set, and we take three different trials for an average result. The second heuristic baseline is human performance. We post the task to Amazon Mechanical Turk and ask workers to answer SCIENCEQA questions. Only workers who obtain a high school or higher degree and pass the qualification examples are qualified for the study. Each worker needs to answer a set of 10 test questions, and each question is answered by three different workers. For more details of the human performance study, see Appendix B.2.
83
+
84
+ Zero-shot and few-shot baselines. We establish the zero-shot baselines on top of UnifiedQA [19] and GPT-3 [4]. The zero-shot setup follows the format of $\mathrm { Q C M } { } \mathbf { A }$ where the input is the concatenation of tokens of the question text (Q), the context text (C), and multiple options (M), while the output is to predict the answer (A) from the option set. We extract the caption from the captioning model based on ViT [7] and GPT-2 [47] for the image as the visual context. In the few-shot setting, we follow the standard prompting [4] where in-context examples from the training set are concatenated before the test instance. These in-context examples serve as an instruction for the language model to adjust to the specific task in SCIENCEQA.
85
+
86
+ Fine-tuning baselines. We first consider the fine-tuning baselines from VQA models [1, 21, 55, 9, 22, 35, 26] proposed in recent years. These VQA baselines take the question, the context, and choices as the textual input, take the image as the visual input, and predict the score distribution over choice candidates via a linear classifier. In addition, we build the fine-tuning baseline on top of the large language model UnifiedQA [19]. UnifiedQA takes the textual information as the input and outputs the answer option. Similarly, the image is converted into a caption that provides the visual semantics for the language model.
87
+
88
+ # 4.2 Language Models with the Chain of Thought
89
+
90
+ A chain of thought refers to a coherent flow of sentences that reveals the premises and conclusion of a reasoning problem [54]. A chain of thought clearly decomposes a multi-hop reasoning task into intermediate steps instead of solving the task in a black-box way. The chain of thought can be the step-by-step thought process [54] before arriving at the final answer or explanations [41] that come after the answer. The annotated lectures and explanations in SCIENCEQA serve as demonstrations of the chain of thought that mimics the multi-step reasoning steps of human beings. In this paper, we study if large language models can generate reasonable explanations as the chain of thought to reveal the thought process when answering SCIENCEQA questions. Further, we explore how the chain of thought can improve the reasoning ability of language models on SCIENCEQA in both few-shot and fine-tuning learning.
91
+
92
+ UnifiedQA with the chain of thought. UnifiedQA [19] is a state of the art model for multi-option question answering. The original architecture of UnifiedQA takes the question and options as the input and outputs a short phrase as the final answer. We make a format modification to develop UnifiedQA with the chain of thought (CoT), i.e., UnifiedQA is fine-tuned to generate a long sequence of text which consists of the answer followed by the lecture and explanation.
93
+
94
+ GPT-3 via chain-of-thought prompting. Recent research work [4, 38, 34] has shown that GPT-3 [4] can perform various tasks when provided with in-context examples in a standard prompt. Take multi-option question answering as an example, the standard prompt [36, 57, 29] builds instructions using in-context examples with components of the question text, options, and the correct answer text. This style of few-shot learning enables the GPT-3 model to answer specific questions without parameter updates. Different from standard prompting, we build GPT-3 via chain-of-thought (CoT) prompting, as shown in Figure 5. To be specific, for each test problem $t$ , we map the prompt instruction $I : \{ I _ { i } \} _ { n } , I _ { t }$ into a textual format where $\{ I _ { i } \} _ { n }$ refers to the instruction set of $n$ -shot in-context examples from the training set, while $I _ { t }$ denotes the test instruction. Instead of the way where the explanation comes before the answer [54], we feed the instruction $I$ into the encoderdecoder model GPT-3 to generate the answer $a$ followed by the lecture lect and explanation exp: $M : \{ I _ { i } \} _ { n } , I _ { t } \to a , l e c t , e x p$ .
95
+
96
+ ![](images/876d55776abed6ad3892ae62fd2151924a63d53a1b4beb077052566aaa63f7d8.jpg)
97
+ Figure 5: Prompt instruction encoding for the test example $t$ in GPT-3 (CoT). The prompt above consists of the instruction $\{ I _ { i } \} _ { 1 }$ for the 1-shot training example and $I _ { t }$ for the test example.
98
+
99
+ # 5 Experiments
100
+
101
+ # 5.1 Experimental Setup
102
+
103
+ Evaluation metrics. The heuristics and VQA baselines treat our SCIENCEQA task as a multi-class classification problem with multiple options and are evaluated with the accuracy metrics. UnifiedQA and GPT-3 treat SCIENCEQA as a text generation problem. So the most similar option is selected as the final prediction to evaluate the question answering accuracy. The generated lectures and explanations are evaluated by automatic metrics [44, 28, 49] and human scores by annotators.
104
+
105
+ Implementation details. The VQA baselines are trained for a maximum number of 50 epochs with a learning rate of $5 e { - 5 }$ . We fine-tune the UnifiedQA for $5 0 k$ iterations and evaluate every $1 k$ iteration. The training process is stopped following the early stopping strategy with a patience period of three evaluations. For GPT-3, we use the text-davinci-002 engine, which is the most capable model version suggested in the official documentation. More details can be found in Appendix B.1.
106
+
107
+ # 5.2 Results for Question Answering
108
+
109
+ Table 3 demonstrates the empirical results for Science Question Answering.
110
+
111
+ VQA baselines. We feed the VQA baseline models with the input of QCM format to predict answers A. Out of all the VQA models we benchmarked, VisualBERT [26, 27] performs the best on average $( 6 1 . 8 7 \% )$ . Interestingly, Patch-TRM [35] beats VisualBERT in natural science (NAT) and language science (LAN), and it also performs better in higher-grade questions $6 7 . 5 0 \%$ v.s. $5 9 . 9 2 \%$ ). However, in the subject of social science (SOC), VisualBERT outperforms Patch-TRM by a large margin $( + 2 2 . 3 9 \% )$ . Such drastic changes in performance might imply that current VQA models are not generalized to process the challenging questions in SCIENCEQA.
112
+
113
+ Language models. We evaluate whether large-scale pretraining on text can help language models learn scientific knowledge and thus perform better on the SCIENCEQA task. For this purpose, we have tried two of the state-of-the-art pre-trained language models: UnifiedQA and GPT-3.
114
+
115
+ (i) UnifiedQA. The results show that without any supervised fine-tuning (zero-shot), UnifiedQA cannot beat any VQA baseline model, while the pretraining does help the model obtain some scientific knowledge to outperform the random baseline. When fine-tuned with the answer labels in SCIENCEQA, UnifiedQABASE reports an accuracy of $7 0 . 1 2 \%$ on average. By further teaching the model to generate the answer along with lecture and explanation, the developed language model with chain-of-thought (UnifiedQABASE (CoT)) brings additional improvements of $+ 3 . 2 1 \%$ $\mathrm { ( Q C M \to A E }$ ) and $+ 3 . 9 9 \%$ ( $\mathrm { Q C M } $ ALE). These results show that generating the chain of thought along with the answer benefits the reasoning ability of language models.
116
+
117
+ (ii) GPT-3. The positive effect of pretraining is also proved by the surprisingly good results from GPT-3 in the same zero-shot setting as UnifiedQA. Without any fine-tuning, GPT-3 already reaches almost the best performance we can get. Interestingly, prompting the GPT-3 with two training examples with only answers results in a negligible difference. However, if we prompt GPT-3 with chain-of-thought prompting (QCM ALE), we obtain the state-of-the-art result so far $( 7 5 . 1 7 \% )$ .
118
+
119
+ Figure 6: One example of the predicted answer along with the chain of thought from GPT-3 (CoT).
120
+
121
+ <table><tr><td>Model</td><td>Learning</td><td>Format</td><td>NAT</td><td>SOC</td><td>LAN</td><td>TXT</td><td>IMG</td><td>NO</td><td>G1-6</td><td>G7-12</td><td>Avg</td></tr><tr><td>Random chance</td><td>-</td><td>M→A</td><td>40.28</td><td>46.13</td><td>29.25</td><td>47.45</td><td>40.08</td><td>33.66</td><td>39.35</td><td>40.67</td><td>39.83</td></tr><tr><td>Qonly [1]</td><td>train set</td><td>Q→A</td><td>41.34</td><td>27.22</td><td>47.00</td><td>41.79</td><td>35.15</td><td>44.60</td><td>39.28</td><td>40.87</td><td>39.85</td></tr><tr><td>C1 only[1]</td><td>train set</td><td>C1→A</td><td>41.34</td><td>29.25</td><td>45.45</td><td>42.33</td><td>36.09</td><td>42.93</td><td>39.21</td><td>41.07</td><td>39.87</td></tr><tr><td>Q+Monly [1]</td><td>train set</td><td>QM→A</td><td>52.66</td><td>51.86</td><td>60.18</td><td>55.57</td><td>50.37</td><td>57.42</td><td>52.53</td><td>57.88</td><td>54.44</td></tr><tr><td>Q+Cr+Monly [1]</td><td>train set</td><td>QCrM→A</td><td>57.28</td><td>49.04</td><td>61.36</td><td>60.46</td><td>52.80</td><td>58.82</td><td>54.44</td><td>60.51</td><td>56.61</td></tr><tr><td>Q+C1+Monly [1]</td><td>train set</td><td>QCiM→A</td><td>58.97</td><td>53.77</td><td>60.45</td><td>62.85</td><td>54.49</td><td>57.63</td><td>56.72</td><td>61.04</td><td>58.26</td></tr><tr><td>MCAN [55]</td><td>train set</td><td>QCM→A</td><td>56.08</td><td>46.23</td><td>58.09</td><td>59.43</td><td>51.17</td><td>55.40</td><td>51.65</td><td>59.72</td><td>54.54</td></tr><tr><td>Top-Down [1]</td><td>train set</td><td>QCM→A</td><td>59.50</td><td>54.33</td><td>61.82</td><td>62.90</td><td>54.88</td><td>59.79</td><td>57.27</td><td>62.16</td><td>59.02</td></tr><tr><td>BAN [21]</td><td>train set</td><td>QCM→A</td><td>60.88</td><td>46.57</td><td>66.64</td><td>62.61</td><td>52.60</td><td>65.51</td><td>56.83</td><td>63.94</td><td>59.37</td></tr><tr><td>DFAF [9]</td><td>train set</td><td>QCM→A</td><td>64.03</td><td>48.82</td><td>63.55</td><td>65.88</td><td>54.49</td><td>64.11</td><td>57.12</td><td>67.17</td><td>60.72</td></tr><tr><td>ViLT [22]</td><td>train set</td><td>QCM→A</td><td>60.48</td><td>63.89</td><td>60.27</td><td>63.20</td><td>61.38</td><td>57.00</td><td>60.72</td><td>61.90</td><td>61.14</td></tr><tr><td>Patch-TRM[35]</td><td>train set</td><td>QCM→A</td><td>65.19</td><td>46.79</td><td>65.55</td><td>66.96</td><td>55.28</td><td>64.95</td><td>58.04</td><td>67.50</td><td>61.42</td></tr><tr><td>VisualBERT [26,27]</td><td>train set</td><td>QCM→A</td><td>59.33</td><td>69.18</td><td>61.18</td><td>62.71</td><td>62.17</td><td>58.54</td><td>62.96</td><td>59.92</td><td>61.87</td></tr><tr><td>UnifiedQAsMALL [48]</td><td>zero-shot</td><td>QCM→A</td><td>47.78</td><td>40.49</td><td>46.00</td><td>50.24</td><td>44.12</td><td>44.39</td><td>45.56</td><td>46.21</td><td>45.79</td></tr><tr><td>UnifiedQABASE [48]</td><td>zero-shot</td><td>QCM→A</td><td>50.13</td><td>44.54</td><td>48.18</td><td>53.08</td><td>48.09</td><td>46.69</td><td>47.58</td><td>50.03</td><td>48.46</td></tr><tr><td>UnifiedQAsMALL [48]</td><td>train set</td><td>QCM→A</td><td>53.77</td><td>58.04</td><td>61.09</td><td>52.10</td><td>51.51</td><td>61.46</td><td>58.22</td><td>53.59</td><td>56.57</td></tr><tr><td>UnifiedQABASE [48]</td><td>train set</td><td>QCM→A</td><td>68.16</td><td>69.18</td><td>74.91</td><td>63.78</td><td>61.38</td><td>77.84</td><td>72.98</td><td>65.00</td><td>70.12</td></tr><tr><td>UnifiedQABASE (CoT)</td><td>train set</td><td>QCM→AE</td><td>70.60</td><td>74.02</td><td>78.36</td><td>65.69</td><td>64.80</td><td>81.53</td><td>75.48</td><td>69.48</td><td>73.333.21↑</td></tr><tr><td>UnifiedQABASE (CoT)</td><td>train set</td><td>QCM→ALE</td><td>71.00</td><td>76.04</td><td>78.91</td><td>66.42</td><td>66.53</td><td>81.81</td><td>77.06</td><td>68.82</td><td>74.113.99↑</td></tr><tr><td>GPT-3 [4]</td><td>zero-shot</td><td>QCM→A</td><td>75.04</td><td>66.59</td><td>78.00</td><td>74.24</td><td>65.74</td><td>79.58</td><td>76.36</td><td>69.87</td><td>74.04</td></tr><tr><td>GPT-3 [4]</td><td>2-shot</td><td>QCM→A</td><td>74.64</td><td>69.74</td><td>76.00</td><td>74.44</td><td>67.28</td><td>77.42</td><td>76.80</td><td>68.89</td><td>73.97</td></tr><tr><td>GPT-3 (CoT)</td><td>2-shot</td><td>QCM→AE</td><td>76.60</td><td>65.92</td><td>77.55</td><td>75.51</td><td>66.09</td><td>79.58</td><td>78.49</td><td>67.63</td><td>74.610.64↑</td></tr><tr><td>GPT-3 (CoT)</td><td>2-shot</td><td>QCM→ALE</td><td>75.44</td><td>70.87</td><td>78.09</td><td>74.68</td><td>67.43</td><td>79.93</td><td>78.23</td><td>69.68</td><td>75.171.20↑</td></tr><tr><td>Human</td><td>-</td><td>QCM→A</td><td>90.23</td><td>84.97</td><td>87.48</td><td>89.60</td><td>87.50</td><td>88.10</td><td>91.59</td><td>82.42</td><td>88.40</td></tr></table>
122
+
123
+ Table 3: Evaluation of baselines over different classes in accuracy $( \% )$ . Model names: $\mathrm { Q } =$ question, $\mathbf { M } =$ multiple options, $\mathbf { C } =$ context, $\mathrm { C } _ { T } =$ text context, $\mathrm { C } _ { I } =$ image context, $\mathbf { C o T = }$ chain of thought. Format names: $\mathbf { A } =$ answer, $\mathbf { A } \mathbf { E } =$ answer with explanation, $\mathbf { A L E = }$ answer with lecture and explanation. Question classes: $\mathbf { N A T } =$ natural science, ${ \bf S O C = }$ social science, $\mathrm { L A N } =$ language science, $\mathrm { T X T = }$ text context, $\mathbf { I M G } =$ image context, ${ \mathrm { N O } } =$ no context, G1- $\cdot 6 =$ grades 1-6, G7- $\cdot 1 2 =$ grades 7-12. Segments 1: Random chance; Segment 2: Ablation studies on top of Top-Down; Segment 3: VQA baselines; Segment 4: UnifiedQA baselines and UnifiedQA with CoT; Segment 5: GPT-3 baselines and GPT-3 with CoT; Segment 6: Average human performance.
124
+
125
+ Question: What do these two changes have in common?\n
126
+ bleaching clothes\n
127
+ a piece of apple turning brown\n
128
+ Options: (A) Both are only physical changes. (B) Both are caused by cooling. (C) Both are chemical changes. (D) Both are caused by heating. $\backslash \mathsf { n }$
129
+ Answer: The answer is C. BECAUSE: A physical change is a change to a substance that does not change what the substance is. A physical change only changes the substance’s physical properties, such as its size, shape, or color.\n
130
+ A chemical change is a change to a substance that changes what the substance is. A chemical change changes the substance’s chemical properties, such as its chemical structure. $\backslash \mathsf { n }$
131
+ The changes that you listed are both chemical changes.\n
132
+ When you bleach clothes, the chemical structure of the fabric changes. This change makes the fabric less likely to hold color. $\backslash \mathsf { n }$ When a piece of fruit turns brown, the chemical structure of the fruit changes. This change makes the fruit taste different.
133
+
134
+ Human performance. Humans outperform all benchmarks consistently across question classes, context types, and grades, e.g., a $2 0 . 0 7 \%$ gap for questions with the image context (IMG) between humans and our best performing model. The gap is to be filled by future research on multimodal reasoning for scientific question answering.
135
+
136
+ # 5.3 Results for Generated Explanations
137
+
138
+ One prediction example of GPT-3 (CoT) is visualized in Figure 6. We can see that GPT-3 (CoT) predicts the correct answer and generates a reasonable lecture and explanation to mimic the human thought process. We further report automatic metrics (BLEU-1/4 [44], ROUGE-L [44], and (sentence)
139
+
140
+ Similarity [49] to evaluate the generated lectures and explanations, as shown in Table 4. The Similarity metric computes the cosine-similarity of semantic embeddings between two sentences based on the Sentence-BERT network [49]. The results show that UnifiedQABASE (CoT) generates the most similar explanations to the given ones. However, it’s commonly agreed that automatic evaluation of generated texts only provides a partial view and has to be complemented by a human study. By asking annotators to rate the relevance, correctness, and completeness of generated explanations, we find that the explanations generated by GPT-3 (CoT) conform best to human judgment.
141
+
142
+ <table><tr><td>Model</td><td>Format</td><td>BLEU-1</td><td>BLEU-4 ROUGE-L</td><td></td><td>Similarity</td><td>Relevant Correct Complete</td><td>Gold</td></tr><tr><td>UnifiedQABASE :(CoT)</td><td>QCM→ALE</td><td>0.397 0.370</td><td>0.714</td><td>0.811</td><td>80.4%</td><td>76.6% 76.1%</td><td>56.9%</td></tr><tr><td>GPT-3 (CoT)</td><td>QCM→AE</td><td>0.234 0.048</td><td>0.351</td><td>0.561</td><td>76.9%</td><td>73.0% 70.5%</td><td>52.5%</td></tr><tr><td>GPT-3 (CoT)</td><td>QCM→ALE</td><td>0.192 0.052</td><td>0.323</td><td>0.595</td><td>88.5%</td><td>78.8% 84.5%</td><td>65.2%</td></tr></table>
143
+
144
+ Table 4: Automatic metrics (BLEU-1/4, ROUGE-L, Similarity) and human evaluation of generated explanations. Note that a gold explanation refers to one that is relevant, correct, and complete.
145
+
146
+ # 5.4 Analysis
147
+
148
+ Blind studies. Blind studies are conducted on top of the modification of the full model, Top-Down [1]. The results achieved in blind studies of Q only and $\mathrm { C } _ { I }$ only are close to random chance, showing that the SCIENCEQA dataset is robust and reliable in distribution. The performance drops in $\mathbf { Q } { + } \mathbf { M }$ only, $\mathrm { Q + C } _ { T } { + } \mathrm { M }$ only, and $\mathrm { Q + C } _ { I } + \mathrm { M }$ only indicate that all input components provide critical information for answering SCIENCEQA questions.
149
+
150
+ Prompt types. We study the effect of prompt types and visualize the comparison in Figure 7 (a). It shows that prompting the GPT-3 model with both lectures and explanations $( \mathrm { Q C M } { } \mathrm { A L E }$ ) results in the highest accuracy on average and the smallest variance. In contrast, prompting with only explanations $( \mathrm { Q C M } { } \mathrm { A E }$ ) gives the largest variance, resulting in a less stable model.
151
+
152
+ ![](images/a2766859334855e5040f180d65c4fbbe5a8e73d5405ce43a36b1af8c81c655d0.jpg)
153
+ (a) Acc. v.s. different prompts with 4-shot examples.
154
+ (b) Acc. v.s. different # of training examples.
155
+ Figure 7: Accuracy of GPT-3 (CoT) cross different prompt types (a) and # of training examples (b).
156
+
157
+ Number of in-context examples. In Figure 7 (b), we further investigate how different numbers of training examples encoded in prompts can affect the prediction accuracy. The $\mathrm { Q C M } { } \mathrm { A L E }$ prompt type outperforms or performs comparably to the $\mathrm { Q C M } { } \mathbf { A }$ type with all numbers of examples. And we observe the peak performance of $\mathrm { Q C M } .$ ALE with 2 training examples being prompted. After that, the accuracy goes down as more training examples are added to the model.
158
+
159
+ Dynamic sampling. In Table 5, instead of random sampling, we try to dynamically select the in-context examples to prompt with the same class as the test sample. However, slight differences in prediction accuracy are observed when comparing them to simple random sampling.
160
+
161
+ <table><tr><td>Prompt type</td><td>Sampling</td><td>Acc.(%)</td></tr><tr><td>QCM→ALE</td><td>Dynamic (same topic)</td><td>75.15</td></tr><tr><td>QCM→ALE</td><td>Dynamic (same category)</td><td>74.58</td></tr><tr><td>QCM→ALE</td><td>Dynamic (same skill)</td><td>75.10</td></tr></table>
162
+
163
+ Table 5: Dynamic sampling for GPT-3 (CoT).
164
+
165
+ Upper bound. We search the upper bound of the GPT-3 accuracy by feeding the gold lecture and explanation in the test prompt. As reported in Table 6, $\mathrm { Q C M E ^ { * } { } A }$ outperforms the $\mathrm { Q C M } { } \mathrm { A L E }$ baseline by $1 8 . 8 6 \%$ and $\mathrm { Q C M L E ^ { * } { } A }$ outperforms $\mathrm { Q C M } { } \mathrm { A L E }$ by $1 8 . 9 6 \%$ , indicating a potential improvement direction by generating correct explanations before answering science questions.
166
+
167
+ Table 6: Upper bound of GPT-3 (CoT).
168
+
169
+ <table><tr><td>Prompt type</td><td>Sampling</td><td>Acc.(%)</td></tr><tr><td>QCML*→A</td><td>Random</td><td>73.59</td></tr><tr><td>QCML*→AE</td><td>Random</td><td>74.32</td></tr><tr><td>QCME*→A</td><td>Random</td><td>94.0318.86↑</td></tr><tr><td>QCMLE*→A</td><td>Random</td><td>94.1318.96↑</td></tr><tr><td>QCM→ALE</td><td>Random</td><td>75.17</td></tr></table>
170
+
171
+ <table><tr><td>Prompt type</td><td>Sampling</td><td>Acc.(%)</td></tr><tr><td>QCM→LA</td><td>Random</td><td>60.6</td></tr><tr><td>QCM→EA</td><td>Random</td><td>56.0</td></tr><tr><td>QCM→LEA</td><td>Random</td><td>55.4</td></tr><tr><td>QCM→ELA</td><td>Random</td><td>51.5</td></tr><tr><td>QCM→ALE</td><td>Random</td><td>73.6</td></tr></table>
172
+
173
+ Table 7: Different positions of L/E for GPT-3 (CoT).
174
+
175
+ Positions of lectures and explanations. We study the performance of GPT-3 (CoT) in terms of different positions of lectures and explanations on 1,000 test examples. The results are shown in Table 7. There could be huge accuracy decreases if GPT-3 (CoT) predicts lectures and explanations before answers. It is mainly because if GPT-3 (CoT) is formulated to generate the long lecture and explanation first, there is a greater chance that it will stop generating the prediction early or use up the maximum token limits before obtaining the required answer.
176
+
177
+ CoT learns with fewer data. To study if the chain of thought helps language models learn more efficiently, we report the accuracies of UnifiedQA and UnifiedQA (CoT) fine-tuned on different sizes of the training set in Figure 8. UnifiedQA (CoT) benefits language models by learning the coherent reasoning path when answering questions, resulting in similar accuracy with fewer training examples.
178
+
179
+ Error analysis. GPT-3 via chain-of-thought prompting obtains promising results but still fails to answer a wide range of challenging questions in SCIENCEQA. See examples of failure cases in Appendix B.4. The failure cases can be classified into two types: (a) the model fails to understand the multimodal inputs and lacks domain-specific knowledge to arrive at the correct answer; (b) the model generates the wrong chain of thought with irrelevant, incorrect, or incomplete information.
180
+
181
+ ![](images/937c2ce21b0f22e8bf103dd8666bbdfba8582936e413aad8da0c9300e4b3adb9.jpg)
182
+ Figure 8: UnifiedQA (CoT) learns efficiently with fewer training examples.
183
+
184
+ # 6 Discussion and Conclusion
185
+
186
+ In this paper, we propose SCIENCEQA, a dataset that features 21,208 multi-option questions with multimodal contexts from the science curriculum. To the best of our knowledge, SCIENCEQA is the first large-scale multimodal science dataset where most questions are annotated with corresponding lectures and explanations. We establish various baselines, including recent VQA models and large language models on SCIENCEQA. We further study if language models can generate reasonable explanations and then benefit the reasoning ability. Experiments show that UnifiedQA with the chain of thought can achieve an improvement of $3 . 9 9 \%$ and few-shot GPT-3 via chain-of-thought (CoT) prompting can obtain a satisfactory accuracy of $7 5 . 1 7 \%$ on SCIENCEQA. $6 5 . 2 \%$ of the generated explanations from GPT-3 (CoT) meet the gold standard by human evaluations.
187
+
188
+ # 7 Acknowledgment
189
+
190
+ We would like to thank the anonymous reviewers for their valuable comments and suggestions. We would also like to thank Xiaodan Liang for insightful discussions on dataset collection. We thank our colleagues at The Allen Institute of AI (AI2), Jiasen Lu and Jungo Kasai for helpful discussions. The work does not relate to Liang Qiu’s position at Amazon Alexa.
191
+
192
+ # References
193
+
194
+ [1] Peter Anderson, Xiaodong He, Chris Buehler, Damien Teney, Mark Johnson, Stephen Gould, and Lei Zhang. Bottom-up and top-down attention for image captioning and visual question answering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
195
+ [2] Stanislaw Antol, Aishwarya Agrawal, Jiasen Lu, Margaret Mitchell, Dhruv Batra, C Lawrence Zitnick, and Devi Parikh. Vqa: Visual question answering. In Proceedings of the IEEE international conference on computer vision (CVPR), pages 2425–2433, 2015.
196
+
197
+ [3] Jonathan Bragg, Arman Cohan, Kyle Lo, and Iz Beltagy. Flex: Unifying evaluation for few-shot nlp. Advances in Neural Information Processing Systems (NeurIPS), 34, 2021.
198
+
199
+ [4] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems (NeurIPS), 33:1877–1901, 2020.
200
+
201
+ [5] Peter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. Think you have solved question answering? try arc, the ai2 reasoning challenge. arXiv preprint arXiv:1803.05457, 2018.
202
+
203
+ [6] Bhavana Dalvi, Peter Jansen, Oyvind Tafjord, Zhengnan Xie, Hannah Smith, Leighanna Pipatanangkura, and Peter Clark. Explaining answers with entailment trees. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2021.
204
+
205
+ [7] 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 The International Conference on Learning Representations (ICLR), 2021.
206
+
207
+ [8] Feng Gao, Qing Ping, Govind Thattai, Aishwarya Reganti, Ying Nian Wu, and Prem Natarajan. Transformretrieve-generate: Natural language-centric outside-knowledge visual question answering. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 5067–5077, June 2022.
208
+
209
+ [9] Peng Gao, Zhengkai Jiang, Haoxuan You, Pan Lu, Steven CH Hoi, Xiaogang Wang, and Hongsheng Li. Dynamic fusion with intra-and inter-modality attention flow for visual question answering. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 6639–6648, 2019.
210
+
211
+ [10] Peng Gao, Hongsheng Li, Shuang Li, Pan Lu, Yikang Li, Steven CH Hoi, and Xiaogang Wang. Questionguided hybrid convolution for visual question answering. In The European Conference on Computer Vision (ECCV), pages 469–485, 2018.
212
+
213
+ [11] Yash Goyal, Tejas Khot, Douglas Summers-Stay, Dhruv Batra, and Devi Parikh. Making the V in VQA matter: Elevating the role of image understanding in Visual Question Answering. In Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
214
+
215
+ [12] Drew A Hudson and Christopher D Manning. Gqa: A new dataset for real-world visual reasoning and compositional question answering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 6700–6709, 2019.
216
+
217
+ [13] Peter A Jansen, Elizabeth Wainwright, Steven Marmorstein, and Clayton T Morrison. Worldtree: A corpus of explanation graphs for elementary science questions supporting multi-hop inference. arXiv preprint arXiv:1802.03052, 2018.
218
+
219
+ [14] Harsh Jhamtani and Peter Clark. Learning to explain: Datasets and models for identifying valid reasoning chains in multihop question-answering. arXiv preprint arXiv:2010.03274, 2020.
220
+
221
+ [15] Justin Johnson, Bharath Hariharan, Laurens van der Maaten, Li Fei-Fei, C Lawrence Zitnick, and Ross Girshick. Clevr: A diagnostic dataset for compositional language and elementary visual reasoning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 2901–2910, 2017.
222
+
223
+ [16] Kushal Kafle, Brian Price, Scott Cohen, and Christopher Kanan. Dvqa: Understanding data visualizations via question answering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 5648–5656, 2018.
224
+
225
+ [17] Aniruddha Kembhavi, Mike Salvato, Eric Kolve, Min Joon Seo, Hannaneh Hajishirzi, and Ali Farhadi. A diagram is worth a dozen images. In Proceedings of the European Conference on Computer Vision (ECCV), 2016.
226
+
227
+ [18] Aniruddha Kembhavi, Minjoon Seo, Dustin Schwenk, Jonghyun Choi, Ali Farhadi, and Hannaneh Hajishirzi. Are you smarter than a sixth grader? textbook question answering for multimodal machine comprehension. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 4999–5007, 2017.
228
+
229
+ [19] Daniel Khashabi, Sewon Min, Tushar Khot, Ashish Sabharwal, Oyvind Tafjord, Peter Clark, and Hannaneh Hajishirzi. Unifiedqa: Crossing format boundaries with a single qa system. In Findings of the Association for Computational Linguistics (EMNLP), pages 1896–1907, 2020.
230
+
231
+ [20] Tushar Khot, Peter Clark, Michal Guerquin, Peter Alexander Jansen, and Ashish Sabharwal. Qasc: A dataset for question answering via sentence composition. ArXiv, abs/1910.11473, 2020.
232
+ [21] Jin-Hwa Kim, Jaehyun Jun, and Byoung-Tak Zhang. Bilinear attention networks. In Advances in Neural Information Processing Systems (NeurIPS), pages 1571–1581, 2018.
233
+ [22] Wonjae Kim, Bokyung Son, and Ildoo Kim. Vilt: Vision-and-language transformer without convolution or region supervision. In Proceedings of the 38th International Conference on Machine Learning (ICML), pages 5583–5594, 2021.
234
+ [23] Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A Shamma, et al. Visual genome: Connecting language and vision using crowdsourced dense image annotations. International Journal of Computer Vision (IJCV), pages 32–73, 2017.
235
+ [24] Jayant Krishnamurthy, Oyvind Tafjord, and Aniruddha Kembhavi. Semantic parsing to probabilistic programs for situated question answering. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 160–170, 2016.
236
+ [25] Andrew K Lampinen, Ishita Dasgupta, Stephanie CY Chan, Kory Matthewson, Michael Henry Tessler, Antonia Creswell, James L McClelland, Jane X Wang, and Felix Hill. Can language models learn from explanations in context? arXiv preprint arXiv:2204.02329, 2022.
237
+ [26] Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. Visualbert: A simple and performant baseline for vision and language. arXiv preprint arXiv:1908.03557, 2019.
238
+ [27] Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. What does bert with vision look at? In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics (ACL), pages 5265–5275, 2020.
239
+ [28] Chin-Yew Lin. Rouge: A package for automatic evaluation of summaries. In Text summarization branches out, pages 74–81, 2004.
240
+ [29] Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. What makes good in-context examples for gpt-3? arXiv preprint arXiv:2101.06804, 2021.
241
+ [30] Jiasen Lu, Dhruv Batra, Devi Parikh, and Stefan Lee. Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. In Advances in Neural Information Processing Systems (NeurIPS), pages 13–23, 2019.
242
+ [31] Pan Lu, Ran Gong, Shibiao Jiang, Liang Qiu, Siyuan Huang, Xiaodan Liang, and Song-Chun Zhu. Intergps: Interpretable geometry problem solving with formal language and symbolic reasoning. In The 59th Annual Meeting of the Association for Computational Linguistics (ACL), 2021.
243
+ [32] Pan Lu, Lei Ji, Wei Zhang, Nan Duan, Ming Zhou, and Jianyong Wang. R-vqa: learning visual relation facts with semantic attention for visual question answering. In The ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (SIGKDD), pages 1880–1889, 2018.
244
+ [33] Pan Lu, Hongsheng Li, Wei Zhang, Jianyong Wang, and Xiaogang Wang. Co-attending free-form regions and detections with multi-modal multiplicative feature embedding for visual question answering. In The AAAI Conference on Artificial Intelligence (AAAI), 2018.
245
+ [34] Pan Lu, Liang Qiu, Kai-Wei Chang, Ying Nian Wu, Song-Chun Zhu, Tanmay Rajpurohit, Peter Clark, and Ashwin Kalyan. Dynamic prompt learning via policy gradient for semi-structured mathematical reasoning. arXiv preprint arXiv:2209.14610, 2022.
246
+ [35] Pan Lu, Liang Qiu, Jiaqi Chen, Tony Xia, Yizhou Zhao, Wei Zhang, Zhou Yu, Xiaodan Liang, and Song-Chun Zhu. Iconqa: A new benchmark for abstract diagram understanding and visual language reasoning. In The 35th Conference on Neural Information Processing Systems (NeurIPS) Track on Datasets and Benchmarks, 2021.
247
+ [36] Yao Lu, Max Bartolo, Alastair Moore, Sebastian Riedel, and Pontus Stenetorp. Fantastically ordered prompts and where to find them: Overcoming few-shot prompt order sensitivity. arXiv preprint arXiv:2104.08786, 2021.
248
+ [37] Todor Mihaylov, Peter Clark, Tushar Khot, and Ashish Sabharwal. Can a suit of armor conduct electricity? a new dataset for open book question answering. Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2018.
249
+ [38] Swaroop Mishra, Matthew Finlayson, Pan Lu, Leonard Tang, Sean Welleck, Chitta Baral, Tanmay Rajpurohit, Oyvind Tafjord, Ashish Sabharwal, Peter Clark, and Ashwin Kalyan. Lila: A unified benchmark for mathematical reasoning. In The 2022 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2022.
250
+ [39] Swaroop Mishra, Daniel Khashabi, Chitta Baral, Yejin Choi, and Hannaneh Hajishirzi. Reframing instructional prompts to gptk’s language. ACL Findings, 2021.
251
+ [40] Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi. Cross-task generalization via natural language crowdsourcing instructions. The 59th Annual Meeting of the Association for Computational Linguistics (ACL), 2021.
252
+ [41] Sharan Narang, Colin Raffel, Katherine Lee, Adam Roberts, Noah Fiedel, and Karishma Malkan. Wt5?! training text-to-text models to explain their predictions. arXiv preprint arXiv:2004.14546, 2020.
253
+ [42] Maxwell Nye, Anders Johan Andreassen, Guy Gur-Ari, Henryk Michalewski, Jacob Austin, David Bieber, David Dohan, Aitor Lewkowycz, Maarten Bosma, David Luan, et al. Show your work: Scratchpads for intermediate computation with language models. arXiv preprint arXiv:2112.00114, 2021.
254
+ [43] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02155, 2022.
255
+ [44] 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 of the Association for Computational Linguistics (ACL), pages 311–318, 2002.
256
+ [45] Mihir Parmar, Swaroop Mishra, Mirali Purohit, Man Luo, Murad Mohammad, and Chitta Baral. InBoXBART: Get instructions into biomedical multi-task learning. In Findings of the Association for Computational Linguistics: NAACL 2022, pages 112–128, Seattle, United States, July 2022. Association for Computational Linguistics.
257
+ [46] Ethan Perez, Douwe Kiela, and Kyunghyun Cho. True few-shot learning with language models. Advances in Neural Information Processing Systems (NeurIPS), 34, 2021.
258
+ [47] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
259
+ [48] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research (JMLR), 21:1–67, 2020.
260
+ [49] Nils Reimers and Iryna Gurevych. Sentence-bert: Sentence embeddings using siamese bert-networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing (EMNLP). Association for Computational Linguistics, 11 2019.
261
+ [50] Mrinmaya Sachan, Kumar Dubey, and Eric Xing. From textbooks to knowledge: A case study in harvesting axiomatic knowledge from textbooks to solve geometry problems. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 773–784, 2017.
262
+ [51] Mrinmaya Sachan and Eric Xing. Learning to solve geometry problems from natural language demonstrations in textbooks. In Proceedings of the 6th Joint Conference on Lexical and Computational Semantics (\* SEM 2017), pages 251–261, 2017.
263
+ [52] Shailaja Keyur Sampat, Yezhou Yang, and Chitta Baral. Visuo-lingustic question answering (vlqa) challenge. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings (EMNLP), pages 4606–4616, 2020.
264
+ [53] Jason Wei, Maarten Bosma, Vincent Y Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M Dai, and Quoc V Le. Finetuned language models are zero-shot learners. The International Conference on Learning Representations (ICLR), 2021.
265
+ [54] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022.
266
+ [55] Zhou Yu, Jun Yu, Yuhao Cui, Dacheng Tao, and Qi Tian. Deep modular co-attention networks for visual question answering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 6281–6290, 2019.
267
+ [56] Peng Zhang, Yash Goyal, Douglas Summers-Stay, Dhruv Batra, and Devi Parikh. Yin and Yang: Balancing and answering binary visual questions. In Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
268
+ [57] Zihao Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In International Conference on Machine Learning (ICML), pages 12697–12706. PMLR, 2021.
269
+ [58] Yuke Zhu, Oliver Groth, Michael Bernstein, and Li Fei-Fei. Visual7w: Grounded question answering in images. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
270
+
271
+ # Checklist
272
+
273
+ 1. For all authors...
274
+
275
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
276
+ (b) Did you describe the limitations of your work? [Yes] Yes, we did the error analysis in Section 5.4 and discussed the limitations of the work in Appendix B.4.
277
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] We discussed the broader impacts in Appendix B.5.
278
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
279
+
280
+ 2. If you are including theoretical results...
281
+
282
+ (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]
283
+
284
+ 3. If you ran experiments...
285
+
286
+ (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 included 100 data examples and the data visualizer tool in the supplemental material. The whole dataset and code will be available at https://scienceqa.github.io.
287
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.1 and Appendix B.1 for experimental details.
288
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We reported the error bars for GPT-3 (CoT) experiments in Figure 7, where each experiment was repeated four times.
289
+ (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] We discussed compute resources in Appendix B.1.
290
+
291
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
292
+
293
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We collected the SCIENCEQA dataset from https://www.ixl.com/. The copyright belongs to IXL.
294
+ (b) Did you mention the license of the assets? [Yes] SCIENCEQA is under the CC BY-NCSA 4.0 license and is used for non-commercial research purposes.
295
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We included data examples and a visualizer tool in the supplemental material. The dataset will be available at https://scienceqa.github.io.
296
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
297
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] The collected data does not contain personally identifiable information or offensive content.
298
+
299
+ 5. If you used crowdsourcing or conducted research with human subjects...
300
+
301
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [Yes] We included screenshots of the instructions in Appendix B.2 and B.3.
302
+
303
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
304
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes] We included the monetary compensation details in Appendix B.2 and B.3.
md/dev/HtqnVSCj3q/HtqnVSCj3q.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/KWCZfuqshd/KWCZfuqshd.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Real-World Robot Learning with Masked Visual Pre-training
2
+
3
+ Ilija Radosavovic∗ Tete Xiao∗ Stephen James Pieter Abbeel Jitendra Malik† Trevor Darrell†
4
+
5
+ University of California, Berkeley
6
+
7
+ Abstract: In this work, we explore self-supervised visual pre-training on images from diverse, in-the-wild videos for real-world robotic tasks. Like prior work, our visual representations are pre-trained via a masked autoencoder (MAE), frozen, and then passed into a learnable control module. Unlike prior work, we show that the pre-trained representations are effective across a range of real-world robotic tasks and embodiments. We find that our encoder consistently outperforms CLIP (up to $7 5 \%$ ), supervised ImageNet pre-training (up to $8 1 \%$ ), and training from scratch (up to $81 \%$ ). Finally, we train a 307M parameter vision transformer on a massive collection of $4 . 5 { \mathrm { M } }$ images from the Internet and egocentric videos, and demonstrate clearly the benefits of scaling visual pre-training for robot learning.
8
+
9
+ Keywords: Self-supervised Learning, Visual Representations, Robot Learning
10
+
11
+ # 1 Introduction
12
+
13
+ Learning representations with large neural networks is the workhorse of modern deep learning. This has enabled impressive results in computer vision [1, 2], natural language processing [3, 4, 5], and audio generation [6, 7]. How can we transfer the success stories of representation learning to robotics? We can approach this from two ends: shared representations on the perception side or shared representations on the action side. Our focus in this paper is on shared visual representations.
14
+
15
+ Of course, the devil is in the details. Recent developments in the field of visual learning have made this more feasible: (1) the use of diverse, real-world data from the Internet and egocentric videos, (2) self-supervised objectives that do not overly rely on data augmentations or other forms of strong human-designed priors, (3) scalable and high-capacity transformer models [8, 9], and (4) training of control policies on top of frozen visual representations. In our recent work [10], we have shown that this recipe for self-supervised visual pre-training is effective for motor control in simulation.
16
+
17
+ In this paper, we show that this framework is effective for real-world robotic tasks as well (Figure 1). We build on our prior work, but make significant advances in terms of data scale and diversity $( 7 \times$ larger), model size $1 5 \times$ bigger), and real-world experiments (extensive real robot evaluations).
18
+
19
+ In particular, we train self-supervised visual representations on real-world images and videos from the Internet [11, 12, 13] and egocentric video datasets [14, 15]. We leverage the masked autoencoders [16] that learn visual representations by masked prediction. The hope is that, by learning to predict the missing content in real-world images, the model will learn useful properties of the visual world that will enable it to learn to perform real-world robotic tasks. Given the pre-trained vision encoder, we freeze the encoder and learn control policies on top. The same visual representations are used for all downstream robotic tasks and embodiments. We focus on efficient real-world learning through behavior cloning with a handful of human-provided demonstrations per task (20 - 80).
20
+
21
+ ![](images/3e24ba6ce57701e11f7668f898c8c5ffdf603bbef390659b90fbc076725a6f88.jpg)
22
+ Figure 1: Real-world robot learning with masked visual pre-training. We learn visual representations from a massive collection of Internet and egocentric data. We pre-train representations with masked image modeling, freeze the encoder, and learn control policies for robotic tasks on top.
23
+
24
+ We evaluate our approach in an extensive real-world study and report results from 981 real-world experiments. We consider basic motor control tasks (reach, push, pick), as well as tasks with variations in scenes and objects (Figure 1, right). We find that our approach achieves considerably higher performance than CLIP (up to $7 5 \%$ ), supervised pre-training (up to $8 1 \%$ ), and training from scratch (up to $81 \%$ ). Furthermore, we observe that our representations lead to large improvements in sample complexity, reaching the strongest baseline performance with half the number of demonstrations.
25
+
26
+ In addition, we demonstrate the benefits of scaling visual pre-training for robotics by training a 307M parameter transformer [9] on a massive collection of $4 . 5 { \mathrm { M } }$ images from ImageNet [11], Epic Kitchens [17], Something Something [12], 100 Days of Hands [13], and Ego4D [15] datasets. Importantly, we observe that it is not sufficient to scale the model alone and that larger models require bigger datasets. To the best of our knowledge, ours is the largest vision model deployed for robotics, and demonstrates clearly the benefits of visual pre-training scale for robot learning. We encourage the readers to see the the extended version of this work on arXiv and also to check the project page.
27
+
28
+ # 2 Related Work
29
+
30
+ End-to-end control is concerned with learning to predict robot actions (e.g., joint velocities, endeffector poses, etc) directly from observations [18, 19, 20], without the need to perform explicit 3D pose estimation [21], grasp planning [22], and motion planning [23]. However, these end-to-end approaches tend to be too sample inefficient for real-world training. Some works have tried to find a balance between these explicitly pipelined approaches and end-to-end approaches [24, 25, 26].
31
+
32
+ Supervised pre-training for robotics learns one or more pretext tasks through strong supervision and then transfers the representations to downstream robotic tasks. Lin et al. [27] shows that representations learned from semantic tasks such as detection and segmentation correlate with affordance maps for object manipulation. Shridhar et al. [28] use language-supervised CLIP model [29] for learning language-conditioned imitation policy. In concurrent work, Nair et al. [30] explore pre-training visual representations using time contrastive learning and language descriptions from human annotators. These methods all require expert labels or cross-domain supervision.
33
+
34
+ Self-supervised learning in robotics has been explored in a number of settings: learning a dynamic models [31]; learning visual representations from interaction with the environment [32]; learning vision-based grasping policies [33, 34]; learning visual autoencoders [35]; learning spatiotemporal representations through videos [36, 37]; learning visual correspondence [38]; utilizing non-parametric nearest-neighbor retrieval [39]; and conducting visual self-supervised learning on pre-collected demonstrations [40]. These methods require in-domain data collection, and thus may be difficult to extend beyond the training environment and task. In contrast, our approach uses a large-scale and diverse collection of real-world images and videos, making it more generalizable.
35
+
36
+ ![](images/07da7f98b63876bf5d4968c4241a2cc43d68ccfa314b285c375951a9ce307618.jpg)
37
+ Figure 2: One encoder for all robots and tasks. We train control policies per task, on top of the frozen encoder. The same vision encoder is used for all downstream robotic tasks and embodiments.
38
+
39
+ # 3 Real-World Robot Learning with Masked Visual Pre-training
40
+
41
+ # 3.1 Masked Visual Pre-training
42
+
43
+ Data collection. We first compile a large-scale dataset for learning visual representations. We primarily use Ego4D [15], a massive scale, egocentric dataset from nine countries recorded via portable devices, covering over 3,670 hours of daily-life activities. We combine the Ego4D data with the ImageNet [11], as well as the Hand-object Interaction (HoI) data used in [10], which comprises of the egocentric Epic Kitchens [17] dataset, the YouTube 100 Days of Hands dataset [13], and the crowd-sourced Something-Something dataset [12]. Our training data totals 4.5 million images, $6 . 5 \mathrm { x }$ of the HoI data. We find that a sufficiently large and diverse pre-training dataset to perform the mask image modeling self-supervisory task is critical to scale up the vision backbone for real robot tasks.
44
+
45
+ Self-supervised objective. At the core of our self-supervised representation learning approach is masked image modeling via the masked autoencoders (MAE) [16]. MAE masks out random patches in an image and reconstructs the missing content with a vision transformer (ViT) [9]. A high masking ratio, e.g., $7 5 \%$ , and asymmetrical heavy-encoder light-decoder design, are important for learning good visual representations efficiently. Simple and free from dataset or task-specific augmentations [41], MAE is the state-of-the-art self-supervised framework in computer vision [42, 43, 44, 45], and has been demonstrated to work well for motor control tasks in simulation as well [10].
46
+
47
+ Architecture. We use the ViT models as our vision encoders. While the MAE-trained ViT models yield improving performance in vision tasks as model sizes grow [9, 16, 46], previous work [10] does not show improvement from switching a ViT-Small model to the ViT-Base counterpart of $4 \mathbf { x }$ as many parameters. In this work, we scale the model up to the ViT-Large and deploy it on the real robot. The model contains 307M parameters and runs at ${ \sim } 6 4$ gigaflops at input size $2 2 4 \times 2 2 4$ , approximately $1 5 \mathrm { x }$ as many as the commonly adopted ResNet-50 [47], the largest vision model deployed for robotics. As we will show in the experiments, scaling model sizes while training on sufficiently large data leads to consistent performance improvement on downstream robotic tasks.
48
+
49
+ # 3.2 Real-World Robot Learning
50
+
51
+ We learn to perform real-robot tasks through behavior cloning (BC). We collect demonstrations containing trajectories of RGB images from a wrist-mounted camera and the robot’s joint state at each time step. For most of the tasks, we use the motion-tracked HTC Vive VR system to control the end-effector. For some tasks that are difficult to demonstrate via the motion controller, e.g., closing fridge door, we use kinesthetic teaching. Given the recorded demonstrations, we train a control policy that takes in the input image features and proprioceptive states (joint positions) at time step $t$ and predicts the action at time step $t + 1$ . We perform joint position control; we do not use any end-effector information (e.g., the 6-DoF pose). We build on our MVP pipeline [10] and freeze the image encoder throughout the policy learning, which prevents large pre-trained encoders from overfitting to a specific setting or task, and greatly reduces GPU memory footprint and training time.
52
+
53
+ ![](images/1ce482e8bcadc4d497516e080b8305cb6817d7d9b402862c15233920d46c7472.jpg)
54
+ Figure 3: Real-world robotic tasks. We perform extensive real robot evaluations using a 7 DoF robot arm with a parallel jaw gripper. Our tasks include basic motor control skills (reaching a red block, pushing a wooden cube, and picking a yellow cube), variations in scenes (closing a fridge), objects (picking fruits), and scenes and objects (picking a detergent bottle from a cluttered sink).
55
+
56
+ # 4 Experimental Setup
57
+
58
+ In this section we provide implementation details for our approach and describe our evaluation setup.
59
+
60
+ Data. We extract frames from Ego4D, Epic Kitchens, and Something-Something at 0.2 fps, 1fps and 0.3fps, respectively. We then combine the Ego4d with ImageNet and the YouTube 100 Days of Hands dataset. This process yields 2.6M frames from Ego4D, 1.2M images from ImageNet, and 700k HoI images from the rest, a total of $4 . 5 \mathrm { M }$ images. We term the combined dataset as “Ego” for abbreviation. Note that [10] only uses the $7 0 0 \mathrm { k }$ HoI images, excluding the Ego4D and ImageNet.
61
+
62
+ Encoders. We use the standard Vision Transformer (ViT) architecture as the image encoder. We use three models of various sizes: ViT-Small [48], ViT-Base, and ViT-Large models, of 22M, 86M, and 307M parameters, respectively. The ViT-Small model is approximately the same size as the ResNet50 model, while the ViT-Large model has $\sim 1 5 \mathrm { x }$ as many parameters as the ResNet-50 model.
63
+
64
+ Pre-training. We pre-train the models via the MAE framework [16]. The training recipe closely follows [16], with dataset specific settings from [10]. We use the auxiliary dummy classification token for transferring to downstream robotics tasks. We train the MAE models for 400 epochs for the combined Ego dataset; 1600 epochs for the HOI dataset; and 1600 epochs for ImageNet dataset. We use the pre-training recipe in [49] for the study that involves ImageNet supervised models.
65
+
66
+ Controllers. The controller takes in both image features and the robot’s proprioceptive state. We use joint positions as the proprioceptive state without explicitly appending the end-effector pose to the state. We do not use velocity in the state as our low-cost arm does not support true velocity sensing. The controller outputs delta joint angles. The controller’s design closely follows [50], i.e., a four-layer MLP with a SeLU [51] activation following each hidden layer. The hidden size is [256, 128, 64] for most tasks and [512, 256, 128] for the PickSink task. We linearly project the image features and the proprioceptive states to a joint embedding space as the controller’s input.
67
+
68
+ Robot and robotic tasks. We use the low-cost UFACTORY xArm7 robot (a 7-DoF arm) and a 1- DoF parallel jaw gripper. We use the arm’s maximum control frequency of $5 \mathrm { H z }$ for both collecting demonstrations and control. We use a first-person wrist-mounted RealSense camera for all tasks. We do not use depth information from the camera. We consider basic motor control tasks, i.e., ReachBlock, PushCube, and PickCube, and more challenging in-context tasks, i.e., CloseFridge, PickFruit, and PickSink. The tasks are shown in Figure 3 (more details in the next section).
69
+
70
+ Demonstrations. We collect 80 demonstrations per task. We use the motion-tracked HTC Vive VR system for most tasks, except for CloseFridge we use kinematics teaching. We use trajectory replay on the robot for trajectory pruning. We do not use the key-frame information for the learning.
71
+
72
+ Evaluation. We systematically sweep across 16 variations of the environment, e.g., shifting the target object. For consistency and reliability of the study, we use the same 16 variations for all models in an individual task, and evaluate models sequentially at each variation, in order for similar lighting conditions, robot conditions, precise object initial locations, etc (see also the arXiv).
73
+
74
+ ![](images/1fdff47c2fdab1149f467c53f26fe414e19cf8b609be1c38f90df4ca99694046.jpg)
75
+ Figure 4: Comparison to vision encoders. We compare our approach to visual encoders trained with CLIP, supervised learning on the ImageNet, and from scratch on the task at hand. In all cases, we observe that our approach consistently outperforms the baselines by a considerable margin.
76
+
77
+ ![](images/d20275889b914b3d9ef123d27925466f6594a59a4b288e947a89824979dbd6b8.jpg)
78
+ Figure 5: Sample complexity. We show the performance of our approach as the number of demonstrations varies from 20 to 80. CLIP performance at 80 demonstrations is shown with a dashed lined for reference. Our approach is comparable to CLIP using only half the number of demonstrations.
79
+
80
+ # 5 Experimental Results
81
+
82
+ We perform extensive evaluations across a range of visual backbones, real-world robotic tasks, objects, and environments (Figure 3). In total, we report results from 981 real-world experiments.
83
+
84
+ # 5.1 Basic Motor Control
85
+
86
+ We evaluate three basic motor control tasks in visually simple contexts: reaching a red block, pushing a wooden cube, and picking a yellow cube (see Figure 3 for task visualization). These tasks serve as stepping stones for more complex tasks, and the visual representations that can potentially be fundamental for robotics should learn these tasks efficiently. In all cases, we randomize the initial object and robot positions (see arXiv for details about the learning and task setup).
87
+
88
+ Comparison to various vision encoders. In Figure 4 we compare our approach to a set of stateof-the-art vision backbones: CLIP [3] trained on 400M text-image pairs, supervised model trained on the ImageNet, and a model trained from scratch with in-domain demonstration data. For fair comparisons, we use the ViT-Base [9] vision encoder for all methods. We empirically observe that the CLIP encoder performs the best among the baselines, and the ranking order is consistent across the benchmark tasks. Our approach consistently outperforms the baselines by a considerable margin.
89
+
90
+ Sample complexity. In Figure 5 we study the performance of our approach as the number of demonstrations varies from 20 to 80. For reference, we show the performance of the most competitive baseline, CLIP, trained with 80 demonstrations (dashed horizontal line). In aggregate, we observe that our approach reaches CLIP performance while using $50 \%$ fewer demonstrations. This result is a promising signal for using our models for learning more complex robotic tasks, as discussed next.
91
+
92
+ ![](images/075f581ff9d443d36854271944533f19707c445fcd840a3f80b3cc9e0a60a7a7.jpg)
93
+ Figure 6: Variations in scenes and objects. We compare our approach to CLIP on tasks with variations in scenes (closing the fridge), objects (picking fruits), and scenes and objects (picking an object from a cluttered sink). The models are ViT-Base. Our approach considerably outperforms CLIP and the gap is larger than in simpler settings (see Figure 4). This may suggest that our representations capture more precise spatial structure that is helpful for robotic tasks in more realistic contexts.
94
+
95
+ # 5.2 Visually Diverse Scenes and Objects
96
+
97
+ We have previously shown that our approach can learn basic motor control tasks, such as reaching, pushing, and picking, at a higher success rate and better sample complexity than the baseline vision backbones. To focus on the motor control aspect, we used a visually simple environment and basic objects. However, one of the main potential benefits of our approach is that learning visual representations from diverse, real-world images may enable to solve robotic tasks that involve the interaction with everyday objects in more visually complex environments. In this subsection, we evaluate our visual representations on robotic tasks with variations in scenes and objects in more realistic setups.
98
+
99
+ Scene context. We first evaluate our approach in a more realistic scene by considering the task of closing the door of a toy fridge that is left open (termed CloseFridge). We randomize the location of the fridge, which side of the door to close, and initial angle of the door. As shown in Figure 6, bottom-left, the initial configuration of the fridge and the robot vary considerably, which is quite common in everyday settings. Figure 6, top-left, shows that our approach outperforms all baselines.
100
+
101
+ Different objects. Next, we evaluate on a task with a variety of objects. The goal is to pick up eight different fruits that vary in color, shape, and size (termed PickFruit). In each trial, a fruit is selected at random, and both the fruit and the robot’s positions are randomized. The number of training demonstrations remain unchanged, i.e., we provide 10 demonstrations for each fruit. In Figure 6, middle, we show the evaluation results (top) and starting configuration samples (bottom). We see that baselines struggles in this setting while our approach achieves nearly perfect score.
102
+
103
+ Objects in context. Finally, we evaluate our approach on a task that features interacting with objects in everyday contexts. We task the robot with picking a detergent bottle from a cluttered sink (termed PickSink). The task is challenging as the visual configuration of the scene, such as the toy plates, mug cups, and silverware, can vary in unlimited ways, as shown in Figure 6 right We observe that our approach considerably outperforms baseline approaches using the same ViT-B encoder.
104
+
105
+ ![](images/622f83b411b935abe8cc736f96f1839fe79e93ff324384a1bb411e3ac41647b6.jpg)
106
+ Figure 7: Scaling model and data. We study the scaling properties of our approach. We observe that scaling the model size alone from ViT-S to ViT-B while keeping the dataset fixed (HoI image collection; see text for details) does not improve the performance and even hurts (left). However, when we scale both the model and data (our massive Ego image collection; see text for details) we see clear benefits from a larger model. The trend continues when going further from the 86M ViT-B to the 307M ViT-L model (middle & right). Moreover, the gains are larger for harder tasks (right).
107
+
108
+ # 5.3 Scaling Model and Data Size
109
+
110
+ Importantly, our visual pre-training approach uses a self-supervised objective [16] that makes few assumptions about the data distribution, and does not rely on human-designed pretext tasks such as data augmentations. Therefore, the framework is well-suited for pre-training from a massive collection of unlabeled and in-the-wild visual data. Here we study scaling model and data size.
111
+
112
+ We first consider increasing the model capacity. In Figure 7, left, we see that increasing the model size $( { \sim } 4 . 5 \mathrm { x } )$ from ViT-S to ViT-B, while keeping the data size fixed (HOI image collection [10]), does not increase performance and even hurts. This is consistent with the in-simulation results reported in [10]. However, if we also scale the data size from HOI to our massive Ego data collection, ViT-B yields better results. These results suggests that we must scale both the model and the data.
113
+
114
+ In Figure 7, middle & right, we show the performance as a function of model size. Additionally increasing the model size from the 86M parameter ViT-B to the 307M parameter ViT-L leads to further improvements. The gain is larger for the visually more challenging task (PickSink). To the best of our knowledge, our work is the largest vision model deployed to real robot tasks, which clearly demonstrates the benefits of scaling visual pre-training for real-world robot learning.
115
+
116
+ # 5.4 Comparison to Concurrent Work
117
+
118
+ We compare our approach to a concurrent work [30], submitted to the same conference (CoRL 2022). Similarly, it pre-trains visual representations on inthe-wild video data from Ego4D [15]. However, it relies on paired language-video annotations that are available as part of Ego4D. In contrast, our approach is fully self-supervised and makes minimal assumptions about the data distribution, enabling us to leverage massive collections of uncurated data (e.g., from the Internet). In Table 1, we compare our models to the strongest available R3M ResNet-50 model. We observe that our medium-sized ViT-B model outperforms R3M ResNet-50 by a large margin $9 3 . 8 \%$ vs. $3 1 . 3 \%$ ). We also see that our smallest ViT-S model from [10] outperforms it as well $6 8 . 8 \%$ vs. $3 1 . 3 \%$ ).
119
+
120
+ <table><tr><td></td><td>supervision</td><td>params (M)</td><td>success (%)</td></tr><tr><td>R3M</td><td>video-text</td><td>23</td><td>31.3</td></tr><tr><td>CLIP</td><td>image-text</td><td>86</td><td>18.8</td></tr><tr><td rowspan="2">Ours</td><td>image-only</td><td>22</td><td>68.8</td></tr><tr><td></td><td>86 307</td><td>93.8 100.0</td></tr></table>
121
+
122
+ Table 1: Comparison to concurrent work. All of our vision models, trained with imageonly self-supervision, considerably outperform the strongest available R3M [30] model trained on paired video-language labels from Ego4D [15]. The gains are larger for larger models. Evaluated on the PickFruit task.
123
+
124
+ ![](images/ad4d01fbe1c7766222989cc03132691b3acb6ad897210ad361facbdb78fe6f13.jpg)
125
+ Figure 8: Multi-finger hand. We show that our framework readily generalizes to a different robot morphology. We experiment with finger reaching, using seen and unseen objects, and cube flipping.
126
+
127
+ # 5.5 Case Study: Multi-finger Hand
128
+
129
+ Our approach makes no assumptions about the downstream robotic tasks or embodiments. In particular, our policies take pixel images as input and predict joint position angles as actions (rather than, e.g., end-effector pose). In this subsection, we test the generality of our approach by applying it for downstream tasks with a multi-finger Allegro hand (see arXiv for more details on the setup).
130
+
131
+ Visual reaching. We design a reaching task in which the hand learns to reach the top of an object with the tip of the index finger. The object’s position is randomized across the palm. We provide 10 demonstrations for each of the 8 different objects. At test time, we evaluate the trained policy on the 8 seen objects as well as 45 unseen objects (see Figure 8). The success rate is ${ \sim } 5 0 \%$ across both.
132
+
133
+ Visual flipping. Next, we consider a cube flipping task in which the goal is to flip a rubber cube that is placed in the palm. The position of the cube is randomized across the palm. Thus, the policy must rely on visual cues to accomplish the task. In aggregate, we observe a success rate of $50 \%$ across 30 trials. See Figure 8 for example key frames and also check out the videos on the project page.
134
+
135
+ Understanding vision through action. Training policies on top of frozen visual representations enables us to perform studies to understand what the pre-trained visual representations utilize for downstream tasks. Here we first train a policy to reach a yellow cube, but test with objects of different shape and color. First, we find that when given the same shape of different color (wooden cube) or same color and different shape (yellow ball), the policy reaches for the object. Next, when given both the yellow cube and a distractor it reaches for the yellow cube. Finally, when given an object of different shape and color (blue cube) the hand stays still. See project page for videos.
136
+
137
+ # 6 Discussion
138
+
139
+ Limitations. While the scenes and objects used in our study are more realistic than in simpler robotic benchmarks, we still mostly use toy objects in relatively clean lab environments, rather than real objects in real-world scene contexts. Our tasks involve a single object, and do not require the robot to learn feedback control, or to learn multi-step planning. Factors such as robot up-time may influence the results as well. Overcoming these limitations is essential as we move toward developing, benchmarking, and widely deploying pre-trained models for real-world robotic applications.
140
+
141
+ Conclusion. We explore learning visual representations from a massive collection of real-world data and using them for downstream robotic tasks. We pre-train representations with masked modeling, freeze the encoder, and learn control policies on top. We perform extensive evaluations in the real world and show that, across various robotic tasks, our approach leads to higher success rate and better sample complexity than CLIP, supervised ImageNet pre-training, and training from scratch. We further demonstrate the benefits of scaling the model and data size for real world robot learning.
142
+
143
+ # Acknowledgments
144
+
145
+ We gratefully acknowledge the following colleagues for valuable discussions and support of our project: Shankar Sastry for Allegro hand access, Ken Goldberg for feedback and suggestions, Adam Curtis for help with wiring, Kevin Hu for help with Allegro hand retargeting, Erik Rogers for ROS suggestions, Lerrel Pinto for Allegro hand discussions, Raven Huang and Justin Kerr for help with 3D printing, and William Peebles for discussions. This work was supported in part by DARPA Machine Common Sense, LwLL, and RACER programs; ONR MURI program (N00014-21-1-2801); Hong Kong Centre for Logistics Robotics, BMW, as well as BAIR’s industrial alliance programs.
146
+
147
+ # References
148
+
149
+ [1] A. Krizhevsky, I. Sutskever, and G. E. Hinton. Imagenet classification with deep convolutional neural networks. NeurIPS, 2012.
150
+ [2] R. Girshick, J. Donahue, T. Darrell, and J. Malik. Rich feature hierarchies for accurate object detection and semantic segmentation. In CVPR, 2014.
151
+ [3] A. Radford, K. Narasimhan, T. Salimans, and I. Sutskever. Improving language understanding by generative pre-training. 2018.
152
+ [4] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HCT, 2019.
153
+ [5] T. B. Brown, B. Mann, N. Ryder, M. Subbiah, J. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. Language models are few-shot learners. NeurIPS, 2020.
154
+ [6] A. Van Den Oord, S. Dieleman, H. Zen, K. Simonyan, O. Vinyals, A. Graves, N. Kalchbrenner, A. W. Senior, and K. Kavukcuoglu. Wavenet: A generative model for raw audio. SSW, 2016.
155
+ [7] P. Dhariwal, H. Jun, C. Payne, J. W. Kim, A. Radford, and I. Sutskever. Jukebox: A generative model for music. arXiv:2005.00341, 2020.
156
+ [8] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is all you need. In NeurIPS, 2017.
157
+ [9] 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, 2020.
158
+ [10] T. Xiao, I. Radosavovic, T. Darrell, and J. Malik. Masked visual pre-training for motor control. arXiv:2203.06173, 2022.
159
+ [11] 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.
160
+ [12] R. Goyal, S. Ebrahimi Kahou, V. Michalski, J. Materzynska, S. Westphal, H. Kim, V. Haenel, I. Fruend, P. Yianilos, M. Mueller-Freitag, et al. The” something something” video database for learning and evaluating visual common sense. In ICCV, 2017.
161
+ [13] D. Shan, J. Geng, M. Shu, and D. F. Fouhey. Understanding human hands in contact at internet scale. In CVPR, 2020.
162
+ [14] D. Damen, H. Doughty, G. M. Farinella, S. Fidler, A. Furnari, E. Kazakos, D. Moltisanti, J. Munro, T. Perrett, W. Price, et al. Scaling egocentric vision: The epic-kitchens dataset. In ECCV, 2018.
163
+ [15] K. Grauman, A. Westbury, E. Byrne, Z. Chavis, A. Furnari, R. Girdhar, J. Hamburger, H. Jiang, M. Liu, X. Liu, et al. Ego4d: Around the world in 3,000 hours of egocentric video. arXiv:2110.07058, 2021.
164
+ [16] K. He, X. Chen, S. Xie, Y. Li, P. Dollar, and R. Girshick. Masked autoencoders are scalable ´ vision learners. arXiv:2111.06377, 2021.
165
+ [17] D. Damen, H. Doughty, G. M. Farinella, , A. Furnari, J. Ma, E. Kazakos, D. Moltisanti, J. Munro, T. Perrett, W. Price, and M. Wray. Rescaling egocentric vision: Collection, pipeline and challenges for epic-kitchens-100. IJCV, 2021.
166
+ [18] S. Levine, C. Finn, T. Darrell, and P. Abbeel. End-to-end training of deep visuomotor policies. JMLR, 2016.
167
+ [19] S. James, A. J. Davison, and E. Johns. Transferring end-to-end visuomotor control from simulation to real world for a multi-stage task. CoRL, 2017.
168
+ [20] D. Kalashnikov, A. Irpan, P. Pastor, J. Ibarz, A. Herzog, E. Jang, D. Quillen, E. Holly, M. Kalakrishnan, V. Vanhoucke, et al. Scalable deep reinforcement learning for vision-based robotic manipulation. In CoRL, 2018.
169
+ [21] OpenAI, M. Andrychowicz, B. Baker, M. Chociej, R. Jozefowicz, B. McGrew, J. Pachocki, ´ A. Petron, M. Plappert, G. Powell, A. Ray, J. Schneider, S. Sidor, J. Tobin, P. Welinder, L. Weng, and W. Zaremba. Learning dexterous in-hand manipulation. IJRR, 2020.
170
+ [22] A. T. Miller, S. Knoop, H. I. Christensen, and P. K. Allen. Automatic grasp planning using shape primitives. In ICRA, 2003.
171
+ [23] J. J. Kuffner and S. M. LaValle. Rrt-connect: An efficient approach to single-query path planning. In ICRA, 2000.
172
+ [24] A. Zeng, S. Song, S. Welker, J. Lee, A. Rodriguez, and T. Funkhouser. Learning synergies between pushing and grasping with self-supervised deep reinforcement learning. In IROS, 2018.
173
+ [25] A. Zeng, P. Florence, J. Tompson, S. Welker, J. Chien, M. Attarian, T. Armstrong, I. Krasin, D. Duong, V. Sindhwani, et al. Transporter networks: Rearranging the visual world for robotic manipulation. CoRL, 2020.
174
+ [26] S. James and A. J. Davison. Q-attention: Enabling Efficient Learning for Vision-based Robotic Manipulation. RA-L, 2022.
175
+ [27] L. Yen-Chen, A. Zeng, S. Song, P. Isola, and T.-Y. Lin. Learning to see before learning to act: Visual pre-training for manipulation. In ICRA, 2020.
176
+ [28] M. Shridhar, L. Manuelli, and D. Fox. Cliport: What and where pathways for robotic manipulation. In CoRL, 2021.
177
+ [29] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, et al. Learning transferable visual models from natural language supervision. In ICML, 2021.
178
+ [30] S. Nair, A. Rajeswaran, V. Kumar, C. Finn, and A. Gupta. R3m: A universal visual representation for robot manipulation. arXiv:2203.12601, 2022.
179
+ [31] P. Agrawal, A. V. Nair, P. Abbeel, J. Malik, and S. Levine. Learning to poke by poking: Experiential learning of intuitive physics. NeurIPS, 2016.
180
+ [32] L. Pinto, D. Gandhi, Y. Han, Y.-L. Park, and A. Gupta. The curious robot: Learning visual representations via physical interactions. In ECCV, 2016.
181
+ [33] L. Pinto and A. Gupta. Supersizing self-supervision: Learning to grasp from 50k tries and 700 robot hours. In ICRA, 2016.
182
+ [34] S. Levine, P. Pastor, A. Krizhevsky, J. Ibarz, and D. Quillen. Learning hand-eye coordination for robotic grasping with deep learning and large-scale data collection. IJRR, 2018.
183
+ [35] C. Finn, X. Y. Tan, Y. Duan, T. Darrell, S. Levine, and P. Abbeel. Deep spatial autoencoders for visuomotor learning. In ICRA, 2016.
184
+ [36] P. Sermanet, K. Xu, and S. Levine. Unsupervised perceptual rewards for imitation learning. In RSS, 2017.
185
+ [37] P. Sermanet, C. Lynch, Y. Chebotar, J. Hsu, E. Jang, S. Schaal, S. Levine, and G. Brain. Timecontrastive networks: Self-supervised learning from video. In ICRA, 2018.
186
+ [38] P. Florence, L. Manuelli, and R. Tedrake. Self-supervised correspondence in visuomotor policy learning. RA-L, 2019.
187
+ [39] J. Pari, N. Muhammad, S. P. Arunachalam, L. Pinto, et al. The surprising effectiveness of representation learning for visual imitation. arXiv:2112.01511, 2021.
188
+ [40] A. Zhan, P. Zhao, L. Pinto, P. Abbeel, and M. Laskin. A framework for efficient robotic manipulation. arXiv:2012.07975, 2020.
189
+ [41] T. Xiao, X. Wang, A. A. Efros, and T. Darrell. What should not be contrastive in contrastive learning. In ICLR, 2021.
190
+ [42] Y. Li, S. Xie, X. Chen, P. Dollar, K. He, and R. Girshick. Benchmarking detection transfer learning with vision transformers. arXiv:2111.11429, 2021.
191
+ [43] Z. Tong, Y. Song, J. Wang, and L. Wang. Videomae: Masked autoencoders are data-efficient learners for self-supervised video pre-training. arXiv:2203.12602, 2022.
192
+ [44] C. Feichtenhofer, H. Fan, Y. Li, and K. He. Masked autoencoders as spatiotemporal learners. arXiv:2205.09113, 2022.
193
+ [45] R. Bachmann, D. Mizrahi, A. Atanov, and A. Zamir. Multimae: Multi-modal multi-task masked autoencoders. arXiv:2204.01678, 2022.
194
+ [46] X. Zhai, A. Kolesnikov, N. Houlsby, and L. Beyer. Scaling vision transformers. In CVPR, 2022.
195
+ [47] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In CVPR, 2016.
196
+ [48] H. Touvron, M. Cord, M. Douze, F. Massa, A. Sablayrolles, and H. Jegou. Training data- ´ efficient image transformers & distillation through attention. In ICML, 2021.
197
+ [49] T. Xiao, P. Dollar, M. Singh, E. Mintun, T. Darrell, and R. Girshick. Early convolutions help transformers see better. In NeurIPS, 2021.
198
+ [50] V. Makoviychuk, L. Wawrzyniak, Y. Guo, M. Lu, K. Storey, M. Macklin, D. Hoeller, N. Rudin, A. Allshire, A. Handa, et al. Isaac gym: High performance gpu-based physics simulation for robot learning. In NeurIPS, 2021.
199
+ [51] G. Klambauer, T. Unterthiner, A. Mayr, and S. Hochreiter. Self-normalizing neural networks. In NeurIPS, 2017.
md/dev/MAMOi89bOL/MAMOi89bOL.md ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Masked Autoencoders that Listen
2
+
3
+ Po-Yao Huang1 Hu Xu1 Juncheng Li2 Alexei Baevski1 Michael Auli1 Wojciech Galuba1 Florian Metze1 Christoph Feichtenhofer1
4
+
5
+ 1Meta AI 2Carnegie Mellon University
6
+
7
+ # Abstract
8
+
9
+ This paper studies a simple extension of image-based Masked Autoencoders (MAE) [1] to self-supervised representation learning from audio spectrograms. Following the Transformer encoder-decoder design in MAE, our Audio-MAE first encodes audio spectrogram patches with a high masking ratio, feeding only the non-masked tokens through encoder layers. The decoder then re-orders and decodes the encoded context padded with mask tokens, in order to reconstruct the input spectrogram. We find it beneficial to incorporate local window attention in the decoder, as audio spectrograms are highly correlated in local time and frequency bands. We then fine-tune the encoder with a lower masking ratio on target datasets. Empirically, Audio-MAE sets new state-of-the-art performance on six audio and speech classification tasks, outperforming other recent models that use external supervised pre-training. Our code and models is available at https://github.com/facebookresearch/AudioMAE.
10
+
11
+ # 1 Introduction
12
+
13
+ Transformers [2] and self-supervised learning [3, 4, 5, 6, 7, 1] are dominating computer vision (CV) and natural language processing (NLP) research. The revolution firstly started in NLP with the invention of the Transformer architecture and self-attention [8]. Masked autoencoding with BERT [3] set a new state-of-the-art on various NLP tasks by self-supervised pre-training on large-scale language corpus. Similarly in the CV community, Vision Transformers (ViT) [9] have become popular for CV tasks, and, for self-supervised image representation learning, Masked Autoencoders (MAE) [1] have brought the CV community closer to the success of BERT in NLP. In addition to the existing masked autoencoders that can read (BERT) or see (MAE), in this work we study those that can listen.
14
+
15
+ Transformer-based models have recently refreshed leaderboards for audio understanding tasks. For example, AST [10] and MBT [11] improved the audio classification performance on the AudioSet [12], Event Sound Classification [13], etc. The key technique behind this is initialization of audio model weights with ImageNet pre-trained supervised models (e.g., DeiT [14]) by deflating patch embeddings and interpolating positional embeddings for encoding audio spectrograms. However, exploiting ImageNet pre-trained models could be sub-optimal. Unlike initializing video models with weights from image models (e.g., the initial weights of I3D [15] or 3D-ResNets [16] are inflated from ImageNet pre-trained image models), there are clear and notable discrepancies between spectrograms representing audio content and natural images. It remains unclear why such heterogeneous image-toaudio transfer is useful beyond arguably similar low-level semantics such as shapes of spectrograms and shapes of visual objects. Further, any label bias would inevitably be transferred to audio models.
16
+
17
+ Addressing these concerns, self-supervised audio representation learning has recently attracted much research attention. Based on BEiT [17] that learns to reconstruct image patches or learnt patch tokens, SS-AST [18] extends to the audio domain and exploits spectrograms (akin to 1-channel 2D images) and use both contrastive and reconstruction objective as self-supervision. Without using any labels, the key enabler to effective self-supervised representation learning is large-scale pre-training data. In this work we use AudioSet [12] for pre-training, a common dataset containing ${ \sim } 2$ million audio recordings. Performing large-scale training with Transformer architectures is challenging as self-attention in Transformers has quadratic complexity w.r.t. the length of input sequence.
18
+
19
+ ![](images/7b578eaf9796ad13f1638cd79725ff0dce34d674e35e6e70f80938d322ab078e.jpg)
20
+ Figure 1: Audio-MAE for audio self-supervised learning. An audio recording is first transformed into a spectrogram and split into patches. We embed patches and mask out a large subset $( 8 0 \% )$ . An encoder then operates on the visible $( 2 0 \% )$ patch embeddings. Finally, a decoder processes the order-restored embeddings and mask tokens to reconstruct the input. Audio-MAE is minimizing the mean square error (MSE) on the masked portion of the reconstruction and the input spectrogram.
21
+
22
+ This computational burden has been addressed in different ways. A popular approach is to reduce the sequence length in self-attention. Various ViT-based architectures have been developed to alleviate such issues for image and video understanding. For example, Swin-Transformer [19] only performs local attention within windows that shift across layers. MViT [20] employs pooling attention to construct a hierarchy of Transformers where sequence lengths are downsampled. For self-supervised learning, MAE [1] efficiently encodes only a small portion $( 2 5 \% )$ of visual patches while the majority of patches is discarded. The simplicity and scalability in MAE make it a promising framework for large-scale self-supervised learning.
23
+
24
+ In this work, we study MAE for sound recognition and the unique challenges of the audio domain. We present Audio-MAE (Fig. 1) as unified and scalable framework for learning self-supervised audio representations. Similar to MAE, it is composed of a pair of a Transformer encoder and decoder. Sound is first transformed and embedded into spectrogram patches. Before feeding them into the Transformer encoder, we mask and discard the majority and only feed a small number of non-masked embeddings into the encoder for efficient encoding. After padding encoded patches with learnable embeddings to represent masked patches, it then restores the order of these patches in frequency and time and propagates them through a Transformer decoder to reconstruct the audio spectrogram.
25
+
26
+ Different from image patches, spectrogram patches are comparably local-correlated. For example, formants, the vocal tract resonances, are typically grouped and continuous locally in the spectrogram. The location in frequency and time embeds essential information that determines the semantics of a spectrogram patch and how it sounds like. To this end, we further investigate using localized attention and a hybrid architecture in the Transformer decoder to properly decode for reconstruction. This simple-yet-effective upgrade leads to improved performance for Audio-MAE.
27
+
28
+ Similar to MAE for images, we minimize the patch-normalized mean square error. At the fine-tuning stage, we discard the decoder and fine-tune the encoder with patch-masking. Empirically, AudioMAE sets a new state-of-the-art performance on six audio and speech classification tasks. It is the first audio-only self-supervised model that achieves state-of-the-art mAP on AudioSet-2M, outperforming other recent models with external supervision. We further provide the visualization and audible examples to qualitatively demonstrate the effectiveness of the Audio-MAE decoder.
29
+
30
+ # 2 Related Work
31
+
32
+ Visual masked pre-training. Masked/Denoising autoencoders [21, 22, 3] are a general representation learning methodology by reconstructing source from masked or corrupted inputs. In CV, visual masked pre-training has made recent progress [23, 24, 1, 20]. Based on ViT [9] that applies Transformers to image patches, BEiT [17] and MAE [1] present masked image modeling frameworks. BEiT [17] learns to predict discrete visual tokens generated by VAE [25] in masked patches. MAE [1] reduces sequence length by masking a large portion of image patches randomly and encoding only non-masked ones for reconstruction of pixel color information. MaskFeat [20] studies features for masked pre-training and finds that Histograms of Oriented Gradients (HoG) [26], which are in turn related to spectrogram features, perform strongly for image and video classification models. Our work extends the MAE framework for representation learning with audio spectrograms.
33
+
34
+ Out-of-domain pre-training for audio. Transferring ImageNet supervised pre-trained ViT [9] or ResNet [27] has become a popular practice for audio models [10, 28, 11, 29, 30, 31]. After pre-training, these models operate over audio spectrograms by deflating from 3-channels (RGB) into 1-channel (spectrogram) in the pre-trained patch embedding in ViT and employing the rest of the transformer blocks on top. For example, HTS-AT [29] encodes spectrograms with hierarchical Transformer initialized from the Swin Transformer [19]. MBT [11] uses ImageNet-21K pre-trained ViT; AST [10] and PaSST [28] employ DeiT [14] as the Transformer backbone. Without using out-of-domain (non-audio) data, the proposed Audio-MAE focuses on audio-only self-supervised pre-training from scratch.
35
+
36
+ In-domain pre-training for audio. Existing in-domain (i.e., audio-only) self-supervised methods can be broadly categorized by the input signal type (e.g., raw waveform [32, 33, 34], frame-level features [35, 36, 37], or spectrogram patches [18, 38]); and the objective used for self-supervision (e.g., contrastive [39, 33, 40, 41, 35] or prediction/reconstruction [18, 34, 37, 36]). For example, wav2vec 2.0 [33] takes raw waveform as inputs and exploits contrastive learning to discriminate contextualized representations in different time segments. Mockingjay [42] proposed a masked acoustic model pretext task to reconstruct frame-level Mel-features of masked time frames. SSAST [18] is the closest work to Audio-MAE and is our main benchmark. Inspired by the success of BERT [3], SS-AST proposed a self-supervised learning method which operates over spectrogram patches and employs joint contrastive and reconstructive objectives on masked patches. These previous methods generate audio representations by encoding full-view of both masked and nonmasked time or spectrogram segments for self-supervised pre-training. In contrast, Audio-MAE encodes only the non-masked spectrogram patches.
37
+
38
+ Our work is done independently and concurrently with [38, 43, 44] related methods. We also compare our model to these concurrent works in the experiments and showcase the superiority of Audio-MAE.
39
+
40
+ # 3 Audio Masked Autoencoders (Audio-MAE)
41
+
42
+ Audio-MAE is a conceptually simple extension of MAE to learn self-supervised representations from audio spectrograms. Fig. 1 depicts an overview. The details of each component are as follows.
43
+
44
+ Spectrogram Patch Embeddings. Following [10, 18], we transform audio recordings into Melspectrograms and divide them into non-overlapped regular grid patches. These patches are then flattened and embedded by a linear projection. Similar to MAE [1], we add fixed sinusoidal positional embeddings to the embedded patches.
45
+
46
+ ![](images/31a937966647bc9c70a9fc197b7e10a2aa38720c7ea2a23229a1c5f045f9bb94.jpg)
47
+ Figure 2: Audio-MAE’s masking strategies on Mel-spectrograms.
48
+
49
+ Masking Strategies. Audio-MAE masks out a large subset of spectrogram patches. As a spectrogram can be viewed as a 2D representation of time and frequency components of a sound, it is reasonable to explore treating time and frequency differently during masking. In this work, we investigate both the unstructured (i.e., random masking without any prior) and structured (i.e., randomly masking a portion of time, frequency, or time $^ +$ frequency of a spectrogram) in the pre-training and fine-tuning phase. Illustrative examples are shown in Fig. 2. We show masked regions with dark overlay.
50
+
51
+ The masking mechanism, as introduced in MAE [1], is the key ingredient for efficient self-supervised learning. For a input patch sequence, this can be regarded as a Bernoulli process where each patch is masked/dropped with probability $p$ (masking ratio). Masking reduces input patch sequence length and encourages learning global, contextualized representations from limited “visible” patches. We observe that akin to images, a large masking rate ( $80 \%$ in our experiments for spectrogram patches, which is similar to $7 5 \%$ in MAE for images) is feasible for learning self-supervised audio representations. Unlike BERT [3] that uses $15 \%$ masking rate for self-supervised learning in NLP, most of the tokens/patches can be discarded for spectrograms as well as images due to high redundancy in these modalities. Beyond self-supervised pre-training, we further explore the effectiveness of masking in the supervised fine-tuning stage. Empirically, we found unstructured (random) masking at a higher ratio for pre-training and structured (time+frequency masking) at a lower ratio for fine-tuning provide best accuracy (ablations are in $\ S \_ 4 )$ ).
52
+
53
+ Encoder. Audio-MAE uses a stack of standard Transformers [2] as its encoder. The encoder only processes $( 2 0 \% )$ non-masked patches to reduce computation overhead which is quadratic to the input sequence length. We use the 12-layer ViT-Base (ViT-B) [9] Transformer as our default.
54
+
55
+ Decoder with Local Attention. The decoder is also composed of standard Transformer blocks. The encoded patches from the encoder are padded with trainable masked tokens. After restoring the original time-frequency order in the audio spectrogram, we add the decoder’s (fixed sinusoidal) positional embeddings and feed the restored sequence into the decoder. At the top of the decoder stack, we add a linear head to predict and reconstruct the input spectrogram.
56
+
57
+ To address the unique characteristics of audio spectrograms, our work investigates an enhancement to the vanilla MAE decoder. Image-based MAE uses global self-attention in the Transformer decoder which is appropriate for visual context, because visual objects are typically invariant under translation or scaling, and their exact position may not affect the semantics of an image. In contrast, the position, scale, and translation of spectrogram features however directly affects the sound or semantics of an audio recording. Consequently, global self-attention is sub-optimal for spectrograms if the timefrequency components is predominantly local. For instance, we would have better success to use the harmonics (e.g., Fig. 2a) in lower bands of a vowel to predict the spectrogram patch vertically in a higher frequency band rather than horizontally in the time domain. Similarly, a frictional sound of a consonant likely only correlates to other part of the consonant, and is without dependency to other silence segments in the audio recording. Compared to images, the spectrogram patches are more similar to speech or text tokens where its order and position is more relevant.
58
+
59
+ To address the nature of audio spectrograms, in addition to using Transformers with global self-attention as in vanilla MAE, we incorporate the local attention mechanism which groups and separates the spectrogram patches in to local windows in self-attention for decoding. We investigate two types of local attention: (1) Shifted window location: Inspired by the shifted-window in Swin Transformers [19], we shift window attention by $50 \%$ between consecutive Transformer decoder layers. For padding the margin when shifting, we cyclically shift the spectrogram to the top-left direction. Fig. 3 illustrates the localized decoder attention by shifted windows. (2) Hybrid window attention (global+local attention): Inspired by [45], to add better cross-window connections, we design a simple hybrid (global+local) attention that computes local attention within a window in all but the last few top layers. In this way, the input feature maps for the final reconstruction layer also contain global information. For simplicity, we use $_ { n o }$ pooling or hierarchical structure. Decoders with different attention types are compared in $\ S \ O = 4$ .
60
+
61
+ ![](images/eac4e377de5817b96d0854d87b3e709eb9a487a2db0842240cefe54d8a061b6c.jpg)
62
+ Figure 3: Decoder’s local attention and shifted window (right).
63
+
64
+ Objective. The Audio-MAE decoder learns to reconstruct the input spectrogram by predicting the values in the spectrogram patches or their per-patch normalized ones. The objective is the mean squared error (MSE) between the prediction and the input spectrogram, averaged over unknown patches. Empirically we found employing the reconstruction loss alone is sufficient while including additional contrastive objectives (e.g., InfoNCE loss [46]) does not improve Audio-MAE.
65
+
66
+ Fine-tuning for Downstream Tasks. In the fine-tuning stage, we only keep and fine-tune the AudioMAE encoder and discard the decoder. Different from the original MAE, and inspired by [47, 28], we also explore to employ masking in the fine-tuning stage to remove a portion of patches to further regularize learning from a limited view of spectrogram inputs, which, as a side effect, also reduces computation during fine-tuning. Compared to SpecAug [48] which takes full-length input with the masked portion set to zero as data augmentation, Audio-MAE sees only a subset of real-valued input patches without the nullified ones. Audio-MAE then encodes these non-masked patches and applies an average pooling layer followed by a linear layer on top for fine-tuning in classification tasks.
67
+
68
+ # 4 Experiments
69
+
70
+ We perform an extensive evaluation on six tasks, including audio classification on AudioSet (AS-2M, AS-20K) and Environmental Sound Classification (ESC-50), and speech classification on Speech Commands (SPC-1 and SPC-2) and VoxCeleb (SID). We use AudioSet for ablation studies.
71
+
72
+ # 4.1 Datasets and Tasks
73
+
74
+ AudioSet [12] (AS-2M, AS-20K) contains ${ \sim } 2$ million 10-second YouTube clips for audio classification. 527 types of audio events are weakly annotated [49, 50, 51] for each clip. There could be multiple events in a clip. The full training set has 2 subsets: A class-wise balanced (22,176 clips) and an unbalanced (2,042,985 clips) set. The eval set has 20,383 clips. We downloaded and processed around 1.96M unbalanced training, 21K balanced training, and 19K evaluation clips.
75
+
76
+ For the AS-2M experiments, we use the union of unbalanced and balanced training audio for pretraining and fine-tuning. For the AS-20K experiments, we use AS-2M for pre-training and the 20K balanced set for fine-tuning. We report the testing mAP on the 19K eval set used by AST [10].
77
+
78
+ Environmental Sound Classification (ESC-50) [13] is an audio classification dataset consists of 2,000 5-second environmental sound recordings. There are 50 classes in ESC. We report accuracy under 5-fold cross-validation with the same split used by [10].
79
+
80
+ Speech Commands (SPC-2, SPC-1) [52] are two keyword spotting tasks. In SPC-2, there are 35 speech commands. The training/validation/testing set has 84,843/9,981/11,005 1-second recordings, respectively. In SPC-1, there are 10 classes of keywords, 1 silence class, and 1 unknown class that includes all the other 20 common speech commands. We use the data and split provided in the SUPERB [53] benchmark to report the testing accuracy.
81
+
82
+ VoxCeleb (SID) [54] contains 150K utterances from 1,251 speakers. The speaker identification task (SID) is to classify the utterances to identify its original speaker. We use the V1 standard train (138,361), validation (6,904), testing (8,251) sets and report the testing accuracy.
83
+
84
+ # 4.2 Implementation Details
85
+
86
+ We use a vanilla 12-layer ViT-B by default as the Transformer encoder. For the decoder, we use a 16-layer Transformer with shifted local attention. We investigate the vanilla (global attention) and hybrid (global+local attention) decoder variants (see Table. 1c).
87
+
88
+ Following [10, 11], we transform raw waveform (pre-processed as mono channel under 16,000 sampling rate) into 128 Kaldi [55]-compatible Mel-frequency bands with a $2 5 \mathrm { m s }$ Hanning window that shifts every $1 0 ~ \mathrm { m s }$ . For a 10-second recording in AudioSet, the resulting spectrogram is of $1 \times 1 0 2 4 \times 1 2 8$ dimension.
89
+
90
+ For patch embedding, we use convolutional kernels with (16, 16) size and stride in time and frequency (thus, patches are non-overlapping) to avoid short-cuts via overlap in self-supervision (though, at high masking ratios such short-cuts are less severe). By default, we use a masking ratio of 0.8 with (unstructured) random masking for pre-training. During fine-tuning, we employ a lower masking ratio (0.3 in time and 0.3 in frequency). Ablations on these design choices are given in $\ S \ O = 4$ .
91
+
92
+ # 4.3 Pre-training and Fine-tuning
93
+
94
+ We use AudioSet-2M for pre-training and randomly iterate over all audio recordings. We train for 32 epochs with a batch size of 512 and a 0.0002 learning rate. We distribute the training load over 64 V100 GPUs and the total training time is ${ \sim } 3 6$ hours. For each audio, we randomly sample the starting time, cyclically extract 10-second audio, and randomly jitter its magnitude by up to $\pm 6 \mathrm { d B }$ . We use only natural audio spectrograms and apply no augmentations (e.g., [48, 56, 57]) as we do not find these strong augmentations helpful in the pre-training phase.
95
+
96
+ In the fine-tuning phase, we remove the decoder and only fine-tune the encoder. For the supervised fine-tuning on AudioSet-2M, since the size of training samples are uneven across classes (unbalanced), we follow the common practice of using a weighted sampling to balance the classes during training. In each epoch, we sample 200K instances ( $\mathord { \sim } 1 0 \%$ of AudioSet-2M) without replacement. We fine-tune for 100 epochs, which aggregate to ${ \sim } 1 0$ full epochs of AudioSet-2M. The probability of sampling an instance is inversely proportional to the dataset-wise occurrences of its classes. Fine-tuning on 64 GPUs takes ${ \sim } 1 2$ hours. For the smaller balanced AudioSet-20K, we fine-tune on 4 GPUs for 60 epochs without weighted sampling. Please see Supplementary for the details on other datasets.
97
+
98
+ ![](images/77981a7649efa2be98251d63c87ce0bb29948d0455d85ac60829270b7d834094.jpg)
99
+ Figure 4: Masking strategy. For pre-training, a higher ratio and unstructured masking (random) is preferred. For fine-tuning, a lower ratio and structured masking (time $^ +$ frequency) is better. The y-axes are mAP on AS-2M and the $\mathbf { X }$ -axes are masking ratio. This ablation format follows [1].
100
+
101
+ # 4.4 Ablations and Model Properties
102
+
103
+ Masking Strategies in Pre-training and Fine-tuning. In Fig. 4, we compare different pre-training and fine-tuning masking strategies for Audio-MAE. First, in Fig. 4a we explore the pre-training masking ratio. We observe, similar as in MAE for images [1], that a high pre-training masking ratio $80 \%$ in our case) is optimal for audio spectrograms. This is due to the fact that both audio spectrograms and images are continuous signals with significant redundancy. Further, we find the unstructured random masking works the best for self-supervised pre-training over more structured masking (e.g., time+frequency).
104
+
105
+ Unlike MAE for images, there are clear performance differences among masking strategies when pre-training with audio spectrograms. Comparing Audio-MAE reconstructions between Fig. 6a to 6e and 6d to 6h, under the same masking ratio, we observe the unstructured random masking is comparably easier than structured masking (i.e., time and/or frequency) as the model can guess the missing component by extrapolating nearby context (e.g., formants in vowels and frictional sounds in consonants around). We also observe that for higher masking ratios, the structured masking alternatives drop in performance, presumably because the task becomes too difficult while random masking improves steadily up to $80 \%$ . This result show that designing a pretext task with proper hardness is important for effective self-supervised learning of audio representations. We therefore use random masking with ratio of $80 \%$ as our default for pre-training.
106
+
107
+ Fig. 4b studies the effect of masking during the fine-tuning phase. We see that in this case, it is more beneficial to use structured masking: time+frequency performs better than time- or frequency-based masking, and these perform better than unstructured masking. Overall, we see that the optimal masking ratios are lower than for pre-training and we use 0.3 as our default in the fine-tuning phase.
108
+
109
+ In general, we observe that for task-agnostic pre-training, unstructured masking with a higher ratio is preferred. While in task-specific fine-tuning, structured masking with lower ratios performs better.
110
+
111
+ Impact of Patch Size and Stride. We compare the performance of Audio-MAE trained with different patch sizes and strides in Table 1a. A non-zero overlap (i.e., stride $<$ patch size) between patches will increase the number of patches and quadratically increase computation in floating point operations (FLOPs), as reported in the table. Most prior works follow AST [10] to use overlapped patches (patch $= 1 6$ and stride $= 1 0$ ) to boost end task performance. As shown in Table 1a, we do not observe a performance improvement using overlapped patches for Audio-MAE (both $4 7 . 3 \mathrm { m A P }$ ), presumably because due to overlap, the patch embedding can leak information into the masked patches. The non-overlapped $1 6 \times 1 6$ patches achieve a good balance between computation and performance. By default, we use this setup in our experiments.
112
+
113
+ Encoder. We investigate the design choices of encoder and decoder architectures in Audio-MAE. Table 1b shows the trade-off between encoder model size and performance. As expected, larger models achieve better performance, at a cost of computation and memory. The accuracy gain of ViT-L over ViT-B/S is more significant on the smaller and balanced AS-20K. For ViT-S, the performance
114
+
115
+ <table><tr><td>(16,16), (16,16)</td><td>64×8</td><td>48.647.3</td><td></td></tr><tr><td>(16,16), (10,10)</td><td>101×12</td><td>130.5</td><td>47.3</td></tr><tr><td>(32,16), (16,16)</td><td>63×8</td><td>47.8</td><td>46.6</td></tr><tr><td>(16,32), (16,16)</td><td>64×7</td><td>42.1</td><td>46.8</td></tr></table>
116
+
117
+ <table><tr><td>ViT-S</td><td>22M</td><td>32.1</td><td>45.0</td></tr><tr><td>ViT-B</td><td>86M</td><td>37.1</td><td>47.3</td></tr><tr><td>ViT-L</td><td>304M</td><td>37.6</td><td>47.4</td></tr></table>
118
+
119
+ scenario IN-SSL IN-SL AS-SSL AS-20K AS-2M
120
+
121
+ <table><tr><td>Attention type</td><td>AS-20K AS-2M ESC-50 SID</td></tr><tr><td>Global(8) (vanilla)</td><td>36.6 46.8</td></tr><tr><td>93.6 94.1 47.3 94.1</td><td>Local(16) (shifted) 37.1</td></tr><tr><td>Hwin (local(8)+ global(4) 36.8</td><td>94.8 47.3 93.8 95.0</td></tr></table>
122
+
123
+ ![](images/c8970b78f179014b4562bee38cb0d12fbbb43623ba5e47ab3c3b6f7e874f2872.jpg)
124
+ (h) External ImageNet (IN) pre-training. SSL: w/ selfsupervised MAE. SL: w/ supervised (fine-tuned) MAE.
125
+
126
+ Table 1: Ablation studies on AS-2M. The gray entries are the default Audio-MAE setup (ViT-B encoder, decoder with shifted local attention, pre-trained for 32 epochs). Table format follows [1].
127
+
128
+ gap to ViT-B can be significantly closed $\mathrm { 5 . 0 \to 2 . 3 \ m A P }$ ) when fine-tuning with more in-domain data $( \mathrm { A S } - 2 0 \mathrm { K } \mathrm { A S } - 2 \mathrm { M } )$ ).
129
+
130
+ Decoder. Table 1c compares decoder attention types in Audio-MAE. Note that decoders are discarded after pretraining and only the equal-sized ViT-B encoders are fine-tuned for the end task. Our results show that local attention with shifted window achieves the best performance. Combining local and global attention (i.e., hybrid attention, Hwin) also improves vanilla global self-attention. Fig. 5 shows the qualitative reconstruction comparison. In the spectrogram of vowels, the decoder with local attention reconstructs better harmonics and recovers more context in the spectrogram. Similar phenomena are observed in the frictional sound in the middle consonant.
131
+
132
+ ![](images/2eac13304af84b06c5760b4abdf221924cb45af9f00f2bcb95dca8f6af1aa8b1.jpg)
133
+ Figure 5: Decoder reconstruction comparison.
134
+
135
+ Table 1d ablates the impact of decoder depth on mAP. A deeper 16-layer decoder achieves better performance against its shallower variants. Note that our decoder uses local window attention by default where only a fraction of tokens $4 { \times } 4$ local windows vs. $6 4 \times 8$ with global attention) are attended. For global attention we find 8-layer decoders to perform better than 16-layer. Table 1e compares decoder width (embedding dimension). A 512-dimension decoder achieves a good trade-off between computation and performance as a wider one is not better.
136
+
137
+ Pre-training Data and Setup. Table 1f summarizes the impact of pre-training dataset size. Overall the model performance is monotonically increasing when using more data for pre-training. Comparing the performance of using $1 \%$ well-annotated AS-20K balanced data to using randomly sampled 20K unbalanced data for pre-training, the similar mAPs (39.4 vs 39.6) suggest that the distribution of data classes (balanced vs. unbalanced) is less important for pre-training. Meanwhile, as shown in Table $1 \mathrm { g }$ , training for longer is beneficial yet the performance saturates after the 24-th epoch.
138
+
139
+ Out-of-domain Pre-training on ImageNet. Initializing audio models from ImageNet pre-trained weights has become popular for audio classification. However, as there are significant discrepancies between image and audio modalities, it is questionable if out-of-domain pre-training benefits audio representation learning. In Table 1h we design 3 scenarios to investigate this for Audio-MAE: (1)
140
+
141
+ Table 2: Comparison with other state-of-the-art models on audio and speech classification tasks. Metrics are mAP for AS and accuracy $( \% )$ for ESC/SPC/SID. For pre-training (PT) dataset, AS:AudioSet, LS:LibriSpeech, and IN:ImageNet. †: Fine-tuning results with additional supervised training on AS-2M. We gray-out models pre-trained with external non-audio datasets (e.g., ImageNet). Best single models in AS-2M are compared (no ensembles). \*: linear evaluation results from [53].
142
+
143
+ <table><tr><td>Moder</td><td>Backbone</td><td></td><td>P1-DataAS-20K</td><td>AS-ZMI</td><td>ESC-30</td><td>SPC-2</td><td>SPC-1</td><td>SID</td></tr><tr><td>No pre-training</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ERANN [58]</td><td>CNN</td><td></td><td></td><td>45.0</td><td>89.2</td><td></td><td></td><td></td></tr><tr><td>PANN [59]</td><td>CNN</td><td></td><td>27.8</td><td>43.1</td><td>83.3</td><td>61.8</td><td></td><td></td></tr><tr><td colspan="9">In-domain self-supervised pre-training</td></tr><tr><td>wav2vec 2.0 [33]</td><td>Transformer</td><td>LS</td><td></td><td></td><td></td><td></td><td>96.2*</td><td>75.2*</td></tr><tr><td>HuBERT[35]</td><td>Transformer</td><td>LS</td><td></td><td></td><td></td><td></td><td>96.3*</td><td>81.4*</td></tr><tr><td>Conformer [37]</td><td>Conformer</td><td>AS</td><td>=</td><td>41.1</td><td>88.0</td><td>=</td><td>-</td><td>-</td></tr><tr><td>SS-AST[18]</td><td>ViT-B</td><td>AS+LS</td><td>31.0</td><td>1</td><td>88.8</td><td>98.0</td><td>96.0</td><td>64.3</td></tr><tr><td colspan="9">Concurrent MAE-based works</td></tr><tr><td>MaskSpec [43]</td><td>ViT-B</td><td>AS</td><td>32.3</td><td>47.1</td><td>89.6</td><td>97.7</td><td>=</td><td></td></tr><tr><td>MAE-AST[38]</td><td>ViT-B</td><td>AS+LS</td><td>30.6</td><td>-</td><td>90.0</td><td>97.9</td><td>95.8</td><td>63.3</td></tr><tr><td>Audio-MAE (global)</td><td>ViT-B</td><td>AS</td><td>36.6±.11</td><td>46.8±.06</td><td>93.6±.11</td><td>98.3±.06</td><td>97.6±.06</td><td>94.1±.06</td></tr><tr><td>Audio-MAE (local)</td><td>ViT-B</td><td>AS</td><td>37.0±.11</td><td>47.3±.11</td><td>94.1±.10</td><td>98.3±.06</td><td>96.9±.00</td><td>94.8± .11</td></tr><tr><td colspan="9">Out-of-domain supervised pre-training</td></tr><tr><td>PSLA [30]</td><td>EffNet [60]</td><td>IN</td><td>31.9</td><td>44.4</td><td>=</td><td>96.3</td><td>=</td><td></td></tr><tr><td>AST[10]</td><td>DeiT-B</td><td>IN</td><td>34.7</td><td>45.9</td><td>88.7</td><td>98.1</td><td>95.5</td><td>41.1</td></tr><tr><td>MBT[11]</td><td>ViT-B</td><td>IN-21K</td><td>31.3</td><td>44.3</td><td>1</td><td>-</td><td>=</td><td></td></tr><tr><td>HTS-AT [29]</td><td>Swin-B</td><td>IN</td><td>=</td><td>47.1</td><td>97.0t</td><td>98.0</td><td></td><td></td></tr><tr><td>PaSST[28]</td><td>DeiT-B</td><td>IN</td><td></td><td>47.1</td><td>96.8†</td><td>-</td><td></td><td></td></tr></table>
144
+
145
+ Audio-only pre-training (AS-SSL) from scratch. We consider this the ideal schema for learning audio representations as it is a simple and clean setup that prevents uncontrollable bias transfer from other modalities. (2) Directly using self-supervised ImageNet MAE models (IN-SSL) and its fine-tuned variant (IN-SL). (3) Audio-MAE self-supervised pre-training on top of these ImageNet weights.
146
+
147
+ The results show that (1) from-scratch audio-only pre-training is the best. For scenarios (2) and (3), we observe that ImageNet pre-training alone (2) is not sufficient (especially when the downstream data is smaller, AS-20K), and, in self-supervised pre-training on AudioSet, ImageNet initialization (3) does not help but degrades accuracy. Also in (3), supervised ImageNet pre-training (IN-SL) seems harmful. Consequently, the result suggests that out-of-domain pre-training (i.e., ImageNet) is not helpful for Audio-MAE, possibly due to domain shift.
148
+
149
+ # 4.5 Comparison with the State-of-the-art
150
+
151
+ Table 2 compares Audio-MAE (with 3-run error bars) to prior state-of-the-art. We categorize the comparison into 3 groups. For fair comparison, our main benchmark is the models in the middle group with self-supervised pre-training on in-domain (audio) datasets (AudioSet and LibriSpeech). For reference we also list other models without pre-training (the top group) and other models with supervised pre-training on out-of-domain ImageNet (the bottom group), where the latter contains previous best systems on the datasets.
152
+
153
+ Pre-trained on AudioSet, Audio-MAE achieves the best performance across all tasks compared to other models with in-domain self-supervised pre-training. On AudioSet-20K, its $3 7 . 1 \ \mathrm { m A P }$ significantly outperforms all other approaches including concurrent works and other models with outof-domain pre-training. On AudioSet-2M and ESC-50, our method also outperforms Conformer [37] and SS-AST [18]. Notably, unlike SS-AST and concurrent MAE-AST [38], which trained with additional 1,000 hours of speech in Librispeech, we use only AudioSet for pre-training.
154
+
155
+ In the bottom group of Table 2, Audio-MAE also outperforms previous state-of-the-art models with ImageNet supervised pre-training. Note that the proposed Audio-MAE does not rely on any out-ofdomain data and labels, nor using knowledge distillation (e.g., DeiT) from additional CNN-based models. Also, compared to HTS-AT [29] and PaSST [28], Audio-MAE is trained with audio under 16K sampling rate. As experimented in [59], there could be up to 0.4 potential mAP improvement for Audio-MAE if audio with 32K sampling rate are available.
156
+
157
+ ![](images/6244fd1a7a46c5c39262c96d30a4dfd6f022b65c3eb7f73ba45382c9f667a734.jpg)
158
+ Figure 6: Spectrogram reconstruction visualizations on the AudioSet eval set. Column-wise type: speech, music, event, others. Masking type: (a-d) unstructured (random); (e-h) structured (time $^ +$ frequency). Masking Ratio: $70 \%$ . In each group, we show the original spectrogram (1, top), masked input (2, middle), and MAE output (3, bottom). The spectrogram size is $1 0 2 4 \times 1 2 8$ ; patch size is $1 6 \times 1 6$ . Each sample has $6 4 \times 8 = 5 1 2$ patches with 154 ( $70 \%$ masked) patches being visible to Audio-MAE. Please click (1 2 3) for audible .wavs. More audible examples are in Supplementary.
159
+
160
+ For the speech tasks (SPC-1, SPC-2, and SID), Audio-MAE outperforms other models without pre-training (ERANN [58], PANN [59]), supervised (AST) and self-supervised models (SS-AST, MAE-AST). We further list other works (marked with \*) to include the latest results introduced in the SUPERB [53] benchmark. But note that these results are not strictly comparable since SUPERB employs linear evaluation where the underlying pre-trained models are not end-to-end fine-tuned.
161
+
162
+ In summary, with audio-only from-scratch pre-training on AudioSet, our Audio-MAE performs well for both the audio and speech classification tasks.
163
+
164
+ # 4.6 Visualization and Audible Examples by Audio-MAE Decoder
165
+
166
+ For better visualization, we follow MAE [1] to use MSE over non-normalized spectrograms as the selfsupervised objective. We use ViT-L as the Audio-MAE encoder for visualization. Fig. 6 illustrates the reconstruction results sampled from the AudioSet-2M eval set. We further reconstruct .wavs using the Griffin-Lim [61] algorithm, audible under the anonymous links (accessible in respective 1 2 3).
167
+
168
+ As can be seen and heard, for various masking strategies and different sounds, our Audio-MAE generates reasonable reconstruction. It works well for noisy event sounds (e.g., the reconstructed siren in Fig. 6c-3), as well as speech and music (e.g., the reconstructed singing in Fig. 6b-3). Notably, unlike visual contents that are typically scale/translation/position invariant [19], absolute positions and arrangement of spectrogram components are critical for humans to understand sound [62]. For example, shifting a pitch will make an audio sounds completely different. Also, phoneme sequences in time are important cues for speech understanding. Consequently, unstructured masking produces better aligned outputs that are closer to the ground-truth (top row in each subfigure) as the model can make better predictions based on nearby spectrogram patches; while structured masking is harder (less accurate or with words missing), especially when masking is performed over the time axis. A failure example (missing words) is the reconstructed speech in Fig. 6e-3.
169
+
170
+ # 5 Conclusion
171
+
172
+ We have explored a simple extension of MAE [1] to audio data. Our Audio-MAE learns to reconstruct masked spectrogram patches from audio recordings and achieves state-of-the-art performance on six audio and speech classification tasks. We have drawn four interesting observations: First, a simple MAE approach works surprisingly well for audio spectrograms. Second, we find that it is possible to learn stronger representations with local self-attention in the decoder. Third, we show that masking can be applied to both pre-training and fine-tuning, improving accuracy and reducing training computation. The optimal strategy depends on the nature of the data (audio, image, etc.) and the learning type (self-/supervised). Fourth, the best performance can be achieved by pre-training and fine-tuning under the same modality, without reliance on cross-modality transfer learning. In future work, we aim to explore multimodal self-supervised learning with a joint audio-visual MAE approach as these domains share natural correspondences in video data.
173
+
174
+ Acknowledgements. We thank Kaiming He and Luke Zettlemoyer for their feedback and discussions.
175
+
176
+ # References
177
+
178
+ [1] K. He, X. Chen, S. Xie, Y. Li, P. Dollár, and R. Girshick, “Masked autoencoders are scalable vision learners,” arXiv preprint arXiv:2111.06377, 2021. [2] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin, “Attention is all you need,” in Proceedings of the 31st International Conference on Neural Information Processing Systems, ser. NIPS’17. USA: Curran Associates Inc., 2017, pp. 6000–6010.
179
+ [3] J. Devlin, M. 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, NAACL-HLT 2019, Minneapolis, MN, USA, June 2-7, 2019, Volume 1 (Long and Short Papers). Association for Computational Linguistics, 2019, pp. 4171–4186.
180
+ [4] 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. [5] Y. Liu, M. Ott, N. Goyal, J. Du, M. Joshi, D. Chen, O. Levy, M. Lewis, L. Zettlemoyer, and V. Stoyanov, “Roberta: A robustly optimized BERT pretraining approach,” CoRR, vol. abs/1907.11692, 2019.
181
+ [6] 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. Computer Vision Foundation / IEEE, 2020, pp. 9726–9735.
182
+ [7] X. Chen, S. Xie, and K. He, “An empirical study of training self-supervised vision transformers,” in 2021 IEEE/CVF International Conference on Computer Vision, ICCV 2021, Montreal, QC, Canada, October 10-17, 2021. IEEE, 2021, pp. 9620–9629. [8] R. Paulus, C. Xiong, and R. Socher, “A deep reinforced model for abstractive summarization,” arXiv, vol. abs/1705.04304, 2017. [9] 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,” arXiv preprint arXiv:2010.11929, 2020.
183
+ [10] Y. Gong, Y. Chung, and J. R. Glass, “AST: audio spectrogram transformer,” in Interspeech 2021, 22nd Annual Conference of the International Speech Communication Association, Brno, Czechia, 30 August - 3 September 2021. ISCA, 2021, pp. 571–575.
184
+ [11] A. Nagrani, S. Yang, A. Arnab, A. Jansen, C. Schmid, and C. Sun, “Attention bottlenecks for multimodal fusion,” in Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, 2021, pp. 14 200–14 213.
185
+ [12] J. F. Gemmeke, D. P. Ellis, D. Freedman, A. Jansen, W. Lawrence, R. C. Moore, M. Plakal, and M. Ritter, “Audio set: An ontology and human-labeled dataset for audio events,” in 2017 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). IEEE, 2017, pp. 776–780.
186
+ [13] K. J. Piczak, “ESC: Dataset for Environmental Sound Classification,” in Proceedings of the 23rd Annual ACM Conference on Multimedia. ACM Press, 2015, pp. 1015–1018.
187
+ [14] H. Touvron, M. Cord, M. Douze, F. Massa, A. Sablayrolles, and H. Jégou, “Training dataefficient image transformers & distillation through attention,” in International Conference on Machine Learning. PMLR, 2021, pp. 10 347–10 357.
188
+ [15] J. Carreira and A. Zisserman, “Quo vadis, action recognition? A new model and the kinetics dataset,” in 2017 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, Honolulu, HI, USA, July 21-26, 2017. IEEE Computer Society, 2017, pp. 4724–4733.
189
+ [16] C. Feichtenhofer, A. Pinz, and R. P. Wildes, “Spatiotemporal residual networks for video action recognition,” in NIPS, 2016.
190
+ [17] H. Bao, L. Dong, and F. Wei, “Beit: BERT pre-training of image transformers,” CoRR, vol. abs/2106.08254, 2021.
191
+ [18] Y. Gong, C.-I. Lai, Y.-A. Chung, and J. R. Glass, “Ssast: Self-supervised audio spectrogram transformer,” ArXiv, vol. abs/2110.09784, 2021.
192
+ [19] Z. Liu, Y. Lin, Y. Cao, H. Hu, Y. Wei, Z. Zhang, S. Lin, and B. Guo, “Swin transformer: Hierarchical vision transformer using shifted windows,” in 2021 IEEE/CVF International Conference on Computer Vision, ICCV 2021, Montreal, QC, Canada, October 10-17, 2021. IEEE, 2021, pp. 9992–10 002.
193
+ [20] C. Wei, H. Fan, S. Xie, C. Wu, A. L. Yuille, and C. Feichtenhofer, “Masked feature prediction for self-supervised visual pre-training,” CoRR, vol. abs/2112.09133, 2021.
194
+ [21] P. Vincent, H. Larochelle, Y. Bengio, and P. Manzagol, “Extracting and composing robust features with denoising autoencoders,” in Machine Learning, Proceedings of the Twenty-Fifth International Conference (ICML 2008), Helsinki, Finland, June 5-9, 2008, ser. ACM International Conference Proceeding Series, vol. 307. ACM, 2008, pp. 1096–1103.
195
+ [22] P. Vincent, H. Larochelle, I. Lajoie, Y. Bengio, and P. Manzagol, “Stacked denoising autoencoders: Learning useful representations in a deep network with a local denoising criterion,” J. Mach. Learn. Res., vol. 11, pp. 3371–3408, 2010.
196
+ [23] D. Pathak, P. Krähenbühl, J. Donahue, T. Darrell, and A. A. Efros, “Context encoders: Feature learning by inpainting,” in 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016. IEEE Computer Society, 2016, pp. 2536–2544.
197
+ [24] M. Chen, A. Radford, R. Child, J. Wu, H. Jun, D. Luan, and I. Sutskever, “Generative pretraining from pixels,” in Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, ser. Proceedings of Machine Learning Research, vol. 119. PMLR, 2020, pp. 1691–1703.
198
+ [25] A. Ramesh, M. Pavlov, G. Goh, S. Gray, C. Voss, A. Radford, M. Chen, and I. Sutskever, “Zero-shot text-to-image generation,” in Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, ser. Proceedings of Machine Learning Research, vol. 139. PMLR, 2021, pp. 8821–8831.
199
+ [26] N. Dalal and B. Triggs, “Histograms of oriented gradients for human detection,” in 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR 2005), 20-26 June 2005, San Diego, CA, USA. IEEE Computer Society, 2005, pp. 886–893.
200
+ [27] K. He, X. Zhang, S. Ren, and J. Sun, “Deep residual learning for image recognition,” 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778, 2015.
201
+ [28] K. Koutini, J. Schlüter, H. Eghbal-zadeh, and G. Widmer, “Efficient training of audio transformers with patchout,” CoRR, vol. abs/2110.05069, 2021.
202
+ [29] K. Chen, X. Du, B. Zhu, Z. Ma, T. Berg-Kirkpatrick, and S. Dubnov, “Hts-at: A hierarchical token-semantic audio transformer for sound classification and detection,” arXiv preprint arXiv:2202.00874, 2022.
203
+ [30] Y. Gong, Y. Chung, and J. Glass, “Psla: Improving audio tagging with pretraining, sampling, labeling, and aggregation,” IEEE/ACM Transactions on Audio, Speech, and Language Processing, 2021.
204
+ [31] Y. Gong, S. Khurana, A. Rouditchenko, and J. Glass, “Cmkd: Cnn/transformer-based cross-model knowledge distillation for audio classification,” 2022.
205
+ [32] S. Schneider, A. Baevski, R. Collobert, and M. Auli, “wav2vec: Unsupervised pre-training for speech recognition,” in Interspeech 2019, 20th Annual Conference of the International Speech Communication Association, Graz, Austria, 15-19 September 2019. ISCA, 2019, pp. 3465–3469.
206
+ [33] A. Baevski, Y. Zhou, A. Mohamed, and M. Auli, “wav2vec 2.0: A framework for self-supervised learning of speech representations,” in Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
207
+ [34] A. Baevski, W. Hsu, Q. Xu, A. Babu, J. Gu, and M. Auli, “data2vec: A general framework for self-supervised learning in speech, vision and language,” CoRR, vol. abs/2202.03555, 2022.
208
+ [35] W.-N. Hsu, B. Bolte, Y.-H. H. Tsai, K. Lakhotia, R. Salakhutdinov, and A. Mohamed, “Hubert: Self-supervised speech representation learning by masked prediction of hidden units,” IEEE/ACM Transactions on Audio, Speech, and Language Processing, vol. 29, pp. 3451–3460, 2021.
209
+ [36] B. Shi, W. Hsu, and A. Mohamed, “Robust self-supervised audio-visual speech recognition,” CoRR, vol. abs/2201.01763, 2022.
210
+ [37] S. Srivastava, Y. Wang, A. Tjandra, A. Kumar, C. Liu, K. Singh, and Y. Saraf, “Conformer-based self-supervised learning for non-speech audio tasks,” arXiv preprint arXiv:2110.07313, 2021.
211
+ [38] A. Baade, P. Peng, and D. Harwath, “Mae-ast: Masked autoencoding audio spectrogram transformer,” arXiv preprint arXiv:2203.16691, 2022.
212
+ [39] A. van den Oord, Y. Li, and O. Vinyals, “Representation learning with contrastive predictive coding,” CoRR, vol. abs/1807.03748, 2018.
213
+ [40] R. Arandjelovic and A. Zisserman, “Objects that sound,” in Computer Vision - ECCV 2018 - 15th European Conference, Munich, Germany, September 8-14, 2018, Proceedings, Part I, ser. Lecture Notes in Computer Science, vol. 11205. Springer, 2018, pp. 451–466.
214
+ [41] M. Patrick, P. Huang, I. Misra, F. Metze, A. Vedaldi, Y. M. Asano, and J. F. Henriques, “Space-time crop & attend: Improving cross-modal video representation learning,” in 2021 IEEE/CVF International Conference on Computer Vision, ICCV 2021, Montreal, QC, Canada, October 10-17, 2021. IEEE, 2021, pp. 10 540–10 552.
215
+ [42] A. T. Liu, S. Yang, P. Chi, P. Hsu, and H. Lee, “Mockingjay: Unsupervised speech representation learning with deep bidirectional transformer encoders,” in 2020 IEEE International Conference on Acoustics, Speech and Signal Processing, ICASSP 2020, Barcelona, Spain, May 4-8, 2020. IEEE, 2020, pp. 6419–6423.
216
+ [43] D. Chong, H. Wang, P. Zhou, and Q. Zeng, “Masked spectrogram prediction for self-supervised audio pre-training,” 2022.
217
+ [44] D. Niizumi, D. Takeuchi, Y. Ohishi, N. Harada, and K. Kashino, “Masked spectrogram modeling using masked autoencoders for learning general-purpose audio representation,” arXiv:2204.12260, 2022.
218
+ [45] Y. Li, C.-Y. Wu, H. Fan, K. Mangalam, B. Xiong, J. Malik, and C. Feichtenhofer, “Mvitv2: Improved multiscale vision transformers for classification and detection,” in CVPR, 2022.
219
+ [46] A. van den Oord, Y. Li, and O. Vinyals, “Representation learning with contrastive predictive coding,” CoRR, vol. abs/1807.03748, 2018.
220
+ [47] A. Baevski, M. Auli, and A. Mohamed, “Effectiveness of self-supervised pre-training for speech recognition,” CoRR, vol. abs/1911.03912, 2019.
221
+ [48] D. S. Park, W. Chan, Y. Zhang, C.-C. Chiu, B. Zoph, E. D. Cubuk, and Q. V. Le, “Specaugment: A simple data augmentation method for automatic speech recognition,” ArXiv, vol. abs/1904.08779, 2019.
222
+ [49] J. B. Li, S. Qu, P. Huang, and F. Metze, “Audiotagging done right: 2nd comparison of deep learning methods for environmental sound classification,” CoRR, vol. abs/2203.13448, 2022.
223
+ [50] S. Hershey, S. Chaudhuri, D. P. W. Ellis, J. F. Gemmeke, A. Jansen, C. Moore, M. Plakal, D. Platt, R. A. Saurous, B. Seybold, M. Slaney, R. Weiss, and K. Wilson, “Cnn architectures for large-scale audio classification,” in International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2017.
224
+ [51] S. Hershey, D. P. Ellis, E. Fonseca, A. Jansen, C. Liu, R. C. Moore, and M. Plakal, “The benefit of temporally-strong labels in audio event classification,” in ICASSP 2021-2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). IEEE, 2021, pp. 366–370.
225
+ [52] P. Warden, “Speech Commands: A Dataset for Limited-Vocabulary Speech Recognition,” ArXiv e-prints, Apr. 2018.
226
+ [53] S. wen Yang, P.-H. Chi, Y.-S. Chuang, C.-I. J. Lai, K. Lakhotia, Y. Y. Lin, A. T. Liu, J. Shi, X. Chang, G.-T. Lin, T.-H. Huang, W.-C. Tseng, K. tik Lee, D.-R. Liu, Z. Huang, S. Dong, S.-W. Li, S. Watanabe, A. Mohamed, and H. yi Lee, “SUPERB: Speech Processing Universal PERformance Benchmark,” in Proc. Interspeech 2021, 2021, pp. 1194–1198.
227
+ [54] A. Nagrani, J. S. Chung, W. Xie, and A. Zisserman, “Voxceleb: Large-scale speaker verification in the wild,” Comput. Speech Lang., vol. 60, 2020.
228
+ [55] D. Povey, A. Ghoshal, G. Boulianne, L. Burget, O. Glembek, N. Goel, M. Hannemann, P. Motlicek, Y. Qian, P. Schwarz et al., “The kaldi speech recognition toolkit,” in IEEE 2011 workshop on automatic speech recognition and understanding, no. CONF. IEEE Signal Processing Society, 2011.
229
+ [56] S. Yun, D. Han, S. Chun, S. J. Oh, Y. Yoo, and J. Choe, “Cutmix: Regularization strategy to train strong classifiers with localizable features,” in 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019. IEEE, 2019, pp. 6022–6031.
230
+ [57] H. Zhang, M. Cissé, Y. N. Dauphin, and D. Lopez-Paz, “mixup: Beyond empirical risk minimization,” in 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018.
231
+ [58] S. Verbitskiy, V. Berikov, and V. Vyshegorodtsev, “Eranns: Efficient residual audio neural networks for audio pattern recognition,” arXiv preprint arXiv:2106.01621, 2021.
232
+ [59] Q. Kong, Y. Cao, T. Iqbal, Y. Wang, W. Wang, and M. D. Plumbley, “Panns: Large-scale pretrained audio neural networks for audio pattern recognition,” IEEE ACM Trans. Audio Speech Lang. Process., vol. 28, pp. 2880–2894, 2020.
233
+ [60] M. Tan and Q. V. Le, “Efficientnet: Rethinking model scaling for convolutional neural networks,” in Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, ser. Proceedings of Machine Learning Research, vol. 97. PMLR, 2019, pp. 6105–6114.
234
+ [61] D. Griffin and J. Lim, “Signal estimation from modified short-time fourier transform,” IEEE Transactions on Acoustics, Speech, and Signal Processing, vol. 32, no. 2, pp. 236–243, 1984.
235
+ [62] Y. Suzuki and H. Takeshima, “Equal-loudness-level contours for pure tones,” The Journal of the Acoustical Society of America, vol. 116, no. 2, pp. 918–933, 2004.
md/dev/MkbcAHIYgyS/MkbcAHIYgyS.md ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MASS-EDITING MEMORY IN A TRANSFORMER
2
+
3
+ Kevin Meng1,2 Arnab Sen Sharma2 Alex Andonian1 Yonatan Belinkov† 3 David Bau2 1MIT CSAIL 2Northeastern University 3Technion – IIT
4
+
5
+ # ABSTRACT
6
+
7
+ Recent work has shown exciting promise in updating large language models with new memories, so as to replace obsolete information or add specialized knowledge. However, this line of work is predominantly limited to updating single associations. We develop MEMIT, a method for directly updating a language model with many memories, demonstrating experimentally that it can scale up to thousands of associations for GPT-J (6B) and GPT-NeoX (20B), exceeding prior work by orders of magnitude. Our code and data are at memit.baulab.info.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ How many memories can we add to a deep network by directly editing its weights?
12
+
13
+ Although large autoregressive language models (Radford et al., 2019; Brown et al., 2020; Wang & Komatsuzaki, 2021; Black et al., 2022) are capable of recalling an impressive array of common facts such as “Tim Cook is the CEO of Apple” or “Polaris is in the constellation Ursa Minor” (Petroni et al., 2020; Brown et al., 2020), even very large models are known to lack more specialized knowledge, and they may recall obsolete information if not updated periodically (Lazaridou et al., 2021; Agarwal & Nenkova, 2022; Liska et al., 2022). The ability to maintain fresh and customizable information is desirable in many application domains, such as question answering, knowledge search, and content generation. For example, we might want to keep search models updated with breaking news and recently-generated user feedback. In other situations, authors or companies may wish to customize models with specific knowledge about their creative work or products. Because re-training a large model can be prohibitive (Patterson et al., 2021) we seek methods that can update knowledge directly.
14
+
15
+ To that end, several knowledge-editing methods have been proposed to insert new memories directly into specific model parameters. The approaches include constrained fine-tuning (Zhu et al., 2020), hypernetwork knowledge editing (De Cao et al., 2021; Hase et al., 2021; Mitchell et al., 2021; 2022), and rank-one model editing (Meng et al., 2022). However, this body of work is typically limited to updating at most a few dozen facts; a recent study evaluates on a maximum of 75 (Mitchell et al., 2022) whereas others primarily focus on single-edit cases. In practical settings, we may wish to update a model with hundreds or thousands of facts simultaneously, but a naive sequential application of current state-of-the-art knowledge-editing methods fails to scale up (Section 5.2).
16
+
17
+ ![](images/47d0fae4ebb5301f53fbc8c35686cf6697331147c98f59fafd96bca809cb4b24.jpg)
18
+ Figure 1: MEMIT is capable of updating thousands of memories at once. (a) Language models can be viewed as knowledge bases containing memorized tuples $( s , r , o )$ , each connecting some subject $s$ to an object $o$ via a relation $r$ , e.g., ( $s =$ Michael Jordan, $r =$ plays sport, $o =$ basketball). (b) MEMIT modifies transformer weights to edit memories, e.g., “Michael Jordan now plays the sport baseball,” while (c) maintaining generalization, specificity, and fluency at scales beyond other methods. As Section 5.2.2 details, editing score is the harmonic mean of efficacy, generalization, and specificity metrics.
19
+
20
+ We propose MEMIT, a scalable multi-layer update algorithm that uses explicitly calculated parameter updates to insert new memories. Inspired by the ROME direct editing method (Meng et al., 2022), MEMIT targets the weights of transformer modules that we determine to be causal mediators of factual knowledge recall. Experiments on GPT-J (6B parameters; Wang & Komatsuzaki 2021) and GPT-NeoX (20B; Black et al. 2022) demonstrate that MEMIT can scale and successfully store thousands of memories in bulk. We analyze model behavior when inserting true facts, counterfactuals, 27 specific relations, and different mixed sets of memories. In each setting, we measure robustness in terms of generalization, specificity, and fluency while comparing the scaling of MEMIT to rank-one, hypernetwork, and fine-tuning baselines.
21
+
22
+ # 2 RELATED WORK
23
+
24
+ Scalable knowledge bases. The representation of world knowledge is a core problem in artificial intelligence (Richens, 1956; Minsky, 1974), classically tackled by constructing knowledge bases of real-world concepts. Pioneering hand-curated efforts (Lenat, 1995; Miller, 1995) have been followed by web-powered knowledge graphs (Auer et al., 2007; Bollacker et al., 2007; Suchanek et al., 2007; Havasi et al., 2007; Carlson et al., 2010; Dong et al., 2014; Vrandeciˇ c & Krötzsch´ , 2014; Bosselut et al., 2019) that extract knowledge from large-scale sources. Structured knowledge bases can be precisely queried, measured, and updated (Davis et al., 1993), but they are limited by sparse coverage of uncatalogued knowledge, such as commonsense facts (Weikum, 2021).
25
+
26
+ Language models as knowledge bases. Since LLMs can answer natural-language queries about real-world facts, it has been proposed that they could be used directly as knowledge bases (Petroni et al., 2019; Roberts et al., 2020; Jiang et al., 2020; Shin et al., 2020). However, LLM knowledge is only implicit; responses are sensitive to specific phrasings of the prompt (Elazar et al., 2021; Petroni et al., 2020), and it remains difficult to catalog, add, or update knowledge (AlKhamissi et al., 2022). Nevertheless, LLMs are promising because they scale well and are unconstrained by a fixed schema (Safavi & Koutra, 2021). In this paper, we take on the update problem, asking how the implicit knowledge encoded within model parameters can be mass-edited.
27
+
28
+ Hypernetwork knowledge editors. Several meta-learning methods have been proposed to edit knowledge in a model. Sinitsin et al. (2019) proposes a training objective to produce models amenable to editing by gradient descent. De Cao et al. (2021) proposes a Knowledge Editor (KE) hypernetwork that edits a standard model by predicting updates conditioned on new factual statements. In a study of KE, Hase et al. (2021) find that it fails to scale beyond a few edits, and they scale an improved objective to 10 beliefs. MEND (Mitchell et al., 2021) also adopts meta-learning, inferring weight updates from the gradient of the inserted fact. To scale their method, Mitchell et al. (2022) proposes SERAC, a system that routes rewritten facts through a different set of parameters while keeping the original weights unmodified; they demonstrate scaling up to 75 edits. Rather than meta-learning, our method employs direct parameter updates based on an explicitly computed mapping.
29
+
30
+ Direct model editing. Our work most directly builds upon efforts to localize and understand the internal mechanisms within LLMs (Elhage et al., 2021; Dar et al., 2022). Based on observations from Geva et al. (2021; 2022) that transformer MLP layers serve as key–value memories, we narrow our focus to them. We then employ causal mediation analysis (Pearl, 2001; Vig et al., 2020; Meng et al., 2022), which implicates a specific range of layers in recalling factual knowledge. Previously, Dai et al. (2022) and Yao et al. (2022) have proposed editing methods that alter sparse sets of neurons, but we adopt the classical view of a linear layer as an associative memory (Anderson, 1972; Kohonen, 1972). Our method is closely related to Meng et al. (2022), which also updates GPT as an explicit associative memory. Unlike the single-edit approach taken in that work, we modify a sequence of layers and develop a way for thousands of modifications to be performed simultaneously.
31
+
32
+ # 3 PRELIMINARIES: LANGUAGE MODELING AND MEMORY EDITING
33
+
34
+ The goal of MEMIT is to modify factual associations stored in the parameters of an autoregressive LLM. Such models generate text by iteratively sampling from a conditional token distribution
35
+
36
+ $\mathbb { P } \left[ x _ { [ t ] } ~ | ~ x _ { [ 1 ] } , \dots , x _ { [ E ] } \right]$ parameterized by a $D$ -layer transformer decoder, $G$ (Vaswani et al., 2017):
37
+
38
+ $$
39
+ \mathbb { P } \left[ x _ { [ t ] } \ | \ x _ { [ 1 ] } , \dots , x _ { [ E ] } \right] \triangleq G ( [ x _ { [ 1 ] } , \dots , x _ { [ E ] } ] ) = \mathrm { s o f t m a x } \left( W _ { y } h _ { [ E ] } ^ { D } \right) ,
40
+ $$
41
+
42
+ where This s $h _ { [ E ] } ^ { D }$ is the transformer’s hidden state representation at the final layer s computed using the following recursive relation: $D$ and ending token $E$
43
+
44
+ $$
45
+ \begin{array} { r l r } & { } & { h _ { [ t ] } ^ { l } ( x ) = h _ { [ t ] } ^ { l - 1 } ( x ) + a _ { [ t ] } ^ { l } ( x ) + m _ { [ t ] } ^ { l } ( x ) \qquad } \\ & { } & { \mathrm { w h e r e \ } a ^ { l } = \mathrm { a t t n } ^ { l } \left( h _ { [ 1 ] } ^ { l - 1 } , h _ { [ 2 ] } ^ { l - 1 } , \dots , h _ { [ t ] } ^ { l - 1 } \right) } \\ & { } & { m _ { [ t ] } ^ { l } = W _ { o u t } ^ { l } \sigma \left( W _ { i n } ^ { l } \gamma \left( h _ { [ t ] } ^ { l - 1 } \right) \right) , \qquad } \end{array}
46
+ $$
47
+
48
+ $h _ { [ t ] } ^ { 0 } ( x )$ is the embedding of token $x _ { [ t ] }$ , and $\gamma$ is layernorm. Note that we have written attention and MLPs in parallel as done in Black et al. (2021) and Wang & Komatsuzaki (2021).
49
+
50
+ Large language models have been observed to contain many memorized facts (Petroni et al., 2020; Brown et al., 2020; Jiang et al., 2020; Chowdhery et al., 2022). In this paper, we study facts of the form (subject $s$ , relation $r$ , object $o$ ), e.g., $s =$ Michael Jordan, $r =$ plays sport, $o =$ basketball). A generator $G$ can recall a memory for $( s _ { i } , r _ { i } , * )$ if we form a natural language prompt $p _ { i } = p ( s _ { i } , r _ { i } )$ such as “Michael Jordan plays the sport of” and predict the next token(s) representing $o _ { i }$ . Our goal is to edit many memories at once. We formally define a list of edit requests as:
51
+
52
+ $$
53
+ { \mathcal { E } } = \{ ( s _ { i } , r _ { i } , o _ { i } ) \mid i \} \ \mathrm { s . t . } \ \not \exists i , j . \ ( s _ { i } = s _ { j } ) \land ( r _ { i } = r _ { j } ) \land ( o _ { i } \neq o _ { j } ) .
54
+ $$
55
+
56
+ The logical constraint ensures that there are no conflicting requests. For example, we can edit Michael Jordan to play $o _ { i } =$ “baseball”, but then we exclude associating him with professional soccer.
57
+
58
+ What does it mean to edit a memory well? At a superficial level, a memory can be considered edited after the model assigns a higher probability to the statement “Michael Jordan plays the sport of baseball” than to the original prediction (basketball); we say that such an update is effective. Yet it is important to also view the question in terms of generalization, specificity, and fluency:
59
+
60
+ • To test for generalization, we can rephrase the question: “What is Michael Jordan’s sport? What sport does he play professionally?” If the modification of $G$ is superficial and overfitted to the specific memorized prompt, such predictions will fail to recall the edited memory, “baseball.” • Conversely, to test for specificity, we can ask about similar subjects for which memories should not change: “What sport does Kobe Bryant play? What does Magic Johnson play?” These tests will fail if the updated $G$ indiscriminately regurgitates “baseball” for subjects that were not edited. • When making changes to a model, we must also monitor fluency. If the updated model generates disfluent text such as “baseball baseball baseball baseball,” we should count that as a failure.
61
+
62
+ Achieving these goals is challenging, even for a few edits (Hase et al., 2021; Mitchell et al., 2022;
63
+ Meng et al., 2022). We investigate whether they can be attained at the scale of thousands of edits.
64
+
65
+ # 4 METHOD
66
+
67
+ MEMIT inserts memories by updating transformer mechanisms that have recently been elucidated using causal mediation analysis (Meng et al., 2022). In GPT-2 XL, we found that there is a sequence of critical MLP layers $\mathcal { R }$ that mediate factual association recall at the last subject token $S$ (Figure 2). MEMIT operates by (i) calculating the vector associations we want the critical layers to remember, then (ii) storing a portion of the desired memories in each layer $l \in \mathcal { R }$ .
68
+
69
+ Throughout this paper, our focus will be on states representing the last subject token $S$ of prompt $p _ { i }$ , so we shall abbreviate $h _ { i } ^ { l } = h _ { [ S ] } ^ { l } ( p _ { i } )$ . Similarly, $m _ { i } ^ { l }$ and $a _ { i } ^ { l }$ denote $m _ { [ S ] } ^ { l } ( p _ { i } )$ and $a _ { [ S ] } ^ { l } ( p _ { i } )$ .
70
+
71
+ # 4.1 IDENTIFYING THE CRITICAL PATH OF MLP LAYERS
72
+
73
+ Figure 3 shows the results of applying causal tracing to the larger GPT-J (6B) model; for implementation details, see Appendix A. We measure the average indirect causal effect of each $h _ { i } ^ { l }$ on a sample of memory prompts $p _ { i }$ , with either the Attention or MLP modules for token $S$ disabled. The results confirm that GPT-J has a concentration of mediating states $h _ { i } ^ { l }$ ; moreover, they highlight a mediating causal role for a range of MLP modules, which can be seen as a large gap between the effect of single states (purple bars in Figure 3) and the effects with MLP severed (green bars); this gap diminishes after layer 8. Unlike Meng et al. (2022) who use this test to identify a single edit layer, we select the whole range of critical MLP layers $l \in \mathcal { R }$ . For GPT-J, we have $\mathcal { R } \overset { \cdot } { = } \{ 3 , \overset { \cdot } { 4 } , 5 , 6 , 7 , \overset { \cdot } { 8 } \}$ .
74
+
75
+ ![](images/b9dea340cb32a7fc575a9170deb530c7e5b511bf48827ea389810d508d25645b.jpg)
76
+ Figure 2: MEMIT modifies transformer parameters on the critical path of MLP-mediated factual recall. We edit stored associations based on observed patterns of causal mediation: (a) first, the early-layer attention modules gather subject names into vector representations at the last subject token $S$ . (b) Then MLPs at layers $l \in \mathcal { R }$ read these encodings and add memories to the residual stream. (c) Those hidden states are read by attention to produce the output. (d) MEMIT edits memories by storing vector associations in the critical MLPs.
77
+
78
+ Given that a range of MLPs play a joint mediating role in recalling facts, we ask: what is the role of one MLP in storing a memory? Each token state in a transformer is part of the residual stream that all attention and MLP modules read from and write to (Elhage et al., 2021). Unrolling Eqn. 2 for $h _ { i } ^ { L ^ { \bf ^ { - } } } = h _ { [ S ] } ^ { L } ( p _ { i } )$ :
79
+
80
+ $$
81
+ h _ { i } ^ { L } = h _ { i } ^ { 0 } + \sum _ { l = 1 } ^ { L } a _ { i } ^ { l } + \sum _ { l = 1 } ^ { L } m _ { i } ^ { l } .
82
+ $$
83
+
84
+ ![](images/dfafe5cd3db0d393f4e139abe80dd2d3895bfc8c2d4e4edc4ae6bab0861bf6ea.jpg)
85
+ Figure 3: A critical mediating role for mid-layer MLPs.
86
+ Eqn. 6 highlights that each individual
87
+
88
+ MLP contributes by adding to the memory at $h _ { i } ^ { L }$ (Figure 2b), which is later read by last-token attention modules (Figure 2c). Therefore, when writing new memories into $G$ , we can spread the desired changes across all the critical layers $m _ { i } ^ { l }$ for $l \in \mathcal { R }$ .
89
+
90
+ # 4.2 BATCH UPDATE FOR A SINGLE LINEAR ASSOCIATIVE MEMORY
91
+
92
+ In each individual layer $l$ , we wish to store a large batch of $u \gg 1$ memories. This section derives an optimal single-layer update that minimizes the squared error of memorized associations, assuming that the layer contains previously-stored memories that should be preserved. We denote $W _ { 0 } \triangleq W _ { o u t } ^ { l }$ (Eqn. 4, Figure 2) and analyze it as a linear associative memory (Kohonen, 1972; Anderson, 1972) that associates a set of input keys $k _ { i } \triangleq k _ { i } ^ { l }$ (encoding subjects) to corresponding memory values $m _ { i } \triangleq m _ { i } ^ { l }$ (encoding memorized properties) with minimal squared error:
93
+
94
+ $$
95
+ W _ { 0 } \triangleq \underset { \hat { W } } { \mathrm { a r g m i n } } \sum _ { i = 1 } ^ { n } \left\| \hat { W } k _ { i } - m _ { i } \right\| ^ { 2 } .
96
+ $$
97
+
98
+ If we stack keys and memories as matrices $K _ { 0 } = [ k _ { 1 } \ | \ k _ { 2 } \ | \ \cdot \ \cdot \ | \ k _ { n } ]$ and $M _ { 0 } = [ m _ { 1 } \mid m _ { 2 } \mid \cdot \cdot \cdot \mid m _ { n } ]$ then Eqn. 7 can be optimized by solving the normal equation (Strang, 1993, Chapter 4):
99
+
100
+ $$
101
+ W _ { 0 } K _ { 0 } K _ { 0 } ^ { T } = M _ { 0 } K _ { 0 } ^ { T } .
102
+ $$
103
+
104
+ Suppose that pre-training sets a transformer MLP’s weights to the optimal solution $W _ { 0 }$ as defined in Eqn. 8. Our goal is to update $W _ { 0 }$ with some small change $\Delta$ that produces a new matrix $W _ { 1 }$ with
105
+
106
+ ![](images/39a7dca4c66a971091e1e7866e1e074fe55b8940648b40fcf362fb062e28faeb.jpg)
107
+ Figure 4: The MEMIT update. We first (i) replace $h _ { i } ^ { l }$ with the vector $z _ { i }$ and optimize Eqn. 16 so that it conveys the new memory. Then, after all $z _ { i }$ are calculated we (ii) iteratively insert a fraction of the residuals for all $z _ { i }$ over the range of critical MLP modules, executing each layer’s update by applying Eqn. 14. Because changing one layer will affect activations of downstream modules, we recollect activations after each iteration.
108
+
109
+ a set of additional associations. Unlike Meng et al. (2022), we cannot solve our problem with a constraint that adds only a single new association, so we define an expanded objective:
110
+
111
+ $$
112
+ W _ { 1 } \triangleq \underset { \hat { W } } { \mathrm { a r g m i n } } \left( \sum _ { i = 1 } ^ { n } \left\| \hat { W } k _ { i } - m _ { i } \right\| ^ { 2 } + \sum _ { i = n + 1 } ^ { n + u } \left\| \hat { W } k _ { i } - m _ { i } \right\| ^ { 2 } \right) .
113
+ $$
114
+
115
+ We can solve Eqn. 9 by again applying the normal equation, now written in block form:
116
+
117
+ $$
118
+ \begin{array} { r l } { W _ { 1 } \left[ K _ { 0 } \quad K _ { 1 } \right] \left[ K _ { 0 } \quad K _ { 1 } \right] ^ { T } = \left[ M _ { 0 } \quad M _ { 1 } \right] \left[ K _ { 0 } \quad K _ { 1 } \right] ^ { T } } & { { } } \end{array}
119
+ $$
120
+
121
+ $$
122
+ \begin{array} { r l } { \mathrm { n d s ~ t o } : } & { { } ( W _ { 0 } + \Delta ) ( K _ { 0 } K _ { 0 } ^ { T } + K _ { 1 } K _ { 1 } ^ { T } ) = M _ { 0 } K _ { 0 } ^ { T } + M _ { 1 } K _ { 1 } ^ { T } } \end{array}
123
+ $$
124
+
125
+ $$
126
+ W _ { 0 } K _ { 0 } K _ { 0 } ^ { T } + W _ { 0 } K _ { 1 } K _ { 1 } ^ { T } + \Delta K _ { 0 } K _ { 0 } ^ { T } + \Delta K _ { 1 } K _ { 1 } ^ { T } = M _ { 0 } K _ { 0 } ^ { T } + M _ { 1 } K _ { 1 } ^ { T }
127
+ $$
128
+
129
+ $$
130
+ \mathrm { i n g ~ E q n . ~ 8 ~ f r o m ~ E q n . ~ 1 2 : } \quad \Delta ( K _ { 0 } K _ { 0 } ^ { T } + K _ { 1 } K _ { 1 } ^ { T } ) = M _ { 1 } K _ { 1 } ^ { T } - W _ { 0 } K _ { 1 } K _ { 1 } ^ { T } .
131
+ $$
132
+
133
+ A succinct solution can be written by defining two additional quantities: $C _ { 0 } \triangleq K _ { 0 } K _ { 0 } ^ { T }$ , a constant proportional to the uncentered covariance of the pre-existing keys, and $R \triangleq M _ { 1 } - W _ { 0 } K _ { 1 } ^ { \ast }$ , the residual error of the new associations when evaluated on old weights $W _ { 0 }$ . Then Eqn. 13 can be simplified as:
134
+
135
+ $$
136
+ \Delta = R K _ { 1 } ^ { T } ( C _ { 0 } + K _ { 1 } K _ { 1 } ^ { T } ) ^ { - 1 } .
137
+ $$
138
+
139
+ Since pretraining is opaque, we do not have access to $K _ { 0 }$ or $M _ { 0 }$ . Fortunately, computing Eqn. 14 only requires an aggregate statistic $C _ { 0 }$ over the previously stored keys. We assume that the set of previously memorized keys can be modeled as a random sample of inputs, so that we can compute
140
+
141
+ $$
142
+ C _ { 0 } = \lambda \cdot \mathbb { E } _ { k } \left[ k k ^ { T } \right]
143
+ $$
144
+
145
+ by estimating $\mathbb { E } _ { k } \left[ k k ^ { T } \right]$ , an uncentered covariance statistic collected using an empirical sample of vector inputs to the layer. We must also select $\lambda$ , a hyperparameter that balances the weighting of new v.s. old associations; a typical value is $\lambda = 1 . 5 \times \bar { 1 } 0 ^ { 4 }$ .
146
+
147
+ # 4.3 UPDATING MULTIPLE LAYERS
148
+
149
+ We now define the overall update algorithm (Figure 4). Inspired by the observation that robustness is improved when parameter change magnitudes are minimized (Zhu et al., 2020), we spread updates evenly over the range of mediating layers $\mathcal { R }$ . We define a target layer $L \triangleq \operatorname* { m a x } ( \mathcal { R } ) ^ { * }$ at the end of the mediating layers, at which the new memories should be fully represented. Then, for each edit $( s _ { i } , r _ { i } , o _ { i } ) \in \mathbf { \bar { \mathcal { E } } }$ , we (i) compute a hidden vector $z _ { i }$ to replace $h _ { i } ^ { L }$ such that adding $\delta _ { i } \triangleq z _ { i } - h _ { i } ^ { L }$ to the hidden state at layer $L$ and token $T$ will completely convey the new memory. Finally, one layer at a time, we (ii) modify the MLP at layer $l$ , so that it contributes an approximately-equal portion of the change $\delta _ { i }$ for each memory $i$ .
150
+
151
+ (i) Computing $z _ { i }$ . For the $i$ th memory, we first compute a vector $z _ { i }$ that would encode the association $( s _ { i } , r _ { i } , o _ { i } )$ if it were to replace $h _ { i } ^ { L }$ at layer $L$ at token $S$ . We find $z _ { i } = h _ { i } ^ { L } + \delta _ { i }$ by optimizing the residual vector $\delta _ { i }$ using gradient descent:
152
+
153
+ $$
154
+ z _ { i } = h _ { i } ^ { L } + \underset { \delta _ { i } } { \mathrm { a r g m i n } } \frac { 1 } { P } \sum _ { j = 1 } ^ { P } - \log \mathbb { P } _ { G ( h _ { i } ^ { L } + = \delta _ { i } ) } \left[ o _ { i } \mid x _ { j } \oplus p ( s _ { i } , r _ { i } ) \right] .
155
+ $$
156
+
157
+ In words, we optimize $\delta _ { i }$ to maximize the model’s prediction of the desired object $o _ { i }$ , given a set of factual prompts $\{ x _ { j } \oplus p ( s _ { i } , r _ { i } ) \}$ that concatenate random prefixes $x _ { j }$ to a templated prompt to aid generalization across contexts. $\overset { \triangledown } { \boldsymbol { G } } ( h _ { i } ^ { L } + = \delta _ { i } )$ indicates that we modify the transformer execution by substituting the modified hidden state $z _ { i }$ for $h _ { i } ^ { L }$ ; this is called “hooking” in popular ML libraries.
158
+
159
+ (ii) Spreading $z _ { i } - h _ { i } ^ { L }$ over layers. We seek delta matrices $\Delta ^ { l }$ such that:
160
+
161
+ $$
162
+ \begin{array} { r l } & { \mathrm { t i n g } \ \hat { W } _ { o u t } ^ { l } : = W _ { o u t } ^ { l } + \Delta ^ { l } \mathrm { \ f o r \ a l l } \ l \in { \mathcal { R } } \mathrm { \ o p t i m i z e s \ } \displaystyle \operatorname* { m i n } _ { \{ \Delta ^ { l } \} } \sum _ { i } \left\| z _ { i } - \hat { h } _ { i } ^ { L } \right\| ^ { 2 } , } \\ & { \mathrm { \ w h e r e } \ \hat { h } _ { i } ^ { L } = h _ { i } ^ { 0 } + \displaystyle \sum _ { l = 1 } ^ { L } a _ { i } ^ { l } + \sum _ { l = 1 } ^ { L } \hat { W } _ { o u t } ^ { l } \sigma \left( W _ { i n } ^ { l } \gamma \left( h _ { t } ^ { l - 1 } \right) \right) . } \end{array}
163
+ $$
164
+
165
+ Because edits to any layer will influence all following layers’ activations, we calculate $\Delta ^ { l }$ iteratively in ascending layer order (Figure 4ii-a,b,c). To compute each individual $\Delta ^ { l }$ , we need the corresponding keys $K ^ { l } = \mathsf { \bar { [ } } k _ { 1 } ^ { l ^ { \prime } } | \cdots | k _ { n } ^ { l } ]$ and memories $M ^ { l } = [ \dot { m } _ { 1 } ^ { l } \ | \ \cdots | \ m _ { n } ^ { l } ]$ to insert using Eqn. 14. Each key $k _ { i } ^ { l }$ is computed as the input to $W _ { o u t } ^ { l }$ at each layer $l$ (Figure 2d):
166
+
167
+ $$
168
+ k _ { i } ^ { l } = \frac { 1 } { P } \sum _ { j = 1 } ^ { P } k ( x _ { j } + s _ { i } ) , \mathrm { ~ w h e r e ~ } k ( x ) = \sigma \left( W _ { i n } ^ { l } \gamma \left( h _ { i } ^ { l - 1 } ( x ) \right) \right) .
169
+ $$
170
+
171
+ $m _ { i } ^ { l }$ is then computed as the sum of its current value and a fraction of the remaining top-level residual:
172
+
173
+ where the denominator of $r _ { i }$ spreads the residual out evenly. Algorithm 1 summarizes MEMIT, and additional implementation details are offered in Appendix B.
174
+
175
+ # Algorithm 1: The MEMIT Algorithm
176
+
177
+ <table><tr><td colspan="2">Data: Requested edits ε= {(si, ri,Oi)}, generator G,layers to edit S,covariances Cl Result: Modified generator containing edits from £</td></tr><tr><td colspan="2">forSi,ri,Oi∈εdo // Compute target zi vectors for every memory i</td></tr><tr><td></td><td>optimize δi ← argmins𝑖 p∑𝑗=1-log PG(h +=δi)[0i |xj p(si,ri)] (Eqn. 16)</td></tr><tr><td>3 4 end</td><td>z←h+δi</td></tr><tr><td colspan="2"></td></tr><tr><td>5 forl∈Rdo 6</td><td>//Perform update:spread changes over layers h←h-1+a+m (Eqn.2) //Run layer l with updated weights</td></tr><tr><td>7</td><td>for Si,ri,Oi ∈εdo</td></tr><tr><td>8</td><td>k←= 1 P k(xj+si) (Eqn.19) P j=1</td></tr><tr><td>9</td><td>2-h r← (Eqn. 20) //Distribute residual over remaining layers L-+1</td></tr><tr><td>10</td><td>end</td></tr><tr><td>11</td><td>K←[,..,k]</td></tr><tr><td>12</td><td>Rl←[r&#x27;,...,.r]</td></tr><tr><td>13</td><td>△¹ ←R¹K𝑙T(C𝑙 +K¹K𝑙𝑇)-1 (Eqn.14)</td></tr><tr><td>14</td><td>Wl←Wl+△ / Update layer l MLP weights in model</td></tr><tr><td>15 end</td><td></td></tr></table>
178
+
179
+ # 5 EXPERIMENTS
180
+
181
+ # 5.1 MODELS AND BASELINES
182
+
183
+ We run experiments on two autoregressive LLMs: GPT-J (6B) and GPT-NeoX (20B). For baselines, we first compare with a naive fine-tuning approach that uses weight decay to prevent forgetfulness (FT-W). Next, we experiment with MEND, a hypernetwork-based model editing approach that edits multiple facts at the same time (Mitchell et al., 2021). Finally, we run a sequential version of ROME (Meng et al., 2022): a direct model editing method that iteratively updates one fact at a time. The recent SERAC model editor (Mitchell et al., 2022) does not yet have public code, so we cannot compare with it at this time. See Appendix B for implementation details.
184
+
185
+ # 5.2 MEMIT SCALING
186
+
187
+ # 5.2.1 EDITING 10K MEMORIES IN ZSRE
188
+
189
+ We first test MEMIT on zsRE (Levy et al., 2017), a question-answering task from which we extract 10,000 real-world facts; zsRE tests MEMIT’s ability to add correct information. Because zsRE does not contain generation tasks, we evaluate solely on prediction-based metrics. Efficacy
190
+
191
+ Table 1: 10,000 zsRE Edits on GPT-J (6B).
192
+
193
+ <table><tr><td>Editor</td><td>Score 个</td><td>Efficacy ↑</td><td>Paraphrase 个</td><td>Specificity ↑</td></tr><tr><td>GPT-J</td><td>26.4</td><td>26.4 (±0.6)</td><td>25.8 (±0.5)</td><td>27.0 (±0.5)</td></tr><tr><td>FT-W</td><td>42.1</td><td>69.6(±0.6)</td><td>64.8 (±0.6)</td><td>24.1 (±0.5)</td></tr><tr><td>MEND</td><td>20.0</td><td>19.4 (±0.5)</td><td>18.6 (±0.5)</td><td>22.4 (±0.5)</td></tr><tr><td>ROME</td><td>2.6</td><td>21.0 (±0.7)</td><td>19.6 (±0.7)</td><td>0.9 (±0.1)</td></tr><tr><td>MEMIT</td><td>50.7</td><td>96.7 (±0.3)</td><td>89.7 (±0.5)</td><td>26.6 (±0.5)</td></tr></table>
194
+
195
+ measures the proportion of cases where $o$ is the argmax generation given $p ( s , r )$ , Paraphrase is the same metric but applied on paraphrases, Specificity is the model’s argmax accuracy on a randomly-sampled unrelated fact that should not have changed, and Score is the harmonic mean of the three aforementioned scores; Appendix C contains formal definitions. As Table 1 shows, MEMIT performs best at 10,000 edits; most memories are recalled with generalization and minimal bleedover. Interestingly, simple fine-tuning FT-W performs better than the baseline knowledge editing methods MEND and ROME at this scale, likely because its objective is applied only once.
196
+
197
+ # 5.2.2 COUNTERFACT SCALING CURVES
198
+
199
+ Next, we test MEMIT’s ability to add counterfactual information using COUNTERFACT, a collection of 21,919 factual statements (Meng et al. (2022), Appendix C). We first filter conflicts by removing facts that violate the logical condition in Eqn. 5 (i.e., multiple edits modify the same $( s , r )$ prefix to different objects). For each problem size $n \ \in \ \{ 1 , 2 , 3 , 6 , 1 0 , 1 8 , 3 2 $ , $5 6 , 1 0 0 , 1 7 8 , 3 1 6 , 5 6 2 , 1 0 0 0 , 1 7 7 8 , 3 1 6 \dot { 2 } , 5 6 2 3 , 1 0 0 0 0 \dot { 5 } ^ { 1 }$ , $n$ counterfactuals are inserted.
200
+
201
+ Following Meng et al. (2022), we report several metrics designed to test editing desiderata. Efficacy Success (ES) evaluates editing success and is the proportion of cases for which the new object $o _ { i }$ ’s probability is greater than the probability of the true real-world object $o _ { i } ^ { c }$ : 2 $\mathbb { E } _ { i } \left[ \mathbb { P } _ { G } \left[ o _ { i } \ | \ p ( s _ { i } , \bar { r } _ { i } ) \right] > \mathbb { P } _ { G } \left[ o _ { i } ^ { c } \ | \ \bar { p } ( s _ { i } , r _ { i } ) \right] \right]$ . Paraphrase Success (PS) is a generalization measure defined similarly, except $G$ is prompted with rephrasings of the original statement. For testing specificity, Neighborhood Success (NS) is defined similarly, but we check the probability $G$ assigns to the correct answer $o _ { i } ^ { c }$ (instead of $o _ { i }$ ), given prompts about distinct but semantically-related subjects (instead of $s _ { i }$ ). Editing Score (S) aggregates metrics by taking the harmonic mean of ES, PS, NS.
202
+
203
+ We are also interested in measuring generation quality of the updated model. First, we check that $G$ ’s generations are semantically consistent with the new object using a Reference Score (RS), which is collected by generating text about $s$ and checking its TF-IDF similarity with a reference Wikipedia text about $o$ . To test for fluency degradation due to excessive repetition, we measure Generation Entropy (GE), computed as the weighted sum of the entropy of bi- and tri-gram $n$ -gram distributions of the generated text. See Appendix C for further details on metrics.
204
+
205
+ Figure 5 plots performance v.s. number of edits on log scale, up to 10,000 facts. ROME performs well up to $n = 1 0$ but degrades starting at $n = 3 2$ . Similarly, MEND performs well at $n = 1$ but rapidly declines at $n = 6$ , losing all efficacy before $n = 1 , 0 0 0$ and, curiously, having negligible effect on the model at $n = 1 0 { , } 0 0 0$ (the high specificity score is achieved by leaving the model nearly unchanged). MEMIT performs best at large $n$ . At small $n$ , ROME achieves better generalization at the cost of slightly lower specificity, which means that ROME’s edits are more robust under rephrasings, likely due to that method’s hard equality constraint for weight updates, compared to MEMIT’s soft error minimization. Table 2 provides a direct numerical comparison at 10,000 edits on both GPT-J and GPT-NeoX. FT-W3 does well on probability-based metrics but suffers from complete generation failure, indicating significant model damage.
206
+
207
+ Appendix B provides a runtime analysis of all four methods on 10,000 edits. We find that MEND is fastest, taking 98 sec. FT is second at around $2 9 \mathrm { { m i n } }$ , while MEMIT and ROME are the slowest at
208
+
209
+ ![](images/74fc87faad1c8262ed6b9f61d961fe0b03090ac8b6dee27725e030b9026fcb8c.jpg)
210
+ Figure 5: MEMIT scaling curves plot editing performance against problem size (log-scale). The dotted line indicates GPT-J’s pre-edit performance; specificity (NS) and fluency (GE) should stay close to the baseline. $9 5 \%$ confidence intervals are shown as areas.
211
+
212
+ Table 2: Numerical results on COUNTERFACT for 10,000 edits.
213
+
214
+ <table><tr><td rowspan="2">Editor</td><td>Score</td><td>Efficacy</td><td>Generalization</td><td>Specificity</td><td>Fluency</td><td>Consistency</td></tr><tr><td>S个</td><td>ES个</td><td>PS个</td><td>NS↑</td><td>GE↑</td><td>RS个</td></tr><tr><td>GPT-J</td><td>22.4</td><td>15.2 (0.7)</td><td>17.7 (0.6)</td><td>83.5 (0.5)</td><td>622.4 (0.3)</td><td>29.4 (0.2)</td></tr><tr><td>FT-W</td><td>67.6</td><td>99.4 (0.1)</td><td>77.0 (0.7)</td><td>46.9 (0.6)</td><td>293.9 (2.4)</td><td>15.9 (0.3)</td></tr><tr><td>MEND</td><td>23.1</td><td>15.7 (0.7)</td><td>18.5 (0.7)</td><td>83.0 (0.5)</td><td>618.4 (0.3)</td><td>31.1 (0.2)</td></tr><tr><td>ROME</td><td>50.3</td><td>50.2 (1.0)</td><td>50.4 (0.8)</td><td>50.2 (0.6)</td><td>589.6 (0.5)</td><td>3.3 (0.0)</td></tr><tr><td>MEMIT</td><td>85.8</td><td>98.9 (0.2)</td><td>88.6 (0.5)</td><td>73.7 (0.5)</td><td>619.9 (0.3)</td><td>40.1 (0.2)</td></tr><tr><td>GPT-NeoX</td><td>23.7</td><td>16.8 (1.9)</td><td>18.3 (1.7)</td><td>81.6 (1.3)</td><td>620.4 (0.6)</td><td>29.3 (0.5)</td></tr><tr><td>MEMIT</td><td>82.0</td><td>97.2 (0.8)</td><td>82.2 (1.6)</td><td>70.8 (1.4)</td><td>606.4 (1.0)</td><td>36.9 (0.6)</td></tr></table>
215
+
216
+ $7 . 4 4 \mathrm { h r }$ and $1 2 . 2 9 \mathrm { h r }$ , respectively. While MEMIT’s execution time is high relative to MEND and FT, we note that its current implementation is naive and does not batch the independent $z _ { i }$ optimizations, instead computing each one in series. These computations are actually “embarrassingly parallel” and thus could be batched.
217
+
218
+ # 5.3 EDITING DIFFERENT CATEGORIES OF FACTS
219
+
220
+ For insight into MEMIT’s performance on different types of facts, we pick the 27 categories from COUNTERFACT that have at least 300 cases each, and assess each algorithm’s performance on those cases. Figure 6a shows that MEMIT achieves better overall scores compared to FT and MEND in all categories. It also reveals that some relations are harder to edit compared to others; for example, each of the editing algorithms faced difficulties in changing the sport an athlete plays. Even on harder cases, MEMIT outperforms other methods by a clear margin.
221
+
222
+ Model editing methods are known to occasionally suffer from a trade-off between attaining high generalization and good specificity. This trade-off is clearly visible for MEND in Figure 6b. FT consistently fails to achieve good specificity. Overall, MEMIT achieves a higher score in both dimensions, although it also exhibits a trade-off in editing some relations such as P127 (“product owned by company”) and P641 (“athlete plays sport”).
223
+
224
+ ![](images/757268e61ba87ac711aa352f9fbfde96936f7851bf36ab7e91eeece6e598a89b.jpg)
225
+ Figure 6: (a) Category-wise rewrite scores achieved by different approaches in editing 300 similar facts. (b) Category-wise specificity vs generalization scores by different approaches on 300 edits.
226
+
227
+ ![](images/0470dd56be757dbc3ad997d56aa33d885d173a7b073387d320a443a70b2e56fe.jpg)
228
+ Figure 7: When comparing mixes of edits, MEMIT gives consistent near-linear (near-average) performance while scaling up to 700 facts.
229
+
230
+ # 5.4 EDITING DIFFERENT CATEGORIES OF FACTS TOGETHER
231
+
232
+ To investigate whether the scaling of MEMIT is sensitive to differences in the diversity of the memories being edited together, we sample sets of cases ${ \mathcal { E } } _ { m i x }$ that mix two different relations from the COUNTERFACT dataset. We consider four scenarios depicted in Figure 7, where the relations have similar or different classes of subjects or objects. In all of the four cases, MEMIT’s performance on ${ \mathcal { E } } _ { m i x }$ is close to the average of the performance of each relation without mixing. This provides support to the hypothesis that the scaling of MEMIT is neither positively nor negatively affected by the diversity of the memories being edited. Appendix D contains implementation details.
233
+
234
+ # 6 DISCUSSION AND CONCLUSION
235
+
236
+ We have developed MEMIT, a method for editing factual memories in large language models by directly manipulating specific layer parameters. Our method scales to much larger sets of edits (100x) than other approaches while maintaining excellent specificity, generalization, and fluency.
237
+
238
+ Our investigation also reveals some challenges: certain relations are more difficult to edit with robust specificity, yet even on challenging cases we find that MEMIT outperforms other methods by a clear margin. The knowledge representation we study is also limited in scope to working with directional $( s , r , o )$ relations: it does not cover spatial or temporal reasoning, mathematical knowledge, linguistic knowledge, procedural knowledge, or even symmetric relations. For example, the association that “Tim Cook is CEO of Apple” must be processed separately from the opposite association that “The CEO of Apple is Tim Cook.”
239
+
240
+ Despite these limitations, it is noteworthy that large-scale model updates can be constructed using an explicit analysis of internal computations. Our results raise a question: might interpretability-based methods become a commonplace alternative to traditional opaque fine-tuning approaches? Our positive experience brings us optimism that further improvements to our understanding of network internals will lead to more transparent and practical ways to edit, control, and audit models.
241
+
242
+ # 7 ETHICAL CONSIDERATIONS
243
+
244
+ Although we test a language model’s ability to serve as a knowledge base, we do not find these models to be a reliable source of knowledge, and we caution readers that a LLM should not be used as an authoritative source of facts. Our memory-editing methods shed light on the internal mechanisms of models and potentially reduce the cost and energy needed to fix errors in a model, but the same methods might also enable a malicious actor to insert false or damaging information into a model that was not originally present in the training data.
245
+
246
+ # 8 ACKNOWLEDGEMENTS.
247
+
248
+ Thanks to Jaden Fiotto-Kaufmann for building the demonstration at memit.baulab.us. This project was supported by an AI Alignment grant from Open Philanthropy. YB was also supported by the Israel Science Foundation (grant No. 448/20) and an Azrieli Foundation Early Career Faculty Fellowship.
249
+
250
+ # 9 REPRODUCIBILITY
251
+
252
+ The code and data for our methods and experiments are available at memit.baulab.info.
253
+
254
+ All experiments are run on workstations with NVIDIA A6000 GPUs. The language models are loaded using HuggingFace Transformers (Wolf et al., 2019), and PyTorch (Paszke et al., 2019) is used for executing the model editing algorithms on GPUs.
255
+
256
+ GPT-J experiments fit into one 48GB A6000, but GPT-NeoX runs require at least two: one 48GB GPU for running the model in float16, and another slightly smaller GPU for executing the editing method. Due to the size of these language models, our experiments will not run on GPUs with less memory.
257
+
258
+ # REFERENCES
259
+
260
+ Oshin Agarwal and Ani Nenkova. Temporal effects on pre-trained models for language processing tasks. Transactions of the Association for Computational Linguistics, 10:904–921, 2022.
261
+ Badr AlKhamissi, Millicent Li, Asli Celikyilmaz, Mona Diab, and Marjan Ghazvininejad. A review on language models as knowledge bases. arXiv preprint arXiv:2204.06031, 2022.
262
+ James A Anderson. A simple neural network generating an interactive memory. Mathematical biosciences, 14(3-4):197–220, 1972.
263
+ Sören Auer, Christian Bizer, Georgi Kobilarov, Jens Lehmann, Richard Cyganiak, and Zachary Ives. Dbpedia: A nucleus for a web of open data. In The semantic web, pp. 722–735. Springer, 2007.
264
+ Sid Black, Leo Gao, Phil Wang, Connor Leahy, and Stella Biderman. GPT-Neo: Large Scale Autoregressive Language Modeling with Mesh-Tensorflow, March 2021. URL https://doi. org/10.5281/zenodo.5297715.
265
+ Sid Black, Stella Biderman, Eric Hallahan, Quentin Anthony, Leo Gao, Laurence Golding, Horace He, Connor Leahy, Kyle McDonell, Jason Phang, Michael Pieler, USVSN Sai Prashanth, Shivanshu Purohit, Laria Reynolds, Jonathan Tow, Ben Wang, and Samuel Weinbach. Gpt-neox-20b: An open-source autoregressive language model, 2022.
266
+ Kurt Bollacker, Robert Cook, and Patrick Tufts. Freebase: A shared database of structured general human knowledge. In AAAI, volume 7, pp. 1962–1963, 2007.
267
+ Antoine Bosselut, Hannah Rashkin, Maarten Sap, Chaitanya Malaviya, Asli Celikyilmaz, and Yejin Choi. Comet: Commonsense transformers for automatic knowledge graph construction. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 4762–4779, 2019.
268
+
269
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D 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 Ziegler, Jeffrey Wu, Clemens Winter, Chris 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. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 1877–1901, 2020.
270
+
271
+ Andrew Carlson, Justin Betteridge, Bryan Kisiel, Burr Settles, Estevam R Hruschka, and Tom M Mitchell. Toward an architecture for never-ending language learning. In Twenty-Fourth AAAI conference on artificial intelligence, 2010.
272
+
273
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
274
+
275
+ Damai Dai, Li Dong, Yaru Hao, Zhifang Sui, Baobao Chang, and Furu Wei. Knowledge neurons in pretrained transformers. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 8493–8502, 2022.
276
+
277
+ Guy Dar, Mor Geva, Ankit Gupta, and Jonathan Berant. Analyzing transformers in embedding space. arXiv preprint arXiv:2209.02535, 2022.
278
+
279
+ Randall Davis, Howard Shrobe, and Peter Szolovits. What is a knowledge representation? AI magazine, 14(1):17–17, 1993.
280
+
281
+ Nicola De Cao, Wilker Aziz, and Ivan Titov. Editing factual knowledge in language models. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 6491–6506, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics.
282
+
283
+ Xin Dong, Evgeniy Gabrilovich, Geremy Heitz, Wilko Horn, Ni Lao, Kevin Murphy, Thomas Strohmann, Shaohua Sun, and Wei Zhang. Knowledge vault: A web-scale approach to probabilistic knowledge fusion. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 601–610, 2014.
284
+
285
+ Yanai Elazar, Nora Kassner, Shauli Ravfogel, Abhilasha Ravichander, Eduard Hovy, Hinrich Schütze, and Yoav Goldberg. Measuring and improving consistency in pretrained language models. Transactions of the Association for Computational Linguistics, 9:1012–1031, 2021.
286
+
287
+ Nelson Elhage, Neel Nanda, Catherine Olsson, Tom Henighan, Nicholas Joseph, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, Tom Conerly, Nova DasSarma, Dawn Drain, Deep Ganguli, Zac Hatfield-Dodds, Danny Hernandez, Andy Jones, Jackson Kernion, Liane Lovitt, Kamal Ndousse, Dario Amodei, Tom Brown, Jack Clark, Jared Kaplan, Sam McCandlish, and Chris Olah. A mathematical framework for transformer circuits. Transformer Circuits Thread, 2021. https://transformer-circuits.pub/2021/framework/index.html.
288
+
289
+ Mor Geva, Roei Schuster, Jonathan Berant, and Omer Levy. Transformer feed-forward layers are key-value memories. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 5484–5495, 2021.
290
+
291
+ Mor Geva, Avi Caciularu, Kevin Ro Wang, and Yoav Goldberg. Transformer feed-forward layers build predictions by promoting concepts in the vocabulary space. arXiv preprint arXiv:2203.14680, 2022.
292
+
293
+ Peter Hase, Mona Diab, Asli Celikyilmaz, Xian Li, Zornitsa Kozareva, Veselin Stoyanov, Mohit Bansal, and Srinivasan Iyer. Do language models have beliefs? methods for detecting, updating, and visualizing model beliefs. arXiv preprint arXiv:2111.13654, 2021.
294
+
295
+ Catherine Havasi, Robert Speer, and Jason Alonso. Conceptnet: A lexical resource for common sense knowledge. Recent advances in natural language processing V: selected papers from RANLP, 309: 269, 2007.
296
+
297
+ Zhengbao Jiang, Frank F Xu, Jun Araki, and Graham Neubig. How can we know what language models know? Transactions of the Association for Computational Linguistics, 8:423–438, 2020.
298
+
299
+ Teuvo Kohonen. Correlation matrix memories. IEEE transactions on computers, 100(4):353–359, 1972.
300
+
301
+ Angeliki Lazaridou, Adhi Kuncoro, Elena Gribovskaya, Devang Agrawal, Adam Liska, Tayfun Terzi, Mai Gimenez, Cyprien de Masson d’Autume, Tomas Kocisky, Sebastian Ruder, et al. Mind the gap: Assessing temporal generalization in neural language models. Advances in Neural Information Processing Systems, 34:29348–29363, 2021.
302
+
303
+ Douglas B Lenat. Cyc: A large-scale investment in knowledge infrastructure. Communications of the ACM, 38(11):33–38, 1995.
304
+
305
+ 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.
306
+
307
+ Adam Liska, Tomas Kocisky, Elena Gribovskaya, Tayfun Terzi, Eren Sezener, Devang Agrawal, D’Autume Cyprien De Masson, Tim Scholtes, Manzil Zaheer, Susannah Young, et al. StreamingQA: A benchmark for adaptation to new knowledge over time in question answering models. In International Conference on Machine Learning, pp. 13604–13622. PMLR, 2022.
308
+
309
+ Kevin Meng, David Bau, Alex Andonian, and Yonatan Belinkov. Locating and editing factual associations in GPT. Advances in Neural Information Processing Systems, 35, 2022.
310
+
311
+ George A Miller. Wordnet: a lexical database for english. Communications of the ACM, 38(11): 39–41, 1995.
312
+
313
+ Marvin Minsky. A framework for representing knowledge, 1974.
314
+
315
+ Eric Mitchell, Charles Lin, Antoine Bosselut, Chelsea Finn, and Christopher D. Manning. Fast model editing at scale, 2021.
316
+
317
+ Eric Mitchell, Charles Lin, Antoine Bosselut, Chelsea Finn, and Christopher D. Manning. Memorybased model editing at scale. In International Conference on Machine Learning, 2022.
318
+
319
+ 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. Advances in neural information processing systems, 32, 2019.
320
+
321
+ David Patterson, Joseph Gonzalez, Quoc Le, Chen Liang, Lluis-Miquel Munguia, Daniel Rothchild, David So, Maud Texier, and Jeff Dean. Carbon emissions and large neural network training. arXiv preprint arXiv:2104.10350, 2021.
322
+
323
+ Judea Pearl. Direct and indirect effects. In Proceedings of the Seventeenth conference on Uncertainty in artificial intelligence, pp. 411–420, 2001.
324
+
325
+ Fabio Petroni, Tim Rocktäschel, Sebastian Riedel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, and Alexander Miller. Language models as knowledge bases? 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. 2463–2473, 2019.
326
+
327
+ Fabio Petroni, Patrick Lewis, Aleksandra Piktus, Tim Rocktäschel, Yuxiang Wu, Alexander H Miller, and Sebastian Riedel. How context affects language models’ factual predictions. In Automated Knowledge Base Construction, 2020.
328
+
329
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, pp. 9, 2019.
330
+
331
+ Richard H Richens. Preprogramming for mechanical translation. Mechanical Translation, 3(1): 20–25, 1956.
332
+
333
+ Adam Roberts, Colin Raffel, and Noam Shazeer. How much knowledge can you pack into the parameters of a language model? In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 5418–5426, 2020.
334
+
335
+ Tara Safavi and Danai Koutra. Relational world knowledge representation in contextual language models: A review. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 1053–1067, 2021.
336
+
337
+ Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. Autoprompt: Eliciting knowledge from language models with automatically generated prompts. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 4222–4235, 2020.
338
+
339
+ Anton Sinitsin, Vsevolod Plokhotnyuk, Dmitry Pyrkin, Sergei Popov, and Artem Babenko. Editable neural networks. In International Conference on Learning Representations, 2019.
340
+
341
+ Gilbert Strang. Introduction to linear algebra. Wellesley-Cambridge Press Wellesley, MA, 1993.
342
+
343
+ Fabian M Suchanek, Gjergji Kasneci, and Gerhard Weikum. Yago: a core of semantic knowledge. In Proceedings of the 16th international conference on World Wide Web, pp. 697–706, 2007.
344
+
345
+ 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.
346
+
347
+ Jesse Vig, Sebastian Gehrmann, Yonatan Belinkov, Sharon Qian, Daniel Nevo, Yaron Singer, and Stuart M Shieber. Investigating gender bias in language models using causal mediation analysis. In NeurIPS, 2020.
348
+
349
+ Denny Vrandeciˇ c and Markus Krötzsch. Wikidata: a free collaborative knowledgebase. ´ Communications of the ACM, 57(10):78–85, 2014.
350
+
351
+ Ben Wang and Aran Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
352
+
353
+ Gerhard Weikum. Knowledge graphs 2021: a data odyssey. Proceedings of the VLDB Endowment, 14(12):3233–3238, 2021.
354
+
355
+ Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, et al. Huggingface’s transformers: State-of-the-art natural language processing. arXiv preprint arXiv:1910.03771, 2019.
356
+
357
+ Yunzhi Yao, Shaohan Huang, Li Dong, Furu Wei, Huajun Chen, and Ningyu Zhang. Kformer: Knowledge injection in transformer feed-forward layers. In CCF International Conference on Natural Language Processing and Chinese Computing, pp. 131–143. Springer, 2022.
358
+
359
+ Chen Zhu, Ankit Singh Rawat, Manzil Zaheer, Srinadh Bhojanapalli, Daliang Li, Felix Yu, and Sanjiv Kumar. Modifying memories in transformer models, 2020.
360
+
361
+ ![](images/d325077eebe626e3eb1ddd80edbfbbd05f6db85d4156f5fa5d55900e17a249c9.jpg)
362
+
363
+ ![](images/42090dc6c25bfc314835311d92384a60dd9bdf05a08737351d34c7582dd9aa88.jpg)
364
+ Figure 8: Causal Tracing (using the method of Meng et al. 2022). Each grid cell’s intensity reflects the average causal indirect effect of a hidden state on the expression of a factual association, with strong causal mediators highlighted with darker colors. We find that MLPs at the last subject token and attention modules at the last token are important. The presence of influential attention activations at the earliest layers of the last subject token is investigated with additional path dependent experiments (Figure 3).
365
+
366
+ ![](images/f9f4f25e018e345bed47c067279a35e4bbd3674dd6e28183ceff93b60b8d638a.jpg)
367
+
368
+ MEMIT begins by identifying MLP layers that are causal mediators for recall of factual associations in the model. To do so in GPT-J, we use code provided by Meng et al. (2022): beginning with a sample of 501 true statements of facts that are correctly predicted by GPT-J, we measure baseline predicted probabilities of each true fact when noise is introduced into encoding of the subject tokens to degrade the accuracy of the model. Then in Figure 8 (a) for each individual $h _ { t } ^ { l }$ , we restore the state to the value that it would have had without injected noise, and we plot the average improvement of predicted probability. As in Meng et al. (2022), we use Gaussian noise with standard deviation $3 \sigma$ ( $\cdot \sigma ^ { 2 }$ is the empirically observed variance of embedding activations) and plot averages for all 501 statements over 10 noise samples. For (b) and (c) we use the same procedure, except we restore runs of 10 layers of MLP outputs $\hat { m } _ { t } ^ { l }$ and 10 layers of Attn $a _ { t } ^ { l }$ , instead of full hidden states.
369
+
370
+ These measurements confirm that GPT-J has a causal structure that is similar to the structure reported by Meng et al. (2022) in their study of GPT2-XL. Unlike with GPT-XL, a strong causal effect is observed in the earliest layers of Attention at the last subject token, which likely reflects a concentrated attention computation when GPT-J is recognizing and chunking the n-gram subject name, but the path-dependent experiment (Figure 3) suggests that Attention is not an important mediator of factual recall of memories about the subject.
371
+
372
+ In the main paper, Figure 3 plots the same data as Figure 8 (a) as a bar graph, focused on only the last subject token, and it adds two additional measurements. In red bars, it repeats the measurement of causal effects of states with Attention modules at the last subject token frozen in the corrupted state, so that cannot be influenced by the state being probed, and in green bars it repeats the experiment with the MLP modules at the last subject token similarly frozen, so they cannot be influenced by the causal probe. Severing the Attention modules does not shift the curve, which suggests that Attention computations do not play a decisive mediating role in knowledge recall at the last subject token. In contrast, severing the MLP modules reveals a large gap, which suggests that, at layers where the gap is largest, the role of the MLP computation is important. We select the layers where the gap is largest as the range $\mathcal { R }$ to use for the intervention done by MEMIT.
373
+
374
+ # B IMPLEMENTATION DETAILS
375
+
376
+ # B.1 FINE-TUNING WITH WEIGHT DECAY
377
+
378
+ Our fine-tuning baseline updates layer 21 of GPT-J, which Meng et al. (2022) found to provide the best performance in the single-edit case. Rather than using a hard $L _ { \infty }$ -norm constraint, we use a soft weight decay regularizer. However, the optimal amount of regularization depends strongly on the number of edits (more edits require higher-norm edits), so we tune this hyperparameter for the $n = 1 0 { , } 0 0 0$ case. Figure 9 shows that $5 \times 1 0 ^ { - 4 }$ selects for the optimal tradeoff between generalization and specificity. FT-W optimization proceeds for a maximum of 25 steps with a learning rate of $5 \times 1 0 ^ { - 4 }$ . To prevent overfitting, early stopping is performed when the loss reaches $1 0 ^ { - 2 }$ . Regarding runtime, FT takes $1 , 7 1 6 . 2 1 \sec \approx 0 . 4 8 \mathrm { h r }$ to execute 10,000 edits on GPT-J.
379
+
380
+ ![](images/da0596f6cdb26723e5a91aba74144cc347274f2501564ea9068cde0073fed101.jpg)
381
+ Figure 9: Optimizing fine-tuning weight decay on 10,000 edits. We find an evident tradeoff between generalization and specificity, opting for the value with the highest Score.
382
+
383
+ Note that we choose not to complicate the analysis by tuning FT-W on more than one layer. Table 2 demonstrates that FT-W, with just one layer, already gets near-perfect efficacy at the cost of low specificity, which indicates sufficient edit capacity.
384
+
385
+ # B.2 MODEL EDITING NETWORKS WITH GRADIENT DECOMPOSITION (MEND)
386
+
387
+ MEND makes concurrent edits by accumulating gradients from all edit examples, then passing them through the hypernetwork together. We use the GPT-J MEND hypernetwork trained by Meng et al. (2022). During inference, learning rate scale is set to the default value of 1.0. MEND is by far the fastest method, taking 98.25 seconds to execute 10,000 updates on GPT-J.
388
+
389
+ # B.3 RANK-ONE MODEL EDITING (ROME)
390
+
391
+ The default ROME hyperparameters are available in their open source code: GPT-J updates are executed at layer 5, where optimization proceeds for 20 steps with a weight decay of 0.5, KL factor of 0.0625, and learning rate of $5 \times 1 0 ^ { - \bar { 1 } }$ . ROME uses prefix sampling, resulting in 10 prefixes of length 5 and 10 prefixes of length 10. Covariance statistics are collected in fp32 on Wikitext using a sample size of 100,000. See Meng et al. (2022) for more details.
392
+
393
+ ROME takes $4 4 , 2 4 8 . 2 6 \sec \approx 1 2 . 2 9 \mathrm { h r }$ for 10,000 edits on GPT-J, which works out to approximately 4 seconds per edit.
394
+
395
+ # B.4 MASS-EDITING MEMORY IN A TRANSFORMER (MEMIT)
396
+
397
+ On GPT-J, we choose $\mathcal { R } = \{ 3 , 4 , 5 , 6 , 7 , 8 \}$ and set $\lambda$ , the covariance adjustment factor, to 15,000. Similar to ROME, covariance statistics are collected using 100,000 samples of Wikitext in fp32. $\delta _ { i }$ optimization proceeds for 25 steps with a learning rate of $5 \times 1 0 ^ { - 1 }$ . In practice, we clamp the $L _ { 2 }$ norm of $\delta _ { i }$ such that it is less than $\frac 3 4$ of the original hidden state norm, $\lceil \rceil h _ { i } ^ { L } \rceil |$ . On GPT-NeoX, we select $\mathcal { R } = \{ 6 , 7 , 8 , 9 , 1 0 \}$ and set $\lambda ^ { ' } = 2 0 { , } 0 0 0$ . Covariance statistics are collected over 50,000 samples of Wikitext in $\tt f p 1 6$ but stored in $\tt f p 3 2$ . Optimization for $\delta _ { i }$ proceeds for 20 steps using a learning rate of $5 \times 1 0 ^ { - 1 }$ while clamping $\| h _ { i } ^ { L } \|$ to $\frac { 3 } { 1 0 } \Vert h _ { i } ^ { L } \Vert$ .
398
+
399
+ In MEMIT, we have the luxury of being able to pre-compute and cache $z _ { i }$ values, since they are inserted in parallel. If all such vectors are already computed, MEMIT takes $3 , 2 2 6 . 3 5 \sec \approx 0 . 9 0 \mathrm { h r }$ for 10,000 updates on GPT-J, where the most computationally expensive step is inverting a large square matrix (Eqn. 14). Computing each $z _ { i }$ vector is slightly less expensive than computing a ROME update; to get all $1 0 { , } 0 0 0 \ z _ { i }$ vectors, we need $2 3 , 5 4 6 . 6 5 \sec \approx 6 . 5 4 \mathrm { h r }$ . This optimization is currently done in series, but it is actually “embarrassingly parallel,” as we can greatly reduce computation time by batching the gradient descent steps. Note that this speed-up does not apply to ROME, since each update must be done iteratively.
400
+
401
+ # C EVALUATION METRICS
402
+
403
+ # C.1 FOR ZSRE
404
+
405
+ For consistency with previous works that use the zsRE task (Mitchell et al., 2021; Meng et al., 2022), we report the same three probability tests:
406
+
407
+ • Efficacy is the proportion of edits that $G$ recalls with top-1 accuracy. Note that the prompt matches exactly what the edit method sees at runtime:
408
+
409
+ $$
410
+ \mathbb { E } _ { i } \left[ o _ { i } = \underset { x _ { E } } { \mathrm { a r g m a x } } \mathbb { P } _ { G } \left[ x _ { E } \mid p ( s _ { i } , r _ { i } ) \right] \right] .
411
+ $$
412
+
413
+ • Paraphrase is the accuracy on rephrasings of the original statement:
414
+
415
+ $$
416
+ \mathbb { E } _ { i } \left[ \mathbb { E } _ { p \in \mathrm { p a r a p h r a s e s } ( s _ { i } , r _ { i } ) } \left[ o _ { i } = \underset { x _ { E } } { \mathrm { a r g m a x } } \mathbb { P } _ { G } \left[ x _ { E } \mid p \right] \right] \right] .
417
+ $$
418
+
419
+ • Specificity is the proportion of neighborhood prompts that the model gets correct. In COUNTERFACT, all such prompts have the same correct answer $o _ { i } ^ { c }$ :
420
+
421
+ $$
422
+ \mathbb { E } _ { i } \left[ \mathbb { E } _ { p \in { \mathrm { n e i g h b o r h o o d p r o m p t s } } ( s _ { i } , r _ { i } ) } \left[ o _ { i } ^ { c } = \underset { x _ { E } } { \mathrm { a r g m a x } } \mathbb { P } _ { G } \left[ x _ { E } \mid p \right] \right] \right] .
423
+ $$
424
+
425
+ We also report an aggregated Score: the harmonic mean of Efficacy, Paraphrase, and Specificity.
426
+
427
+ # C.2 FOR COUNTERFACT
428
+
429
+ COUNTERFACT contains an assortment of prompts and texts for evaluating model rewrites (Figure 14). This section provides formal definitions for each COUNTERFACT metric. First, the probability tests:
430
+
431
+ • Efficacy Success (ES) is the proportion of cases where $o _ { i }$ exceeds $o _ { i } ^ { c }$ in probability. Note that the prompt matches exactly what the edit method sees at runtime:
432
+
433
+ $$
434
+ \mathbb { E } _ { i } \left[ \mathbb { P } _ { G } \left[ o _ { i } \ | \ p ( s _ { i } , r _ { i } ) \right] > \mathbb { P } _ { G } \left[ o _ { i } ^ { c } \ | \ p ( s _ { i } , r _ { i } ) \right] \right] .
435
+ $$
436
+
437
+ • Paraphrase Success $\mathbf { ( P S ) }$ is the proportion of cases where $o _ { i }$ exceeds $o _ { i } ^ { c }$ in probability on rephrasings of the original statement:
438
+
439
+ $$
440
+ \mathbb { E } _ { i } \left[ \mathbb { E } _ { p \in \mathrm { p a r a p h r a s e s } ( s _ { i } , r _ { i } ) } \left[ \mathbb { P } _ { G } \left[ o _ { i } \mid p \right] > \mathbb { P } _ { G } \left[ o _ { i } ^ { c } \mid p \right] \right] \right] .
441
+ $$
442
+
443
+ • Neighborhood Success (NS) is the proportion of neighborhood prompts where the models assigns higher probability to the correct fact:
444
+
445
+ $$
446
+ \begin{array} { r } { \mathbb { E } _ { i } \left[ \mathbb { E } _ { p \in \mathrm { n e i g h b o r h o o d p r o m p t s } ( s _ { i } , r _ { i } ) } \left[ \mathbb { P } _ { G } \left[ o _ { i } \mid p \right] < \mathbb { P } _ { G } \left[ o _ { i } ^ { c } \mid p \right] \right] \right] . } \end{array}
447
+ $$
448
+
449
+ • Editing Score (S), is the harmonic mean of ES, PS, and NS.
450
+
451
+ Now, the generation tests:
452
+
453
+ • Reference Score (RS) measures the consistency of $G$ ’s free-form generations. To compute it, we first prompt $G$ with the subject $s$ , then compute TF-IDF vectors for both $G ( s )$ and a reference Wikipedia text about $o$ ; RS is defined as their cosine similarity. Intuitively, $G ( s )$ will match better with $o$ ’s reference text if it has more consistent phrasing and vocabulary.
454
+
455
+ • We also check for excessive repetition (a common failure case with model editing) using Generation Entropy (GE), which relies on the entropy of $n$ -gram distributions:
456
+
457
+ $$
458
+ - \left( { \frac { 2 } { 3 } } \sum _ { k } f _ { 2 } ( k ) \log _ { 2 } f _ { 2 } ( k ) + { \frac { 4 } { 3 } } \sum _ { k } f _ { 3 } ( k ) \log _ { 2 } f _ { 3 } ( k ) \right) .
459
+ $$
460
+
461
+ Here, $f _ { n } ( \cdot )$ is the $n$ -gram frequency distribution.
462
+
463
+ # D EDITING DIFFERENT CATEGORIES OF FACTS TOGETHER
464
+
465
+ For an edit $( s , r , o )$ , $r$ associates a subject $s$ and object $o$ . Both $s$ and $o$ have their associated types $\tau ( s )$ and $\tau ( o )$ . For example, $r =$ “is a citizen of” is an association between a Person and Country. We say that $\tau ( s _ { 1 } )$ and $s _ { 2 }$ are diverse if $\tau ( s _ { 1 } ) \neq ( \tau ( s _ { 2 } ) )$ , and similar otherwise. The definition follows similarly for objects. For any relation pair $( r _ { 1 } , r _ { 2 } )$ , we sample from COUNTERFACT a set of edits $\mathcal { E } _ { m i x } = \{ ( s , r , o ) ~ | ~ r \in \{ r _ { 1 } , r _ { 2 } \} \}$ , such that numbers of edits for each relation are equal. We compare MEMIT’s performance on the set of edits ${ \mathcal { E } } _ { m i x }$ in four pairs of relations that have different levels of diversity between them. Each relation is followed by its corresponding relation_id in WikiData:
466
+
467
+ (a) Subject different $( \tau ( s _ { 1 } ) \neq \tau ( s _ { 2 } ) )$ , Object different $( \tau ( o _ { 1 } ) \neq \tau ( o _ { 2 } ) )$ :
468
+
469
+ $$
470
+ ( \tau ( s _ { 1 } ) = \mathtt { P e r s o n } , r _ { 1 } = \mathrm { c i t i z e n o f } ( \mathbf { P 2 7 } ) , \tau ( o _ { 1 } ) = \mathtt { C o u n t r y } ) ,
471
+ $$
472
+
473
+ $$
474
+ ( \tau ( s _ { 2 } ) = \mathrm { { c o u n t r y } } , r _ { 2 } = \mathrm { { o f f i c i a l l a n g u a g e } } \left( \mathbf P 3 7 \right) , \tau ( o _ { 2 } ) = \mathrm { { L a n g u a g e } } )
475
+ $$
476
+
477
+ (b) Subject similar $( \tau ( s _ { 1 } ) = \tau ( s _ { 2 } ) )$ ), Object different $( \tau ( o _ { 1 } ) \neq \tau ( o _ { 2 } ) )$ ):
478
+
479
+ (τ (s1) = Person, $r _ { 1 } =$ plays position in sport (P413), $\tau ( o _ { 1 } ) = { \tt S p o r } ^ { \sf { 1 } }$ t position),
480
+
481
+ $$
482
+ \begin{array} { r } { \textrm { \tiny ( \tau ( s _ { 2 } ) = P e r s o n , } r _ { 2 } = \mathrm { n a t i v e \ l a n g u a g e \left( P 1 4 1 2 \right) , } \tau ( o _ { 2 } ) = \mathrm { L a n g u a g e } ) } \end{array}
483
+ $$
484
+
485
+ (c) Subject different $( \tau ( s _ { 1 } ) \neq \tau ( s _ { 2 } ) )$ , Object similar $\dot { \varrho } _ { 1 } = \tau ( o _ { 2 } ) \mathrm { , }$
486
+
487
+ $$
488
+ \begin{array} { r } { \big ( \tau ( s _ { 1 } ) = \mathtt { P l a c e } , r _ { 1 } = \mathrm { l o c a t e d i n } ( \mathbf { P 1 7 } ) , \tau \big ( o _ { 1 } \big ) = \mathtt { C o u n t r y } \big ) , } \end{array}
489
+ $$
490
+
491
+ $$
492
+ ( \tau ( s _ { 2 } ) = \mathrm { I t } \tan / \mathrm { P r o d u c t } , r _ { 2 } = \mathrm { c o u n t r y ~ o f ~ o r i g i n } ( \mathbf { P 4 9 5 } ) , \tau ( o _ { 2 } ) = \mathrm { C o u n t r y } )
493
+ $$
494
+
495
+ (d) Subject similar $( \tau ( s _ { 1 } ) = \tau ( s _ { 2 } ) )$ ), Object similar $( \tau ( o _ { 1 } ) = \tau ( o _ { 2 } ) $ ):
496
+
497
+ $$
498
+ \begin{array} { r l } { \left( \tau ( s _ { 1 } ) = \mathtt { P e r s o n } , r _ { 1 } = \mathrm { c i t i z e n ~ o f ~ } ( \mathbf { P 2 7 } ) , \tau \big ( o _ { 1 } \right) = } & { { } } \end{array}
499
+ $$
500
+
501
+ $$
502
+ \left( \tau ( s _ { 2 } ) = \mathtt { P e r s o n } , r _ { 2 } = \mathrm { w o r k s ~ i n ~ } ( \mathbf { P 9 3 7 } ) , \tau ( o _ { 2 } ) = \mathtt { C i t y } / \mathtt { C o u n t r y } \right)
503
+ $$
504
+
505
+ Figure D depicts MEMIT rewrite performance in these four scenarios. We find that the effectiveness of ${ \mathcal { E } } _ { m i x }$ closely follows the average of the individual splits. Therefore, the presence of diversity in the edits (or lack thereof) does not tangibly influence MEMIT’s performance.
506
+
507
+ # E DEMONSTRATIONS
508
+
509
+ This section provides two case studies, in which we apply MEMIT to mass-edit new or corrected memories into GPT-J (6B).
510
+
511
+ Knowledge freshness. On November 8th, 2022, the United States held elections for 435 congressional seats, 36 governor seats, and 35 senator seats, several of which changed hands. We applied MEMIT to incorporate the election results into GPT-J in the form of (congressperson, elected from, district) and (governor/senator, elected from, state). 4 The MEMIT edit attained $100 \%$ efficacy (ES) and $94 \%$ generalization (PS).
512
+
513
+ Application in a specialized knowldge domain. For a second application, we used MEMIT to create a model with specialized knowledge of amateur astronomy. We scraped the names of stars that were referenced more than 100 times from WikiData and belong to one of the 18 constellations named below.
514
+
515
+ Andromeda, Aquarius, Cancer, Cassiopeia, Gemini, Hercules, Hydra, Indus, Leo, Libra, Orion, Pegasus, Perseus, Pisces, Sagittarius, Ursa Major, Ursa Minor, Virgo
516
+
517
+ We obtained 289 tuples of the form (star, belongs to, constellation). The accuracy of the unmodified GPT-J in recalling constellation of a star was only $53 \%$ . Post-MEMIT, accuracy increased to $86 \%$ .
518
+
519
+ ![](images/18eaedce27b5c6c25df7ec22ac0e92432c492bee7128a9049f7abc7ef758f1f7.jpg)
520
+ Figure 10: MEMIT’s performance while editing memories with four levels of diversity. Each data point is a mean of 10 experiments. Filled areas show $90 \%$ confidence intervals of the values from those experiments.
521
+
522
+ # F ABLATIONS
523
+
524
+ MEMIT contains several critical design choices: it uses a (i) range of critical mid-layer (ii) MLP modules at the (iii) last subject token, with the (iv) hyperparameter $\lambda$ (Eqn. 15) to control the impact of the update. Choice (iii) was already demonstrated by Meng et al. (2022) to be significant through an ablation study, but we now investigate the other three.
525
+
526
+ # F.1 VARYING THE NUMBER AND LOCATION OF EDITED LAYERS
527
+
528
+ We test five total configurations of $\mathcal { R }$ , the set of critical MLP layers to be targeted during editing. Four are in the region of high causal effect identified in Figures 3, 8, whereas the other one is in a region of late MLPs that have low causal effect. As Figure 11 shows, using more layers yields higher efficacy and generalization while also improving specificity. Moreover, edits at the late-layer MLPs are considerably worse. These results confirm the importance of the causal analysis to MEMIT’s performance.
529
+
530
+ ![](images/e5413937214835647fa052c8a9c4ba7d92d54a2acdcfe546c7339f19509a84a4.jpg)
531
+ Figure 11: Varying the edited MLP layers
532
+
533
+ # F.2 VARYING THE TARGETED MODULE: EDITING ATTENTION
534
+
535
+ Next, we check whether edits at either early or late-layer attention modules perform comparably to their MLP counterparts. As Figure 12 shows, attention edits perform considerably worse.
536
+
537
+ # F.3 VARYING THE COVARIANCE HYPERPARAMETER $\lambda$
538
+
539
+ Finally, we investigate the impact of the covariance adjustment factor (denoted $\lambda$ in Eqn. 15) on performance; Figure 13 displays the results. Specificity and fluency increase monotonically with $\lambda$ , indicating that higher $\lambda$ values preserve original model behavior. However, at the same time, efficacy and generalization fall when $\lambda$ is increased. We can see that around $\approx 1 0 ^ { 4 }$ , the aggregated score reaches a maximum.
540
+
541
+ ![](images/76dceea45fdff1cb1e932fecfe6440877217abac304cb5396eabecfb65b57e60.jpg)
542
+ Figure 12: Varying the edited attention layers
543
+
544
+ ![](images/52590d52bb9fad9c18907bb32e1c5078c4ee5087bdd0088e16b1e606f7ef479d.jpg)
545
+ Figure 13: Varying the covariance adjustment factor $\lambda$
546
+
547
+ "case_id":15,
548
+ "pararel_idx":8062,
549
+ "requested_rewrite":{ "prompt":"{}, the", "relation_id":"P413", "target_new":{ "str":"goaltender", "id":"Q1317534" }, "target_true":{ "str":"linebacker", "id":"Q528145" }, "subject":"Percy Snow"
550
+ },
551
+ "paraphrase_prompts":[ "Victoriano Salado Alvarez (1867–1931). Which position does Percy Snow play? They play as", "It is found in the Indomalayan realm. Percy Snow plays in the position of"
552
+ ],
553
+ "neighborhood_prompts":[ "Michael Morgan plays in the position of", "Which position does Nathan Stupar play? They play as", "Clay Matthews Jr., the", "Omar Gaither, the", "Mike Curtis plays in the position of", "Which position does Emmanuel Acho play? They play as", "Clay Matthews Jr. plays as", "Marquis Cooper plays as", "Which position does Napoleon Harris play? They play as", "Brendon Ayanbadejo, the"
554
+ ],
555
+ "generation_prompts":[ "Percy Snow is incredible at", "The expertise of Percy Snow becomes important when", "The expertise of Percy Snow becomes important when", "The expertise of Percy Snow becomes important when", "The expertise of Percy Snow becomes important when", "The expertise of Percy Snow becomes important when", "Percy Snow is incredible at", "The expertise of Percy Snow becomes important when", "The expertise of Percy Snow becomes important when", "Percy Snow is incredible at"
md/dev/NHeAUKlTO8/NHeAUKlTO8.md ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PartialFormer: Modeling Part Instead of Whole for Machine Translation
2
+
3
+ Anonymous EMNLP submission
4
+
5
+ # Abstract
6
+
7
+ The parameter redundancy problem in Transformer models has been widely acknowledged in the literature. To address this weakness, we introduce PartialFormer, a parameter-efficient Transformer architecture for machine translation. Compared to previous parameter-efficient Transformer architecture, PartialFormer modifies the modeling strategy of the feed-forward network to allow it to spare tremendous parameters while maintaining large hidden dimension. Additionally, PartialFormer applies two efficient scaling strategies, namely depth scaling and width scaling, to improve performance within a given parameter budget. To efficiently benefit from these scaling strategies, PartialFormer is further enhanced by two costeffective modifications: 1) a head scaling strategy for efficient width scaling and 2) a residuallike attention calculation for better depth scaling. Extensive experiments on 9 translation tasks validate the effectiveness of our PartialFormer approach.
8
+
9
+ ![](images/87577d14d81bfcc2eba8bcf72cc758b909e4169ed43a7f8857f2625ad2502291.jpg)
10
+ Figure 1: Illustration of our idea.
11
+
12
+ # 1 Introduction
13
+
14
+ The Transformer model (Vaswani et al., 2017) has emerged as a cornerstone in the natural language processing (NLP) domain, overshadowing convolutional neural networks (Gehring et al., 2017) and recurrent neural networks (Sutskever et al., 2014) by virtue of its minimal inductive bias, superior scalability, and proficiency in modeling extended sequences. Nonetheless, its substantial computational and parametric requisites pose significant challenges to its deployment and training, warranting an ongoing trend in the research community toward eliminating redundant parameters and computations in the Transformer model (Dehghani et al., 2019; Lan et al., 2020; Reid et al., 2021; Li et al., 2022; Ahmed et al., 2017; Yan et al., 2020; Wu et al., 2020; Mehta et al., 2019, 2021).
15
+
16
+ it is noteworthy that these approaches ignore the importance of feed-forward networks (FFN). Feedforward networks consume significant parametric and computational overhead due to the inherent large feature space and hidden dimension. To cut down FFNs’ overhead, previous studies (Mehta et al., 2021; Wu et al., 2020; Ge et al., 2022) just adopt smaller hidden dimension, e.g., equal to or even lower than the size of feature space. That leads to a question: Are current lightweight FFNs optimal?
17
+
18
+ Despite their success in improving the parametric and computational efficiency of the Transformer,
19
+
20
+ To address this concern, we turn to the insights provided by Geva et al. (2021), who depicted FFNs as a collection of key-value memories, where the number of memories is equal to the number of hidden dimensions in FFNs. This finding underscores the significance of hidden dimension in FFNs. Drawing inspiration from this finding and the successful application of large hidden sizes in FFNs as evidenced by Meta’s 4B model (Tran et al., 2021)1, we postulate that a truly efficient lightweight FFN should maintain, if not enlarge, the hidden dimension while reducing parameters.
21
+
22
+ To this end, we propose PartialFormer, an innovative approach to Transformer architecture. The central design of PartialFormer is the Partial-Level Gated Feed-Forward Networks (PG-FFN). We designed the PG-FFN as a set of smaller FFNs in unison, each producing lower-dimensional hidden features, yet collectively matching or exceeding the hidden dimension of a conventional larger FFN. Moreover, we further equipped PartialFormer with two cost-effective operations: a head scaling strategy for efficient width scaling, and a residual-like attention calculation for stable optimization. These techniques empower PartialFormer to achieve deeper layer stacking or increased width within the same parameter budget.
23
+
24
+ The strength of PartialFormer has been affirmed through rigorous empirical evaluations on $9 \ \mathrm { m a }$ chine translation tasks. Remarkably, even while maintaining similar parameter consumption, our PartialFormer consistently surpasses the vanilla Transformer, employing the same layer depth and embedding width, by an average of 1.29 BLEU points across all 6 WMT’17 machine translations. Furthermore, it achieved a BLEU score of 29.56 on the challenging WMT’14 En-De task with only 68 million parameters, showcasing its effectiveness and efficiency. Our work with PartialFormer thus marks an important step towards the goal of optimized Transformer architectures, marrying performance with efficiency in a manner that has potential for broad impact in NLP applications.
25
+
26
+ # 2 Preliminary: Transformer
27
+
28
+ In this section, we present some prior knowledge about the Transformer. Typically, Transformer block always consists of a multi-head self-attention and a feed-forward network. Let $X \in \mathbb { R } ^ { T \times d }$ be a $T \times d$ input matrix of $T$ tokens. Each multi-head self-attention component owns $H$ heads. For simplicity, we ignore the layer-normalization operation and residual connection.
29
+
30
+ Multi-Head Self-Attention MHSA aims to model the global dependency among tokens. MHSA computes as follows:
31
+
32
+ $$
33
+ \begin{array} { r c l } { { { \cal A } ^ { i } } } & { { = } } & { { \mathrm { S o f t m a x } ( \displaystyle \frac { Q ^ { i } ( K ^ { i } ) ^ { \top } } { \sqrt { d _ { k } } } ) , } } \\ { { \mathrm { h e a d } _ { i } } } & { { = } } & { { { \cal A } ^ { i } V ^ { i } , } } \\ { { X } } & { { = } } & { { \displaystyle \sum _ { i = 1 } ^ { H } \mathrm { h e a d } _ { i } W _ { i } ^ { O } , } } \end{array}
34
+ $$
35
+
36
+ where $Q ^ { i } , K ^ { i } , V ^ { i }$ denote the query, key and value of $i$ -th head, which are derived from input with three learnable matrics $W _ { i } ^ { Q } , W _ { i } ^ { K } , W _ { i } ^ { V } \ \in \ \mathbb { R } ^ { d \times d _ { k } }$ as follows: $Q ^ { i } \ : = \ : X W _ { i } ^ { Q } , K ^ { i } \ : = \ : X W _ { i } ^ { K } , V ^ { i } \ : =$
37
+
38
+ $X W _ { i } ^ { V }$ , respectively. $W _ { i } ^ { O } \in \mathbb { R } ^ { d _ { k } \times d }$ is a learnable matrix. $A ^ { i }$ and headi denote the attention matrix and representation of $i$ -th head, respectively.
39
+
40
+ Feed-Forward Network Feed-forward network is responsible for improving the expressiveness of the whole representation space by adopting an "expansion-activation-reduction" mapping strategy. It computes as follows:
41
+
42
+ $$
43
+ X = \mathrm { R e L U } ( X W _ { 1 } + b _ { 1 } ) W _ { 2 } + b _ { 2 } ,
44
+ $$
45
+
46
+ where $W _ { 1 } ~ \in ~ \mathbb { R } ^ { d \times d _ { \mathrm { f n } } } , W _ { 2 } ~ \in ~ \mathbb { R } ^ { d _ { \mathrm { f n } } \times d } , b _ { 1 } ~ \in$ $\mathbb { R } ^ { d _ { \mathrm { f f n } } } , b _ { 2 } \in \mathbb { R } ^ { d }$ as learnable matrices and $d _ { \mathrm { { f f n } } }$ denotes the hidden dimension in FFN that is usually set to $4 d$ .
47
+
48
+ # 3 PartialFormer
49
+
50
+ # 3.1 Overall Architecture
51
+
52
+ Figure 2 illustrates the overall architecture of PartialFormer, encompassing both an encoder and a decoder. Although the foundational structure adheres to the design of the vanilla Transformer (Vaswani et al., 2017), there are some notable modifications.
53
+
54
+ Encoder. Different from vanilla Transformer, each encoder layer in PartialFormer consists of a unified sub-layer that integrates the PG-FFNs into the multi-head self-attention mechanism rather than separate two sub-layers.
55
+
56
+ Decoder. Each decoder layer is composed of two types of sub-layers, both of which integrate the multi-head attention mechanism with PG-FFNs. The sub-layers differ based on the type of multihead attention mechanisms employed, specifically whether it’s a decoder self-attention or an encoderdecoder cross-attention mechanism.
57
+
58
+ # 3.2 Information Flow in Unified Sub-Layer
59
+
60
+ Taking the Encoder as an instance. Each unified sub-layer first computes the multiple attention scores via Eq. (5), then obtains the multiple head features $\{ \mathrm { h e a d } ^ { i } | 1 \leq i \leq H \}$ via Eq. (2), which is the same as vanilla Transformer. Then, using multiple small FFNs, it processes these head features and ultimately combines the representations via a fusion function according to Eq. (7). That is to say, the PG-FFN is encapsulated into the multiheadattention mechanism.
61
+
62
+ ![](images/f547cefb32e903685c4ce5bcb23dff57d1f371265a2596bde12acbe0dee13f9d.jpg)
63
+ Figure 2: (a) Architecture of Transformer. (b) Architecture of PartialFormer. (c) Details of Self-AFFN Block. All architecture are based on pre-normalization strategy. We omit the layer normalization operation, residual connection, softmax operation and scale coefficient for simplicity.
64
+
65
+ $$
66
+ \begin{array} { l l l } { { A ^ { i } } } & { { = } } & { { \displaystyle \mathrm { S o f t m a x } ( \frac { Q ^ { i } ( K ^ { i } ) ^ { \top } } { \sqrt { d _ { k } } } + A _ { G } ^ { i } ) , } } \\ { { O ^ { i } } } & { { = } } & { { \displaystyle \mathrm { P G } \mathrm { - } \mathrm { F F N } ( \mathrm { h e a d } ^ { i } ) , } } \\ { { X } } & { { = } } & { { \displaystyle \sum _ { i = 1 } ^ { H } O ^ { i } W _ { i } ^ { O } } } \end{array}
67
+ $$
68
+
69
+ # 3.3 Partial-Level Gated FFN
70
+
71
+ Intuition Previous studies (Wu et al., 2020; Mehta et al., 2021; Ge et al., 2022) have commonly reduced the parameters in feed-forward networks by decreasing the hidden dimension (e.g., 2048 to 256). In contrast, we tackle this issue through a matrix factorization approach. Our key idea involves utilizing a collection of small FFNs to model smaller input features, rather than relying on a single large FFN.
72
+
73
+ Assume a FFN with mappings of $1 0 2 4 \mathrm { - } { > } 4 0 9 6 \mathrm { - }$ ${ > } 1 0 2 4$ , which consumes around 8.4 million parameters. By decomposing this into 8 smaller FFNs with mappings of $1 2 8 \mathrm { - } > 5 1 2 \mathrm { - } > 1 2 8$ , we can retain the same hidden dimension, such as $8 ^ { * } 5 1 2$ , while using only 1.05 million parameters. This approach significantly reduces parameters while maintaining the crucial desired hidden dimension, as emphasized in previous studies (Geva et al., 2021; Tran et al., 2021).
74
+
75
+ Furthermore, we have observed that the Transformer architecture inherently consists of multiple smaller subspaces, namely “heads” within the multi-head attention (MHA) mechanism. These heads act as sub-components of the original inputs and retain substantial information from the original data. As a result, PG-FFNs should naturally be constructed based on the MHA mechanism.
76
+
77
+ Calculation of PG-FFNs While group transformation operations could be used to instantiate our idea, they are not optimal on GPUs due to their low I/O efficiency (Ma et al., 2018), causing significant inference latency. To address this, we propose sharing parameters across each FFN within different heads, thereby eliminating the need for group transformation operations.
78
+
79
+ However, directly sharing weights may result in homogeneous representations across different heads, which may potentially hinder the performance (Li et al., 2018). To mitigate this, we further introduce a head-specific gated mechanism. The core idea is to use a set of diverse masks to filter the information of different heads so that the head representation will be more diverse. Formally, given a set of smaller features $\{ \mathrm { h e a d } ^ { i } | 1 \leq i \leq H \}$ and diverse masks $\{ G ^ { i } | 1 \leq i \leq H \}$ , the Eq. (6) can rewritten as:
80
+
81
+ $$
82
+ O ^ { i } = G ^ { i } \odot \mathrm { F F N } ( \mathrm { h e a d } ^ { i } ) ,
83
+ $$
84
+
85
+ where $\mathrm { F F N } ( \cdot )$ is the same as Eq. (4).
86
+
87
+ Generating $\{ G ^ { i } | 1 \le i \le H \}$ In our preliminary experiments, we observed significant diversity in the features generated by different parameters from sub-layer inputs, e.g., $\{ V ^ { 1 } , \ldots , V ^ { H } \}$ . Motivated by this finding, we generate diverse masks in the following manner:
88
+
89
+ $$
90
+ G ^ { i } = \sigma ( X W _ { i } ^ { G } ) ,
91
+ $$
92
+
93
+ where $W _ { i } ^ { G }$ is a learnable matrix and $\sigma$ denotes the activation function, e.g., ReLU, Sigmoid and Tanh. We compare them in Table 8.
94
+
95
+ # 3.4 Efficient Scaling Strategy
96
+
97
+ Though PG-FFN offers the advantage of reducing lots of parameters when applied directly to the transformer, it also leads to performance degradation. Thus, a crucial aspect of this study is to determine how to effectively utilize the spared parameters. In this work, we adopt a hybrid scaling strategy, combining both width scaling and depth scaling, which has been validated in computer vision, e.g., EfficientNet (Tan and Le, 2019).
98
+
99
+ # 3.4.1 Enabling Efficient Depth Scaling for PartialFormer
100
+
101
+ Wang et al. (2019); Dong et al. (2021); Wang et al. (2022) have shown that the original location of FFNs plays an essential role in optimizing transformers, e.g., alleviating Token Uniformity. Thus, we need to consider the impact brought by the change of FFNs. While the densely residual connection is an efficient way to alleviate it, they are typically either based on feature level (e.g., DLCL (Wang et al., 2019)) or coupled with the network structure (e.g., Realformer (He et al., 2021)).
102
+
103
+ To this end, we design a new variant of the residual connection integrated into the attention calculation, while also decoupling from the network architecture. Specifically, the calculation of attention maps consists of two parts: 1) $A _ { G }$ , the global part, and 2) $A _ { L }$ , the local part. The calculation of $A _ { L }$ remains the same as in the vanilla Transformer, while $A _ { G }$ is computed once by using the original embedding as input through Eq. (1). Inspired by He et al. (2021), to efficiently fuse these components, we add them together and apply a Softmax function, as shown in Eq. (5).
104
+
105
+ In addition to the benefit of efficient depth scaling (See Appendix F), this approach provides remarkable flexibility in combining different attention mechanisms, specifically tailored to address specific conditions. For instance, it allows for the utilization of local attention to calculate $A _ { G }$ when dealing with small datasets (see Appendix D).
106
+
107
+ # 3.4.2 Head Scaling: An Efficient Width Scaling for PartialFormer
108
+
109
+ Existing approach to width scaling, which is based on the embedding size, necessitates the simultaneous scaling of both the encoder and decoder for machine translation tasks. This is primarily because researchers commonly employ shared encoder and decoder embedding. However, taking cues from the achievements of depth scaling, it may be more advantageous to adopt a distinct method for scaling width, similar to the approach used for scaling depth. Here we show how PartialFormer has inherent superiority to achieve so.
110
+
111
+ The width of a Transformer model typically refers to the widest part of the Transformer. In this context, both the vanilla Transformer and previous lightweight Transformer models have widths that are related to the embedding dimension, such as $4 d$ or $d$ . Therefore, by increasing the embedding size, we can effectively enlarge their width. However, the width definition in PartialFormer is different and can be expressed as $w = H \times d _ { \mathrm { f f n } }$ , where $w$ denotes the width of model and $d _ { \mathrm { { f f n } } }$ is associated with the head dimension $d _ { k }$ . Consequently, we can expand the width by either increasing the number of heads or enlarging $d _ { k }$ . A comparison between these approaches is presented in Table 7. Notably, if the head dimension and number of heads are independent of the embedding dimension, PartialFormer allows for easy scaling of width in different ways within the encoder and decoder components.
112
+
113
+ ![](images/dcc02863d4f889023bf37de14a7d7d957b53cd0fca0d0347221602cad1538aa8.jpg)
114
+ Figure 3: Comparison of ways to generate subspaces in Transformer and PartialFormer.
115
+
116
+ To this end, we propose a new scaling mechanism, namely head scaling, that scales the width of PartialFormer by directly adding more heads and increasing head dimension, as illustrated in Figure 3. Given the head dimension $d _ { k }$ , the embedding dimension $d$ , and the number of heads $H$ , we consider two strategies to generate $H$ attention heads:
117
+
118
+ (a) Simple strategy: We employ three learnable matrices, each with a shape of $d \times ( d _ { k } \times H )$ , to directly obtain the expected number of $Q$ , $K$ , and $V$ .
119
+
120
+ (b) Complex strategy: we employ a two-step process. First, we generate an intermediate quantity of $Q$ and $K$ , and then use a powerful MLP network to expand the attention maps to the desired number. This innovative design draws inspiration from the inherent redundancy found within the attention map (Michel et al., 2019; Clark et al., 2019; Voita et al., 2019), allowing for more heads in PartialFormer under the same parameter budget. We show the comparisons in Table 6.
121
+
122
+ ![](images/5bd9198300e5fd500b403dbe34b7b2366bd59237b2fedae9ea0ef1a734622101.jpg)
123
+
124
+ ![](images/fa37f7a5a3a2beb8d9f67b378d00f636a4c0fffb083e25cf799ff2241f27f30b.jpg)
125
+
126
+ <table><tr><td>Type</td><td>Model</td><td>N-M</td><td>ddk</td><td></td><td></td><td></td><td>H MACs Param</td><td>BLEU</td><td>COMET-22</td></tr><tr><td rowspan="4">Multi-Branch Architecture</td><td>Weighted Transformer (Ahmed et al.,2017)</td><td>6-6</td><td>1024</td><td></td><td></td><td></td><td>211M</td><td>28.90</td><td></td></tr><tr><td>Multi-Unit Transformer (Yan et al.,2020)</td><td>6-6</td><td></td><td></td><td></td><td></td><td>130M</td><td>29.30</td><td></td></tr><tr><td>MAT (Fan et al., 2020)</td><td>6-6</td><td></td><td></td><td></td><td></td><td>206M</td><td>29.90</td><td></td></tr><tr><td>Multi-Path Transformer (Lin et al., 2022)</td><td>6-6</td><td></td><td></td><td></td><td></td><td>193M</td><td>29.68</td><td></td></tr><tr><td>Lightweight Architecture</td><td>Evolved Transformer (So et al., 2019) Delight (Mehta et al., 2021)</td><td></td><td></td><td></td><td></td><td></td><td>64M</td><td>28.20</td><td></td></tr><tr><td rowspan="5">Weight Sharing</td><td></td><td></td><td>640</td><td></td><td></td><td></td><td>54M</td><td>28.00</td><td></td></tr><tr><td>Universal Transformer (Dehghani et al.,2019)</td><td></td><td>1024</td><td></td><td>=</td><td></td><td>65M</td><td>28.90</td><td></td></tr><tr><td>SubFormer (Reid et al., 2021)</td><td></td><td>-</td><td></td><td>=</td><td></td><td>63M</td><td>28.50</td><td></td></tr><tr><td>SubFormer-big (Reid et al., 2021)</td><td></td><td></td><td></td><td></td><td></td><td>197M</td><td>29.30</td><td></td></tr><tr><td>ODE Transformer (RK4) (Li et al., 2022) ODE Transformer (RK4) (Li et al., 2022)</td><td>6-6 24-6</td><td>512 512</td><td></td><td>=</td><td></td><td>62M 118M</td><td>29.03 29.80</td><td></td></tr><tr><td rowspan="3">Other Comparisons</td><td></td><td></td><td></td><td>64</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>RealFormer (He et al., 2021) DMAN (Fan et al., 2021)</td><td>18-18</td><td>512 512</td><td></td><td>8 8</td><td></td><td>151M</td><td>29.35</td><td></td></tr><tr><td>Mega-Softmax (Ma et al.,2022)</td><td>6-6 6-6</td><td>512</td><td></td><td></td><td></td><td>63M 67M</td><td>29.10 29.01</td><td></td></tr><tr><td rowspan="7">Our System</td><td>Transformer</td><td></td><td></td><td>64</td><td>1</td><td></td><td></td><td></td><td></td></tr><tr><td>PartialFormer (w/o Head Scaling)</td><td>24-6</td><td>512</td><td>8-8</td><td></td><td>11.1B</td><td>118M</td><td>29.05</td><td>83.60</td></tr><tr><td>PartialFormer</td><td>24-6</td><td>512</td><td>64 24-16</td><td>8-8</td><td>8.8B</td><td>66M</td><td>28.86 30.09</td><td>83.35 84.17</td></tr><tr><td></td><td>24-6</td><td>512</td><td>64</td><td></td><td>12.2B</td><td>115M</td><td></td><td></td></tr><tr><td>Transformer</td><td>6-6</td><td>512</td><td>64 45</td><td>8-8</td><td>9.9B</td><td>62M</td><td>27.43</td><td>82.19</td></tr><tr><td>Transformer PartialFormer (w/o Head Scaling)</td><td>24-6 24-6</td><td>360 360</td><td>45</td><td>8-8 8-8</td><td>6.3B 5.2B</td><td>62M 36M</td><td>28.00 27.88</td><td>82.72 82.49</td></tr><tr><td></td><td></td><td>360</td><td>45</td><td>24-16</td><td>6.8B</td><td>61M</td><td>29.23</td><td></td></tr><tr><td></td><td>PartialFormer PartialFormer</td><td>24-6 24-6</td><td>360</td><td>45 30-16</td><td></td><td>6.9B</td><td>68M</td><td>29.56</td><td>83.74 83.94</td></tr></table>
127
+
128
+ Table 1: Results on the WMT’14 En-De task. MACs denote the multiplication-addition operations. We compute them via 20 source and target tokens following Mehta et al. (2021).
129
+
130
+ # 4 Experimental Setups
131
+
132
+ In our evaluation, we assess the performance of PartialFormer across 9 machine translation tasks2. More details are given in Appendix A
133
+
134
+ Dataset. We evaluate our approach on three widely-used datasets: WMT’14 English-German (En-De), WMT’14 English-French (En-Fr), and WMT’16 English-Romanian (En-Ro). Besides, to further validate the effectiveness of PartialFormer, we also evaluate PartialFormer on six translation tasks from WMT’17 benchmark. We preprocess the raw data following the standard strategy.
135
+
136
+ Architectures and Selected Baselines. We use a 24-6 encoder-decoder PartialFormer architecture for its strong performance, on all 9 machine translation tasks. Detailed configurations are provided in the results tables. We compare our approach with various baselines, including vanilla Transformer models, multi-branch architecture, lightweight architecture, weight-sharing methods, and other strong baselines.
137
+
138
+ Training & Evaluation. We train all the models on GeForce RTX 3090 cards via Fairseq (Ott et al., 2019) toolkit. For evaluation, we utilized multi-BLEU (Papineni et al., 2002) and COMET22 (Rei et al., 2022) scores. Beam sizes were 4, 4, and 5 for En-De, En-Fr, and En-Ro tasks respectively. Length_penalty of 0.6, 0.8, and 1.3 were applied to En-De, En-Fr, and En-Ro tasks respectively. For the WMT’17 benchmark, beam size and Length_penalty were set to 4 and 1, respectively. We used an ensemble of the last ten checkpoints.
139
+
140
+ # 5 Experiments
141
+
142
+ Results of WMT’14 En-De Table 1 presents the results for the WMT’14 En-De task. Note that we also provide a “strong” baseline which also benefits from deep model stacking. Even though the performance of PartialFormer (w/o Head Scaling) is slightly inferior to that of the Transformer model (27.88 vs. 28.00 and 28.86 vs. 29.05), it outshines the latter in terms of parameter efficiency, consuming significantly fewer parameters (36M vs. 62M, 66M vs. 118M). We attribute this phenomenon to our PG-FFN, which leverages a group of compact FFNs. This approach enables PG-FFN to maintain high hidden dimension, while drastically reducing parameter consumption.
143
+
144
+ Upon utilizing our head scaling technique to amplify the capacity, our Partialformer delivers a BLEU score 29.56 and 30.09 on two configurations, respectively. This surpasses the standard Transformer by 1.56 BLEU points (29.56 vs. 28.00) and
145
+
146
+ Table 2: Results on the WMT’14 En-Fr task.
147
+
148
+ <table><tr><td>Model</td><td>N</td><td>ddk</td><td>HParam BLEU</td></tr><tr><td>Weighted Transformer (2017)</td><td>6</td><td></td><td>- 211M 41.40</td></tr><tr><td>Evolved Transformer (2019)</td><td>=</td><td></td><td>64M 40.60</td></tr><tr><td>Delight (2021)</td><td>-640</td><td></td><td>54M 40.50</td></tr><tr><td>ODE Transformer (2022)</td><td>6</td><td>=</td><td>69M 42.56</td></tr><tr><td>ODE Transformer (2022)</td><td>24</td><td></td><td>123M 43.28</td></tr><tr><td>Multi-Path Transformer (2022)</td><td>=</td><td></td><td>168M 42.44</td></tr><tr><td>Transformer</td><td>24 512 64</td><td>8-8</td><td>120M 42.33</td></tr><tr><td>PartialFormer (w/o Head Scaling) 24 512 648-8</td><td></td><td></td><td>68M 41.68</td></tr><tr><td>PartialFormer</td><td></td><td>24 512 64 24-18</td><td>119M 43.10</td></tr><tr><td>PartialFormer</td><td></td><td>24 512 64 24-24</td><td>127M 43.29</td></tr><tr><td>Transformer</td><td>6 512 64</td><td>8-8</td><td>63M 40.79</td></tr><tr><td>Transformer</td><td>24 360 45</td><td>8-8</td><td>64M 40.96</td></tr><tr><td>PartialFormer(w/o Head Scaling) 24 360 45</td><td></td><td>8-8</td><td>38M 40.44</td></tr><tr><td>PartialFormer</td><td></td><td>24 360 45 24-18</td><td>63M 42.16</td></tr><tr><td>PartialFormer</td><td></td><td>24 360 45 24-24</td><td>67M 42.39</td></tr></table>
149
+
150
+ 1.04 BLEU points (30.09 vs. 29.05) within a similar model capacity. The enhancement here can be attributed to the head scaling method, which allows PartialFormer to possess a larger hidden dimension, thereby bolstering its capacity for memory storage (Geva et al., 2021). These observations are further confirmed by the COMET-22 scores.
151
+
152
+ Moreover, PartialFormer can even surpass all selected multi-branch Transformers while using fewer parameters. Notably, PartialFormer $N =$ $2 4 , d \ = \ 5 1 2 )$ outperforms the latest multi-path Transformer (Lin et al., 2022) by 0.41 BLEU points with 78M fewer parameters. This highlights the efficiency of building a multi-branch network based on inherent subspaces. Additionally, PartialFormer excels over previous lightweight approaches and outperforms state-of-the-art weight-sharing methods, e.g., ODE Transformer (Li et al., 2022), and other strong baselines, e.g., Mega (Ma et al., 2022). Notably, both ODE Transformer and Mega utilize relative position encoding (Shaw et al., 2018).
153
+
154
+ Results of WMT’14 En-Fr Table 2 presents the results of PartialFormer on the WMT’14 En-Fr task. Similar to the findings in the En-De task, PartialFormer demonstrates a similar phenomenon. Notably, PartialFormer achieves comparable results to Transformer $( N = 2 4 , d = 5 1 2 )$ (42.39 vs. 42.33) while utilizing 53M fewer parameters (67M vs. 120M). This highlights the remarkable parameter efficiency of PartialFormer.
155
+
156
+ Results of WMT’16 En-Ro Table 3 presents the results on the test set of the WMT’16 En-Ro task. Notably, PartialFormer achieves the highest BLEU points among all selected baselines. It is particularly remarkable that PartialFormer achieves similar results to ODE Transformer while utilizing 178M fewer parameters. This highlights the exceptional efficiency of PartialFormer.
157
+
158
+ Table 3: Results on the WMT’16 En-Ro task.
159
+
160
+ <table><tr><td>Model</td><td>N</td><td>ddk</td><td>H Param BLEU</td></tr><tr><td>Delight (Mehta et al., 2021)</td><td>- 640-</td><td>■</td><td>53M 34.70</td></tr><tr><td>Subformer (Reid et al.,2021)</td><td>■</td><td>- ■ -</td><td>48M 34.70</td></tr><tr><td>ODE Transformer (Li et al.,2022)</td><td>6 1024 64 16-16</td><td></td><td>226M 35.28</td></tr><tr><td>Transformer</td><td>24 512 64</td><td>8-8</td><td>111M 35.00</td></tr><tr><td>PartialFormer (w/o Head Scaling)</td><td>24 512</td><td>64 8-8</td><td>59M 35.07</td></tr><tr><td>PartialFormer</td><td>24</td><td>320 4024-24</td><td>48M 35.30</td></tr></table>
161
+
162
+ Table 4: Results on the WMT’17 benchmark. PartialFormer has the same depth and $d$ as the Transformer but consumes 1M fewer parameters on average.
163
+
164
+ <table><tr><td rowspan="2">Model</td><td colspan="2">Fi←→En</td><td colspan="2">De←→En</td><td colspan="2">Lv← →En</td><td rowspan="2">Avg.</td></tr><tr><td>Fi→En En→FiDe→En En-→DeLv-→En En→Lv</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Transformer</td><td>26.07</td><td>22.14</td><td>35.04</td><td>28.59</td><td>17.59</td><td>16.23</td><td>24.27</td></tr><tr><td>PartialFormer</td><td>27.48</td><td>23.35</td><td>35.60</td><td>29.91</td><td>19.65</td><td>17.37</td><td>25.56</td></tr></table>
165
+
166
+ Results of WMT’17 Benchmark Table 4 presents the WMT’17 benchmark results, showing that PartialFormer consistently outperforms Transformer by an average of 1.29 BLEU points in all six translation tasks. This finding is consistent with the observed performance in the En-De task.
167
+
168
+ # 6 Analysis
169
+
170
+ # 6.1 Ablation Studies
171
+
172
+ Table 5 presents an ablation study of PartialFormer on the WMT’14 En-De task, demonstrating the critical role of each component. Omitting any element causes performance decline, underscoring the holistic design. The PG-FFN removal (#3 vs. #4) results in a large performance drop of 2.05 BLEU points, despite a mere 16 million parameters reduction. This evidence corroborates previous findings (Dong et al., 2021) on the subpar performance of pure attention networks sans FFN, highlighting the essential role of PG-FFN in PartialFormer.
173
+
174
+ Besides, Table 5 shows the results of different PartialFormer configurations on the WMT’14 En-De task. The encoder-decoder PartialFormer achieves the highest performance, reaching 29.56 BLEU points, indicating the effectiveness of our approach in enhancing both the encoder and the decoder. Employing our concept to either the encoder or the decoder individually also improves performance, yet the encoder-decoder configuration persistently surpasses others, marking the greatest performance improvement.
175
+
176
+ Table 5: Ablation studies on WMT’14 En-De task.
177
+
178
+ <table><tr><td># Model</td><td>Param BLEU</td></tr><tr><td>1 Transformer (N = 24,d = 360)</td><td>62M 28.00</td></tr><tr><td>2 Pure Attention (N= 24,d = 360)</td><td>31M 25.70</td></tr><tr><td>3 PartialFormer</td><td>68M 29.56</td></tr><tr><td>4 w/o Partial-level Gated FFN</td><td>52M 27.51</td></tr><tr><td>5 w/o Residual-like Attention Calculation</td><td>66M 29.26</td></tr><tr><td>6 w/o Head Scaling</td><td>36M 27.88</td></tr><tr><td>7 PartialFormer (encoder only)</td><td>67M 29.15</td></tr><tr><td>8 PartialFormer (decoder only)</td><td>63M 28.80</td></tr></table>
179
+
180
+ Table 7: Comparison of different width scaling strategy on the En-De task.
181
+
182
+ <table><tr><td>Model</td><td>Param BLEU</td></tr><tr><td>PartialFormer (w/o Head Scaling)</td><td>36M 27.88</td></tr><tr><td>+ Simple Head Scaling</td><td>68M 29.33</td></tr><tr><td>+ Complex Head Scaling</td><td>68M 29.56</td></tr></table>
183
+
184
+ Table 6: Comparison of head scaling strategy on WMT’14 En-De task.
185
+
186
+ # 6.2 Comparison of Head Scaling Strategy
187
+
188
+ Table 6 presents the results of PartialFormer on the En-De task test set with varying head scaling techniques. Both simple and complex strategies effectively utilize additional parameters to enhance PartialFormer’s performance. Notably, the complex head scaling technique, allowing for more parameters allocated to additional heads, demonstrates superior performance.
189
+
190
+ # 6.3 Discussions on Width Scaling Strategies
191
+
192
+ Table 7 presents the results of analyzing three key ways to increase the width in PartialFormer: 1) $d _ { k }$ , 2) $H$ , and 3) $d$ , on the En-De task’s test set. Notably, the findings indicate that both increasing $H$ and adding $d _ { k }$ can effectively enhance the capacity of PartialFormer. Additionally, enlarging $d$ can be beneficial for performance improvements when it is small, e.g., less than 360. However, beyond a certain threshold, further increments of $d$ become redundant and do not lead to performance gains. This aligns with previous studies (Mehta et al., 2021; Baevski and Auli, 2019) highlighting redundant information in the embedding layer.
193
+
194
+ # 6.4 Comparison of Gating Strategy
195
+
196
+ Table 8 presents a comparison of various activation functions used in PG-FFN. The results indicate that the default choice, ReLU activation, yields the best performance. One explanation is that the ReLU activation provides hard masks for filtering the information of different heads, compared to other activation functions. Such hard masks can make different heads more diverse.
197
+
198
+ <table><tr><td>Model</td><td>Seting</td><td>H d</td><td>dk Param</td><td>BLEU</td></tr><tr><td rowspan="7">PartialFormer</td><td>Basic</td><td>|30-16 360</td><td>45 68M</td><td>29.56</td></tr><tr><td>Varying Encoder H</td><td>|24-16 360 45 16-16 360 45</td><td>61M 51M</td><td>29.23 29.02</td></tr><tr><td>Varying Decoder H</td><td>[16-24 360 45 16-30360 45</td><td>56M 60M</td><td>28.85 29.20</td></tr><tr><td></td><td>|30-16 360 30</td><td>49M</td><td>28.70</td></tr><tr><td>Varying dh</td><td>30-16 360 60 30-16 360 90</td><td>86M 124M</td><td>29.68</td></tr><tr><td></td><td></td><td></td><td>30.00</td></tr><tr><td>Varying d</td><td>|30-16 180 45 30-16 270 45 30-16 450 45</td><td>35M 51M 84M</td><td>27.61 28.80 29.41</td></tr></table>
199
+
200
+ # 6.5 Efficiency Analysis
201
+
202
+ Table 9 exhibits the inference efficiency on the test set of En-De task. It is evident that PartialFormer incurs a reasonable increase in inference cost, which remains within acceptable limits.
203
+
204
+ # 6.6 Analysis on Behaviours of FFN
205
+
206
+ Metric. Following Zhang et al. (2022), we examine FFN behaviors across four aspects: activation neuron count (namely $n _ { \mathrm { a c t . } } )$ ), FFNs’ hidden dimension, activation-neuron ratio (activations divided by hidden dimension, namely $R _ { \mathrm { a c t . } }$ ), and FFN efficiency (activations divided by parameters, namely $\eta _ { \mathrm { { f f i n } } } )$ . Notably, for PartialFormer, the hidden dimension represents the concatenation of hidden dimensions from all smaller FFNs.
207
+
208
+ Results. Figure 4(a-c) exhibits the results on the En-De test set. It is evident that PartialFormer has a lower activation ratio than the vanilla Transformer, as shown in Figure 4(b). This indicates that PGFFNs based on matrix factorization present lower utilization of the hidden dimension compared to the vanilla FFNs. However, our PG-FFN is parameter consumption friendly, enabling larger hidden layer dimensions with the same parameter budget (e.g., 5400 vs. 1440). Despite lower utilization of hidden dimension, it can still own more activated neurons, as depicted in Figure 4(a). Additionally, our PGFFN exhibits higher efficiency compared to vanilla FFNs, as shown in Figure 4(c). Multiple small FFNs, like “Swarm Intelligence” (Bonabeau et al., 1999), outperform large FFNs by leveraging the collective strength of weak individuals.
209
+
210
+ Table 8: Comparison of activation functions in PGFFNs.
211
+
212
+ <table><tr><td>Model</td><td>Param BLEU</td></tr><tr><td>PG-FFNs</td><td>68M 29.56</td></tr><tr><td>PG-FFNs with Sigmoid activation</td><td>68M 29.21</td></tr><tr><td>PG-FFNs with Tanh activation</td><td>68M 29.03</td></tr></table>
213
+
214
+ Table 9: Efficiency comparison between Transformer and PartialFormer in inference.
215
+
216
+ <table><tr><td>Model</td><td colspan="4">Param Speed (Tok./s)Memory BLEU</td></tr><tr><td>Transformer</td><td>62M</td><td>4325</td><td>3.0G</td><td>28.00</td></tr><tr><td>PartialFormer (w/o head scaling)</td><td>66M</td><td>3634</td><td>3.2G</td><td>28.86</td></tr><tr><td>PartialFormer</td><td>68M</td><td>3023</td><td>3.3G</td><td>29.56</td></tr></table>
217
+
218
+ # 6.7 Analysis on Head Diversity
219
+
220
+ Metric. We select the same metric, namely $D _ { o u t p u t }$ , as that in Li et al. (2018) to measure the diversity among head features. In this metric, a larger value indicates a higher level of diversity.
221
+
222
+ Results. From Figure 4(d), we can observe that PartialFormer exhibits more diverse head features compared to the vanilla Transformer, even though the vanilla Transformer already demonstrates diverse features. This aligns with previous study (Li et al., 2018), which demonstrates the positive impact of head feature diversity on the Transformer model’s performance. Thus, we conclude that the insertion of FFNs into attention mechanism may be a more optimal design.
223
+
224
+ # 7 Related Work
225
+
226
+ Lightweight Transformers Many methods have been proposed to improve the parameter efficiency of Transformer architecture. The first line is to directly cut down redundant computations and parameters via a more efficient design such as adopting more efficient transformation operations (Mehta et al., 2019, 2021), integrating different but complementary patterns (Wu et al., 2020) and neural architecture search (So et al., 2019). Another research direction for improving parameter efficiency in the Transformer is weight sharing. The popular cross-layer sharing method is utilized by the Universal Transformer (Dehghani et al., 2019). Reid et al. (2021) propose better performance by freeing the first and last encoder layers and widening the intermediate layers. Li et al. (2022) introduce an ordinary differential equation-inspired weightsharing method for more precise results. Different from these work, our study focus on the design of efficient lightweight FFN.
227
+
228
+ ![](images/5cec8e8c7564f86b66a2a3fde975639ff37eeaac9506bd16cdd39ff8be563e0f.jpg)
229
+ Figure 4: Analysis on behaviours of FFNs and head diversity in Transformer and PartialFormer.
230
+
231
+ Multi-Branch Transformer The multi-branch strategy is widely used in Transformer design. Weighted Transformer (Ahmed et al., 2017) employs a multi-branch FFN, while Multi-attentive Transformer (Fan et al., 2020), Multi-units Transformer (Yan et al., 2020), and Multi-Path Transformer (Lin et al., 2022) extend this concept to different components of the Transformer. Our work introduces a pure multi-branch architecture based on natural subspaces.
232
+
233
+ Scaling Strategy in Transformer Deepening (Bapna et al., 2018; Wang et al., 2019) and widening (Vaswani et al., 2017; Wu et al., 2021) Transformer have been well-acknowledged as two strategies to improve the capacity of Transformer in literature. In this work, PartialFormer adopts two alternative strategies to improve capacity, adding a number of heads and head dimensions.
234
+
235
+ # 8 Conclusion
236
+
237
+ In this paper, we present PartialFormer, a new parameter-efficient Transformer architecture that offers an alternative approach to the design of the lightweight FFN. By employing multiple small FFNs and leveraging matrix factorization techniques, PartialFormer effectively reduces the number of parameters in the FFN. Moreover, we propose two innovative operations to further efficiently enhance the model capabilities. Experimental results across various machine translation tasks showcase the significant performance improvements achieved by PartialFormer, while maintaining comparable parameter consumption.
238
+
239
+ # Limitations
240
+
241
+ Despite the potential advantages of Partialformer in terms of parameter utilization and performance within a limited parameter budget, it is important to note that the existing conclusions regarding its effectiveness have not been thoroughly examined in the context of large-scale datasets and a higher number of parameters. Further research is needed to validate the claims and assess the scalability of Partialformer in more challenging scenarios.
242
+
243
+ # References
244
+
245
+ Karim Ahmed, Nitish Shirish Keskar, and Richard Socher. 2017. Weighted transformer network for machine translation. CoRR.
246
+
247
+ Alexei Baevski and Michael Auli. 2019. Adaptive input representations for neural language modeling. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019.
248
+
249
+ Ankur Bapna, Mia Chen, Orhan Firat, Yuan Cao, and Yonghui Wu. 2018. Training deeper neural machine translation models with transparent attention. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 3028– 3033, Brussels, Belgium. Association for Computational Linguistics.
250
+
251
+ Eric Bonabeau, Marco Dorigo, and Guy Theraulaz. 1999. Swarm Intelligence: From Natural to Artificial Systems. Oxford University Press.
252
+
253
+ Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D. Manning. 2019. What does BERT look at? an analysis of BERT’s attention. In Proceedings of the 2019 ACL Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pages 276–286, Florence, Italy. Association for Computational Linguistics.
254
+
255
+ Yann N. Dauphin, Angela Fan, Michael Auli, and David Grangier. 2017. Language modeling with gated convolutional networks. 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 933–941. PMLR.
256
+
257
+ Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Lukasz Kaiser. 2019. Universal transformers. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019.
258
+
259
+ Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas. 2021. Attention is not all you need: pure attention loses rank doubly exponentially with depth. In Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, pages 2793–2803.
260
+
261
+ Yang Fan, Shufang Xie, Yingce Xia, Lijun Wu, Tao Qin, Xiang-Yang Li, and Tie-Yan Liu. 2020. Multi-branch attentive transformer. ArXiv, abs/2006.10270.
262
+
263
+ Zhihao Fan, Yeyun Gong, Dayiheng Liu, Zhongyu Wei, Siyuan Wang, Jian Jiao, Nan Duan, Ruofei Zhang, and Xuanjing Huang. 2021. Mask attention networks: Rethinking and strengthen transformer. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 1692–1701, Online. Association for Computational Linguistics.
264
+
265
+ Tao Ge, Si-Qing Chen, and Furu Wei. 2022. EdgeFormer: A parameter-efficient transformer for ondevice seq2seq generation. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 10786–10798, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
266
+
267
+ Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. 2017. Convolutional sequence to sequence learning. In Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, 6-11 August 2017, pages 1243–1252.
268
+
269
+ Mor Geva, Roei Schuster, Jonathan Berant, and Omer Levy. 2021. Transformer feed-forward layers are keyvalue memories. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 5484–5495, Online and Punta Cana, Dominican Republic. Association for Computational Linguistics.
270
+
271
+ Ruining He, Anirudh Ravula, Bhargav Kanagal, and Joshua Ainslie. 2021. RealFormer: Transformer likes residual attention. In Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 929–943, Online. Association for Computational Linguistics.
272
+
273
+ Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. 2020. ALBERT: A lite BERT for self-supervised learning of language representations. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020.
274
+
275
+ Bei Li, Quan Du, Tao Zhou, Yi Jing, Shuhan Zhou, Xin Zeng, Tong Xiao, JingBo Zhu, Xuebo Liu, and Min Zhang. 2022. ODE transformer: An ordinary differential equation-inspired model for sequence generation. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 8335–8351, Dublin, Ireland. Association for Computational Linguistics.
276
+
277
+ Jian Li, Zhaopeng Tu, Baosong Yang, Michael R. Lyu, and Tong Zhang. 2018. Multi-head attention with disagreement regularization. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 2897–2903, Brussels, Belgium. Association for Computational Linguistics.
278
+
279
+ Ye Lin, Shuhan Zhou, Yanyang Li, Anxiang Ma, Tong Xiao, and Jingbo Zhu. 2022. Multi-path transformer is better: A case study on neural machine translation. In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 5646–5656, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
280
+
281
+ Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, and Jian Sun. 2018. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In Computer Vision – ECCV 2018: 15th European Conference, Munich, Germany, September 8–14, 2018, Proceedings, Part XIV, page 122–138, Berlin, Heidelberg. SpringerVerlag.
282
+
283
+ Xuezhe Ma, Chunting Zhou, Xiang Kong, Junxian He, Liangke Gui, Graham Neubig, Jonathan May, and Luke Zettlemoyer. 2022. Mega: Moving average equipped gated attention. CoRR.
284
+
285
+ Sachin Mehta, Marjan Ghazvininejad, Srinivasan Iyer, Luke Zettlemoyer, and Hannaneh Hajishirzi. 2021. Delight: Deep and light-weight transformer. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021.
286
+
287
+ Sachin Mehta, Rik Koncel-Kedziorski, Mohammad Rastegari, and Hannaneh Hajishirzi. 2019. Define: Deep factorized input word embeddings for neural sequence modeling. ArXiv, abs/1911.12385.
288
+
289
+ Paul Michel, Omer Levy, and Graham Neubig. 2019. Are sixteen heads really better than one? Advances in neural information processing systems, 32.
290
+
291
+ Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan Ng, David Grangier, and Michael Auli. 2019. fairseq: A fast, extensible toolkit for sequence modeling. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics (Demonstrations), pages 48–53, Minneapolis, Minnesota. Association for Computational Linguistics.
292
+
293
+ Kishore Papineni, Salim Roukos, Todd Ward, and WeiJing Zhu. 2002. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics, pages 311–318, Philadelphia, Pennsylvania, USA. Association for Computational Linguistics.
294
+
295
+ Ricardo Rei, José G. C. de Souza, Duarte Alves, Chrysoula Zerva, Ana C Farinha, Taisiya Glushkova, Alon Lavie, Luisa Coheur, and André F. T. Martins. 2022. COMET-22: Unbabel-IST 2022 submission for the metrics shared task. In Proceedings of the Seventh Conference on Machine Translation (WMT), pages 578–585, Abu Dhabi, United Arab Emirates (Hybrid). Association for Computational Linguistics.
296
+
297
+ Machel Reid, Edison Marrese-Taylor, and Yutaka Matsuo. 2021. Subformer: Exploring weight sharing for parameter efficiency in generative transformers. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 4081–4090, Punta Cana, Dominican Republic. Association for Computational Linguistics.
298
+
299
+ Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. 2018. Self-attention with relative position representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), pages 464–468, New Orleans, Louisiana. Association for Computational Linguistics.
300
+
301
+ Noam Shazeer. 2020. Glu variants improve transformer. arXiv preprint arXiv:2002.05202.
302
+
303
+ David R. So, Quoc V. Le, and Chen Liang. 2019. The evolved transformer. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, pages 5877–5886.
304
+
305
+ Ilya Sutskever, Oriol Vinyals, and Quoc V. Le. 2014. Sequence to sequence learning with neural networks. In Advances in Neural Information Processing Systems 27: Annual Conference on Neural Information Processing Systems 2014, December 8-13 2014, Montreal, Quebec, Canada, pages 3104–3112.
306
+
307
+ Mingxing Tan and Quoc Le. 2019. Efficientnet: Rethinking model scaling for convolutional neural networks. In International conference on machine learning, pages 6105–6114. PMLR.
308
+
309
+ Chau Tran, Shruti Bhosale, James Cross, Philipp Koehn, Sergey Edunov, and Angela Fan. 2021. Facebook AI’s WMT21 news translation task submission. In Proceedings of the Sixth Conference on Machine Translation, pages 205–215, Online. Association for Computational Linguistics.
310
+
311
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. 2017. 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.
312
+
313
+ Elena Voita, David Talbot, Fedor Moiseev, Rico Sennrich, and Ivan Titov. 2019. Analyzing multi-head self-attention: Specialized heads do the heavy lifting, the rest can be pruned. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 5797–5808, Florence, Italy. Association for Computational Linguistics.
314
+
315
+ Peihao Wang, Wenqing Zheng, Tianlong Chen, and Zhangyang Wang. 2022. Anti-oversmoothing in deep vision transformers via the fourier domain analysis: From theory to practice. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022.
316
+
317
+ Qiang Wang, Bei Li, Tong Xiao, Jingbo Zhu, Changliang Li, Derek F. Wong, and Lidia S. Chao. 2019. Learning deep transformer models for machine translation. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 1810–1822, Florence, Italy. Association for Computational Linguistics.
318
+
319
+ Lijun Wu, Juntao Li, Yue Wang, Qi Meng, Tao Qin, Wei Chen, Min Zhang, Tie-Yan Liu, et al. 2021. R-drop: Regularized dropout for neural networks. Advances in Neural Information Processing Systems, 34:10890– 10905.
320
+
321
+ Zhanghao Wu, Zhijian Liu, Ji Lin, Yujun Lin, and Song Han. 2020. Lite transformer with long-short range attention. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020.
322
+
323
+ Jianhao Yan, Fandong Meng, and Jie Zhou. 2020. Multiunit transformers for neural machine translation. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 1047–1059, Online. Association for Computational Linguistics.
324
+
325
+ Zhengyan Zhang, Yankai Lin, Zhiyuan Liu, Peng Li, Maosong Sun, and Jie Zhou. 2022. MoEfication: Transformer feed-forward layers are mixtures of experts. In Findings of the Association for Computational Linguistics: ACL 2022, pages 877–890, Dublin, Ireland. Association for Computational Linguistics.
326
+
327
+ # A Detailed Setups of Experiments
328
+
329
+ # A.1 Dataset
330
+
331
+ Table 10 displays the statistics of all the 9 translation task.
332
+
333
+ # A.2 Training Details
334
+
335
+ Table 11 and 12 exhibits the training details on all translation tasks.
336
+
337
+ # B Metric Definition
338
+
339
+ # B.1 Measurement of Head Diversity
340
+
341
+ Following Li et al. (2018), we measure the head diversity as follows:
342
+
343
+ $$
344
+ D _ { \mathrm { o u t p u t } } = \exp ( - \frac { 1 } { H ^ { 2 } } \sum _ { i = 1 } ^ { H } \sum _ { j = 1 } ^ { H } \frac { | O ^ { i } \cdot O ^ { j } | } { \| O ^ { i } \| \| O ^ { j } \| } )
345
+ $$
346
+
347
+ During evaluation, we calculate the metric on all samples and average the values to obtain the final result.
348
+
349
+ # C More Comparison with Previous Lightweight Transformer
350
+
351
+ Table 13 presents a comprehensive comparison of previous lightweight Transformer models on the En-De task’s test set, with a specific focus on operating within a smaller parameter budget. The results prominently showcase the outstanding performance of PartialFormer, even when faced with constraints on model capacity. This outcome further emphasizes the superior capabilities of PartialFormer in scenarios with limited resources.
352
+
353
+ # D PartialFormer with Different $A _ { G }$ for Small Dataset
354
+
355
+ Table 14 showcases the results of PartialFormer on the WMT’16 En-Ro task, a small-scale translation dataset, specifically when $A _ { G }$ is calculated using local attention (Shaw et al., 2018). Notably, these results reveal that by adopting such an approach, PartialFormer achieves an impressive BLEU score of 35.76. We hope this can shed lights on the area of model integration.
356
+
357
+ # E PartialFormer with GLU and Weight Sharing
358
+
359
+ In this section, we investigate the integration of PartialFormer with two prominent techniques to enhance parameter efficiency: 1) the weight sharing method (Lan et al., 2020), and 2) gated linear units (Dauphin et al., 2017). To ensure the utilization of the latest advancements, we employ a state-of-the-art weight sharing method called ODE Transformer (Li et al., 2022), known for its effectiveness in promoting parameter efficiency in Transformer architectures. Additionally, we incorporate Swi-GLU (Shazeer, 2020), a widely adopted GLUvariant that has served as a foundational component in numerous expressive Transformer architectures.
360
+
361
+ Table 10: The details of datasets of 9 translation tasks.
362
+
363
+ <table><tr><td rowspan="2">Dataset</td><td colspan="3">Sentence</td><td rowspan="2">BPE</td><td rowspan="2">Vocab</td></tr><tr><td>Train</td><td>Dev</td><td>Test</td></tr><tr><td>WMT&#x27;14 En-De</td><td>4.5M</td><td>2999 26815</td><td>3003</td><td>32K 32K</td><td>34040 37288</td></tr><tr><td>WMT&#x27;14 En-Fr WMT&#x27;16 En-Ro</td><td>36M 0.6M</td><td>1999</td><td>3003 1999</td><td>20K</td><td>19064</td></tr><tr><td>WMT&#x27;17 En-De</td><td>5.9M</td><td>7998</td><td>3004</td><td>32K</td><td>35488</td></tr><tr><td>WMT&#x27;17 De-En</td><td>5.9M</td><td>7998</td><td>3004</td><td>32K</td><td>35448</td></tr><tr><td>WMT&#x27;17 En-Fi</td><td>2.7M</td><td>4225</td><td>3002</td><td>32K</td><td>32584</td></tr><tr><td>WMT&#x27;17Fi-En</td><td>2.7M</td><td>4225</td><td>3002</td><td>32K</td><td>32584</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>WMT&#x27;17 En-Lv WMT&#x27;17Lv-En</td><td>4.5M 4.5M</td><td>2003 2003</td><td>2001 2001</td><td>20K 20K</td><td>32368 32368</td></tr></table>
364
+
365
+ Table 11: The training setups of WMT’14 En-De, WMT’16 En-Ro and WMT’14 En-Fr tasks.
366
+
367
+ <table><tr><td colspan="4">Hyper-parameter WMT&#x27;14 En-De WMT&#x27;16En-Ro WMT&#x27;14 En-Fr</td></tr><tr><td>GPUs</td><td>8</td><td>4</td><td>8</td></tr><tr><td>Batch Size</td><td>4096</td><td>4096</td><td>4096</td></tr><tr><td>Update Frequency</td><td>2</td><td>1</td><td>8</td></tr><tr><td>Optimer</td><td>Adam</td><td>Adam</td><td>Adam</td></tr><tr><td>Adamβ</td><td>(0.9,0.997)</td><td>(0.9, 0.997)</td><td>(0.9, 0.997)</td></tr><tr><td>LR</td><td>0.0020</td><td>0.0020</td><td>0.0020</td></tr><tr><td>LR scheduler</td><td>inverse sqrt</td><td>inverse sqrt</td><td>inverse sqrt</td></tr><tr><td>InitialLR</td><td>1e-7</td><td>1e-7</td><td>le-7</td></tr><tr><td>Total updates</td><td>50K</td><td>25K</td><td>100K</td></tr><tr><td>Warmup updates</td><td>16000</td><td>8000</td><td>16000</td></tr><tr><td>Weight decay</td><td>0.0000</td><td>0.0000</td><td>0.0000</td></tr><tr><td>Label smoothing</td><td>0.1</td><td>0.1</td><td>0.1</td></tr><tr><td>Dropout</td><td>0.1</td><td>0.1</td><td>0.1</td></tr><tr><td>Attention dropout</td><td>0.1</td><td>0.1</td><td>0.1</td></tr><tr><td>ReLU dropout</td><td>0.1</td><td>0.1</td><td>0.1</td></tr></table>
368
+
369
+ Table 12: The training setups of WMT’17 benchmark.
370
+
371
+ <table><tr><td colspan="3">Hyper-parameterI En-{De,Lv} {De,Lv}-En</td><td>En-Fi</td><td>Fi-En</td></tr><tr><td>GPUs</td><td>8</td><td>8</td><td>8</td><td>8</td></tr><tr><td>Batch Size</td><td>4096</td><td>4096</td><td>4096</td><td>4096</td></tr><tr><td>Update Frequency</td><td>2</td><td>1</td><td>1</td><td>4</td></tr><tr><td>Optimer</td><td>Adam</td><td>Adam</td><td>Adam</td><td>Adam</td></tr><tr><td>Adamβ</td><td>(0.9, 0.997)</td><td>(0.9, 0.997)</td><td>(0.9,0.997) (0.9,0.997)</td><td></td></tr><tr><td>LR</td><td>0.0020</td><td>0.0020</td><td>0.0020</td><td>0.0020</td></tr><tr><td>LR scheduler</td><td>inverse sqrt</td><td>inverse sqrt</td><td>inverse sqrt</td><td>inverse sqrt</td></tr><tr><td>Initial LR</td><td>1e-7</td><td>1e-7</td><td>1e-7</td><td>le-7</td></tr><tr><td>Total updates</td><td>50K/17K</td><td>50K/17K</td><td>40K</td><td>10K</td></tr><tr><td>Warmup updates</td><td>16000</td><td>16000</td><td>16000</td><td>16000</td></tr><tr><td>Weight decay</td><td>0.0000</td><td>0.0000</td><td>0.0000</td><td>0.0000</td></tr><tr><td>Label smoothing</td><td>0.1</td><td>0.1</td><td>0.1</td><td>0.1</td></tr><tr><td>Dropout</td><td>0.1</td><td>0.1</td><td>0.1</td><td>0.1</td></tr><tr><td>Attention dropout</td><td>0.1</td><td>0.1</td><td>0.1</td><td>0.1</td></tr><tr><td>ReLU dropout</td><td>0.1</td><td>0.1</td><td>0.1</td><td>0.1</td></tr></table>
372
+
373
+ Table 15 displays the results of combining PartialFormer with weight sharing and gated linear units. Despite the integration of these two techniques, the performance gains are marginal. This could be attributed to the fact that PartialFormer already possesses high parameter efficiency, leaving little room for additional enhancements from other technologies. In other words, PartialFormer is inherently a high parameter efficiency architecture.
374
+
375
+ Table 13: Comparison with state-of-the-art models of smaller capacities on the En-De task.
376
+
377
+ <table><tr><td>Model</td><td>Param BLEU</td></tr><tr><td>DELIGHT (Mehta et al., 2021) EdgeFormer (Ge et al., 2022) Lite Transformer (Wu et al.,2020) PartialFormer</td><td>23M 26.70 - 26.90 - 26.50 27M 27.50</td></tr><tr><td>Evolved Transformer (So et al., 2019) DELIGHT (Mehta et al., 2021) ODE Transformer (Li et al., 2022) PartialFormer</td><td>48M 27.70 37M 27.60 37M 28.24 36M 28.35</td></tr></table>
378
+
379
+ Table 14: Results of several PartialFormer variants on the En-De task.
380
+
381
+ <table><tr><td>AG</td><td>AL</td><td>Param</td><td>BLEU</td></tr><tr><td>RPR</td><td>MHSA</td><td>62M</td><td>35.76</td></tr></table>
382
+
383
+ Table 15: Results of PartialFormer variants on the EnDe task.
384
+
385
+ <table><tr><td>Model</td><td>Param</td><td>BLEU</td></tr><tr><td>PartialFormer</td><td>67M</td><td>29.56</td></tr><tr><td>PartialFormer + Weight Sharing</td><td>67M</td><td>29.71</td></tr><tr><td>GLU-based PartialFormer</td><td>67M</td><td>29.67</td></tr></table>
386
+
387
+ # F Analysis on Token Uniformity
388
+
389
+ Following (Dong et al., 2021; Wang et al., 2022), we measure the token uniformity among token representations. We use pearson correlation to compute it.
390
+
391
+ From Figure 5, we can observe that PartialFormer owns a lower token uniformity among token representations than the vanilla Transformer, revealing that PartialFormer can benefit from depth scaling efficiently (Dong et al., 2021; Wang et al., 2022).
392
+
393
+ # G Preliminary Experiments on Language Modeling
394
+
395
+ We also evaluate the effectiveness of PartialFormer on the language modeling task. We can see that
396
+
397
+ ![](images/517907196c26506a55372a37e562c0ab840c57819add59a61bb59d3cc5f52ae6.jpg)
398
+ Figure 5: Comparison of token uniformity (lower is better) in Transformer and PartialFormer.
399
+
400
+ PartialFormer can also show better results compared to strong baseline, e.g., Adaptive Input Transformer (Baevski and Auli, 2019). We will present more comprehensive experiments in the future.
401
+
402
+ <table><tr><td>Model</td><td>Depth 0 (M) Test PPL</td></tr><tr><td>Adaptive Input</td><td>8 147M 21.11</td></tr><tr><td>PartialFormer</td><td>16 143M 19.87</td></tr></table>
403
+
404
+ Table 16: Results on the WikiText-103 dataset.
md/dev/OdnNBNIdFul/OdnNBNIdFul.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/Pyd6Rh9r1OT/Pyd6Rh9r1OT.md ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fast Vision Transformers with HiLo Attention
2
+
3
+ Zizheng Pan Jianfei Cai Bohan Zhuang†
4
+
5
+ Department of Data Science & AI, Monash University, Australia
6
+
7
+ # Abstract
8
+
9
+ Vision Transformers (ViTs) have triggered the most recent and significant breakthroughs in computer vision. Their efficient designs are mostly guided by the indirect metric of computational complexity, i.e., FLOPs, which however has a clear gap with the direct metric such as throughput. Thus, we propose to use the direct speed evaluation on the target platform as the design principle for efficient ViTs. Particularly, we introduce LITv2, a simple and effective ViT which performs favourably against the existing state-of-the-art methods across a spectrum of different model sizes with faster speed. At the core of LITv2 is a novel self-attention mechanism, which we dub HiLo. HiLo is inspired by the insight that high frequencies in an image capture local fine details and low frequencies focus on global structures, whereas a multi-head self-attention layer neglects the characteristic of different frequencies. Therefore, we propose to disentangle the high/low frequency patterns in an attention layer by separating the heads into two groups, where one group encodes high frequencies via self-attention within each local window, and another group encodes low frequencies by performing global attention between the average-pooled low-frequency keys and values from each window and each query position in the input feature map. Benefiting from the efficient design for both groups, we show that HiLo is superior to the existing attention mechanisms by comprehensively benchmarking FLOPs, speed and memory consumption on GPUs and CPUs. For example, HiLo is $1 . 4 \times$ faster than spatial reduction attention and $1 . 6 \times$ faster than local window attention on CPUs. Powered by HiLo, LITv2 serves as a strong backbone for mainstream vision tasks including image classification, dense detection and segmentation. Code is available at https://github.com/ziplab/LITv2.
10
+
11
+ # 1 Introduction
12
+
13
+ Real-world applications usually require a model to have an optimal speed and accuracy trade-off under limited computational budget, such as UAV and autonomous driving. This motivates substantial works toward efficient vision Transformer (ViT) design, such as PVT [51], Swin [32] and Focal Transformer [60], among others. To measure the computational complexity, a widely adopted metric in recent ViT design is the number of float-point operations, i.e., FLOPs. However, FLOPs is an indirect metric, which can not directly reflect the real speed on the target platform. For example, Focal-Tiny is much slower than Swin-Ti on GPUs although their FLOPs are comparable.
14
+
15
+ In general, the discrepancy between the indirect metric (FLOPs) and the direct metric (speed) in recent ViTs can be attributed to two main reasons. First, although self-attention is efficient on low-resolution feature maps, the quadratic complexity in both memory and time makes it much slower on high-resolution images due to intensive memory access cost [34], where fetching data from off-chip DRAM can be speed-consuming. Second, some efficient attention mechanisms in ViTs have low theoretical complexity guarantee but are actually slow on GPUs due to particular operations that are not hardware-friendly or cannot be parallelized, such as the multi-scale window partition [60], recursion [44] and dilated window [20].
16
+
17
+ ![](images/3863cf3f80ae0c2671284d8f8aac929d15e60c053d4009d3925cdf0e063955e0.jpg)
18
+ Figure 1: Framework of HiLo attention. $N _ { h }$ refers to the total number of self-attention heads at this layer. $\alpha$ denotes the split ratio for high/low frequency heads. Best viewed in color.
19
+
20
+ With these observations, in this paper we propose to evaluate ViT by the direct metric, i.e., throughput, not only FLOPs. Based on this principle, we introduce LITv2, a novel efficient and accurate vision Transformer that outperforms most state-of-the-art (SoTA) ViTs on standard benchmarks while being practically faster on GPUs. LITv2 is bulit upon LITv1 [36], a simple ViT baseline which removes all multi-head self-attention layers (MSAs) in the early stages while applying standard MSAs in the later stages. Benefit from this design, LITv1 is faster than many existing works on ImageNet classification due to no computational cost from the early MSAs while the later MSAs only need to process downsampled low-resolution feature maps. However, the standard MSA still suffers from huge computational cost on high-resolution images, especially for dense prediction tasks.
21
+
22
+ To address this problem, we propose a novel efficient attention mechanism, termed HiLo. HiLo is motivated by the fact that natural images contain rich frequencies where high/low frequencies play different roles in encoding image patterns, i.e., local fine details and global structures, respectively. A typical MSA layer enforces the same global attention across all image patches without considering the characteristics of different underlying frequencies. This motivates us to propose to separate an MSA layer into two paths where one path encodes high-frequency interactions via local self-attention with relatively high-resolution feature maps while the other path encodes low-frequency interactions via global attention with down-sampled feature maps, which leads to a great efficiency improvement.
23
+
24
+ Specifically, HiLo employs two efficient attentions to disentangle High/Low frequencies in feature maps. As shown in Figure 1, in the upper path, we allocate a few heads to the high frequency attention (Hi-Fi) to capture fine-grained high frequencies by local window self-attention (e.g., $2 \times 2$ windows), which is much more efficient than standard MSAs. The lower path, implementing the low-frequency attention (Lo-Fi), first applies average pooling to each window to obtain low-frequency signals. Then, we allocate the remaining heads for Lo-Fi to model the relationship between each query position in the input feature map and the average-pooled low-frequency keys and values from each window. Benefit from the reduced length of keys and values, Lo-Fi also achieves significant complexity reduction. Finally, we concatenate the refined high/low-frequency features and forward the resulting output into subsequent layers. Since both Hi-Fi and Lo-Fi are not equipped with time-consuming operations such as dilated windows and recursion, the overall framework of HiLo is fast on both CPUs and GPUs. We show by comprehensive benchmarks that HiLo achieves advantage over the existing attention mechanisms in terms of performance, FLOPs, throughput and memory consumption.
25
+
26
+ Besides, we find the fixed relative positional encoding in LITv1 dramatically slows down its speed on dense prediction tasks due to the interpolation for different image resolutions. For better efficiency, we propose to adopt one $3 \times 3$ depthwise convolutional layer with zero-padding in each FFN to incorporate the implicitly learned position information from zero-padding [27]. Moreover, the $3 \times 3$ convolutional filters simultaneously help to enlarge the receptive field of the early multi-layer perceptron (MLP) blocks in LITv1. Finally, we conduct extensive experiments on ImageNet, COCO and ADE20K to evaluate the performance of LITv2. Comprehensive comparisons with SoTA models show that our architecture achieves competitive performance with faster throughput, making ViTs more feasible to run low-latency applications for real-world scenarios.
27
+
28
+ # 2 Related Work
29
+
30
+ Vision Transformers. Vision Transformers are neural networks that adopt self-attention mechanisms into computer vision tasks. In [18], Dosovitskiy et al. propose a ViT for image classification, which inherits the similar architecture from a standard Transformer [48] in natural language processing (NLP) tasks. Since then, subsequent works have been proposed to improve ViT by incorporating more convolutional layers [54, 61], introducing pyramid feature maps [51, 32], enhancing the locality [62], as well as automatically searching a well-performed architecture [5, 3] with neural architecture search (NAS). Some others also seek for token pruning to accelerate the inference speed of ViTs [37] or applying ViT into low-level vision tasks [47]. Compared to existing works, this paper focuses on a general ViT-based backbone for computer vision (CV) tasks and aims to achieve better efficiency on GPUs while maintaining competitive performance.
31
+
32
+ Efficient attention mechanisms. Efficient attention mechanisms aim to reduce the quadratic complexity of standard MSAs. Existing efforts in NLP can be roughly categories into low-rank decomposition [50], kernelization [28, 39], memory [40] and sparsity mechanism [10]. However, simply adopting these method usually performs suboptimally in CV tasks [32, 63]. In CV, representative efficient self-attention mechanisms includes spatial reduction attention (SRA) [51], local window attention [32, 26] and Twins attention [12]. However, they only focus on either local or global attention at the same layer. To address this problem, TNT [21] introduced additional global tokens and MixFormer [6] mixed local window attention with depthwise convolutional layers. Some other attention mechanisms consider both simultaneously, such as Focal [60] and QuadTree [44]. However, due to the inefficient operations which are not hardware-friendly and cannot be reflected in FLOPs (e.g., multi-scale window partition, recursion), they are slow on GPUs even compared to standard MSA. To this end, the proposed HiLo attention simultaneously captures rich local-global information at the same MSA layer and is faster and more memory-efficient compared to the existing works.
33
+
34
+ Frequency domain analysis in vision. The frequency domain analysis in CV has been well studied in the literature. According to [13, 16], the low frequencies in an image usually capture global structures and color information while the high frequencies contain fine details of objects (e.g., sharp edges). Based on this insight, a plethora of solutions have been proposed for image super-resolution [66, 19], generalization [25], image re-scaling [56] and neural network compression [59, 7]. Furthermore, Octave convolution [9] targeted convolutional layers and proposed to locally applies convolution on high/low-resolution feature maps, separately. Different from it, the proposed HiLo is a novel attention mechanism that captures both local and global relationships with self-attention.
35
+
36
+ # 3 Background
37
+
38
+ Multi-head self-attention. Transformers are built upon multi-head self-attention, which enables to capture long-range relationships for tokens at different positions. Specifically, let $\mathbf { X } \in \mathbb { R } ^ { N \times D }$ be the input sequence into a standard MSA layer, where $N$ is the length of the input sequence and $D$ refers to the number of hidden dimensions. Each self-attention head calculates the query $\mathbf { Q }$ , key $\mathbf { K }$ and value $\mathbf { V }$ matrices with a linear transformation from $\mathbf { X }$ ,
39
+
40
+ $$
41
+ \mathbf { Q } = \mathbf { X } \mathbf { W } _ { q } , \mathbf { K } = \mathbf { X } \mathbf { W } _ { k } , \mathbf { V } = \mathbf { X } \mathbf { W } _ { v } ,
42
+ $$
43
+
44
+ where $\mathbf { W } _ { q }$ , $\mathbf { W } _ { k }$ , $\mathbf { W } _ { v } \in \mathbb { R } ^ { D \times D _ { h } }$ are learnable parameters and $D _ { h }$ is the number of hidden dimensions for a head. Next, the output of a self-attention head is a weighted sum over $N$ value vectors,
45
+
46
+ $$
47
+ \mathrm { S A } _ { h } ( \mathbf { X } ) = \mathrm { S o f t m a x } ( \frac { \mathbf { Q } \mathbf { K } ^ { \top } } { \sqrt { D _ { h } } } ) \mathbf { V } .
48
+ $$
49
+
50
+ For an MSA layer with $N _ { h }$ heads, the final output is computed by a linear projection of the concatenated outputs from each self-attention head, which can be formulated by
51
+
52
+ $$
53
+ \mathrm { M S A } ( \mathbf { X } ) = \operatorname * { c o n c a t } _ { h \in [ N _ { h } ] } [ \mathrm { S A } _ { h } ( \mathbf { X } ) ] \mathbf { W } _ { o } ,
54
+ $$
55
+
56
+ where $\mathbf { W } _ { o } \in \mathbb { R } ^ { ( N _ { h } \times D _ { h } ) \times D }$ is a learnable parameter. In practice, $D$ is usually equal to $N _ { h } \times D _ { h }$ . Overall, a standard MSA layer have the computational cost of $4 N D ^ { 2 } + 2 N ^ { 2 } D$ , where $2 N ^ { 2 } D$ comes from Eq. (2), $3 N D ^ { 2 }$ and $\dot { N } D ^ { 2 }$ comes from Eq. (1) and Eq. (3), respectively.
57
+
58
+ Transformer blocks. A standard vision Transformer as described in [18] consists of a patch embedding layer, several blocks and a prediction head. Let $l$ be the index of a block. Then each block contains an MSA layer and a position-wise feed-forward network (FFN), which can expressed as
59
+
60
+ $$
61
+ \begin{array} { r } { \mathbf { X } _ { l - 1 } ^ { ' } = \mathbf { X } _ { l - 1 } + \mathrm { M S A } ( \mathrm { L N } ( \mathbf { X } _ { l - 1 } ) ) , } \\ { \mathbf { X } _ { l } = \mathbf { X } _ { l - 1 } ^ { ' } + \mathrm { F F N } ( \mathrm { L N } ( \mathbf { X } _ { l - 1 } ^ { ' } ) ) , } \end{array}
62
+ $$
63
+
64
+ where LN denotes the LayerNorm [2] and an FFN consists of two FC layers with GELU [24] nonlinearity in between. Recent works on ViT have proposed to divide the blocks into several stages (typically 4 stages) to generate pyramid feature maps for dense prediction tasks. Furthermore, to reduce the computational cost on high-resolution feature maps in the early stages, the MSA in Eq. (4) has been replaced with efficient alternatives, such as SRA [51] and W-MSA [32].
65
+
66
+ Bottlenecks of LITv1. Recent studies have shown that the MSA layers in the early stages in a model still focus on local patterns [14]. With the same observation, LITv1 [36] removes all early MSAs (i.e., exclude Eq. (4) in each block) while applying standard MSAs at the later stages. This design principle has achieved better efficiency with competitive performance on ImageNet compared to PVT [51] and Swin [32]. However, LITv1 still has two main bottlenecks in speed: 1) Given a high-resolution image, the standard MSAs in the later stages still result in huge computational cost. 2) The fixed relative positional encoding [32] dramatically slows down the speed when dealing with different image resolutions. This is due to interpolating the fixed-size positional encoding for each different image resolution. In the next section, we describe a novel attention mechanism with zero padding positional encoding to comprehensively accelerate LITv1.
67
+
68
+ # 4 Method
69
+
70
+ # 4.1 HiLo Attention
71
+
72
+ We propose to separately process high/low frequencies in a feature map at an attention layer. We name the new attention mechanism as HiLo, which is depicted in Figure 1. Essentially, the low-frequency attention branch (Lo-Fi) is to capture the global dependencies of the input (image/features), which does not need a high-resolution feature map but requires global attention. On the other hand, the high-frequency attention branch (Hi-Fi) is to capture the fine detailed local dependency, which requires a high-resolution feature map but can be done via local attention. In the next, we describe the two attentions in detail.
73
+
74
+ High-frequency attention. Intuitively, as high frequencies encode local details of objects, it can be redundant and computationally expensive to apply global attention on a feature map. Therefore, we propose to design Hi-Fi to capture fine-grained high frequencies with local window self-attention (e.g., $2 \times 2$ windows), which saves significant computational complexity. Furthermore, we employ the simple non-overlapping window partition in Hi-Fi, which is more hardware-friendly compared to the time-consuming operations such as window shifting [32] or multi-scale window partition [60].
75
+
76
+ Low-frequency attention. Recent studies have shown that the global attention in MSA helps to capture low frequencies [38]. However, directly applying MSA to high-resolution feature maps requires huge computational cost. As averaging is a low-pass filter [49], Lo-Fi firstly applies average pooling to each window to get low-frequency signals in the input $\mathbf { X }$ . Next, the average-pooled feature maps are projected into keys $\mathbf { K } \in \mathbb { R } ^ { \bar { N } / s ^ { 2 } \times \bar { D } _ { h } }$ and values $\bar { \mathbf { V } } \in \mathbb { R } ^ { N / s ^ { 2 } \times D _ { h } }$ , where $s$ is the window size. The queries $\mathbf { Q }$ in Lo-Fi still comes from the original feature map X. We then apply the standard attention to capture the rich low-frequency information in feature maps. Note that due to the spatial reduction of $\mathbf { K }$ and $\mathbf { V }$ , Lo-Fi simultaneously reduces the complexity for both Eq. (1) and Eq. (2).
77
+
78
+ Head splitting. A naive solution for head assignment is to allocate both Hi-Fi and Lo-Fi the same number of heads as the standard MSA layer. However, doubling heads results in more computational cost. In order to achieve better efficiency, HiLo separates the same number of heads in an MSA into two groups with a split ratio $\alpha$ , where $( 1 - \alpha ) N _ { h }$ heads will be employed for Hi-Fi and the other $\alpha N _ { h }$ heads are used for Lo-Fi. By doing so, as each attention has a lower complexity than a standard MSA, the entire framework of HiLo guarantees a low complexity and ensures high throughput on GPUs. Moreover, another benefit of head splitting is that the learnable parameter $\mathbf { W } _ { o }$ can be decomposed into two smaller matrices, which helps to reduce model parameters. Finally, the output of HiLo is a
79
+
80
+ ![](images/c3dd3c5a05b524fb30cb83fbc377172c98779c266436e3c6dd34b30951bf6bec.jpg)
81
+ Figure 2: FLOPs comparison for Hi-Fi and Lo-Fi under different image resolutions and equal number of heads (Figures a and b). A larger window size helps HiLo achieve better efficiency on highresolution images (Figure c).
82
+
83
+ 81.8 3.90 concatenation of the outputs from each attention
84
+
85
+ $$
86
+ \mathrm { H i L o ( X ) } = \mathrm { [ H i \mathrm { - } F i ( X ) ; L o \mathrm { - } F i ( X ) ] , }
87
+ $$
88
+
89
+ 81.2where $[ \cdot ]$ denotes the concatenation operation.
90
+
91
+ Complexity Analysis. Without loss of generality, we assume Hi-Fi and Lo-Fi have an equal number of heads (i.e., $\alpha = 0 . 5$ ) and the feature map has equal width and height. Then, Hi-Fi and Lo-Fi have a computational cost of this result can be found $\scriptstyle { \frac { 7 } { 4 } } N D ^ { 2 } + s ^ { 2 } N D$ and ntar $( \textstyle { \frac { 3 } { 4 } } + \textstyle { \frac { 1 } { s ^ { 2 } } } ) N D ^ { 2 } + \textstyle { \frac { 1 } { s ^ { 2 } } } \bar { N ^ { 2 } D }$ , respectively. Derivation forigure 2-(a) and (b), under a small input image resolution and a small value of $s$ (e.g., $s = 2$ ), both Hi-Fi and Lo-Fi are comparably efficient. However, with a much higher resolution, Lo-Fi will result in a huge computational cost as it still has a quadratic complexity in terms of $N$ in Eq. (2), i.e., $\scriptstyle { \frac { 1 } { s ^ { 2 } } } N ^ { 2 } D$ . In this case, slightly increasing $s$ (e.g., $s = 4$ ) helps Lo-Fi achieve better efficiency while preserving the accuracy. Combining the two attentions together, a larger window size also helps the overall framework of HiLo to reduce more FLOPs on high-resolution images, as shown in Figure 2-(c). Thus, we suggest a practical guideline for adopting HiLo into existing frameworks: increasing the window size in order to get better efficiency on high-resolution images. We further show in Section 5.2 that this principle helps LITv2 achieve a better speed and accuracy trade-off on downstream tasks, e.g., dense object detection.
92
+
93
+ # 4.2 Positional Encoding
94
+
95
+ Positional encoding is essential to self-attention due to its permutation-invariant property. In LITv1, the later MSAs adopt the same relative positional encoding (RPE) scheme as Swin [32]. This approach has significantly improves Swin by $0 . 7 \%$ in Top-1 accuracy on ImageNet compared to using absolute positional encoding [32]. However, on dense prediction tasks, the fixed RPE has to be interpolated for different image resolutions, which dramatically slows down the training/inference speed of LITv1. As a recent study [27] has shown that position information can be implicitly learned from zero-padding in CNNs, we propose to adopt one layer of $3 \times 3$ depthwise convolutional layer with zero-padding in each FFN to replace the time-consuming RPE. Notably, due to the elimination of early MSAs, the early blocks in LITv1 only have FFNs left, which results in a tiny receptive field of $1 \times 1$ . To this end, we show in Section 5.4 that the $3 \times 3$ convolutional filters adopted in each FFN also improve LITv2 by simultaneously enlarging the receptive field in the early stages.
96
+
97
+ # 4.3 Model Architecture
98
+
99
+ LITv2 has three variants: LITv2-S, LITv2-M and LITv2-B, corresponding to the small, medium and base settings in LITv1, respectively. For a fair comparison, we keep the network width and depth as the same as LITv1. The overall modifications are simply in two steps: 1) Adding one layer of depthwise convolution with zero-padding in each FFN and removing all relative positional encodings in all MSAs. 2) Replacing all attention layers with the proposed HiLo attention. Detailed architecture configurations can be found in the supplementary material.
100
+
101
+ # 5 Experiment
102
+
103
+ In this section we conduct experiments to validate the effectiveness of the proposed LITv2. Following common practice [51, 32, 12, 60], we experiment LITv2 on three tasks, including image classification on ImageNet-1K [43], object detection and instance segmentation on COCO [31] and semantic segmentation on ADE20K [65].
104
+
105
+ Table 1: Image classification results on ImageNet-1K. By default, the FLOPs, throughput and memory consumption are measured based on the resolution $2 2 4 \times 2 2 4$ . We report the throughput and training/test time memory consumption with a batch size of 64. Throughput is tested on one NVIDIA RTX 3090 GPU and averaged over 30 runs. ResNet results are from "ResNet Stikes Back" [53]. “↑ 384” means a model is finetuned at the resolution $3 8 4 \times 3 8 4$ . “OOM” means “out-of-memory”.
106
+
107
+ <table><tr><td>Model</td><td>Param (M)</td><td>FLOPs (G)</td><td>Throughput (imgs/s)</td><td>Train Mem (GB)</td><td>Test Mem (GB)</td><td>Top-1 (%)</td></tr><tr><td>ResNet-50 [53]</td><td>26</td><td>4.1</td><td>1,279</td><td>7.9</td><td>2.8</td><td>80.4</td></tr><tr><td>ConvNext-Ti [33]</td><td>28</td><td>4.5</td><td>1,079</td><td>8.3</td><td>1.7</td><td>82.1</td></tr><tr><td>PVT-S [51]</td><td>25</td><td>3.8</td><td>1,007</td><td>6.8</td><td>1.3</td><td>79.8</td></tr><tr><td>Swin-Ti [32]</td><td>28</td><td>4.5</td><td>961</td><td>6.1</td><td>1.5</td><td>81.3</td></tr><tr><td>CvT-13 [54]</td><td>20</td><td>4.5</td><td>947</td><td>6.1</td><td>1.5</td><td>81.6</td></tr><tr><td>Focal-Tiny [60]</td><td>29</td><td>4.9</td><td>384</td><td>12.2</td><td>3.3</td><td>82.2</td></tr><tr><td>Twins-PCPVT-S [12]</td><td>24</td><td>3.8</td><td>998</td><td>6.8</td><td>1.2</td><td>81.2</td></tr><tr><td>LITv1-S [36]</td><td>27</td><td>4.1</td><td>1,298</td><td>5.8</td><td>1.2</td><td>81.5</td></tr><tr><td>LITv2-S</td><td>28</td><td>3.7</td><td>1,471</td><td>5.1</td><td>1.2</td><td>82.0</td></tr><tr><td>ResNet-101[53]</td><td>45</td><td>7.9</td><td>722</td><td>10.5</td><td>3.0</td><td>81.5</td></tr><tr><td>ConvNext-S [33]</td><td>50</td><td>8.7</td><td>639</td><td>12.3</td><td>1.8</td><td>83.1</td></tr><tr><td>PVT-M [51]</td><td>44</td><td>6.7</td><td>680</td><td>9.3</td><td>1.5</td><td>81.2</td></tr><tr><td>Twins-SVT-B[12]</td><td>56</td><td>8.3</td><td>621</td><td>9.8</td><td>1.9</td><td>83.2</td></tr><tr><td>Swin-S [32]</td><td>50</td><td>8.7</td><td>582</td><td>9.7</td><td>1.7</td><td>83.0</td></tr><tr><td>LITv1-M [36]</td><td>48</td><td>8.6</td><td>638</td><td>12.0</td><td>1.4</td><td>83.0</td></tr><tr><td>LITv2-M</td><td>49</td><td>7.5</td><td>812</td><td>8.8</td><td>1.4</td><td>83.3</td></tr><tr><td>ResNet-152 [53]</td><td>60</td><td>11.6</td><td>512</td><td>13.4</td><td>2.9</td><td>82.0</td></tr><tr><td>ConvNext-B [33]</td><td>89</td><td>15.4</td><td>469</td><td>16.9</td><td>2.9</td><td>83.8</td></tr><tr><td>Twins-SVT-L [12]</td><td>99</td><td>14.8</td><td>440</td><td>13.7</td><td>3.1</td><td>83.7</td></tr><tr><td>Swin-B [32]</td><td>88</td><td>15.4</td><td>386</td><td>13.4</td><td>2.4</td><td>83.3</td></tr><tr><td>LITv1-B [36]</td><td>86</td><td>15.0</td><td>444</td><td>16.4</td><td>2.1</td><td>83.4</td></tr><tr><td>LITv2-B</td><td>87</td><td>13.2</td><td>602</td><td>12.2</td><td>2.1</td><td>83.6</td></tr><tr><td>DeiT-B↑ 384 [45]</td><td>86</td><td>55.4</td><td>159</td><td>39.9</td><td>2.5</td><td>83.1</td></tr><tr><td>Swin-B↑ 384 [32]</td><td>88</td><td>47.1</td><td>142</td><td>OOM</td><td>6.1</td><td>84.5</td></tr><tr><td>LITv2-B↑ 384</td><td>87</td><td>39.7</td><td>198</td><td>35.8</td><td>4.6</td><td>84.7</td></tr></table>
108
+
109
+ # 5.1 Image Classification on ImageNet-1K
110
+
111
+ We conduct image classification experiments on ImageNet-1K [43], a large-scale image dataset which contains ${ \sim } 1 . 2 \mathbf { M }$ training images and 50K validation images from 1K categories. We measure the model performance by Top-1 accuracy. Furthermore, we report the FLOPs, throughput, as well as training/test memory consumption on GPUs. We compare with two CNN-based models [53, 33] and several representative SoTA ViTs [51, 32, 54, 60, 12]. Note that this paper does not consider mobile-level architectures [8, 35]. Instead, we focus on models with the similar model size. Besides, we are also not directly comparable with NAS-based methods [3, 5] as LITv2 is manually designed.
112
+
113
+ Implementation details. All models are trained for 300 epochs from scratch on 8 V100 GPUs. At training time, we set the total batch size as 1,024. The input images are resized and randomly cropped into $2 2 4 \times 2 2 4$ . The initial learning rate is set to $1 \times 1 0 ^ { - 5 }$ and the weight decay is set to $5 \times \mathrm { { 1 0 ^ { - 2 } } }$ . We use AdamW optimizer with a cosine decay learning rate scheduler. All training strategies including the data augmentation are same as in LITv1. For HiLo, the window size $s$ is set to 2. The split ratio $\alpha$ is set to 0.9, which is chosen from a simple grid search on ImageNet-1K. The depthwise convolutional layers in FFNs are set with a kernel size of $3 \times 3$ , stride of 1 and zero padding size of 1.
114
+
115
+ Table 2: Object detection and instance segmentation performance on the COCO val2017 split using the RetinaNet [30] and Mask R-CNN [22] framework. $\mathrm { A P } ^ { b }$ and $\mathrm { A P } ^ { m }$ denote the bounding box AP and mask AP, respectively. “\*” indicates the model adopts a local window size of 4 in HiLo.
116
+
117
+ <table><tr><td rowspan="2">Backbone</td><td colspan="4">RetinaNet</td><td colspan="5">MaskR-CNN</td></tr><tr><td>Params</td><td>FLOPs (G)</td><td>FPS</td><td>AP6</td><td>Params</td><td>FLOPs (G)</td><td>FPS</td><td>AP6</td><td>APm</td></tr><tr><td>ResNet-50 [23]</td><td>38M</td><td>239</td><td>18.5</td><td>36.3</td><td>44M</td><td>260</td><td>27.1</td><td>38.0</td><td>34.4</td></tr><tr><td>PVT-S [51]</td><td>34M</td><td>273</td><td>13.0</td><td>40.4</td><td>44M</td><td>292</td><td>16.2</td><td>40.4</td><td>37.8</td></tr><tr><td>Swin-T [32]</td><td>38M</td><td>251</td><td>17.0</td><td>41.5</td><td>48M</td><td>270</td><td>21.1</td><td>42.2</td><td>39.1</td></tr><tr><td>Twins-SVT-S[12]</td><td>34M</td><td>225</td><td>15.5</td><td>43.0</td><td>44M</td><td>244</td><td>20.4</td><td>43.4</td><td>40.3</td></tr><tr><td>LITv1-S [36]</td><td>39M</td><td>305</td><td>3.3</td><td>41.6</td><td>48M</td><td>324</td><td>3.2</td><td>42.9</td><td>39.6</td></tr><tr><td>LITv2-S</td><td>38M</td><td>242</td><td>18.7</td><td>44.0</td><td>47M</td><td>261</td><td>18.7</td><td>44.9</td><td>40.8</td></tr><tr><td>LITv2-S*</td><td>38M</td><td>230</td><td>20.4</td><td>43.7</td><td>47M</td><td>249</td><td>21.9</td><td>44.7</td><td>40.7</td></tr><tr><td>ResNet-101[23]</td><td>57M</td><td>315</td><td>15.2</td><td>38.5</td><td>63M</td><td>336</td><td>20.9</td><td>40.4</td><td>36.4</td></tr><tr><td>PVT-M[51]</td><td>54M</td><td>348</td><td>10.5</td><td>41.9</td><td>64M</td><td>367</td><td>10.8</td><td>42.0</td><td>39.0</td></tr><tr><td>Swin-S [32]</td><td>60M</td><td>343</td><td>13.3</td><td>44.5</td><td>69M</td><td>362</td><td>15.8</td><td>44.8</td><td>40.9</td></tr><tr><td>Twins-SVT-B[12]</td><td>67M</td><td>358</td><td>10.8</td><td>45.3</td><td>76M</td><td>377</td><td>12.7</td><td>45.2</td><td>41.5</td></tr><tr><td>LITv2-M</td><td>59M</td><td>348</td><td>12.2</td><td>46.0</td><td>68M</td><td>367</td><td>12.6</td><td>46.8</td><td>42.3</td></tr><tr><td>LITv2-M*</td><td>59M</td><td>312</td><td>14.8</td><td>45.8</td><td>68M</td><td>315</td><td>16.0</td><td>46.5</td><td>42.0</td></tr><tr><td>ResNeXt101-64x4d [58]</td><td>96M</td><td>473</td><td>10.3</td><td>41.0</td><td>102M</td><td>493</td><td>12.4</td><td>42.8</td><td>38.4</td></tr><tr><td>PVT-L [51]</td><td>71M</td><td>439</td><td>9.5</td><td>42.6</td><td>81M</td><td>457</td><td>8.3</td><td>42.9</td><td>39.5</td></tr><tr><td>Swin-B [32]</td><td>98M</td><td>488</td><td>11.0</td><td>44.7</td><td>107M</td><td>507</td><td>11.3</td><td>45.5</td><td>41.3</td></tr><tr><td>Twins-SVT-L [12]</td><td>111M</td><td>504</td><td>9.9</td><td>45.7</td><td>120M</td><td>524</td><td>10.1</td><td>45.9</td><td>41.6</td></tr><tr><td>LITv2-B</td><td>97M</td><td>481</td><td>9.5</td><td>46.7</td><td>106M</td><td>500</td><td>9.3</td><td>47.3</td><td>42.6</td></tr><tr><td>LITv2-B*</td><td>97M</td><td>430</td><td>11.8</td><td>46.3</td><td>106M</td><td>449</td><td>11.5</td><td>46.8</td><td>42.3</td></tr></table>
118
+
119
+ Results. In Table 1, we report the experiment results on ImageNet-1K. First, compared to LITv1 baselines, LITv2 achieves consistent improvement on Top-1 accuracy while using less FLOPs. Moreover, benefit from HiLo, LITv2 achieves faster throughput and significant training time memory reduction (e.g., $1 3 \%$ , $2 7 \%$ , $3 6 \%$ inference speedup for the small, medium and base settings, respectively) compared to LITv1. Second, compared to CNNs, LITv2 models outperform all counterparts of ResNet and ConvNext in terms of FLOPs, throughput and memory consumption while achieving comparable performance. Last, compared to SoTA ViTs, LITv2 surpasses many models in terms of throughput and memory consumption with competitive performance. For example, under the similar amount of FLOPs, LITv2-S achieves faster inference speed than PVT-S and Twins-PCPVT-S with better performance. Although Focal-Tiny achieves better Top-1 accuracy than LITv2-S, it runs much slower (i.e., 384 vs. 1,471 images/s) and requires a large amount of memory to train. Besides, when finetuning on a higher resolution, LITv2-B outperforms both DeiT-B and Swin-B with a faster throughput and lower complexity.
120
+
121
+ # 5.2 Object Detection and Instance Segmentation on COCO
122
+
123
+ In this section, we conduct experiments on COCO 2017, a common benchmark for object detection and instance segmentation which contains ${ \sim } 1 1 8 \mathrm { K }$ images for the training set and ${ \sim } 5 \mathrm { K }$ images for the validation set. Following common practice [12, 51], we experiment with two detection frameworks: RetinaNet [30] and Mask R-CNN [22]. We measure model performance by Average Precision (AP).
124
+
125
+ Implementation details. All backbones are initialized with pretrained weights on ImageNet-1K. We train each model on 8 GPUs with $1 \times$ schedule (12 epochs) and a total batch size of 16. For a fair comparison, we adopt the same training strategy and hyperparameter settings as in LITv1 [36]. Note that we pretrain LITv2 with a local window size of 2 and $\alpha = 0 . 9$ on ImageNet-1K. Under the same $\alpha$ , a larger window size helps to achieve lower complexity and thus improves the speed at high resolution, as explained in Section 4.1. In this case, we also train models with a slightly larger window size of $s = 4$ for better efficiency, which we denote with “\*”. By default, FLOPs is evaluated based on the input resolution of $1 2 8 0 \times 8 0 0$ . FPS is measured on one RTX 3090 GPU based on the mmdetection [4] framework.
126
+
127
+ Results. In Table 2, we report the experimental results on COCO. In general, LITv2 outperforms LITv1 by a large margin in almost all metrics. Besides, our LITv2 significantly surpasses ResNet in terms of AP, though it runs slightly slower in some cases. More importantly, our LITv2 beats all the compared SoTA ViTs, achieving the best AP with compelling fast inference speed. Furthermore, by adopting a larger window size (i.e., $s = 4$ ), LITv2 achieves better efficiency with a slightly performance drop.
128
+
129
+ ![](images/e1c23fc80b9d93d228356c59d71a9cb8f9c3744fe4adfed45474b49f5b975b11.jpg)
130
+ Figure 3: Comparison with other attention mechanisms based on LITv2-S. We report the FLOPs, throughput, and training/test time memory consumption. Evaluations are based on a batch size of 64 on one RTX 3090 GPU. The black cross symbol means “out-of-memory”.
131
+
132
+ # 5.3 Semantic Segmentation on ADE20K
133
+
134
+ In this section, we evaluate LITv2 on the semantic segmentation task. We conduct experiments on ADE20K [65], a widely adopted dataset for semantic segmentation which has $\sim 2 0 \mathrm { K }$ training images, ${ \sim } 2 \mathbf { K }$ validation images and ${ \sim } 3 \mathrm { K }$ test images. Following prior works, we adopt the framework of Semantic FPN [29] and measure the model performance by mIoU. We train each model on 8 GPUs with a total batch size of 16 with 80K iterations. All backbones are initialized with pretrained weights on ImageNet1K. The stochastic depth for the small, medium and base models of LITv2 are 0.2, 0.2 and 0.3, respectively. All other training strategies are the same as in LITv1 [36].
135
+
136
+ Results. In Table 3, we compare LITv2 with ResNet and representative ViTs on ADE20K. In general, LITv2 achieves fast speed while outperforming many SoTA models. For example, our LITv2-S, LITv2-M and LITv2-B surpass SwinTi, Swin-S and Swin-B by $2 . 8 \%$ , $0 . 5 \%$ and $1 . 2 \%$ in mIoU with higher FPS, respectively.
137
+
138
+ Table 4: Performance comparisons with other efficient attention mechanisms in ViTs based on LITv2-S. We report the Top-1 accuracy on ImageNet-1K and mIoU on ADE20K.
139
+ Table 3: Semantic segmentation performance of different backbones on the ADE20K validation set. FLOPs is evaluated based on the image resolution of $5 1 2 \times 5 1 2$ .
140
+
141
+ <table><tr><td>Backbone</td><td>Params (M)</td><td>FLOPs (G)</td><td>FPS</td><td>mIoU (%)</td></tr><tr><td rowspan="3">ResNet-50[23] PVT-S [51] Swin-Ti[32] Twins-SVT-S [12] LITv1-S [36]</td><td>29</td><td>45</td><td>45.4 38.7</td><td>36.7 39.8</td></tr><tr><td>28 32</td><td>40 46</td><td>39.6</td><td>41.5</td></tr><tr><td>28 32</td><td>37 46</td><td>34.5</td><td>43.2</td></tr><tr><td rowspan="3">LITv2-S ResNet-101[23] PVT-M [51] Swin-S [32]</td><td>31</td><td>41</td><td>18.1 42.6</td><td>41.7 44.3</td></tr><tr><td>48 48</td><td>66 55</td><td>36.7 29.7</td><td>38.8 41.6</td></tr><tr><td>53</td><td>70</td><td></td><td></td></tr><tr><td rowspan="3">Twins-SVT-B[12] LITv2-M</td><td></td><td></td><td>24.4</td><td>45.2</td></tr><tr><td>60</td><td>67</td><td>28.0</td><td>45.3</td></tr><tr><td>52</td><td>63</td><td>28.5</td><td>45.7</td></tr><tr><td rowspan="3">PVT-L [51] Swin-B[32] Twins-SVT-L [12]</td><td>65</td><td>71</td><td>20.5</td><td>42.1</td></tr><tr><td>107</td><td>107</td><td>25.5</td><td>46.0</td></tr><tr><td>104</td><td>102</td><td>25.9</td><td>46.7</td></tr><tr><td>LITv2-B</td><td>90</td><td>93</td><td>27.5</td><td>47.2</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr></table>
142
+
143
+ # 5.4 Ablation Study
144
+
145
+ In this section, we provide ablation studies for LITv2, including the comparison with other efficient attention variants, the effect of $\alpha$ in HiLo, as well as the effect of architecture modifications. By default, the throughput and memory consumption are measured on one RTX 3090 GPU with a batch size of 64 under the resolution of $2 2 4 \times 2 2 4$ .
146
+
147
+ Comparing HiLo with other attention mechanisms. Based on LITv2-S, we compare the performance of HiLo with other efficient attention mechanisms on ImageNet-1K, including spatial reduction attention (SRA) in PVT [51], shifted-window based attention (W-MSA) in Swin [32] and alternated local and global attention (T-MSA) in Twins [12]. In our implementation, we directly replace HiLo with each compared method. The results are reported in Table 4. In general, HiLo reduces more FLOPs while achieving better performance and faster speed than the compared methods. Furthermore, in Figure 3, we provide comprehensive benchmarks for more attention mechanisms based on different image resolutions, including Focal [60], QuadTree [44] and Performer [11]. Suffering from weak parallelizability, they are even slower than that of using standard MSAs on GPUs. Compared to them, HiLo achieves competitive results in terms of the FLOPs, throughput and memory consumption. Moreover, we conduct experiments based on ADE20K and Semantic FPN and show that HiLo achieves more performance gain than other attention mechanisms on the downstream dense prediction task.
148
+
149
+ ![](images/cbb1d473d79c8154b87f092117e77eb635c96c219d6956f092558d34b04d2fe6.jpg)
150
+ Figure 4: Effect of $\alpha$ based on LITv2-S.
151
+
152
+ Table 5: Effect of architecture modifications based on LITv1-S. “ConvFNN” means we add one layer of $3 \times 3$ depthwise convolutional layer into each FFN. “RPE” refers to relative positional encoding [32].
153
+
154
+ <table><tr><td rowspan="2">Name</td><td colspan="2">ImageNet-1K</td><td colspan="2">COCO (RetinaNet)</td></tr><tr><td>FLOPs Mem (G) (GB)</td><td>Top-1 (%)</td><td>FLOPs FPS (G)</td><td>AP</td></tr><tr><td>LITv1-S [36]</td><td>4.1 5.8</td><td>81.5</td><td>305 3.3</td><td>41.6</td></tr><tr><td>+ ConvFFN</td><td>4.1 6.5</td><td>82.5</td><td>306 3.1</td><td>45.1</td></tr><tr><td>+ Remove RPE</td><td>4.1 6.5</td><td>82.3</td><td>306 13.3</td><td>44.7</td></tr><tr><td>+ HiLo</td><td>3.7 5.1</td><td>82.0</td><td>224 18.7</td><td>44.0</td></tr></table>
155
+
156
+ ![](images/5daaae6e60488795ecfa600882462a6338d3c311c84c74c105beee391c097eea.jpg)
157
+ Figure 5: Frequency magnitude $( 1 4 \times 1 4 )$ from 8 output channels of Hi-Fi and Lo-Fi in LITv2-B. The magnitude is averaged over 100 samples. The lighter the color, the larger the magnitude. A pixel that is closer to the centre means a lower frequency. Visualization code can be found in the supplementary material.
158
+
159
+ Effect of $\alpha$ . As shown in Figure 4, since the complexity of Lo-Fi is lower than Hi-Fi under the resolution of $2 2 4 \times 2 2 4$ and the window size of 2, a larger $\alpha$ helps to reduce more FLOPs as we allocate more heads to Lo-Fi. Moreover, we found HiLo performs badly with $\alpha = 0$ , in which case only the Hi-Fi is left and HiLo only focuses on high frequencies. We speculate that low frequencies play an important role in self-attention. For other values of $\alpha$ , we find the performance difference is around $0 . 2 \%$ , where $\alpha = 0 . 9$ achieves the best performance. However, it is worth noting that although the pure Lo-Fi branch $( \alpha = 1 . 0$ ) can achieve competitive results on ImageNet-1K, high-frequency signals play an important role in capturing fine object details, which is particularly important for dense prediction tasks such as semantic segmentation. For example, with $\alpha = 0 . 9$ , LITv2-S based Semantic FPN achieves more performance gain $( + 0 . 6 \% )$ than that of using $\alpha = 1 . 0 \ : ( 4 3 . 7 \% )$ .
160
+
161
+ Effect of architecture modifications. Based on LITv2-S, we explore the effect of architecture modifications. As shown in Table 5, benefit from the enlarged receptive field in the early stages, the adoption of depthwise convolutions improves the performance on both ImageNet and COCO. Next, by removing the relative positional encoding, we significantly improve FPS on dense prediction tasks with a slightly performance drop on both datasets. Also note that since depthwise convolutions have encoded positional information by zero paddings [27], the elimination of RPE does not result in a significant performance drop compared to prior works [32]. Finally, benefit from HiLo, we achieve more gains in model efficiency on both ImageNet and COCO.
162
+
163
+ Spectrum analysis of HiLo. In Figure 5, we visualize the magnitude of frequency component [42] by applying Fast Fourier Transform (FFT) to the output feature maps from Hi-Fi and Lo-Fi attentions, respectively. The visualisation indicates that Hi-Fi captures more high frequencies and Lo-Fi mainly focuses on low frequencies. This strongly aligns with our aim of disentangling high and low frequencies in feature maps at a single attention layer.
164
+
165
+ Table 6: Speed and performance comparisons between LITv2-S and other recent ViTs on different GPUs. All throughput results are averaged over 30 runs with a total batch size of 64 and image resolution of $2 2 4 \times 2 2 4$ on one GPU card. We also report the Top-1 accuracy on ImageNet-1K.
166
+
167
+ <table><tr><td>Model</td><td>Params (M)</td><td>FLOPs (G)</td><td>A100</td><td>V100</td><td>RTX 6000</td><td>RTX 3090</td><td>Top-1 (%)</td></tr><tr><td>ResNet-50 [53]</td><td>26</td><td>4.1</td><td>1,424</td><td>1,123</td><td>877</td><td>1,279</td><td>80.4</td></tr><tr><td>PVT-S [51]</td><td>25</td><td>3.8</td><td>1,460</td><td>798</td><td>548</td><td>1,007</td><td>79.8</td></tr><tr><td>Twins-PCPVT-S[12]</td><td>24</td><td>3.8</td><td>1,455</td><td>792</td><td>529</td><td>998</td><td>81.2</td></tr><tr><td>Swin-Ti [32]</td><td>28</td><td>4.5</td><td>1,564</td><td>1,039</td><td>710</td><td>961</td><td>81.3</td></tr><tr><td>TNT-S [21]</td><td>24</td><td>5.2</td><td>802</td><td>431</td><td>298</td><td>534</td><td>81.3</td></tr><tr><td>CvT-13 [54]</td><td>20</td><td>4.5</td><td>1,595</td><td>716</td><td>379</td><td>947</td><td>81.6</td></tr><tr><td>CoAtNet-0 [15]</td><td>25</td><td>4.2</td><td>1,538</td><td>962</td><td>643</td><td>1,151</td><td>81.6</td></tr><tr><td>CaiT-XS24 [46]</td><td>27</td><td>5.4</td><td>991</td><td>484</td><td>299</td><td>623</td><td>81.8</td></tr><tr><td>PVTv2-B2 [52]</td><td>25</td><td>4.0</td><td>1,175</td><td>670</td><td>451</td><td>854</td><td>82.0</td></tr><tr><td>XCiT-S12[1]</td><td>26</td><td>4.8</td><td>1,727</td><td>761</td><td>504</td><td>1,068</td><td>82.0</td></tr><tr><td>ConvNext-Ti [33]</td><td>28</td><td>4.5</td><td>1,654</td><td>762</td><td>571</td><td>1,079</td><td>82.1</td></tr><tr><td>Focal-Tiny [60]</td><td>29</td><td>4.9</td><td>471</td><td>372</td><td>261</td><td>384</td><td>82.2</td></tr><tr><td>LITv2-S</td><td>28</td><td>3.7</td><td>1,874</td><td>1,304</td><td>928</td><td>1,471</td><td>82.0</td></tr></table>
168
+
169
+ ![](images/c167131df68793aafbb163d5e125013626b52aa2596fd33f47cb38482ef2660f.jpg)
170
+ Intel® Core i9-10900X CPU @ 3.70GHz
171
+ NVIDIA GeForce RTX 3090
172
+ Figure 6: Throughput comparisons with more attention mechanisms on CPUs and GPUs based on a single attention layer and $1 4 \times 1 4$ feature maps.
173
+
174
+ Speed and performance comparisons with more ViTs on different GPUs. We compare the inference speed with more models and on more types of GPUs. Table 6 reports the results. It shows that LITv2-S still achieves consistent faster throughput (images/s) than many ViTs on NVIDIA A100, Tesla V100, RTX 6000, and RTX 3090. It is also worth noting that under similar performance $( 8 2 . 0 \% )$ , LITv2-S is $2 . 1 \times$ faster than PVTv2-B2 [52], $1 . 7 \times$ faster than XCiT-S12 [1] and ConvNext-Ti [33], and $3 . 5 \times$ faster than Focal-Tiny [60] on V100, which is another common GPU version for speed test in previous works [32, 45, 33, 64].
175
+
176
+ Throughput comparisons with more attention mechanisms on CPUs and GPUs. In Figure 6, we show that HiLo is consistently faster than many attention mechanisms [51, 32, 1, 50, 11, 17, 55, 60, 41, 44, 20, 18] on both CPUs and GPUs. In particular, under CPU testing, HiLo is $1 . 4 \times$ faster than SRA [51], $1 . 6 \times$ faster than local window attention [32] and $1 7 . 4 \times$ faster than VAN [20]. Detailed benchmark configurations can be found in the supplementary material.
177
+
178
+ # 6 Conclusion and Future Work
179
+
180
+ In this paper, we have introduced LITv2, a novel efficient vision Transformer backbone with fast speed on GPUs and outperforms most SoTA models on ImageNet and downstream tasks. We have also presented HiLo attention, the core of LITv2 which helps to achieve better efficiency especially on high-resolution images. With competitive performance, HiLo achieves great advantage over the existing attention mechanisms across FLOPs, throughput and memory consumption. Future work may include incorporating convolutional stem [57] and overlapping patch embedding [52] for better performance, or extending HiLo on more tasks such as speech recognition and video processing.
181
+
182
+ Limitations and societal impact. HiLo adopts a head splitting ratio to assign different numbers of heads into Hi-Fi and Lo-Fi. In our experiments, this ratio is determined by a grid search on ImageNet (i.e., $\alpha = 0 . 9$ ). However, different tasks may have different importance on high and low frequencies. Thus, the optimal value of $\alpha$ is task-specific and needs to be set manually. Besides, our work potentially brings some negative societal impacts, such as the huge energy consumption and carbon emissions from large-scale training on GPU clusters.
183
+
184
+ # References
185
+
186
+ [1] A. Ali, H. Touvron, M. Caron, P. Bojanowski, M. Douze, A. Joulin, I. Laptev, N. Neverova, G. Synnaeve, J. Verbeek, and H. Jégou. Xcit: Cross-covariance image transformers. In NIPS, pages 20014–20027, 2021.
187
+ [2] J. Ba, J. Kiros, and G. E. Hinton. Layer normalization. ArXiv, abs/1607.06450, 2016.
188
+ [3] B. Chen, P. Li, C. Li, B. Li, L. Bai, C. Lin, M. Sun, J. Yan, and W. Ouyang. Glit: Neural architecture search for global and local image transformer. In ICCV, 2021.
189
+ [4] K. Chen, J. Wang, J. Pang, Y. Cao, Y. Xiong, X. Li, S. Sun, W. Feng, Z. Liu, J. Xu, Z. Zhang, D. Cheng, C. Zhu, T. Cheng, Q. Zhao, B. Li, X. Lu, R. Zhu, Y. Wu, J. Dai, J. Wang, J. Shi, W. Ouyang, C. C. Loy, and D. Lin. MMDetection: Open mmlab detection toolbox and benchmark. arXiv preprint arXiv:1906.07155, 2019.
190
+ [5] M. Chen, H. Peng, J. Fu, and H. Ling. Autoformer: Searching transformers for visual recognition. In ICCV, pages 12250–12260, 2021.
191
+ [6] Q. Chen, Q. Wu, J. Wang, Q. Hu, T. Hu, E. Ding, J. Cheng, and J. Wang. Mixformer: Mixing features across windows and dimensions. In CVPR, pages 5239–5249, 2022.
192
+ [7] W. Chen, J. T. Wilson, S. Tyree, K. Q. Weinberger, and Y. Chen. Compressing convolutional neural networks in the frequency domain. In KDD, pages 1475–1484. ACM, 2016.
193
+ [8] Y. Chen, X. Dai, D. Chen, M. Liu, X. Dong, L. Yuan, and Z. Liu. Mobile-former: Bridging mobilenet and transformer. In CVPR, pages 5260–5269, 2022.
194
+ [9] Y. Chen, H. Fan, B. Xu, Z. Yan, Y. Kalantidis, M. Rohrbach, S. Yan, and J. Feng. Drop an octave: Reducing spatial redundancy in convolutional neural networks with octave convolution. In ICCV, pages 3434–3443. IEEE, 2019.
195
+ [10] R. Child, S. Gray, A. Radford, and I. Sutskever. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019.
196
+ [11] K. M. Choromanski, V. Likhosherstov, D. Dohan, X. Song, A. Gane, T. Sarlós, P. Hawkins, J. Q. Davis, A. Mohiuddin, L. Kaiser, D. B. Belanger, L. J. Colwell, and A. Weller. Rethinking attention with performers. In ICLR, 2021.
197
+ [12] X. Chu, Z. Tian, Y. Wang, B. Zhang, H. Ren, X. Wei, H. Xia, and C. Shen. Twins: Revisiting the design of spatial attention in vision transformers. In NeurIPS, pages 9355–9366, 2021.
198
+ [13] J. W. Cooley, P. A. W. Lewis, and P. D. Welch. The fast fourier transform and its applications. IEEE Transactions on Education, 12(1):27–34, 1969.
199
+ [14] J. Cordonnier, A. Loukas, and M. Jaggi. On the relationship between self-attention and convolutional layers. In ICLR, 2020.
200
+ [15] Z. Dai, H. Liu, Q. V. Le, and M. Tan. Coatnet: Marrying convolution and attention for all data sizes. In NeurIPS, pages 3965–3977, 2021.
201
+ [16] G. Deng and L. Cahill. An adaptive gaussian filter for noise reduction and edge detection. In 1993 IEEE Conference Record Nuclear Science Symposium and Medical Imaging Conference, pages 1615–1619 vol.3, 1993.
202
+ [17] X. Dong, J. Bao, D. Chen, W. Zhang, N. Yu, L. Yuan, D. Chen, and B. Guo. Cswin transformer: A general vision transformer backbone with cross-shaped windows. In CVPR, pages 12114–12124, 2022.
203
+ [18] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit, and N. Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. ICLR, 2021.
204
+ [19] M. Fritsche, S. Gu, and R. Timofte. Frequency separation for real-world super-resolution. ICCVW, Oct 2019.
205
+ [20] M.-H. Guo, C.-Z. Lu, Z.-N. Liu, M.-M. Cheng, and S.-M. Hu. Visual attention network. arXiv preprint arXiv:2202.09741, 2022.
206
+ [21] K. Han, A. Xiao, E. Wu, J. Guo, C. Xu, and Y. Wang. Transformer in transformer. In NeurIPS, pages 15908–15919, 2021.
207
+ [22] K. He, G. Gkioxari, P. Dollár, and R. B. Girshick. Mask R-CNN. In ICCV, pages 2980–2988, 2017.
208
+ [23] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In CVPR, pages 770–778, 2016.
209
+ [24] D. Hendrycks and K. Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
210
+ [25] J. Huang, D. Guan, A. Xiao, and S. Lu. Rda: Robust domain adaptation via fourier adversarial attacking. In ICCV, pages 8988–8999, 2021.
211
+ [26] Z. Huang, Y. Ben, G. Luo, P. Cheng, G. Yu, and B. Fu. Shuffle transformer: Rethinking spatial shuffle for vision transformer. arXiv preprint arXiv:2106.03650, 2021.
212
+ [27] M. A. Islam, S. Jia, and N. D. B. Bruce. How much position information do convolutional neural networks encode? In ICLR, 2020.
213
+ [28] A. Katharopoulos, A. Vyas, N. Pappas, and F. Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In ICML, pages 5156–5165. PMLR, 2020.
214
+ [29] A. Kirillov, R. B. Girshick, K. He, and P. Dollár. Panoptic feature pyramid networks. In CVPR, pages 6399–6408, 2019.
215
+ [30] T. Lin, P. Goyal, R. B. Girshick, K. He, and P. Dollár. Focal loss for dense object detection. In ICCV, pages 2999–3007, 2017.
216
+ [31] T. Lin, M. Maire, S. J. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick. Microsoft COCO: common objects in context. In D. J. Fleet, T. Pajdla, B. Schiele, and T. Tuytelaars, editors, ECCV, pages 740–755, 2014.
217
+ [32] Z. Liu, Y. Lin, Y. Cao, H. Hu, Y. Wei, Z. Zhang, S. Lin, and B. Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In ICCV, pages 9992–10002, 2021.
218
+ [33] Z. Liu, H. Mao, C.-Y. Wu, C. Feichtenhofer, T. Darrell, and S. Xie. A convnet for the 2020s. In CVPR, pages 11966–11976, 2022.
219
+ [34] N. Ma, X. Zhang, H.-T. Zheng, and J. Sun. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In ECCV, pages 116–131, 2018.
220
+ [35] S. Mehta and M. Rastegari. Mobilevit: Light-weight, general-purpose, and mobile-friendly vision transformer. In ICLR, 2022.
221
+ [36] Z. Pan, B. Zhuang, H. He, J. Liu, and J. Cai. Less is more: Pay less attention in vision transformers. In AAAI, pages 2035–2043, 2022.
222
+ [37] Z. Pan, B. Zhuang, J. Liu, H. He, and J. Cai. Scalable visual transformers with hierarchical pooling. In ICCV, pages 377–386, 2021.
223
+ [38] N. Park and S. Kim. How do vision transformers work? In ICLR, 2022.
224
+ [39] H. Peng, N. Pappas, D. Yogatama, R. Schwartz, N. A. Smith, and L. Kong. Random feature attention. In ICLR, 2021.
225
+ [40] J. W. Rae, A. Potapenko, S. M. Jayakumar, and T. P. Lillicrap. Compressive transformers for long-range sequence modelling. In ICLR, 2020.
226
+ [41] Y. Rao, W. Zhao, Y. Tang, J. Zhou, S.-L. Lim, and J. Lu. Hornet: Efficient high-order spatial interactions with recursive gated convolutions. In NeurIPS, 2022.
227
+ [42] Y. Rao, W. Zhao, Z. Zhu, J. Lu, and J. Zhou. Global filter networks for image classification. In NeurIPS, pages 980–993, 2021.
228
+ [43] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, et al. Imagenet large scale visual recognition challenge. IJCV, pages 211–252, 2015.
229
+ [44] S. Tang, J. Zhang, S. Zhu, and P. Tan. Quadtree attention for vision transformers. ICLR, 2022.
230
+ [45] H. Touvron, M. Cord, M. Douze, F. Massa, A. Sablayrolles, and H. Jégou. Training data-efficient image transformers & distillation through attention. In ICML, pages 10347–10357, 2021.
231
+ [46] H. Touvron, M. Cord, A. Sablayrolles, G. Synnaeve, and H. Jégou. Going deeper with image transformers. In ICCV, pages 32–42. IEEE, 2021.
232
+ [47] Z. Tu, H. Talebi, H. Zhang, F. Yang, P. Milanfar, A. Bovik, and Y. Li. Maxim: Multi-axis mlp for image processing. CVPR, pages 5759–5770, 2022.
233
+ [48] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin. Attention is all you need. In NeurIPS, pages 5998–6008, 2017.
234
+ [49] E. Voigtman and J. D. Winefordner. Low-pass filters for signal averaging. Review of Scientific Instruments, 57(5):957–966, 1986.
235
+ [50] S. Wang, B. Li, M. Khabsa, H. Fang, and H. Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020.
236
+ [51] W. Wang, E. Xie, X. Li, D.-P. Fan, K. Song, D. Liang, T. Lu, P. Luo, and L. Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. In ICCV, pages 548–558, 2021.
237
+ [52] W. Wang, E. Xie, X. Li, D.-P. Fan, K. Song, D. Liang, T. Lu, P. Luo, and L. Shao. Pvtv2: Improved baselines with pyramid vision transformer. Computational Visual Media, 8(3):1–10, 2022.
238
+ [53] R. Wightman, H. Touvron, and H. Jégou. Resnet strikes back: An improved training procedure in timm. CoRR, abs/2110.00476, 2021.
239
+ [54] H. Wu, B. Xiao, N. Codella, M. Liu, X. Dai, L. Yuan, and L. Zhang. Cvt: Introducing convolutions to vision transformers. In ICCV, pages 22–31, 2021.
240
+ [55] Z. Xia, X. Pan, S. Song, L. E. Li, and G. Huang. Vision transformer with deformable attention. In CVPR, pages 4794–4803, 2022.
241
+ [56] M. Xiao, S. Zheng, C. Liu, Y. Wang, D. He, G. Ke, J. Bian, Z. Lin, and T. Liu. Invertible image rescaling. In ECCV, pages 126–144, 2020.
242
+ [57] T. Xiao, M. Singh, E. Mintun, T. Darrell, P. Dollár, and R. B. Girshick. Early convolutions help transformers see better. In NeurIPS, pages 30392–30400, 2021.
243
+ [58] S. Xie, R. B. Girshick, P. Dollár, Z. Tu, and K. He. Aggregated residual transformations for deep neural networks. In CVPR, pages 5987–5995, 2017.
244
+ [59] K. Xu, M. Qin, F. Sun, Y. Wang, Y. Chen, and F. Ren. Learning in the frequency domain. In CVPR, pages 1737–1746. Computer Vision Foundation / IEEE, 2020.
245
+ [60] J. Yang, C. Li, P. Zhang, X. Dai, B. Xiao, L. Yuan, and J. Gao. Focal self-attention for local-global interactions in vision transformers. In NeurIPS, pages 30008–30022, 2021.
246
+ [61] K. Yuan, S. Guo, Z. Liu, A. Zhou, F. Yu, and W. Wu. Incorporating convolution designs into visual transformers. In ICCV, pages 559–568, 2021.
247
+ [62] L. Yuan, Y. Chen, T. Wang, W. Yu, Y. Shi, F. E. Tay, J. Feng, and S. Yan. Tokens-to-token vit: Training vision transformers from scratch on imagenet. In ICCV, pages 538–547, 2021.
248
+ [63] P. Zhang, X. Dai, J. Yang, B. Xiao, L. Yuan, L. Zhang, and J. Gao. Multi-scale vision longformer: A new vision transformer for high-resolution image encoding. In ICCV, pages 2978–2988, 2021.
249
+ [64] Q. Zhang, Y. Xu, J. Zhang, and D. Tao. Vsa: Learning varied-size window attention in vision transformers. ECCV, 2022.
250
+ [65] B. Zhou, H. Zhao, X. Puig, T. Xiao, S. Fidler, A. Barriuso, and A. Torralba. Semantic understanding of scenes through the ADE20K dataset. IJCV, pages 302–321, 2019.
251
+ [66] Y. Zhou, W. Deng, T. Tong, and Q. Gao. Guided frequency separation network for real-world superresolution. In CVPRW, pages 1722–1731, 2020.
252
+
253
+ # Checklist
254
+
255
+ 1. For all authors...
256
+
257
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
258
+ (b) Did you describe the limitations of your work? [Yes] See Section 6.
259
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 6.
260
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
261
+
262
+ 2. If you are including theoretical results...
263
+
264
+ (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]
265
+
266
+ 3. If you ran experiments...
267
+
268
+ (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] Code and pretrained models are included as a URL in the abstract.
269
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.
270
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We use the same random seed as in recent works for fair comparison.
271
+ (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.
272
+
273
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
274
+
275
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Section 5.
276
+ (b) Did you mention the license of the assets? [No] The license of the public datasets can be found in their websites.
277
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] Code and pretrained models are included as a URL in the abstract.
278
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] We use public datasets (e.g., ImageNet [43] and ADE20K [65]).
279
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] No such concerns as we are using widely adopted public datasets.
280
+
281
+ 5. If you used crowdsourcing or conducted research with human subjects...
282
+
283
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
284
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
285
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/RYTBAtyXqJ/RYTBAtyXqJ.md ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CARTOON EXPLANATIONS OF IMAGE CLASSIFIERS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We present CartoonX (Cartoon Explanation), a novel model-agnostic explanation method tailored towards image classifiers and based on the rate-distortion explanation (RDE) framework. Natural images are roughly piece-wise smooth signals—also called cartoon images—and tend to be sparse in the wavelet domain. CartoonX is the first explanation method to exploit this by requiring its explanations to be sparse in the wavelet domain, thus extracting the relevant piece-wise smooth part of an image instead of relevant pixel-sparse regions. We demonstrate experimentally that CartoonX is not only highly interpretable due to its piece-wise smooth nature but also particularly apt at explaining misclassifications.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Powerful machine learning models such as deep neural networks are inherently opaque, which has motivated numerous explanation methods over the last decade (see for example the survey by Das & Rad (2020)). A significant fraction of the research literature has focused on explaining image classifications due to both the practical relevance of computer vision tasks and the ease at which heatmaps can communicate explanatory information. Despite the great variety in methods and explanation philosophies, all current methods share the following characteristic: they operate in pixel space. Roughly speaking, existing explanation methods for image classifiers either allocate additive attribution scores to each pixel or optimize a deletion mask on the pixel coefficients to mark a relevant set of pixels. The result is typically a pixel-sparse and jittery explanation. We challenge the conventional approach to explain in pixel space by successfully applying the rate-distortion explanation (RDE) framework (Macdonald et al., 2019; Heiß et al., 2020) in the wavelet domain of images. Our novel explanation method, CartoonX, extracts the relevant piece-wise smooth part of an image (see Figure 1). Instead of demanding sparsity in pixel space, as in (Macdonald et al., 2019; Chang et al., 2019), CartoonX demands sparsity in the wavelet domain, which produces piece-wise smooth explanations (cartoon-like images). Our work makes the following contributions:
12
+
13
+ ![](images/dc24c4587f388205daecba23a270da795c248d00d7e21388c915cc977296fc88.jpg)
14
+ Dog classified as Egyptian cat
15
+
16
+ ![](images/7b8be6eda1c4fcf43ca641d589d627f2f43768ac5cd270644d7bf6bc47659f3e.jpg)
17
+ CartoonX of misclassification
18
+
19
+ Reformulation and reinterpretation of the RDE framework: We reformulate the RDE framework in a more general manner with enhanced flexibility in the input representation to accommodate complex interpretation queries such as “What is the piece-wise smooth part of the input signal that leads to its model decision?”. Thereby, we reinterpret RDE as a simplification of the input signal, which is interpretable to humans and adheres to a meaningful interpretation query. The simplification is achieved by demanding sparsity in a suitable representation system, which sparsely represents the class of explanations that are desirable for the interpretation query.
20
+
21
+ ![](images/151279dd372408cf29d741b90adc464dd546cc38901a0c7f5d08c3f7889b1f20.jpg)
22
+ Slam dunk classified as basketball
23
+
24
+ CartoonX, a novel explanation method tailored to image classifiers: CartoonX is the first explanation method to extract the relevant piece-wise smooth part of an image instead of relevant pixel sparse regions. This is achieved by demanding sparsity in the wavelet domain of images, where
25
+
26
+ ![](images/f1dc4810d3ca077a16c122ad81a791c1b7bed617df1470748dde8659528a1338.jpg)
27
+ Figure 1: Examples of CartoonX explanations.
28
+
29
+ sparsity translates into piece-wise smooth images. We demonstrate that
30
+ our piece-wise smooth explanations are more interpretable than jittery
31
+ pixel-sparse explanations and that they can reveal relevant piece-wise smooth patterns that are not easily visible with existing pixel-based methods. Surprisingly, we find that our method is particularly well-equipped to explain misclassifications, often showing “what the neural network actually saw” (see Figure 1).
32
+
33
+ # 2 RELATED WORK
34
+
35
+ The Rate-Distortion Explanation (RDE) framework was first introduced in (Macdonald et al., 2019), and extended in (Heiß et al., 2020), as a mathematically well-founded and intuitive explanation framework. RDEs are model-agnostic explanations and inspired by rate-distortion theory, which studies lossy-data compression. An explanation in RDE consists of a relatively sparse mask over the input features, highlighting the relevant set of features. The mask is optimized to produce low distortion in the model output after applying perturbations to the unselected features in the input while remaining relatively sparse. Heiß et al. (2020) also applied RDE to non-canonical input representations to explain model decisions in challenging domains such as audio classification (Engel et al., 2017) and radio-map estimation (Levie et al., 2021; 2020).
36
+
37
+ The explanation principle of optimizing a mask $s \in [ 0 , 1 ] ^ { n }$ was first proposed by Fong & Vedaldi (2017) who explained image classification decisions by considering one of the two “deletion games”: (1) optimizing for the smallest deletion mask that causes the class score to drop significantly or (2) optimizing for the largest deletion mask that has no significant effect on the class score. The original RDE approach (Macdonald et al., 2019) is based on the second deletion game.
38
+
39
+ Other explanation methods developed by the research community are typically either (1) gradientbased such as Smoothgrad (Smilkov et al., 2017), Integrated Gradients (Sundararajan et al., 2017), Image-Specific Class Saliency (Simonyan et al., 2014), and Guided Backpropagation (Springenberg et al., 2015), (2) surrogate models such as LIME (Ribeiro et al., 2016), (3) based on propagation of activations in neurons such as LRP (Bach et al., 2015; Shrikumar et al., 2017), and DeepLIFT (Shrikumar et al., 2017), (4) based on Shapely values from game-theory (Lundberg & Lee, 2017), (6) concept-based such as Concept Activation Vectors (Kim et al., 2018), or (7) based on generative causal explanations (O' Shaughnessy et al., 2020). Also related are methods that were developed to explain individual neurons such as in (Nguyen et al., 2016; Dhamdhere et al., 2019). To our knowledge, all existing explainability methods operate in pixel space and all methods looking for sparse explanations demand sparsity in pixel space (Macdonald et al., 2019; Fong & Vedaldi, 2017; Chang et al., 2019).
40
+
41
+ # 3 BACKGROUND: RATE-DISTORTION EXPLANATION FRAMEWORK
42
+
43
+ In this section, we review the rate-distortion explanation (RDE) framework, which was introduced by Macdonald et al. (2019) and later extended by Heiß et al. (2020) by applying RDE to noncanonical input representations. Suppose $\Phi : \mathbb { R } ^ { n } \mathbb { R } ^ { m }$ is a pre-trained model, e.g., a classifier (with $m$ class labels) or a regression model (with $m$ -dimensional output), where $n$ denotes the dimension of the model input. RDE produces an explanation for a model decision $\Phi ( x )$ with $x \in \mathbb { R } ^ { n }$ as a relatively sparse mask $s \in \{ 0 , 1 \}$ marking the relevant input features in $x$ . More precisely, RDE aims to solve the following optimization problem over a mask $s \in \{ 0 , 1 \} ^ { n }$ :
44
+
45
+ $$
46
+ \operatorname* { m i n } _ { s \in \{ 0 , 1 \} ^ { n } } \quad \operatorname { \mathbb { E } } _ { v \sim \mathcal { V } } \left[ d \Bigl ( \Phi ( x ) , \Phi ( x \odot s + ( 1 - s ) \odot v ) \Bigr ) \right] \quad \mathrm { s . t . } \quad \| s \| _ { 0 } \leq \ell ,
47
+ $$
48
+
49
+ where $\odot$ denotes the Hadamard product (element-wise multiplication), $d ( \Phi ( x ) , \cdot )$ is a measure of distortion (e.g. $d ( \Phi ( x ) , \cdot ) = \lVert \Phi ( { \bar { x } } ) - \cdot \rVert _ { 2 } )$ , $\nu$ is a distribution over input perturbations $v \in \mathbb { R } ^ { n }$ , and $\ell \in \{ 1 , . . . , n \}$ is a given sparsity level for the explanation mask $s$ . A solution $s ^ { * }$ to the optimization problem in (1) marks relatively few components in the model input $x$ that suffice to approximately retain the model output $\Phi ( x )$ . This approach is in the spirit of rate-distortion theory, which deals with lossy compression of data. Therefore, Macdonald et al. (2019) coined such explanations ratedistortion explanations (RDEs).
50
+
51
+ In practice, the optimization problem in (1) is relaxed to continuous masks $s \in [ 0 , 1 ]$ solving
52
+
53
+ $$
54
+ \operatorname* { m i n } _ { s \in \{ 0 , 1 \} ^ { n } } \quad \operatorname { \mathbb { E } } _ { v \sim \mathcal { V } } \left[ d \Bigl ( \Phi ( x ) , \Phi ( x \odot s + ( 1 - s ) \odot v ) \Bigr ) \right] + \lambda \left\| s \right\| _ { 1 } ,
55
+ $$
56
+
57
+ where $\lambda > 0$ determines the sparsity level of the mask. The relaxed optimization problem can be solved with stochastic gradient descent in $s \in [ 0 , 1 ]$ if $\Phi$ is differentiable—as is the case for deep neural networks. Macdonald et al. (2019) applied the RDE method as described above to image classifiers in the pixel domain of images, where each mask entry $s _ { i } \in [ 0 , 1 ]$ corresponds to the $i$ -th pixel values. We refer to this method as Pixel RDE throughout this work.
58
+
59
+ # 4 RDE REFORMULATED AND REINTERPRETED
60
+
61
+ Instead of applying RDE to the standard input representation $\boldsymbol { x } = [ x _ { 1 } \dots x _ { n } ] ^ { T }$ , we can apply RDE to a different representation of $x$ to answer a particular interpretation query. For example, consider a 1D-signal $x \in \mathbb { R } ^ { n }$ : if we ask “What is the smooth part in the signal $x$ that leads to the model decision $\Phi ( x ) ? ^ { , }$ , then we can apply RDE in the Fourier basis of $x$ . Since frequency-sparse signals are smooth, applying RDE in the Fourier basis of $x$ extracts the relevant smooth part of the signal. To accommodate such interpretation queries, we reformulate RDE in Section 4.1. Finally, based on the reformulation, we reinterpret RDE in Section 4.2. Later in Section 5, we use our reformulation and reinterpretation of RDE to derive and motivate CartoonX as a special case and novel explanation method tailored towards image classifiers.
62
+
63
+ # 4.1 GENERAL FORMULATION
64
+
65
+ An input signal $\boldsymbol { x } = [ x _ { 1 } , \dots , x _ { n } ] ^ { T }$ is represented in a basis $\{ b _ { 1 } , \ldots , b _ { n } \}$ as a linear combination $\textstyle \sum _ { i = 1 } ^ { n } h _ { i } b _ { i }$ with coefficients $[ h _ { i } ] _ { i = 1 } ^ { n }$ . As we argued above and demonstrate later on, some choices for a basis may be more suitable than others to explain a model decision $\Phi ( x )$ . Therefore, we define the RDE mask not only on the canonical input representation $[ x _ { i } ] _ { i = 1 } ^ { n }$ but also on a different representation $[ h _ { i } ] _ { i = 1 } ^ { n }$ with respect to a choice of basis $\{ b _ { 1 } , \ldots , b _ { n } \}$ . Examples of non-canonical choices for a basis include the Fourier basis and the wavelet basis. This work is centered around CartoonX, which applies RDE in the wavelet basis, i.e., a linear data representation since $x$ is represented as a linear combination of basis vectors. Nevertheless, there also exist other domains and interpretation queries where applying RDE to a non-linear data representation can make sense (see the interpretation query “Is phase or magnitude more important for an audio classifier?” in (Heiß et al., 2020)). Therefore, we formulate RDE in terms of a data representation function $\textstyle f : \prod _ { i = 1 } ^ { k } \mathbb { R } ^ { c } \to \mathbb { R } ^ { n }$ , $f ( h _ { 1 } , \ldots , h _ { k } ) = x .$ , which does notlinear case and o be linear, we have $c$ ls in the, where e imare ortantfixed $c = 1$ $\begin{array} { r } { f ( h _ { 1 } , \ldots , h _ { k } ) = \sum _ { i = 1 } ^ { k } h _ { i } b _ { i } } \end{array}$ $\{ b _ { i } , \ldots , b _ { k } \} \subset \mathbb { R } ^ { n }$ $k$ $c > 1$
66
+ channels at once, e.g., all color channels of an image, to reduce the number of entries in the mask that will operate on $[ h _ { i } ] _ { i = 1 } ^ { k }$ . In the following, we introduce the important definitions of obfuscations, expected distortion, the RDE mask, and $R D E ' s \ell _ { 1 }$ -relaxation, which generalize the RDE framework of (Macdonald et al., 2019) to abstract input representations.
67
+
68
+ # 4.1.1 DEFINITIONS
69
+
70
+ The first two key concepts in RDE are obfuscations and expected distortion, which are defined below.
71
+
72
+ Definition 1 (Obfuscations and expected distortion) Let $\Phi : \mathbb { R } ^ { n } \mathbb { R } ^ { m }$ be a model and $x \in \mathbb { R } ^ { n }$ a data point with a data representation $x = f ( h _ { 1 } , . . . , h _ { k } )$ as discussed above. For every mask $s \in [ 0 , 1 ] ^ { k }$ , let $\gamma _ { s }$ be a probability distribution over $\textstyle \prod _ { i = 1 } ^ { k } \mathbb { R } ^ { c }$ . Then the obfuscation of $x$ with respect to s and $\gamma _ { s }$ is defined as the random vector $y : = { f ( s \odot h + ( 1 - s ) \odot v ) }$ , where $v \sim \mathcal { V } _ { s }$ , $( s \odot h ) _ { i } = s _ { i } h _ { i } \in \mathbb { R } ^ { c }$ and $( ( 1 - s ) \odot v ) _ { i } = ( 1 - s _ { i } ) v _ { i } \in \mathbb R ^ { c }$ , for $i \in \{ 1 , \ldots , k \}$ . A choice for the distribution $\gamma _ { s }$ is called obfuscation strategy. Furthermore, the expected distortion of $x$ with respect to the mask s and the perturbation distribution $\gamma _ { s }$ is defined as
73
+
74
+ $$
75
+ D ( x , s , \mathcal { V } _ { s } , \Phi ) : = \underset { v \sim \mathcal { V } _ { s } } { \mathbb { E } } \left[ d \Big ( \Phi ( x ) , \Phi ( y ) \Big ) \right] ,
76
+ $$
77
+
78
+ where $d : \mathbb { R } ^ { m } \times \mathbb { R } ^ { m } \to \mathbb { R } _ { + }$ is a measure of distortion between two model outputs.
79
+
80
+ In the RDE framework, the explanation is given by a mask that minimizes distortion while remaining relatively sparse. The rate-distortion explanation mask is defined as follows.
81
+
82
+ Definition 2 (The RDE mask) In the setting of Definition $I$ we define the RDE mask as a solution $s ^ { * } ( \ell )$ to the minimization problem
83
+
84
+ $$
85
+ \operatorname* { m i n } _ { s \in \{ 0 , 1 \} ^ { k } } \quad D ( x , s , \mathcal { V } _ { s } , \Phi ) \quad s . t . \quad \| s \| _ { 0 } \leq \ell ,
86
+ $$
87
+
88
+ where $\ell \in \{ 1 , \ldots , k \}$ is the desired level of sparsity.
89
+
90
+ Geometrically, the RDE mask $s$ is associated with a particular subspace. The complement mask $( 1 - s )$ can be seen as selecting a large stable subspace of $\Phi$ , with each point representing a possible perturbation in unselected coefficients in $h$ . The RDE mask minimizes the expected distortion along its associated subspace, which requires non-local information of $\Phi$ . We illustrate this geometric view of RDE in Figure 2 with a toy example for a hypothetical classifier $\Phi : \mathbb { R } ^ { 2 } \mathbb { R } ^ { \bar { m } }$ and two distinct input representations: (1) Euclidean coordinates, i.e., $f$ is the identity in $x = f ( h )$ , and (2) polar coordinates, i.e. $f ( h ) = ( h _ { 2 } \cos h _ { 1 } , h _ { 2 } \sin h _ { 1 } ) = x$ . In the example, we assume $\gamma _ { s }$ to be a uniform distribution on $[ - 1 , 1 ] ^ { 2 }$ in the Euclidean representation and a uniform distribution on $[ - \pi , \pi ] \times [ 0 , 1 ]$ in the polar representation. The expected distortion associated with the masks $s = ( 1 , 0 )$ and $s = ( 0 , 1 )$ is given by the red and green shaded area, respectively. The RDE mask aims for low expected distortion, and hence, in polar coordinates, the RDE mask would be the green subspace, i.e., $s = ( 0 , 1 )$ . On the other hand, in Euclidean coordinates, neither $s = ( 1 , 0 )$ nor $s = ( 0 , 1 )$ produces a particularly low expected distortion, making the Euclidean explanation less meaningful than the polar explanation. The example illustrates why certain input representations can yield more meaningful explanatory insight for a given classifier than others—an insight that underpins our novel CartoonX method. Moreover, the plot in polar coordinates illustrates why the RDE mask cannot be simply chosen with local distortion information, e.g., with the lowest eigenvalue of the Hessian of $\bar { h } \mathbin { \stackrel { \cdot } { \mapsto } } d ( \Phi ( x ) , \Phi ( f ( h ) ) )$ : the lowest eigenvalue in polar coordinates belongs to the red subspace and does not see the large distortion on the tails.
91
+
92
+ ![](images/479683e2b0840f5f992b0532f0d8810568debf14e35b168351c2027f9e57a0b2.jpg)
93
+ Figure 2: The RDE mask can find low expected distortion in polar coordinates but not in Euclidean coordinates. Therefore, in this example, polar coordinates are more appropriate to explain $\Phi ( x )$ , and RDE would determine that the angle $\varphi$ , not the magnitude $r$ , is relevant for $\Phi ( x )$ .
94
+
95
+ As was shown by Macdonald et al. (2019), the RDE mask from Definition 2 cannot be computed efficiently for non-trivial input sizes. Nevertheless, one can find an approximate solution by considering continuous masks $s \in [ 0 , 1 ] ^ { k }$ and encouraging sparsity through the $\ell _ { 1 }$ -norm.
96
+
97
+ Definition 3 (RDE’s $\ell _ { 1 }$ -relaxation with Lagrange multipliers) In the setting of Definition $I$ , we define RDE’s $\ell _ { 1 }$ -relaxation with Lagrange multipliers as a solution $s ^ { * } ( \lambda )$ to the minimization problem
98
+
99
+ $$
100
+ \begin{array} { r l } { \underset { s \in [ 0 , 1 ] ^ { k } } { \operatorname* { m i n } } } & { { } D ( \boldsymbol { x } , s , \mathcal { V } _ { s } , \boldsymbol { \Phi } ) + \lambda \| s \| _ { 1 } , } \end{array}
101
+ $$
102
+
103
+ where $\lambda > 0$ is a hyperparameter for the sparsity level.
104
+
105
+ The $\ell _ { 1 }$ -relaxation above can be solved with stochastic gradient descent (SGD) over the mask $s$ while approximating $D ( x , s , \mathcal { V } _ { s } , \Phi )$ with i.i.d. samples from $v \sim \mathcal { V } _ { s }$ .
106
+
107
+ # 4.1.2 OBFUSCATION STRATEGIES
108
+
109
+ An obfuscation strategy is defined by the choice of the perturbation distribution $\mathcal { V } _ { s }$ . Common choices are Gaussian noise (Macdonald et al., 2019; Fong & Vedaldi, 2017), blurring (Fong & Vedaldi, 2017), constants (Fong $\&$ Vedaldi, 2017), and inpainting GANs (Heiß et al., 2020; Chang et al., 2019). Inpainting GANs train a generator $G ( s , z , h )$ ( $z$ denotes random latent factors) such that for samples $v \sim G ( s , z , h )$ the obfuscation $f ( s \odot h + ( 1 - s ) \odot v )$ remains in the data manifold. In our work, we refrain from using an inpainting GAN due to the following reason: it is hard to tell whether a GAN-based mask did not select coefficients because they are unimportant or because the GAN can easily inpaint them from a biased context. Instead, we choose a simple and wellunderstood obfuscation strategy, which we call Gaussian adaptive noise, making the explanation as transparent as possible.
110
+
111
+ Gaussian adaptive noise works as follows: Let $A _ { 1 } , . . . , A _ { j }$ be a pre-defined choice of a disjoint partition of $\{ 1 , \ldots , k \}$ (recall $s \in [ 0 , 1 ] ^ { k } )$ . For $i = 1 , . . . , j$ , we compute the empirical mean and empirical standard deviation for each partition across all partition instances:
112
+
113
+ $$
114
+ \mu _ { i } : = \frac { 1 } { \sum _ { a \in A _ { i } } d _ { a } } \sum _ { a \in A _ { i } , t = 1 , \ldots , d _ { a } } h _ { a t } , \sigma _ { i } : = \sqrt { \frac { 1 } { \sum _ { a \in A _ { i } } d _ { a } } \sum _ { a \in A _ { i } , t = 1 , \ldots , d _ { a } } ( \mu _ { i } - h _ { a t } ) ^ { 2 } }
115
+ $$
116
+
117
+ The adaptive Gaussian noise strategy then samples $v _ { a t \_ } \sim \mathcal { N } ( \mu _ { i } , \sigma _ { i } ^ { 2 } )$ for all partition members $a \in$ $A _ { i }$ and channels $t = 1 , . . . , d _ { a }$ . We write $v \sim \mathcal { N } ( \mu , \sigma ^ { 2 } )$ for the resulting Gaussian random vector $\boldsymbol { v } \in \prod _ { i = 1 } ^ { k } \mathbb { R } ^ { c }$ . Note that the distribution $\gamma _ { s }$ chosen as Gaussian adaptive noise does depend on $s$ (unlike with an inpainting GAN). For Pixel RDE, we only use one set $A _ { 1 } = \left\{ 1 , . . . , k \right\}$ for all $k$ pixels. In CartoonX, which represents input signals in the discrete wavelet domain, we will partition $\{ 1 , . . . , k \}$ along the scales of the discrete wavelet transform.
118
+
119
+ # 4.1.3 MEASURES OF DISTORTION
120
+
121
+ There are various choices for the measure of distortion $d ( \Phi ( x ) , \Phi ( y ) )$ . For example, one can take the squared distance in the post-softmax probability of the predicted label for $x$ , i.e.,
122
+
123
+ $$
124
+ d \big ( \Phi ( x ) , \Phi ( y ) \big ) : = \big ( \Phi _ { j ^ { * } } ( x ) - \Phi _ { j ^ { * } } ( y ) \big ) ^ { 2 } ,
125
+ $$
126
+
127
+ where $j ^ { * } : = \arg \operatorname* { m a x } _ { i = 1 , \ldots , m } \Phi _ { i } ( x )$ and $\Phi ( x )$ is assumed to be the post-softmax probabilities of a neural net. Alternatively, one could also choose $d ( \Phi ( x ) , \Phi ( y ) )$ as the $\ell _ { 2 }$ -distance or the KLDivergence in the post-softmax layer of $\Phi$ . In our experiments for CartoonX, we found that these choices had no significant effect on the explanation (see Appendix A.3.3).
128
+
129
+ # 4.2 INTERPRETATION
130
+
131
+ The philosophy of the generalized RDE framework is that an explanation for a decision $\Phi ( x )$ on a generic input signal $x = f ( h )$ should be some simplified version of the signal, which is interpretable to humans. The simplification is achieved by demanding sparsity in a suitable representation system $h$ , which sparsely represents the class of explanations that are desirable for the interpretation query. This philosophy is the fundamental premise of CartoonX, which aims to answer the interpretation query “What is the relevant piece-wise smooth part of the image for a given image classifier?”. CartoonX first employs RDE on a representation system $x = f ( h )$ that sparsely represents piecewise smooth images and finally visualizes the relevant piece-wise smooth part as an image back in pixel space. In the following section, we explain why wavelets provide an appropriate representation system in CartoonX, present the CartoonX implementation, and finally provide experiments on ImageNet to demonstrate the capability of CartoonX.
132
+
133
+ # 5 CARTOONX
134
+
135
+ The focus of this paper is CartoonX, a novel explanation method—tailored to image classifications— that we obtain as a special case of our generalized RDE framework formulated in Section 4. CartoonX first performs RDE in the discrete wavelet position-scale domain of an image $x$ , and finally, visualizes the wavelet mask $s$ as a piece-wise smooth image in pixel space. Wavelets provide optimal representations for piece-wise smooth 1D functions (DeVore, 1998), and represent 2D piecewise smooth images, also called cartoon-like images (Kutyniok & Lim, 2011), efficiently as well (Romberg et al., 2006). In particular, sparse vectors in the wavelet coefficient space encode cartoonlike images reasonably well (Stephane, 2009a)—certainly better than sparse pixel representations. ´ Moreover, wavelets constitute an established tool in signal processing (Stephane, 2009c). ´
136
+
137
+ ![](images/600d34c48f6449578084ae2acb04f5102f541072c868e8f11c61d9f05a838409.jpg)
138
+ Figure 3: CartoonX has many interesting parallels to wavelet-based image compression. Distortion is denoted as $d$ , $\Phi$ is an image classifier, $h$ denotes the discrete wavelet coefficients, $\tau$ is the discrete wavelet transform, and $\ell$ is the coefficient budget.
139
+
140
+ The optimization process underlying CartoonX produces sparse vectors in the discrete wavelet coefficient space, which results in cartoon-like images as explanations. This is the fundamental difference to Pixel RDE, which produces rough, jittery, and pixel-sparse explanations. Cartoon-like images are more interpretable and provide a natural model of simplified images. Since the goal of the RDE framework is to generate an easy to interpret simplified version of the input signal, we argue that CartoonX explanations are more appropriate for image classification than Pixel RDEs.
141
+
142
+ CartoonX exhibits interesting parallels to wavelet-based image compression. In image compression, distortion is minimized in the data domain, which is equivalent to selecting the $\ell$ largest entries in the discrete wavelet transform (DWT) coefficients. In comparison, CartoonX minimizes distortion in the model output of $\Phi$ , which translates to selecting the $\ell$ most relevant entries in the DWT coefficients. The objective in image compression is efficient data representation, i.e., producing minimal data distortion with a budget of $\ell$ entries in the DWT coefficients. Conversely, in CartoonX, the objective is extracting the relevant piece-wise smooth part, i.e., producing minimal model distortion with a budget of $\ell$ entries in the DWT coefficients. We illustrate this connection in Figure 3—highlighting once more the rate-distortion spirit of the RDE framework.
143
+
144
+ # 5.1 IMPLEMENTATION
145
+
146
+ An image $x \in [ 0 , 1 ] ^ { c \times w \times t }$ with $c \in \{ 1 , 3 \}$ channels, width $w \in \mathbb { N }$ , height $t \in \mathbb N$ , and a total of $p = w t$ pixels can be represented in a wavelet basis by computing its discrete wavelet transform (DWT). The DWT of an image is defined by the number of scales $J \in \{ 1 , \ldots , \lfloor \log _ { 2 } p \rfloor \}$ , the padding mode, and a choice of the wavelet family (such as the Haar or Daubechies family). For images, the DWT computes four types of coefficients: details in (1) horizontal, (2) vertical, and (3) diagonal orientation at scale $j \in \{ 1 , \dots , J \}$ , and (4) coefficients of the image at the very coarsest resolution. We briefly illustrate the DWT for an example image in Figure 4.
147
+
148
+ ![](images/39ebb784157d2c6edd31b1dadc49ecf3ff916b928f9b9fd1b5f08907bedcccf9.jpg)
149
+ Figure 4: Left side: an image of a memorial arch dedicated to peace. Right side: visualization of the DWT coefficients for five scales. Three L-shaped sub-images describe coefficients for details in vertical, horizontal, and diagonal orientation at a particular scale. The largest sub-images (the outer L-shape) belong to the lowest scale, i.e., the highest resolution. The smaller L-shaped sub-images gradually build up to higher scales, i.e., lower resolution features.
150
+
151
+ CartoonX, as described in Algorithm 1 in Appendix A.1, computes the RDE mask in the wavelet domain of images. More precisely, for the data representation ${ \bar { \boldsymbol { x } } } = f ( h )$ , we choose $h$ as the concatenation of all the DWT coefficients along the channels, i.e., $\boldsymbol { h } _ { i } \in \mathbb { R } ^ { c }$ . The representation function $f$ is then the discrete inverse wavelet transform, i.e., the summation of the DWT coefficients times the DWT basis vectors. We optimize the mask $s \in [ 0 , 1 ] ^ { k }$ on the DWT coefficients $[ h _ { 1 } , \ldots , h _ { k } ] ^ { T }$ to minimize RDE’s $\ell _ { 1 }$ -relaxation from Definition 3. For the obfuscation strategy $\gamma _ { s }$ , we use adaptive Gaussian noise with a partition by the DWT scale (see Section 4.1.2), i.e., we compute the empirical mean and standard deviation per scale. We measure distortion as the squared difference in the postsoftmax score of the predicted label for $x$ (see Section 4.1.3). To visualize the final DWT mask $s$ as a piece-wise smooth image in pixel space, we multiply the mask with the DWT coefficients of the greyscale image $\hat { x } : = ( 1 \breve { / c } \sum _ { l = 1 } ^ { \hat { c } } x _ { l a i } \dot { ) } _ { a i }$ before inverting the product back to pixel space with the discrete inverse wavelet transform. The inversion is finally clipped into $[ 0 , 1 ] ^ { w \times \dot { t } }$ as are obfuscations during the RDE optimization to avoid overflow (we assume here the pixel values in $x$ are normalized into $[ 0 , 1 ] )$ . The clipped inversion in pixel space is the final explanation, which we call CartoonX.
152
+
153
+ # 5.2 EXPERIMENTS AND ANALYSIS
154
+
155
+ We compare CartoonX to the closely related Pixel RDE (Macdonald et al., 2019) and several other state-of-the-art explanation methods , that is, Integrated Gradients (Sundararajan et al., 2017), Smoothgrad (Smilkov et al., 2017), Guided Backprop (Springenberg et al., 2015), and LRP (Bach et al., 2015). Our experiments show that CartoonX carries the following strengths: Cartoon X is (1) highly interpretable due to its cartoon-like nature and (2) remarkably apt at explaining misclassifications, and highlighting meaningful patterns that are otherwise hard to see. Due to the fast implementation of the DWT, Cartoon RDE is not significantly slower than Pixel RDE. For the ImageNet classifier MobileNetV3-Small, an image of 256 times 256 pixels, and 2001 optimization steps, we reported a runtime of 81.56 seconds for CartoonX and 70.53 seconds for Pixel RDE on the NVIDIA Titan RTX GPU. However, like other perturbation-based methods, CartoonX is significantly slower than gradient or propagation-based methods, which only compute a single or few forward and backward passes and are very fast (Integrated Gradients computes an explanation in 0.48 seconds for the same image, model, and hardware).
156
+
157
+ Our experiments use the pre-trained ImageNet classifiers MobileNetV3-Small (Howard et al., 2019) (top-1 accuracy of $6 7 . 6 6 8 \%$ and VGG16 (Simonyan & Zisserman, 2015) (top-1 accuracy of $7 1 . 5 9 2 \%$ ). We note that the open-source implementation of LRP did not implement propagation rules for certain layers in MobileNetV3-Small, therefore we compare CartoonX to LRP only for VGG16. Images were preprocessed to have 256 times 256 pixel values in [0, 1]. We provide further details about the choice of hyperparameters in the experiments in Appendix A.2. The three main hyperparameters for CartoonX are: (1) the sparsity level $\lambda > 0$ , (2) the measure of distortion $d$ , and (3) the obfuscation strategy (perturbation distribution) $\gamma _ { s }$ . We discuss the sensitivity of CartoonX to these hyperparameters in Appendix A.3. In Appendix A.5, we also shed light on the evolution of ImageNet classifiers from an explanation angle by comparing CartoonX explanations for classifiers of varying generalization power, i.e., AlexNet (Krizhevsky et al., 2012), VGG16 (Simonyan & Zisserman, 2015), InceptionV3 (Szegedy et al., 2016), ResNeXt50 (Xie et al., 2017). Moreover, in Appendix A.4, we argue experimentally why CartoonX is less susceptible than Pixel RDE to so-called explanation artifacts—an unwanted phenomenon that we observed empirically.
158
+
159
+ ![](images/0a1f842c7c2f27339003af5f5ca74ec6399ee2beaa7f81924ce3ed1fbaf9fc58.jpg)
160
+ Figure 5: Each row compares CartoonX explanations of misclassifications by MobileNetV3-Smal to Pixel RDE (Macdonald et al., 2019), Integrated Gradients (Sundararajan et al., 2017), and Smoothgrad (Smilkov et al., 2017). The predicted label is depicted above each misclassified image.
161
+
162
+ In practice, explaining misclassifications is particularly relevant since good explanations can pinpoint model biases and causes for model failures. We observe that CartoonX is particularly good at explaining certain misclassifications, which we illustrate for three examples in Figure 5 and many more in Appendix A.6. In the first row in Figure 5, the input image shows a man holding a dog that was classified as a “diaper”. CartoonX shows the man not holding a dog but a baby, revealing that the neural net associated diapers with babies and babies with the pose with which the man is holding the dog. In the second row, the input image shows a dog sitting on an armchair with leopard patterns. The dog was classified as an “Egyptian cat”, which can exhibit leopard-like patterns. CartoonX exposes the Egyptian cat by connecting the dog’s head to parts of the armchair forming the cat’s torso and legs. In the last row, the input image displays the backside of a man wearing a striped sweater that was classified as a “screw”. CartoonX reveals how the stripe patterns look like a screw to the neural net.
163
+
164
+ ![](images/93b3a56308de3770000542d827bd0e4671770354a0f003b0ff69f08314095854.jpg)
165
+ Figure 6: CartoonX explanations for VGG16 compared to state-of-the-art methods, that is, Pixel RDE (Macdonald et al., 2019), Integrated Gradients (Sundararajan et al., 2017), Smoothgrad (Smilkov et al., 2017), Guided Backprop (Springenberg et al., 2015), and LRP (Bach et al., 2015).
166
+
167
+ # 6 CONCLUSION
168
+
169
+ CartoonX is the first explainability method to extract the relevant piece-wise smooth part of an image and is based on our novel formulation of the RDE framework. We corroborated experimentally that CartoonX explanations are highly interpretable due to their cartoon-like nature and surprisingly well-suited to explain misclassifications. Nonetheless, Cartoon RDE is still computationally quite expensive, like other perturbation-based explanation methods. In the future, we hope to devise new techniques to speed up the runtime for CartoonX. Moreover, we are pursuing applications of CartoonX beyond explanation tasks, such as detecting adversarial examples. We believe CartoonX is a valuable new explanation method for practitioners and potentially a great source of inspiration for future explanation methods aiming to tailor their explanations to other data domains. Our reformulation and reinterpretation of the RDE framework provide a blueprint for such future work: First, formulate an interpretation query related to the underlying model task, then find a representation system that sparsely represents the class of desirable explanations for the interpretation query.
170
+
171
+ # REFERENCES
172
+
173
+ 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.
174
+
175
+ Chun-Hao Chang, Elliot Creager, Anna Goldenberg, and David Duvenaud. Explaining image classifiers by counterfactual generation. In Proceedings of the 7th International Conference on Learning Representations, ICLR, 2019.
176
+
177
+ Arun Das and Paul Rad. Opportunities and challenges in explainable artificial intelligence (xai): A survey. ArXiv, abs/2006.11371, 2020.
178
+
179
+ Ronald A. DeVore. Nonlinear approximation. Acta Numerica, 7:51–150, 1998.
180
+
181
+ Kedar Dhamdhere, Mukund Sundararajan, and Qiqi Yan. How important is a neuron. In International Conference on Learning Representations, 2019.
182
+
183
+ Jesse Engel, Cinjon Resnick, Adam Roberts, Sander Dieleman, Mohammad Norouzi, Douglas Eck, and Karen Simonyan. Neural audio synthesis of musical notes with wavenet autoencoders. In Proceedings of the 34th International Conference on Machine Learning, ICML, volume 70, pp. 1068–1077, 2017.
184
+
185
+ R. C. Fong and A. Vedaldi. Interpretable explanations of black boxes by meaningful perturbation. In Proceedings of 2017 IEEE International Conference on Computer Vision (ICCV), pp. 3449–3457, 2017.
186
+
187
+ Cosmas Heiß, Ron Levie, Cinjon Resnick, Gitta Kutyniok, and Joan Bruna. In-distribution interpretability for challenging modalities. Preprint arXiv:2007.00758, 2020.
188
+
189
+ Andrew Howard, Mark Sandler, Bo Chen, Weijun Wang, Liang-Chieh Chen, Mingxing Tan, Grace Chu, Vijay Vasudevan, Yukun Zhu, Ruoming Pang, Hartwig Adam, and Quoc Le. Searching for MobileNetV3. In Proceedings of the 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pp. 1314–1324, 2019.
190
+
191
+ Been Kim, M. Wattenberg, J. Gilmer, Carrie J. Cai, James Wexler, F. Viegas, and R. Sayres. Inter- ´ pretability beyond feature attribution: Quantitative testing with concept activation vectors (tcav). In ICML, 2018.
192
+
193
+ 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, volume 25. Curran Associates, Inc., 2012.
194
+
195
+ Gitta Kutyniok and Wang-Q Lim. Compactly supported shearlets are optimally sparse. Journal of Approximation Theory, 163(11):1564–1589, 2011. ISSN 0021-9045.
196
+
197
+ Ron Levie, Cagkan Yapar, Gitta Kutyniok, and Giuseppe Caire. Pathloss prediction using deep learning with applications to cellular optimization and efficient d2d link scheduling. In ICASSP 2020 - 2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 8678–8682, 2020. doi: 10.1109/ICASSP40776.2020.9053347.
198
+
199
+ Ron Levie, Cagkan Yapar, Gitta Kutyniok, and Giuseppe Caire. RadioUNet: Fast radio map estimation with convolutional neural networks. IEEE Transactions on Wireless Communications, 20 (6):4001–4015, 2021.
200
+
201
+ Scott M. Lundberg and Su-In Lee. A unified approach to interpreting model predictions. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NeurIPS, pp. 4768–4777, 2017.
202
+
203
+ Jan Macdonald, Stephan Waldchen, Sascha Hauch, and Gitta Kutyniok. A rate-distortion framework ¨ for explaining neural network decisions. Preprint arXiv:1905.11092, 2019.
204
+
205
+ A. Nguyen, A. Dosovitskiy, J. Yosinski, T. Brox, and J. Clune. Synthesizing the preferred inputs for neurons in neural networks via deep generator networks. In Advances in Neural Information Processing Systems (NIPS), 2016.
206
+
207
+ Matthew O' Shaughnessy, Gregory Canal, Marissa Connor, Christopher Rozell, and Mark Davenport. Generative causal explanations of black-box classifiers. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 5453–5467. Curran Associates, Inc., 2020.
208
+
209
+ Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. ”Why should I trust you?”: Explaining the predictions of any classifier. In Proceedings of the 22nd International Conference on Knowledge Discovery and Data Mining, ACM SIGKDD, pp. 1135–1144. Association for Computing Machinery, 2016. ISBN 9781450342322.
210
+
211
+ Justin K. Romberg, Michael B. Wakin, and Richard G. Baraniuk. Wavelet-domain approximation and compression of piecewise smooth images. IEEE Trans. Image Processing, 15:1071–1087, 2006.
212
+
213
+ Avanti Shrikumar, Peyton Greenside, and Anshul Kundaje. Learning important features through propagating activation differences. In Proceedings of the 34th International Conference on Machine Learning, ICML, volume 70, pp. 3145–3153, 2017.
214
+
215
+ K. Simonyan, A. Vedaldi, and Andrew Zisserman. Deep inside convolutional networks: Visualising image classification models and saliency maps. CoRR, abs/1312.6034, 2014.
216
+
217
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations, 2015.
218
+
219
+ Daniel Smilkov, Nikhil Thorat, Been Kim, Fernanda Viegas, and Martin Wattenberg. Smoothgrad: ´ removing noise by adding noise. In Workshop on Visualization for Deep Learning, ICML, 2017.
220
+
221
+ J.T. Springenberg, A. Dosovitskiy, T. Brox, and M. Riedmiller. Striving for simplicity: The all convolutional net. In ICLR (workshop track), 2015.
222
+
223
+ Mallat Stephane. Chapter 11.3. In Mallat St ´ ephane (ed.), ´ A Wavelet Tour of Signal Processing (Third Edition), pp. 535–610. Academic Press, Boston, third edition edition, 2009a. ISBN 978- 0-12-374370-1.
224
+
225
+ Mallat Stephane. Chapter 6. In Mallat St ´ ephane (ed.), ´ A Wavelet Tour of Signal Processing (Third Edition), pp. 232. Academic Press, Boston, third edition edition, 2009b. ISBN 978-0-12-374370- 1.
226
+
227
+ Mallat Stephane. In Mallat St ´ ephane (ed.), ´ A Wavelet Tour of Signal Processing (Third Edition), pp. 232. Academic Press, Boston, third edition edition, 2009c. ISBN 978-0-12-374370-1.
228
+
229
+ Mukund Sundararajan, Ankur Taly, and Qiqi Yan. Axiomatic attribution for deep networks. In Proceedings of the 34th International Conference on Machine Learning, ICML, volume 70, pp. 3319–3328, 2017.
230
+
231
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2818–2826, 2016.
232
+
233
+ Saining Xie, Ross B. Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated residual ´ transformations for deep neural networks. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 5987–5995, 2017.
234
+
235
+ # A APPENDIX
236
+
237
+ # A.1 CARTOONX ALGORITHM
238
+
239
+ The final CartoonX algorithm is depicted in Algorithm 1.
240
+
241
+ # Algorithm 1: CartoonX
242
+
243
+ <table><tr><td>AigormmmrT.CartoonA Data: Image x ∈ [0,1]exwxt with c channels and wt pixels, classifier Φ. Result: CartoonX explanation ε ∈ [0,1]w×t for decision Φ(x). Hyperparameters: Sparsity level X &gt; O, number of steps N, number of noise samples L. Initialize mask s := [1,..,1]T ∈ [0,1]k on DWT coefficients h = [h1,.., hk] with x = f(h), where f is the discrete inverse wavelet transform; Compute predicted label j* := arg maxi Φ(x); fori←1toNdo</td></tr><tr><td>Sample L adaptive Gaussian noise samples u(1),., u(L) ~ N(μ,o²); Compute obfuscations y(1), ),.,y(L) with y() := f(h ① s+ (1- s) ①u(i)); Clip obfuscations into [0,1]cx w ×t;</td></tr><tr><td>Approximate expected distortion D(𝑥x,s,Φ) :=∑𝑖=1(Φj+(x)- Φj(y())²/L;</td></tr><tr><td>Compute loss for the mask l(s) := D(x,s,Φ) + λ|lsll1 and gradient Vsl(s); Update mask s with gradient descent step and clip s back to [0,1]k ;</td></tr><tr><td>end Compute wavelet coefficients h for greyscale image x of x;</td></tr><tr><td>Invert wavelet mask s back to pixel space as &amp; := f(h s) ; Clip the explanation ε into [0,1]w×t to obtain ε. Visualize ε;</td></tr></table>
244
+
245
+ # A.2 EXPERIMENT DETAILS
246
+
247
+ Throughout our experiments with CartoonX and Pixel RDE, we used a learning rate of $\epsilon = 0 . 0 0 1$ , a sample size of $L = 6 4$ for the adaptive Gaussian noise, and $N = 2 0 0 0$ steps. Several different sparsity levels were used. We recommend specifying the sparsity level in terms of the number of mask entries $k$ , i.e., choosing the product $\lambda k$ . Pixel RDE typically requires a smaller sparsity level than CartoonX. We chose $\bar { \lambda k } \in [ \bar { 2 0 } , 8 0 ]$ for CartoonX and $\bar { \lambda } k \in [ 3 , 2 \bar { 0 } ]$ for Pixel RDE. The obfuscation strategy for Pixel RDE was chosen as Gaussian adaptive noise with mean and standard deviation computed for all pixel values (see Section 4.1.2). In Appendix 8, we show that Gaussian adaptive noise produces much more interpretable explanations than using a zero baseline perturbation. We implemented the DWT for CartoonX with the Pytorch Wavelets package, which is compatible with PyTorch gradient computations, and chose the Daubechies wavelet system with $J = 5$ scales and zero-padding. For the Integrated Gradients method, we used 100 steps, and for the Smoothgrad method, we used 10 samples and a standard deviation of 0.1.
248
+
249
+ # A.3 SENSITIVITY TO HYPERPARAMETERS
250
+
251
+ We compare CartoonX’s sensitivity to its main hyperparameters, i.e., the sparsity level $\lambda$ , the perturbation distribution $\gamma _ { s }$ , and the distortion measure $\bar { d ( \Phi ( x ) , \Phi ( y ) ) }$ . For each experiment, we fix all but one of the three parameters.
252
+
253
+ # A.3.1 SENSITVITY TO THE SPARSITY LEVEL $\lambda$
254
+
255
+ Figure 7 plots CartoonX explanations and Pixel RDEs for increasing $\lambda$ —the hyperparameter determining the explanation’s sparsity in the respective representation system. We find that CartoonX is less sensitive than Pixel RDE to $\lambda$ . In practice, this means one can find a suitable $\lambda$ faster for CartoonX than for Pixel RDE.
256
+
257
+ # A.3.2 SENSITVITY TO THE DISTRIBUTION $\gamma _ { s }$
258
+
259
+ Figure 8 plots CartoonX explanations for two choices of $\gamma _ { s }$ : (1) Gaussian adaptive noise (see Section 4.1.2) and (2) constant zero perturbations (i.e. $v = 0$ with probability one under $\gamma _ { s }$ ). We observe that the Gaussian adaptive noise gives much more meaningful explanations than the simple zero baseline perturbations.
260
+
261
+ ![](images/669376803cf15b48772f47190fc15e7b3958a45c1013353768d96a6ea5ac042a.jpg)
262
+ Figure 7: We compare the sensitivity of CartoonX and Pixel RDE to the sparsity level $\lambda$ . The top row depicts CartoonX, and the bottom row depicts Pixel RDE, for increasing values of $\lambda$ . Note that for $\lambda = 0$ , Pixel RDE is entirely yellow because the mask is initialized as $s ^ { \check { = } } [ 1 \ldots 1 ] ^ { T }$ and $\lambda = 0$ provides no incentive to make s sparser. For the same reason, CatoonX is simply the greyscale image for $\lambda = 0$ .
263
+
264
+ ![](images/014f60850b885dee2e6d5318a68d96e55506ad31ed7a0b81c56dda8b69fa0b6c.jpg)
265
+ Figure 8: We compare the sensitivity of CartoonX to the perturbation distribution $\gamma _ { s }$ . The top image was classified as a fountain and the bottom image as a viaduct. The second column depicts CartoonX with $\gamma _ { s }$ as Gaussian adaptive noise, and the third column depicts CartoonX with $\gamma _ { s }$ as constant zero perturbations (zero baseline). We observe that Gaussian adaptive noise is much more interpretable than the zero baseline.
266
+
267
+ # A.3.3 SENSITVITY TO THE DISTORTION MEASURE $d ( \Phi ( x ) , \Phi ( y ) )$
268
+
269
+ Figure 9 plots CartoonX explanations for the following four choices of $d ( \Phi ( x ) , \Phi ( y ) )$ , where $x$ is the original input, $y$ is the RDE obfuscation, and $\Phi$ outputs post-softmax probabilities:
270
+
271
+ 1. $d ( \Phi ( x ) , \Phi ( y ) ) = ( \Phi _ { j ^ { * } } ( x ) - \Phi _ { j ^ { * } } ( y ) ) ^ { 2 }$ , where $j ^ { * } : = \arg \operatorname* { m a x } _ { j } \Phi _ { j } ( x )$ (squared $\ell _ { 2 }$ in label )
272
+
273
+ 2. $d ( \Phi ( x ) , \Phi ( y ) ) = ( \Phi _ { j ^ { * } } ( x ) - 1 ) ^ { 2 }$ , where $j ^ { * } : = \arg \operatorname* { m a x } _ { j } \Phi _ { j } ( x )$ (maximize label)
274
+ 3. $d ( \Phi ( x ) , \Phi ( y ) ) = \lVert \Phi ( x ) - \Phi ( y ) \rVert _ { 2 }$ ( $\ell _ { 2 }$ probabilities)
275
+ 4. $d ( \Phi ( x ) , \Phi ( y ) ) = K L ( \Phi ( y ) , \Phi ( x ) )$ (KL-Divergence)
276
+
277
+ The explanations for $d ( \Phi ( x ) , \Phi ( y ) )$ as “squared $\ell _ { 2 }$ in label”, “maximize label”, and ${ } ^ { 6 6 } \ell _ { 2 }$ probabilities” look indistinguishable. For $\bar { d } ( \Phi ( x ) , \mathbf { \bar { \Phi } } ( y ) )$ as KL-Divergence, we see a slightly less smooth explanation, which may be due to the fact that the KL-Divergence is unbounded unlike the other measures of distortion.
278
+
279
+ ![](images/9187ae880a8b62675d03bda7eac035f50f4ff1e5be910d54d869700c0b8877f3.jpg)
280
+ Figure 9: We compare the sensitivity of CartoonX to four measures of distortion $d ( \Phi ( x ) , \Phi ( y ) )$ . Each of the measures of distortion is marked at the top of each column. We observe almost no difference in the CartoonX explanations for the four distortion measures.
281
+
282
+ # A.4 RELIABILITY AND EXPLANATION ARTIFACTS
283
+
284
+ We argue experimentally why CartoonX is more reliable than Pixel RDE for image data. More precisely, we show that CartoonX is less susceptible to so-called explanation artifacts than Pixel RDE. An explanation artifact is an unwanted phenomenon that we observed for Pixel RDE: instead of marking the relevant entries in $x$ , the mask $s$ creates artificial edges that end up making up an artificial class prototype. Explanation artifacts are problematic because they highlight not actual substructures but artificial structures that trigger the classification. Examples for explanation artifacts in Pixel RDE are given in Figure 11.
285
+
286
+ ![](images/202f6780abcf94eb3a89b7f1a8d763a4bce9c8a43edc6cc45602844f237f5f61.jpg)
287
+ Figure 10: CartoonX and Pixel RDE are both performed on the image of the blue sky. However, both methods are adjusted here to find evidence for the output probabilities of the image of the airplane instead of the blue sky. Pixel RDE, unlike CartoonX, can create an artificial airplane as evidence for an airplane in the smooth blue sky.
288
+
289
+ Pixel RDE can produce artificial edges in smooth regions for the following reason: When $s$ has a curve-like structure in some region, unselected points near $s$ are replaced with perturbations that tend to differ from the values of the curve-like structure in $s$ . Thus, the curve-like structure also appears in the obfuscation and can produce low distortion if the structure makes up a prototypical class feature (see, for example, the airplane in Figure 10).
290
+
291
+ We suspect CartoonX is inherently less susceptible to explanation artifacts for the following reason: Natural images tend to be piece-wise smooth, and piece-wise smooth images have sparse high-frequency DWT coefficients that cluster about the edges Stephane (2009b) (see for example ´ Figure 4). For a DWT mask to create artificial edges, it has to select a curve-like structure in the high-frequency coefficients (low-frequency coefficients cannot create edges) and replace surrounding unselected values with different values. However, in CartoonX, perturbations of high-frequency coefficients are Gaussian with low variance centered close to zero (see adaptive Gaussian noise in Section 4.1.2), which are not very different from the values along the selected curve due to the sparsity of the coefficients.
292
+
293
+ We illustrate our previous reasoning about explanation artifacts in a controlled example (see Figure 10). We take an image $x ^ { ( \mathrm { s k y } ) }$ of a blue sky that is very smooth and an image $x ^ { \mathrm { ( p l a n e ) } }$ of a airplane. The goal is to show that Pixel RDE, unlike CartoonX, can create artificial evidence for the class airplane on the image of the smooth blue sky. We perform CartoonX and Pixel RDE on the blue sky image with the distortion function
294
+
295
+ $$
296
+ \forall y \in \mathbb { R } ^ { n } : \ d ( \Phi ( x ^ { ( \mathrm { s k y } ) } ) , \Phi ( y ) ) = 1 0 ^ { 6 } \| \Phi ( x ^ { ( \mathrm { p l a n e } ) } ) - \Phi ( y ) \| _ { 2 } ,
297
+ $$
298
+
299
+ and a sparsity level of $\lambda = 8 0 0 0 0$ . As expected, we observe that Pixel RDE, unlike CartoonX, can create an artificial plane in the smooth blue sky(see Figure 10).
300
+
301
+ A.5 EXPLAINING THROUGH IMAGENET HISTORY: FROM ALEXNET TO RESNETXT50
302
+
303
+ In the deep learning community, it is well-known that AlexNet (Krizhevsky et al., 2012) provided a major breakthrough in deep learning, improving the top-5 error on ImageNet from $2 5 \%$ to $16 \%$ . Since then, deep learning based ImageNet classifiers have continued to drastically improve on ImageNet—achieving less than $6 \%$ top-5 error in 2016. In Figure 12, we compare CartoonX for four ImageNet classifiers with increasing performance, starting with AlexNet (top-1 accuracy $5 6 . 5 5 \%$ , AlexNet), VGG16 (top-1 accuracy $7 1 . 5 9 \%$ , Simonyan & Zisserman (2015)), InceptionV3 (top-1 accuracy $7 7 . 2 9 \%$ , Szegedy et al. (2016)), and ResNeXt50 (top-1 accuracy $7 7 . 6 2 \%$ , Xie et al. (2017).) Throughout the experiment, the CartoonX hyperparameters for a given image are not changed for any of the four classifiers.
304
+
305
+ # A.6 EXPLAINING MISCLASSIFICATIONS WITH CARTOONX
306
+
307
+ In Figure 13, 14, 15, and 16, we provide further examples where CartoonX provides insightful explanations for misclassified images.
308
+
309
+ # A.7 CARTOONX COMPARED ON RANDOM IMAGENET SAMPLES
310
+
311
+ Figure 17, 18, 19, and 20 compares CartoonX to Pixel RDE (Macdonald et al., 2019), Integrated Gradients (Sundararajan et al., 2017), Smoothgrad (Smilkov et al., 2017), Guided Backprop (Springenberg et al., 2015), and (Bach et al., 2015) on random Imagenet samples classified by VGG16.
312
+
313
+ # A.8 CARTOONX FAILURES
314
+
315
+ We also show failures of CartoonX in Figure 21. These are examples of explanations that are not interpretable and seem to fail at explaining the model prediction. Notably, most failure examples are also not particularly well explained by other state-of-the-art methods. It is challenging to state the underlying reason for the CatoonX failures with certainty (there is always the possibility that the neural net bases its decision on non-interpretable grounds). We intentionally also showed uninterpretable CartoonX explanations that were not too sparse (all or almost black explanations) since one can typically fix these explanations by decreasing $\lambda$ .
316
+
317
+ ![](images/4348604dba432b3c96ce1e643eb3ab00bb1b1360ac0508fa151d7742220d33a6.jpg)
318
+ Figure 11: Explanation artifacts in Pixel RDE. We observe that Pixel RDE tends to create edges that are not a subset of the edges in the original input image. These edges can make prototypical artifact patterns such as wrinkles in the cloak (first row), coral tentacles (second row), or chain mail (third row).
319
+
320
+ ![](images/6787c0907f2780a91eeba9a8c758e1e7e257500e6962b20c21edad4a037d379c.jpg)
321
+ Figure 12: We compare CatoonX explanations for classifications by AlexNet (Krizhevsky et al., 2012), VGG16 (Simonyan & Zisserman, 2015), InceptionV3 (Szegedy et al., 2016), and ResNeXt50 (Xie et al., 2017). Green labels mark correct classifications and red labels mark wrong classifactions.
322
+
323
+ ![](images/eb86233a3b07b868113dda202cab39f6f67461c4de85083de6e1fd8ee8292c8e.jpg)
324
+ Figure 13: Explaining misclassifications with CartoonX on Imagenet and MobileNetV3-Small.
325
+
326
+ ![](images/3f5f295b306da0a5156d30d76a6aa194e591059d0eb184994eb42043169014f0.jpg)
327
+ Figure 14: Explaining misclassifications with CartoonX on Imagenet and MobileNetV3-Small.
328
+
329
+ ![](images/4ad860b0ac3719256544354b20a3432e1aeb4a028fe6c9a3feb6cb20414bd6e9.jpg)
330
+ Figure 15: Explaining misclassifications with CartoonX on Imagenet and MobileNetV3-Small.
331
+
332
+ ![](images/514d598a6d4e95cdbd85c43a862b0a1bd0459a6852d89b3ce2fcb63bcd01792c.jpg)
333
+ Figure 16: Explaining misclassifications with CartoonX on Imagenet and MobileNetV3-Small.
334
+
335
+ ![](images/549aeec35ea55596a58c06d2945f8fdf0faa71d75a7db2cd4edec824a94e0c99.jpg)
336
+ Figure 17: Comparing CartoonX on random ImageNet samples and VGG16.
337
+
338
+ ![](images/e1ef9c14fd73e7ff8291699ed4e3f48b71162eebae779f16441340c19979e5a0.jpg)
339
+ Figure 18: Comparing CartoonX on random ImageNet samples and VGG16.
340
+
341
+ ![](images/0c30ef46b69d0c580910205c2e3cd0a382e2d9d8bbd1b9e1a698153577cf5734.jpg)
342
+ Figure 19: Comparing CartoonX on random ImageNet samples and VGG16.
343
+
344
+ ![](images/3768315f4f3a61a9c20715449365266afdeba73a93b2ac05bad3c5f3932bdd09.jpg)
345
+ Figure 20: Comparing CartoonX on random ImageNet samples and VGG16.
346
+
347
+ ![](images/0c28c40ebfbba6ad0603ee8dcfcf832c0f8224baf75b313d925f83ad2d28135b.jpg)
348
+ Figure 21: Failures of CartoonX.
md/dev/SF9o3-yP1WR/SF9o3-yP1WR.md ADDED
@@ -0,0 +1,485 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ROBUST AND PERSONALIZED FEDERATED LEARNING WITH SPURIOUS FEATURES: AN ADVERSARIAL APPROACH
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ A common approach for personalized federated learning is fine-tuning the global machine learning model to each local client. While this addresses some issues of statistical heterogeneity, we find that such personalization methods are often vulnerable to spurious features, leading to bias and diminished generalization performance. However, debiasing the personalized models under spurious features is difficult. To this end, we propose a strategy to mitigate the effect of spurious features based on our observation that the global model in the federated learning step has a low accuracy disparity due to statistical heterogeneity. Then, we estimate and mitigate the accuracy disparity of personalized models using the global model and adversarial transferability in the personalization step. We theoretically establish the connection between the adversarial transferability and the accuracy disparity between the global and personalized models. Empirical results on MNIST, CelebA, and Coil20 datasets show that our method reduces the accuracy disparity of the personalized model on the bias-conflicting data samples from $1 5 . 1 2 \%$ to $2 . 1 5 \%$ , compared to existing personalization approaches, while preserving the benefit of enhanced average accuracy from fine-tuning.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Federated learning (FL) is a leading framework for clients to collaboratively train a shared global machine learning (ML) model without releasing their local private datasets (McMahan et al., 2017; Kairouz et al., 2019). The jointly trained global model could be further fine-tuned on each client’s local dataset to produce personalized models (Fallah et al., 2020; T. Dinh et al., 2020; Li et al., 2021). While existing theoretical and empirical results highlight how personalized models improve accuracy on local data, few works consider what features the personalized models learn from the local dataset. Our motivating hypothesis is that not all local features are beneficial.
12
+
13
+ For example, consider a gender prediction task using face images, where the ML model learns to predict gender based on hair color because females are more likely to have blond hair (Sagawa et al., 2020). In this case, the hair color is called a spurious feature because it only statistically correlates with the gender on biased-aligned samples but not necessarily on the overall population. Thus, the accuracy of a model that relies on spurious features such as hair color is likely to drop significantly on bias-conflicting samples where the spurious correlation does not hold, e.g., for blond male images (Sagawa et al., 2020). This paper calls the accuracy difference of an ML model on the dataset with spurious features and the dataset without spurious features accuracy disparity. More broadly, the accuracy disparity caused by spurious features leads to issues in both fairness (McNamara et al., 2019; Zhao & Gordon, 2019; Agarwal et al., 2019; Chi et al., 2021), i.e., racial bias (Khani & Liang, 2021) and robustness, i.e., accuracy decrease under distribution shift (Zhao et al., 2019; Koh et al., 2021). Compared to the global model, because of the local fine-tuning, the personalized models are more vulnerable to spurious features and have a larger accuracy disparity.
14
+
15
+ Empirically, we observe that the typical non-i.i.d. data distributions in FL settings reduce the accuracy disparity of the global model. One potential explanation is that the statistical heterogeneity (Wang et al., 2021) under spurious features across users is larger than that of non-spurious features. As a result, the aggregation operation in the central server averages out the diverse shifts under the spurious features (Figure 1) so that the global model becomes more robust against spurious features on the benchmark datasets. On the other hand, the local fine-tuning step will result in a personalized model that entangles spurious features and becomes biased. Hence, it remains a key challenge how to debias the personalized models.
16
+
17
+ ![](images/943c4ccf76f89236f1cc76646f1d32ca12167db90f7fe554926cddd36b005ff0.jpg)
18
+ Figure 1: The statistical heterogeneity of spurious features leads to diverse gradients. The statistical heterogeneity leads to a global ML model with a low accuracy disparity in a federated learning setting because the aggregation step in the central server averages out the gradients resulted from local spurious features.
19
+
20
+ Various methods (Wang et al., 2019; Sagawa et al., 2020; Liu et al., 2021) have been developed to disentangle spurious features from ML models, but few can be easily applied to personalized models under the federated learning setting. The main reason lies in their reliance on bias-conflicting samples. The bias-conflicting samples can be rare. For example, in the CelebA dataset, only around 1.7k samples are bias-conflicting out of more than170k samples. If we distribute the CelebA dataset across users, nearly half do not have any bias-conflicting samples. Prior work (Li & Wang, 2019) has tried using a global proxy dataset for training FL models. However, a global proxy dataset may not characterize the local samples well. Furthermore, estimating the accuracy disparity of the personalized model becomes difficult without access to bias-conflicting samples.
21
+
22
+ To approach this problem, we propose a novel method to reduce the accuracy disparity of personalized models. Our proposed method does not rely on the bias-conflicting samples, e.g., blond male images in the aforementioned task of gender prediction, which are often rare and may not be available for every user. Instead, inspired by prior works (Tramer et al., 2017; Liang et al., 2021) on the \` transferability of adversarial examples, we use the global model as a reference and the adversarial transferability between the global model and the personalized models as a proxy to estimate the accuracy disparity of the personalized models. The intuition is that if two ML models use disjoint subsets of features, the adversarial examples that one ML model generates do not transfer to the other ML model. Based on this intuition, we propose the following hypothesis:
23
+
24
+ If the personalized models entangle spurious features (thus increasing the accuracy disparity), the adversarial examples generated by the global model (that uses non-spurious features) do not transfer to the personalized models.
25
+
26
+ Empirically, we show that the adversarial transferability between the global and personalized models strongly correlates with the accuracy disparity between the global and personalized models (Section 4), validating our hypothesis. We further theoretically connect the adversarial transferability to the accuracy disparity (Section 5). Based on the empirical observations and theoretical results, we develop a method that enforces adversarial transferability between the global and the personalized models to reduce the accuracy disparity of personalized models (Section 6). Our contributions are summarized as follows:
27
+
28
+ • We empirically evaluate the accuracy disparity of the global and personalized models in a federated learning setting with spurious features, highlighting a risk of existing personalization methods.
29
+ • We design a method to estimate the accuracy disparity of the personalized models, based on the low accuracy disparity global model and the adversarial transferability between the global and personalized models.
30
+
31
+ • We theoretically connect the adversarial transferability and the accuracy disparity of the global and personalized models. • We develop a methods to reduce the accuracy disparity of personalized models by enforcing the adversarial transferability between the global and personalized models.
32
+
33
+ Empirically, we conduct extensive experiments to validate the effectiveness of the proposed methods in mitigating accuracy disparity under the FL setting. Our experiments on MNIST (Deng, 2012), CelebA (Liu et al., 2015), and Coil20 (Nene et al., 1996) datasets show that the proposed approach reduces the accuracy disparity of personalized models from $1 5 . 1 2 \%$ to $2 . 1 5 \%$ , which is closer to that of the global model $( - 0 . 6 3 \% )$ . Our method also preserves the benefit of the enhanced average accuracy from fine-tuning, resulting in $3 . 4 3 \%$ accuracy improvement on the biased test set and $0 . 8 5 \%$ accuracy improvement on the biased-conflicting test set.
34
+
35
+ # 2 RELATED WORK
36
+
37
+ Personalized Federated Learning Fine-tuning is typical for personalization methods. The metalearning-based method first trains a global model and fine-tunes the global model locally (Fallah et al., 2020). Other methods using multi-task learning (Li et al., 2021) or Moreau envelopes (T. Dinh et al., 2020) have an interpretation as fine-tuning the local model along with training the global model. Fine-tuning is also compatible with clustering-based method (Ghosh et al., 2020).
38
+
39
+ Debiasing ML Models A few prior works (Li & Vasconcelos, 2019; Sagawa et al., 2020) utilize group labels, which might require human annotation, to debias ML models. For example, the group distributional robust optimization (DRO) method (Sagawa et al., 2020) aims to optimize the worst-case error rate of ML models across different (often manually annotated) groups. Some groups contain bias-conflicting samples while others do not. Residual learning-based methods (He et al., 2019; Nam et al., 2020; Liu et al., 2021) train a biased ML model and up-weight the residual, which mainly contains bias-conflicting samples that the biased ML model mis-predicts. Chi et al. (2021) aims to mitigate the accuracy disparity in regression problems via learning the appropriate representations. However, all these methods rely on the explicit access to the bias-conflicting samples, making them difficult to apply on personalized federated learning, where bias-conflicting samples may not be accessible for every client.
40
+
41
+ # 3 PRELIMINARIES
42
+
43
+ Definitions and Notation A data sample is a vector $\pmb { x } = [ \pmb { x } _ { r } , \pmb { x } _ { s } ]$ , where ${ \mathbf { \mathcal { x } } } _ { r }$ corresponds to the robust and non-spurious features and $\mathbf { \delta } _ { \mathbf { \mathcal { X } } _ { s } }$ are the spurious features. $d _ { s }$ is the dimension of spurious features. Let $y$ be a label, and define $\ell : \mathcal { V } \times \mathcal { V } \mathbb { R }$ to be a $\lambda$ -smooth, twice differentiable loss function and $\mathcal { L } ( f , \mathcal { D } ) = \mathbb { E } _ { ( \pmb { x } , \pmb { y } ) \sim \mathcal { D } } [ \ell ( f ( \pmb { x } ) , \pmb { y } ) ]$ to be the empirical risk. ${ \pmb w } _ { g }$ and ${ \pmb w } _ { p }$ are the weights for the global model $f _ { g } : \mathcal { X } \xrightarrow { } \mathcal { Y }$ and personalized model $f _ { p } : \mathcal { X } \mathcal { Y }$ , respectively. $\gamma$ is the ratio between the gradient norms of the global and personalized models, k∇x\`(fg(x),y)kk∇x\`(fp(x),y)k . Let $\operatorname { s u p p } ( \mathcal { D } )$ be the support of distribution $\mathcal { D }$ . We define a global data distribution $\mathcal { D } _ { g }$ , a biased local data distribution $\mathcal { D } _ { b }$ , and assume a bias-conflicting local data distribution $\mathcal { D } _ { b c }$ . We define the “pseudo-gradient” as the difference between the updated local model and the global model from the previous round (sometimes we will use the term “gradient” when it is clear from context). $\langle \cdot , \cdot \rangle$ denotes an inner product of two vectors and $\cdot \frown \cdot$ denotes a concatenation of two vectors. $\theta$ is the angle between $\nabla _ { \pmb { x } } \hat { \ell ( f _ { g } ( \pmb { x } ) , y ) }$ and $\nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y )$ . $\theta _ { g }$ is the angle between $\nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y )$ and $\nabla _ { \pmb { x } _ { r } } \ell ( f _ { g } ( \pmb { x } ) , y ) \frown \pmb { 0 }$ , which measures the entanglement of the global model to spurious features.
44
+
45
+ Training and Personalization Methods We train the global model using the federated averaging algorithm (McMahan et al., 2017), which learns a model $f : \mathcal { X } \mathcal { Y }$ that minimizes: $\begin{array} { r } { \bar { \mathcal { L } } ( f , \mathcal { D } _ { g } ) \bar { = } } \end{array}$ $\begin{array} { r } { \sum _ { i = 1 } ^ { N } | \mathcal { D } _ { b _ { i } } | / | \mathcal { D } _ { g } | \cdot \mathbb { E } _ { \mathbf { x } , y \sim \mathcal { D } _ { b _ { i } } } \ell ( f ( \mathbf { x } ) , y ) . } \end{array}$ , where $N$ is the number of clients, $\mathcal { D } _ { b _ { i } }$ is the biased local dataset for client $i$ , and $\mathcal { D } _ { g } = \cup _ { i = 1 } ^ { N } \mathcal { D } _ { b _ { i } }$ is the global dataset. When the global model $f _ { g }$ converges, $f _ { g }$ will be sent to local clients for further fine-tuning by minimizing $\mathbb { E } _ { \pmb { x } , \pmb { y } \sim \mathcal { D } _ { b _ { i } } } \ell ( f ( \pmb { x } ) , \breve { y } )$ .
46
+
47
+ Adversarial Examples and Transferability We can generate an adversarial example $\mathbf { \Delta } \mathbf { x } _ { a d v }$ given data sample $_ { \textbf { \em x } }$ with label $y$ by solving:
48
+
49
+ $$
50
+ \pmb { x } _ { a d v } = \underset { \| \pmb { x } ^ { \prime } - \pmb { x } \| \leq \epsilon } { \arg \operatorname* { m a x } } \ell ( f ( \pmb { x } ^ { \prime } ) , y ) ,
51
+ $$
52
+
53
+ ![](images/7b06936813e961aed7b62c6236cf3173dc2923b7daa781525aa9d4e1ed242e65.jpg)
54
+ Figure 2: Datasets with spurious features. The object color spuriously correlates with the label in MNIST (a) and Coil20 (c) datasets. The hair color spuriously correlates with gender in the CelebA dataset (b).
55
+
56
+ ![](images/f5880ea92afd42c3fca9cb12c8c9b0477cb78da6832f2ceb437f243eb43a8cdb.jpg)
57
+ Figure 3: The accuracy of ML models on Biased Dataset and Bias-Conflicting Dataset under centralized and federated training settings. In the centralized setting, an ML model is trained by a single dataset that contains all the samples with a fixed spurious correlation. The global models in the federated setting achieve smaller accuracy disparities between biased and bias-conflicting datasets.
58
+
59
+ where $f$ is the victim ML model, and $\epsilon$ is the attack budget. In this example, we consider the $L _ { 2 }$ attacks, but extensions to general $L _ { p }$ attacks are straightforward. We say an adversarial example to be transferable if it also fools another ML model (e.g., a personalized model) other than the original victim model $f$ (e.g., the global model).
60
+
61
+ # 4 AN EMPIRICAL STUDY WITH SPURIOUS FEATURES
62
+
63
+ To gain some insights into the problem, we first perform an empirical study on the accuracy disparity of the global and personalized models in an FL setting. In this study, the personalization method is fine-tuning. Our results highlight the risk of existing fine-tuning-based personalization methods and the difficulty of mitigating the risk. We also highlight the correlation between the adversarial transferability and the accuracy disparity between the global and personalized models. We provide additional theoretical analysis in Section 5 to support the observed correlation. The spurious features in the empirical study are as follows.
64
+
65
+ Spurious Features We consider color as the spurious feature for the MNIST, CelebA, and Coil20 datasets. In the MNIST and Coil20 datasets, we manually color the objects according to their labels to create spurious correlations, as Figure 2 shows. The spurious correlations vary across clients for the MNIST and Coil20 data (e.g., the red color correlates with label zero on the first client and with label one on the second client) to create additional statistical heterogeneity. In the CelebA dataset, the hair color attribute correlates with the gender label. We assign disjoint subsets of celebrities to different users, which naturally increases statistical heterogeneity for the spurious correlation.
66
+
67
+ # 4.1 STATISTICAL HETEROGENEITY REDUCES ACCURACY DISPARITY
68
+
69
+ Figure 3 shows the accuracy disparity of ML models on biased and bias-conflicting test sets. Compared to the models trained in the centralized setting, where the spurious correlations are fixed, the accuracy disparity of models trained in the federated setting decreased significantly. These empirical results suggest that the global model in FL is more robust to spurious features if the spurious features are non-i.i.d. across clients.
70
+
71
+ To explain this observation, consider the relationship between the gradient directions and the learned features. For the spurious features, its correlation with the label may change across clients. As an example, in some users’ local datasets, the blond hair does not correlate with the gender label because the dataset does not contain any blond female image or the dataset has blond male images, as visualized in Figure 1a. Therefore, the gradient directions for the spurious features are diverse across clients, as shown in Figure 1b. The divergence between the gradient directions, as a consequence, makes learning spurious features difficult. In contrast, the non-spurious features, e.g., shape features, are more consistent across clients, leading to a more consistent gradient direction.
72
+
73
+ ![](images/0b36ed6b6b942aaaec3bb73437450c7587b9b11c40d452d532ccb00ba6a9f59e.jpg)
74
+ Figure 4: The accuracy of personalized model on Biased Dataset (Acc B) and Bias-Conflicting Dataset (Acc BC) with increasing fine-tuning batches. The personalized models entangle spurious features and increase accuracy disparities between biased and bias-conflicting datasets.
75
+
76
+ ![](images/97c373f19c43124da1b887c5b003ab07e32e8d52876ec7a861304d23fb4648dc.jpg)
77
+ Figure 5: The accuracy disparity of personalized models on biased dataset and bias-conflicting dataset (Acc B - Acc BC) and their accuracy on adversarial examples (Acc Adv). As the personalized models entangle spurious features and increase the accuracy disparity, the accuracy of the personalized models on adversarial examples increases, which indicates the adversarial transferability between the global and personalized models decreases.
78
+
79
+ # .2 PERSONALIZATION MAY EXACERBATE ACCURACY DISPARITY
80
+
81
+ Although the global model in the federated setting has a lower accuracy disparity than in the centralized setting, the advantage could vanish during the personalization step.
82
+
83
+ The Personalized Model Entangles Spurious Features As can be observed in Figure 4, the accuracy first increases and decreases on the MNIST bias-conflicting test set and slowly decreases on Coil20. These two observations indicate that the personalized model entangles spurious features and exacerbates the accuracy disparity in a few batches. Although in principle, one may resort to early stopping, this is not feasible when the bias-conflicting dataset is unavailable or scarce.
84
+
85
+ # 4.3 ADVERSARIAL TRANSFERABILITY INDICATES ACCURACY DISPARITY
86
+
87
+ Because the bias-conflicting test set is often unavailable, it is infeasible to directly measure the accuracy disparity across personalized models. To this end, in this section, we focus on methods that implicitly measure the accuracy disparity and determine whether the personalized models entangle spurious features. Following our hypothesis in Section 1, we consider using the adversarial transferability between the global and personalized models as a proxy for the accuracy disparity measurement. Figure 5 plots the accuracy disparity and the adversarial transferability during finetuning. As the accuracy disparity of the personalized models increases and drifts away from that of the global model, the adversarial transferability between the global and personalized models decreases. This result empirically validates our hypothesis.
88
+
89
+ # 5 THEORETICAL INSIGHTS
90
+
91
+ This section presents our theoretical result that supports our hypothesis in Section 1 and the experimental results in Section 4.3. Our theoretical result applies the loss, which has similar behavior to the accuracy as is shown in the empirical results in Section 7. Before we proceed, some additional definitions and notations are needed for the presentation, and we provide a table summarizing all the notations used in Appendix A to ease the reading. Then, we connect both the loss disparity and the adversarial transferability to the angle between the gradients of the global and personalized models. In what follows, we shall show an upper bound of the loss disparity of a personalized model, which consists of the adversarial transferability between the global and personalized models and an indicator of the entanglement of the global model to spurious features.
92
+
93
+ # 5.1 MORE DEFINITIONS AND NOTATION
94
+
95
+ We define natural perturbation $\pmb { \Delta }$ to model the distribution shift between the bias-conflicting $\mathcal { D } _ { b c }$ and biased $\mathcal { D } _ { b }$ . $\pmb { \Delta }$ could change a bias-aligned sample to a corresponding bias-conflicting sample. The distribution ${ \mathcal { D } } _ { \Delta | x }$ of the natural perturbation $\pmb { \Delta }$ conditions on the data sample $_ { \textbf { \em x } }$ . Formally, for any $\pmb { x } \in \mathcal { R } ^ { \mathrm { d } }$ , we have: $\begin{array} { r } { \operatorname* { P r } _ { \pmb { x } \sim \mathcal { D } _ { b c } } ( \pmb { x } ) = \sum _ { \pmb { x } ^ { \prime } \in \mathcal { R } ^ { \mathrm { d } } , \pmb { \Delta } \in \mathcal { R } ^ { \mathrm { d } } } \mathbf { 1 } _ { \{ \pmb { x } = \pmb { x } ^ { \prime } + \pmb { \Delta } \} } \cdot \operatorname* { P r } _ { \pmb { x } ^ { \prime } \sim \mathcal { D } _ { b } } ( \pmb { x } ^ { \prime } ) \cdot \operatorname* { P r } _ { \pmb { \Delta } \sim \mathcal { D } _ { \Delta } | \pmb { x } ^ { \prime } } ( \pmb { \Delta } ) . } \end{array}$ .
96
+
97
+ Running Example For a non-blond male image $_ { \textbf { \em x } }$ , we could draw a natural perturbation $\pmb { \Delta }$ from ${ \mathcal { D } } _ { \Delta | { \boldsymbol { x } } }$ that change the hair color in $_ { \textbf { \em x } }$ to blond. That is saying, $\pmb { x } + \pmb { \Delta }$ is a blond male image. Iteratively drawing data samples from the biased dataset and applying the sampled natural perturbations to the data samples result in a dataset with bias-conflicting samples.
98
+
99
+ Another perturbation to consider is the adversarial perturbation $\delta _ { f , \epsilon } = \pmb { x } _ { a d v } - \pmb { x }$ that is generated using $f$ with budget $\epsilon$ . Plugging the definition of $\delta _ { f , \epsilon }$ into Eq. (1), we have $\begin{array} { r } { \delta _ { f , \epsilon } = \arg \operatorname* { m a x } _ { \| \delta \| \leq \epsilon } \ell ( f ( \pmb { x } + } \end{array}$ $\delta ) , y )$ . Since the budget $\epsilon$ is small, we could approximate the loss function $\ell$ using the first-order gradient: $\begin{array} { r } { \delta _ { f , \epsilon } = \arg \operatorname* { m a x } _ { \| \delta \| \leq \epsilon } \nabla _ { \pmb { x } } \ell ( f ( \pmb { x } ) , y ) ^ { \top } \delta = \epsilon \cdot \frac { \nabla _ { \pmb { x } } \ell ( f ( \pmb { x } ) , y ) } { \| \nabla _ { \pmb { x } } \ell ( f ( \pmb { x } ) , y ) \| } } \end{array}$ (Miyato et al., 2018; Liang et al., 2021). With the adversarial perturbation, we define the adversarial transferability loss:
100
+
101
+ \` ${ } _ { t r a n s } ( f _ { g } , f _ { p } , \mathbf { x } , y ) = \Big ( \ell ( f _ { g } ( \mathbf { x } + \delta _ { f _ { g } , \epsilon } ) , y ) - \ell ( f _ { g } ( \mathbf { x } ) , y ) \Big ) - \Big ( \ell ( f _ { p } ( \mathbf { x } + \delta _ { f _ { g } , \epsilon } ) , y ) - \ell ( f _ { p } ( \mathbf { x } ) , y ) \Big ) ,$ which indicates the effectiveness of the adversarial perturbation generated using the global model applied to the personalized models.
102
+
103
+ # 5.2 LOSS DISPARITY AND ADVERSARIAL TRANSFERABILITY
104
+
105
+ With the definitions of natural and adversarial perturbations, this section shows that both the loss disparity and the adversarial transferability connect to an angle $\theta$ . Next, we outline the assumption:
106
+
107
+ Assumption 1. The distribution shift does not exacerbate the entanglement of a model $f$ to spurious features $\mathbf { \delta } _ { \mathbf { \mathcal { X } } _ { s } }$ , which is measured by $\dot { \nabla } _ { { \pmb x } _ { s } } \ell ( f ( { \pmb x } ) , y )$ :
108
+
109
+ $$
110
+ \mathbb { E } _ { ( \pmb { x } , y ) \sim \mathcal { D } _ { b } , \Delta \sim \mathcal { D } _ { \Delta | \pmb { x } , y } } [ \int _ { \alpha = 0 } ^ { 1 } \langle \nabla _ { \pmb { x } _ { s } } \ell \big ( f ( \pmb { x } + \alpha \cdot \Delta ) , y ) , \mathbf { 1 } \big ) \mathrm { d } \alpha ] \le \mathbb { E } _ { ( \pmb { x } , y ) \sim \mathcal { D } _ { b } } [ \langle \nabla _ { \pmb { x } _ { s } } \ell \big ( f ( \pmb { x } ) , y ) , \mathbf { 1 } \big ) ] .
111
+ $$
112
+
113
+ Under Assumption 1, the following Lemmas hold.
114
+
115
+ Lemma 1. Under Assumption $I$ , let $\Delta$ be the natural perturbation, $\theta$ be the angle between $\nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y )$ and $\nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y )$ , $\theta _ { g }$ be the angle between $\nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y )$ and $\nabla _ { \pmb { x } _ { r } } \ell ( f _ { g } ( \pmb { x } ) , y ) $ 0, and γ $b e ~ { \frac { \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , \pmb { y } ) \| } { \| \nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , \pmb { y } ) \| } }$ , we have:
116
+
117
+ $$
118
+ \begin{array} { r l } & { \mathcal { L } ( f _ { p } , \mathcal { D } _ { b c } ) - \mathcal { L } ( f _ { p } , \mathcal { D } _ { b } ) = \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { b } , \Delta \sim \mathcal { D } _ { \Delta | \alpha } } [ \displaystyle \int _ { \alpha = 0 } ^ { 1 } \left. \nabla _ { \alpha _ { s } } \ell ( f _ { p } ( x + \alpha \cdot \Delta ) , y ) , \mathbf { 1 } \right. \mathrm { d } \alpha ] } \\ & { \quad \quad \quad < \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { b } , \Delta \sim \mathcal { D } _ { \Delta | \alpha } } [ \displaystyle \frac { \sqrt { d _ { s } } } { \gamma } \cdot \| \nabla _ { \mathbf { x } } \ell ( f _ { g } ( x ) , y ) \| \cdot ( \sin \theta _ { g } + \sin \theta ) ] } \end{array}
119
+ $$
120
+
121
+ Lemma 1 connects the loss disparity to $\theta$ . The $\theta _ { g }$ , differing from $\theta$ , is an indicator of the entanglement of the global model to spurious features and is a constant during the personalization step.
122
+
123
+ Lemma 2. Let $\epsilon$ be the attack budget, $\theta$ be the angle between $\nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y )$ and $\nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y )$ , $\gamma$ be $\frac { | | \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) | | } { | | \nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) | | }$ , and the loss function $\ell : \mathcal { V } \times \mathcal { V } \mathbb { R }$ be $\lambda$ -smooth, twice differentiable, we have
124
+
125
+ $$
126
+ \begin{array} { l } { \displaystyle \epsilon \cdot \| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \| \cdot ( 1 - \frac { 1 } { \gamma } \cdot \mathrm { c o s } \theta ) - \lambda \cdot \epsilon ^ { 2 } \leq \ell _ { t r a n s } ( f _ { g } , f _ { p } , x , y ) } \\ { \displaystyle \leq \epsilon \cdot \| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \| \cdot ( 1 - \frac { 1 } { \gamma } \cdot \mathrm { c o s } \theta ) + \lambda \cdot \epsilon ^ { 2 } } \end{array}
127
+ $$
128
+
129
+ Lemma 2 connects the adversarial transferability loss to $\theta$ . In the following analysis, we connect the loss disparity to adversarial transferability via $\theta$ .
130
+
131
+ # 5.3 A GENERALIZATION UPPER BOUND
132
+
133
+ We now present an upper bound of the disparity $\mathcal { L } ( f _ { p } , \mathcal { D } _ { b c } ) - \mathcal { L } ( f _ { p } , \mathcal { D } _ { b } )$ . The main idea is to derive an upper bound of $\| \bar { \nabla _ { \mathbf x } } \ell ( f _ { g } ( \mathbf x ) , y ) \| \cdot \sin \bar { \theta }$ in Eq. (2) from Eq. (3).
134
+
135
+ Theorem 3. Let $\gamma _ { \mathrm { m i n } }$ be the minimum of $\gamma$ , with Lemmas 1-2, we have:
136
+
137
+ $$
138
+ \begin{array} { l } { \displaystyle \mathcal { L } ( f _ { p } , \mathcal { D } _ { b c } ) - \mathcal { L } ( f _ { p } , \mathcal { D } _ { b } ) < \sqrt { d _ { s } } \cdot \Big ( ( \frac { \sin \theta _ { g } + \sqrt { 2 } } { \gamma _ { \mathrm { m i n } } } - 1 ) \cdot \mathbb { E } _ { ( { \pmb x } , { y } ) \sim \mathcal { D } _ { b } } [ \| \nabla _ { \pmb x } \ell ( f _ { g } ( { \pmb x } ) , { y } ) \| ] } \\ { \displaystyle \qquad + \frac { 1 } { \epsilon } \cdot \mathbb { E } _ { ( { \pmb x } , { y } ) \sim \mathcal { D } _ { b } } [ \ell _ { t r a n s } ( f _ { g } , f _ { p } , { \pmb x } , { y } ) ] + \lambda \cdot \epsilon \Big ) } \end{array}
139
+ $$
140
+
141
+ Theorem 3 suggests (1) debiasing the global model $f _ { g }$ , whose entanglement to spurious features is measured by $\theta _ { g }$ , and (2) enforcing the adversarial transferability between $f _ { g }$ and $f _ { p }$ help reducing the loss disparity of personalized models. For the constants $\gamma _ { \mathrm { m i n } }$ and $\lambda$ , we further explore their impacts in the following section and Appendix D.1, respectively.
142
+
143
+ # 6 METHODS
144
+
145
+ With the empirical and theoretical results in Sections 4.3 and 5, respectively, it is natural to ask if enforcing the adversarial transferability in the personalization step reduces the accuracy disparity. In this section, we first introduce adversarial examples to the personalization step as a regularization term added to the original loss function, aiming to enforce the adversarial transferability. However, the accuracy disparity still increases, albeit much slower, even if the adversarial transferability remains high. One possible reason is that the personalized model increases its gradient norm, which helps preserve the adversarial transferability but does not prevent the personalized model from entangling spurious features. To this end, we add an $L _ { 2 }$ regularization term to the loss function, aligning the gradient norms of the global and personalized models. Combing these two methods addresses the accuracy disparity. Both methods are relatively light-weight from a computational perspective.
146
+
147
+ # 6.1 ENFORCING ADVERSARIAL TRANSFERABILITY
148
+
149
+ We enforce that global and personalized models make consistent predictions on adversarial examples, such that adversarial examples transfer from one to the other.
150
+
151
+ Generating Adversarial Examples The projected gradient descent (PGD) attack (Madry et al., 2018) is an effective attack method that uses the neural network’s first-order gradient, and is easy to tion compute. Additionally, . The attack solves $t + 1$ , the adversarial example is: $\begin{array} { r } { \pmb { x } _ { a d v } ^ { t + 1 } = \mathrm { P r o j } _ { \| \pmb { x } _ { a d v } - \pmb { x } \| \leq \epsilon } ( \pmb { x } + \alpha \cdot \mathrm { s i g n } ( \nabla _ { \pmb { x } _ { a d v } ^ { t } } \ell ( f _ { g } ( \pmb { x } _ { a d v } ^ { t } ) , y ) ) ) , } \end{array}$ $\begin{array} { r } { \pmb { x } _ { a d v } = \arg \operatorname* { m a x } _ { \| \pmb { x } ^ { \prime } - \pmb { x } \| \leq \epsilon } \ell ( f ( \pmb { x } ^ { \prime } ) , y ) } \end{array}$ iteratively. At iterawhere Proj is a projection operator.
152
+
153
+ Enforcing Consistent Predictions Both the global model $f _ { g }$ and the personalized model $f _ { p }$ take the adversarial example $\mathbf { { x } } _ { a d v }$ as input and output $z _ { g }$ and $z _ { p }$ from their last layers, respectively. We enforce the adversarial transferability by adding the following regularization term, which maximizes the cross-entropy between $z _ { g }$ and $z _ { p }$ . Since the global model $f _ { g }$ is fixed as a reference in the personalization step and its low accuracy disparity is desirable, we use $z _ { g }$ as the ground-truth:
154
+
155
+ $$
156
+ R _ { a d v } ( z _ { g } , z _ { p } ) = \sum _ { i = 1 } ^ { K } [ z _ { g _ { i } } \cdot \log ( z _ { p _ { i } } ) + ( 1 - z _ { g _ { i } } ) \cdot \log ( 1 - z _ { p _ { i } } ) ] ,
157
+ $$
158
+
159
+ where $K$ is the number of classes. The local model has access to the global model, so there is no additional communication overhead for implementing this regularization. The adversarial examples are computed using the global model once for all. The computation only needs a few back-propagations, much less than training the global model.
160
+
161
+ # 6.2 ALIGNING GRADIENT NORMS
162
+
163
+ In Eq. (3), we have seen that the adversarial transferability loss depends not only on the angle $\theta$ , which connects the transferability to the disparity but also on $\begin{array} { r } { \gamma : = \frac { \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , \dot { \boldsymbol { y } } ) \| } { \| \nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , \boldsymbol { y } ) \| } } \end{array}$ . A small $\gamma$ indicates that the personalized model increases its gradient norm. Then, the personalized model could entangle the spurious features and increase $\theta$ without decreasing the adversarial transferability.
164
+
165
+ To prevent $\gamma$ from decreasing, we employ a simple and effective strategy by adding an $L _ { 2 }$ regularization term $R _ { L _ { 2 } } = \| \pmb { w } _ { g } - \pmb { w } _ { p } \| ^ { 2 }$ to the loss function. The motivation behind the $L _ { 2 }$ term is straightforward: if two models have similar weights, they have similar gradients. Empirical results in Appendix D.2 show the effectiveness of the $L _ { 2 }$ term in controlling $\gamma$ . Although prior works (Li et al., 2020; T. Dinh et al., 2020; Li et al., 2021) have explored similar regularization methods, we develop the regularization term from a different perspective.
166
+
167
+ # 7 EXPERIMENTS
168
+
169
+ This section presents our experimental results, demonstrating that our method reduces the accuracy disparity. We also show that the benefit of enhanced average accuracy from fine-tuning is preserved.
170
+
171
+ # 7.1 SETTING
172
+
173
+ Data Partition We distribute the MNIST and Coil20 dataset across 50 clients where each client have 5 different classes. The local dataset on each client is further partitioned to train/validation/test set with a ratio of 72:8:20, following prior work (Li et al., 2021). We make two data partitions for CelebA: CelebA R using a real partition and CelebA S using a synthetic partition, both have 508 clients. In both CelebA partitions, each client represent a disjoint set of celebrity (Li et al., 2021).
174
+
175
+ Due to the limited space, we further detail the data partition in Appendix C.1, report the hyperparameters in Appendix C.2, and list the neural network architecture in Appendix C.3.
176
+
177
+ # 7.2 THE EFFECTIVENESS OF PROPOSED METHODS
178
+
179
+ We conduct an ablation study on the MNIST dataset. Figures 6b and 6f demonstrate the effectiveness of enforcing adversarial transferability. However, the accuracy and loss disparity still increase during personalization, which is potentially caused by the gradient norm issue (Section 6.2). Aligning the gradient norms by applying the $L _ { 2 }$ regularization term while enforcing adversarial transferability address the accuracy and loss disparity as Figures 6d and 6h show, respectively. Figure 6c and 6g further show that applying the $L _ { 2 }$ regularization term alone does not address the accuracy or loss disparity. Compared to naive fine-tuning, which is reported in Figures 6a and 6e, our method mitigates the accuracy and loss disparities by $\sim 5 0 \%$ .
180
+
181
+ # 7.3 ANALYSIS
182
+
183
+ We compare our method to no personalization (Global), naive fine-tuning (FT), Ditto (Li et al., 2021), up-weighting (UW) (Sagawa et al., 2020), and just train twice (JTT) (Liu et al., 2021). The up-weighting method is implemented via sampling bias-aligned and bias-conflicting samples with equal probability (Sagawa et al., 2020). Up-weighting and JTT are not applicable to Coil20 due to the lack of bias-conflicting samples. We use the local finetuning version of the Ditto solver because the local finetuning solver performs fewer local updates than that of the joint optimization solver and therefore entangles spurious features less. Each experiment is repeated 9 times with 3 random seeds for the federated learning step and 3 for the personalization step. We select models using the validation accuracy minus the decrease of adversarial transferability and using the validation accuracy for other baseline and competitor methods.
184
+
185
+ Tables 1 shows the main result. Our method reduces the accuracy disparity of personalized models from $1 5 . 1 2 \%$ to $2 . 1 5 \%$ , compared to other personalization methods. Our method also preserves the enhanced average accuracy from fine-tuning, resulting in $3 . 4 3 \%$ accuracy improvement on the biased test set and $0 . 8 \hat { 5 } \%$ improvement on the biased-conflicting test set compared to the global model. In contrast, the naive fine-tuning method sacrifices the accuracy on the bias-conflicting test set by up to $1 4 . 3 \%$ and increase the accuracy disparity by $1 5 . 1 2 \%$ . We also find that our methods outperform the supervised up-weighting method and the unsupervised JTT method, which increase the average accuracy disparity to $7 . 5 6 \%$ and $1 7 . 7 6 \%$ , respectively. One possible reason is that the diversity of the up-weighted bias-conflicting samples are small. Therefore, the neural network could memorize them instead of discarding spurious features. Appendix D.3 further shows empirical results that support our analysis.
186
+
187
+ ![](images/8a3e08843a3297b97a6b9f6be0798ecd6221a8e2a75417be1c756020cfa38c53.jpg)
188
+ Figure 6: The accuracy disparity (Acc B - Acc BC) and adversarial transferability accuracy (Acc Adv), and the loss disparity (Loss BC - Loss B) and adversarial transferability loss (MAX Loss Adv - Loss Adv) with different methods. Combining the two proposed methods addresses the accuracy and loss disparities. Acc BC/Loss BC and Acc B/Loss B are the accuracy/losses on the bias-conflicting and biased test sets, respectively. Acc Adv/Loss Adv is the accuracy/loss on adversarial examples. Acc Adv and MAX Loss Adv - Loss Adv, which measures the decrease of Loss Adv, indicate the decrease of adversarial transferability.
189
+
190
+ Table 1: Accuracy of personalized Models on Biased Test Set (Acc B) and Bias-Conflicting Test Set (Acc B). Our proposed method achieves the lowest accuracy disparity $( 2 . 1 5 \% )$ compared to other personalization methods $( 1 5 . 1 2 \% / 1 5 . 3 8 \% )$ , and $3 . 4 3 \%$ accuracy improvement on the biased test set and $0 . 8 5 \%$ improvement on the biased-conflicting test set compared to the global model.
191
+
192
+ <table><tr><td rowspan="2">Method</td><td colspan="2">MNIST</td><td colspan="2">CelebA_S</td><td colspan="2">CelebAR</td></tr><tr><td>Acc_B Acc_BC</td><td>Acc_B</td><td>Acc_BC</td><td>Acc_B Acc_BC</td><td>Acc_B</td><td>Acc_BC</td></tr><tr><td>Global</td><td>.852 ±2e-4 .847 ±6e-4</td><td>.930</td><td>)± 5e-5.910 ± 3e-4</td><td>.909 ± 6e-5.929</td><td>±5e-5</td><td>1.882 ± 6e-4. .903 ±7e-4</td></tr><tr><td>FT</td><td>.989 ±6e-7.704</td><td>±3e-4</td><td>.952 ± 6e-5 .786 ± 5e-4</td><td>.963 ± 6e-6 .849</td><td>±1e-3</td><td>.931 ± le-4 .891 ±2e-4</td></tr><tr><td>Ditto</td><td>.982 ± 3e-6 .724 ± 1e-3</td><td></td><td>.948 ± 5e-5 .715 ± 5e-4</td><td>.966 ± 1e-5 .884 ± 2e-4</td><td></td><td>.939 ± 4e-5 .897 ± 3e-4</td></tr><tr><td>UW</td><td>.968 ±2e-5.823</td><td>3±7e-4</td><td>930 ± 7e-6 .889 ± 5e-4</td><td>.936 ± 1e-5 .895 ± 4e-4</td><td></td><td>N/A N/A</td></tr><tr><td>JTT</td><td>.985 ± 2e-7 .707</td><td>±6e-5 .952</td><td>2±2e-6.817 1±3e-4</td><td>.956 ± 2e-5 .836 ± 1e-3</td><td></td><td>N/A N/A</td></tr><tr><td>Ours</td><td>.951 ±2e-5.870</td><td>±8e-4 .932</td><td>± 3e-5 .910 ± 2e-4</td><td>.925 ±2e-5.927</td><td>±8e-5</td><td>.901 ± 3e-4 .916 ± 5e-8</td></tr></table>
193
+
194
+ # 8 CONCLUSION
195
+
196
+ In this work, we show the risk of prior federated learning personalization methods with spurious features, which lead to high accuracy disparity between the global and local models. Then, we develop a strategy by enforcing the adversarial transferability between the global and personalized models to reduce the accuracy disparity. Both empirical and theoretical results show that our strategy is effective.
197
+
198
+ # 9 ETHICS STATEMENT
199
+
200
+ Our method mitigates the issue of spurious features, which lead to bias towards minority groups, in personalized federated learning. However, completely disentangling spurious features remains challenging and is an issue for many federated learning methods.
201
+
202
+ # 10 REPRODUCIBILITY STATEMENT
203
+
204
+ Our implementation, including data partition scripts, is based on the FedML library (He et al., 2020), which is open-sourced. The proofs of the theoretical results are in Appendix B. The datasets in our experiments are publicly available. We detail the data partition in Appendix C.1, report the hyper-parameter tuning in Appendix C.2, and list the neural network architecture in Appendix C.3.
205
+
206
+ # REFERENCES
207
+
208
+ Alekh Agarwal, Miroslav Dud´ık, and Zhiwei Steven Wu. Fair regression: Quantitative definitions and reduction-based algorithms. In International Conference on Machine Learning, pp. 120–129. PMLR, 2019.
209
+
210
+ Jianfeng Chi, Yuan Tian, Geoffrey J Gordon, and Han Zhao. Understanding and mitigating accuracy disparity in regression. In International Conference on Machine Learning (ICML), 2021.
211
+
212
+ Li Deng. The mnist database of handwritten digit images for machine learning research. IEEE Signal Processing Magazine, 29(6):141–142, 2012.
213
+
214
+ Alireza Fallah, Aryan Mokhtari, and Asuman Ozdaglar. Personalized federated learning with theoretical guarantees: A model-agnostic meta-learning approach. Advances in Neural Information Processing Systems, 33, 2020.
215
+
216
+ Avishek Ghosh, Jichan Chung, Dong Yin, and Kannan Ramchandran. An efficient framework for clustered federated learning. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 19586–19597. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/ file/e32cc80bf07915058ce90722ee17bb71-Paper.pdf.
217
+
218
+ Chaoyang He, Songze Li, Jinhyun So, Mi Zhang, Hongyi Wang, Xiaoyang Wang, Praneeth Vepakomma, Abhishek Singh, Hang Qiu, Li Shen, Peilin Zhao, Yan Kang, Yang Liu, Ramesh Raskar, Qiang Yang, Murali Annavaram, and Salman Avestimehr. Fedml: A research library and benchmark for federated machine learning. arXiv preprint arXiv:2007.13518, 2020.
219
+
220
+ He He, Sheng Zha, and Haohan Wang. Unlearn dataset bias in natural language inference by fitting the residual. arXiv preprint arXiv:1908.10763, 2019.
221
+
222
+ Peter Kairouz, H Brendan McMahan, Brendan Avent, Aurelien Bellet, Mehdi Bennis, Arjun Nitin ´ Bhagoji, Keith Bonawitz, Zachary Charles, Graham Cormode, Rachel Cummings, et al. Advances and open problems in federated learning. arXiv preprint arXiv:1912.04977, 2019.
223
+
224
+ Fereshte Khani and Percy Liang. Removing spurious features can hurt accuracy and affect groups disproportionately. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, pp. 196–205, 2021.
225
+
226
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Yoshua Bengio and Yann LeCun (eds.), 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http: //arxiv.org/abs/1412.6980.
227
+
228
+ Pang Wei Koh, Shiori Sagawa, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasunaga, Richard Lanas Phillips, Irena Gao, Tony Lee, et al. Wilds: A benchmark of in-the-wild distribution shifts. In International Conference on Machine Learning, pp. 5637–5664. PMLR, 2021.
229
+
230
+ Daliang Li and Junpu Wang. Fedmd: Heterogenous federated learning via model distillation. arXiv preprint arXiv:1910.03581, 2019.
231
+
232
+ Tian Li, Anit Kumar Sahu, Manzil Zaheer, Maziar Sanjabi, Ameet Talwalkar, and Virginia Smith. Federated optimization in heterogeneous networks. In I. Dhillon, D. Papailiopoulos, and V. Sze (eds.), Proceedings of Machine Learning and Systems, volume 2, pp. 429–450, 2020. URL https://proceedings.mlsys.org/paper/2020/file/ 38af86134b65d0f10fe33d30dd76442e-Paper.pdf.
233
+
234
+ Tian Li, Shengyuan Hu, Ahmad Beirami, and Virginia Smith. Ditto: Fair and robust federated learning through personalization. In International Conference on Machine Learning, pp. 6357–6368. PMLR, 2021.
235
+
236
+ Yi Li and Nuno Vasconcelos. Repair: Removing representation bias by dataset resampling. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9572–9581, 2019.
237
+
238
+ Kaizhao Liang, Jacky Y Zhang, Boxin Wang, Zhuolin Yang, Sanmi Koyejo, and Bo Li. Uncovering the connections between adversarial transferability and knowledge transferability. In International Conference on Machine Learning, pp. 6577–6587. PMLR, 2021.
239
+
240
+ Evan Z Liu, Behzad Haghgoo, Annie S Chen, Aditi Raghunathan, Pang Wei Koh, Shiori Sagawa, Percy Liang, and Chelsea Finn. Just train twice: Improving group robustness without training group information. In International Conference on Machine Learning, pp. 6781–6792. PMLR, 2021.
241
+
242
+ 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.
243
+
244
+ Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ rJzIBfZAb.
245
+
246
+ Brendan McMahan, Eider Moore, Daniel Ramage, Seth Hampson, and Blaise Aguera y Arcas. Communication-efficient learning of deep networks from decentralized data. In Artificial Intelligence and Statistics, pp. 1273–1282. PMLR, 2017.
247
+
248
+ Daniel McNamara, Cheng Soon Ong, and Robert C Williamson. Costs and benefits of fair representation learning. In Proceedings of the 2019 AAAI/ACM Conference on AI, Ethics, and Society, pp. 263–270, 2019.
249
+
250
+ Takeru Miyato, Shin-ichi Maeda, Masanori Koyama, and Shin Ishii. Virtual adversarial training: a regularization method for supervised and semi-supervised learning. IEEE transactions on pattern analysis and machine intelligence, 41(8):1979–1993, 2018.
251
+
252
+ Junhyun Nam, Hyuntak Cha, Sungsoo Ahn, Jaeho Lee, and Jinwoo Shin. Learning from failure: Training debiased classifier from biased classifier. In Advances in Neural Information Processing Systems, 2020.
253
+
254
+ Sameer A. Nene, Shree K. Nayar, and Hiroshi Murase. Columbia object image library (coil-20. Technical report, 1996.
255
+
256
+ Yurii Nesterov. Introductory lectures on convex optimization: A basic course, volume 87. Springer Science & Business Media, 2003.
257
+
258
+ Shiori Sagawa, Pang Wei Koh, Tatsunori B. Hashimoto, and Percy Liang. Distributionally robust neural networks. In International Conference on Learning Representations, 2020. URL https: //openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ ryxGuJrFvS.
259
+
260
+ Canh T. Dinh, Nguyen Tran, and Josh Nguyen. Personalized federated learning with moreau envelopes. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 21394–21405. Curran Associates, Inc., 2020.
261
+
262
+ Florian Tramer, Nicolas Papernot, Ian Goodfellow, Dan Boneh, and Patrick McDaniel. The space of \` transferable adversarial examples. arXiv preprint arXiv:1704.03453, 2017.
263
+
264
+ Haohan Wang, Zexue He, Zachary L. Lipton, and Eric P. Xing. Learning robust representations by projecting superficial statistics out. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $=$ rJEjjoR9K7.
265
+
266
+ Jianyu Wang, Zachary Charles, Zheng Xu, Gauri Joshi, H Brendan McMahan, Maruan Al-Shedivat, Galen Andrew, Salman Avestimehr, Katharine Daly, Deepesh Data, et al. A field guide to federated optimization. arXiv preprint arXiv:2107.06917, 2021.
267
+
268
+ Han Zhao and Geoff Gordon. Inherent tradeoffs in learning fair representations. Advances in neural information processing systems, 32:15675–15685, 2019.
269
+
270
+ Han Zhao, Remi Tachet Des Combes, Kun Zhang, and Geoffrey Gordon. On learning invariant representations for domain adaptation. In International Conference on Machine Learning, pp. 7523–7532. PMLR, 2019.
271
+
272
+ # Appendix
273
+
274
+ A NOTATION
275
+
276
+ # Symbol
277
+
278
+ # Description
279
+
280
+ $x , y$ A pair of data sample and label
281
+ $\mathbf { \delta } _ { \mathbf { \mathcal { X } } _ { r } , \mathbf { \delta } _ { \mathbf { \mathcal { X } } _ { s } } }$ The robust feature and spurious features in $\pmb { x } = [ \pmb { x } _ { r } , \pmb { x } _ { s } ]$ , respectively
282
+ $d , d _ { r } , d _ { s }$ The dimension of $_ { \textbf { \em x } }$ , ${ \pmb x } _ { r }$ , $\mathbf { \delta } _ { \mathbf { \mathcal { X } } _ { s } }$ , respectively
283
+ $f _ { g }$ The global model
284
+ $f _ { p }$ The personlized local model
285
+ $\delta _ { f _ { g , \epsilon } }$ An adversarial purtubation generated by the global model $f _ { g }$ with attack budget $\epsilon$
286
+ $\pmb { \Delta }$ An natural perturbation, which could flip the spurious attribute
287
+ $\mathcal { D } _ { g }$ The global distribution, which is the union of local distributions
288
+ Db A biased local distribution
289
+ Dbc A bias-conflicting local distribution
290
+ D∆|x,y The distribution of natural perturbation
291
+ $\operatorname { s u p p } ( \mathcal { D } )$ The support of distribution $\mathcal { D }$
292
+ $\langle \cdot , \cdot \rangle$ An inner product of two vectors
293
+ $\frown$ · A concatenation of two vectors
294
+
295
+ # B PROOFS
296
+
297
+ # B.1 PROOF OF LEMMA 1
298
+
299
+ Lemma 1. Let $\Delta$ be the natural perturbation, $\theta$ be the angle between $\nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y )$ and $\nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) ,$ $\theta _ { g }$ be the angle between $\nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y )$ and $\nabla _ { x _ { r } } \ell ( f _ { g } ( { \pmb x } ) , y ) \ \frown \ \mathbf { \bar { 0 } }$ , and $\gamma$ be k∇x\`(fg(x),y)kk∇x\`(fp(x),y)k , we have:
300
+
301
+ $$
302
+ \begin{array} { r l } & { \mathcal { L } ( f _ { p } , \mathcal { D } _ { b c } ) - \mathcal { L } ( f _ { p } , \mathcal { D } _ { b } ) = \mathbb { E } _ { ( \boldsymbol { x } , \boldsymbol { y } ) \sim \mathcal { D } _ { b } , \Delta \sim \mathcal { D } _ { \Delta | \infty } } [ \displaystyle \int _ { \alpha = 0 } ^ { 1 } \langle \nabla _ { \boldsymbol { x } _ { s } } \ell ( f _ { p } ( \boldsymbol { x } + \boldsymbol { \alpha } \cdot \Delta ) , \boldsymbol { y } ) , \mathbf { 1 } \rangle \mathrm { d } \alpha ] } \\ & { \quad \quad \quad \quad < \mathbb { E } _ { ( \boldsymbol { x } , \boldsymbol { y } ) \sim \mathcal { D } _ { b } } [ \displaystyle \frac { \sqrt { d _ { s } } } { \gamma } \cdot \| \nabla _ { \boldsymbol { x } } \ell ( f _ { g } ( \boldsymbol { x } ) , \boldsymbol { y } ) \| \cdot ( \mathrm { s i n } \theta _ { g } + \mathrm { s i n } \theta ) ] } \end{array}
303
+ $$
304
+
305
+ Proof. Rewriting $\mathcal { L } ( f _ { p } , \mathcal { D } _ { b c } )$ and introducing $\pmb { \Delta }$ :
306
+
307
+ $$
308
+ \begin{array} { r l } { \mathcal { L } ( f _ { p } , \mathcal { D } _ { \theta c } ) = \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \theta c } } [ \ell ( f _ { p } ( x ) , y ) ] } \\ & { = \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \theta c } , \Delta \sim \mathcal { D } _ { \Delta \ln } } [ \ell ( f _ { p } ( x + \Delta ) , y ) ] } \\ & { = \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \delta } , \Delta \sim \mathcal { D } _ { \Delta \ln } } [ \ell ( f _ { p } ( x ) , y ) + \ell ( f _ { p } ( x + \Delta ) , y ) - \ell ( f _ { p } ( x ) , y ) ] } \\ & { = \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \delta } , \Delta \sim \mathcal { D } _ { \Delta \ln } } [ \ell ( f _ { p } ( x ) , y ) ] } \\ & { \quad + \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \theta c } , \Delta \sim \mathcal { D } _ { \Delta \ln } } [ \ell ( f _ { p } ( x + \Delta ) , y ) ] - \ell ( f _ { p } ( x ) , y ) ] } \\ & { = \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \theta c } } [ \ell ( f _ { p } ( x ) , y ) ] } \\ & { \quad + \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \delta } , \Delta \sim \mathcal { D } _ { \Delta \ln } } [ \ell ( f _ { p } ( x + \Delta ) , y ) ] - \ell ( f _ { p } ( x ) , y ) ] } \\ & { = \mathcal { L } ( f _ { p } , \mathcal { D } _ { \theta c } ) + \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \Delta \ln } } [ \ell ( f _ { p } ( x + \Delta ) , y ) ] } \\ & { = \mathcal { L } ( f _ { p } , \mathcal { D } _ { \theta c } ) + \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \Delta \ln } } [ \int _ { \alpha = 0 } ^ { 1 } \langle \nabla _ { \pi } \ell ( f _ { p } ( x + \alpha \cdot \Delta ) , y ) , 1 \rangle \mathrm { d } \alpha ] } \\ & = \mathcal { L } ( f _ { p } , \mathcal { D } _ { \theta c } ) + \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { \delta } , \Delta \sim \mathcal { D } _ { \Delta \ln } } [ \int _ \end{array}
309
+ $$
310
+
311
+ Moving $\mathcal { L } ( f _ { p } , \mathcal { D } _ { b } )$ to the left-hand-side (LHS), we have:
312
+
313
+ $$
314
+ \mathcal { L } ( f _ { p } , \mathcal { D } _ { b c } ) - \mathcal { L } ( f _ { p } , \mathcal { D } _ { b } ) = \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { b } , \Delta \sim \mathcal { D } _ { \Delta | \alpha } } [ \int _ { \alpha = 0 } ^ { 1 } \langle \nabla _ { x _ { s } } \ell ( f _ { p } ( x + \alpha \cdot \Delta ) , y ) , \mathbf { 1 } \rangle \mathrm { d } \alpha ] .
315
+ $$
316
+
317
+ According to Assumption 1, we further have:
318
+
319
+ $$
320
+ \mathbb { E } _ { ( \boldsymbol { x } , \boldsymbol { y } ) \sim \mathcal { D } _ { b } , \Delta \setminus \mathcal { D } _ { \Delta | \infty } } [ \int _ { \alpha = 0 } ^ { 1 } \left. \nabla _ { \boldsymbol { x } _ { s } } \ell \big ( f _ { p } ( \boldsymbol { x } + \boldsymbol { \alpha } \cdot \Delta ) , \boldsymbol { y } \big ) , \mathbf { 1 } \right. ] \le \mathbb { E } _ { \boldsymbol { x } \sim \mathcal { D } _ { b } } [ \left. \nabla _ { \boldsymbol { x } _ { s } } \ell \big ( f _ { p } ( \boldsymbol { x } ) , \boldsymbol { y } \big ) , \mathbf { 1 } \right. ]
321
+ $$
322
+
323
+ Next, we connect $\langle \nabla _ { \pmb { x } _ { s } } \ell ( f _ { p } ( \pmb { x } + \alpha \cdot \pmb { \Delta } ) , y ) , \mathbf { 1 } \rangle$ to $\| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| \cdot \mathrm { s i n } \theta$ . The first step is connecting $\langle \nabla _ { \pmb { x } _ { s } } \ell ( f _ { p } ( \pmb { x } + \alpha \cdot \pmb { \Delta } ) , y ) , \pmb { 1 } \rangle$ to $\| \nabla _ { { \pmb x } _ { s } } \ell ( f _ { p } ( { \pmb x } ) , y ) \|$ using Cauchy-Schwarz inequality:
324
+
325
+ $$
326
+ \begin{array} { r l } & { \langle \nabla _ { x _ { s } } \ell ( f _ { p } ( { \pmb x } + { \alpha } \cdot { \pmb \Delta } ) , y ) , { \bf 1 } \rangle } \\ & { \quad \le \sqrt { \langle \nabla _ { x _ { s } } \ell ( f _ { p } ( { \pmb x } + { \alpha } \cdot { \pmb \Delta } ) , y ) , \nabla _ { { \pmb x } _ { s } } \ell ( f _ { p } ( { \pmb x } + { \alpha } \cdot { \pmb \Delta } ) , y ) \rangle \cdot \langle { \bf 1 } , { \bf 1 } \rangle } } \\ & { \quad = \sqrt { d _ { s } } \cdot \| \nabla _ { { \pmb x } _ { s } } \ell ( f _ { p } ( { \pmb x } ) , y ) \| } \end{array}
327
+ $$
328
+
329
+ Then, we connect $\| \nabla _ { { \pmb x } _ { s } } \ell ( f _ { p } ( { \pmb x } ) , y ) \|$ to $\| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \|$ . Assuming the global model $f _ { g }$ entangles spurious features and the angle between $\nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y )$ and $\nabla _ { \pmb { x } _ { r } } \ell ( \bar { f } _ { g } ( \pmb { x } ) , \bar { \mathbf { \xi } } y ) \frown \mathbf { 0 }$ is $\theta _ { g }$ , we have:
330
+
331
+ $$
332
+ \begin{array} { r } { \| \nabla _ { \pmb { x } _ { s } } \ell ( f _ { p } ( \pmb { x } ) , y ) \| \leq \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| \cdot \sin ( \theta _ { g } + \theta ) . } \end{array}
333
+ $$
334
+
335
+ Since it is easy to see that $\theta \in [ 0 , \frac { \pi } { 4 } ]$ and the gradient of $\mathrm { s i n } \theta$ is monotonically decreasing in $[ 0 , \textstyle { \frac { \pi } { 4 } } ]$ , we have:
336
+
337
+ $$
338
+ \begin{array} { l } { \displaystyle \sin ( \theta _ { g } + \theta ) = \int _ { 0 } ^ { \theta _ { g } + \theta } \nabla \mathrm { s i n } \theta \mathrm { d } \theta } \\ { \displaystyle = \int _ { 0 } ^ { \theta _ { g } + \theta } \mathrm { c o s } \theta \mathrm { d } \theta } \\ { \displaystyle < \int _ { 0 } ^ { \theta _ { g } } \mathrm { c o s } \theta \mathrm { d } \theta + \int _ { 0 } ^ { \theta } \mathrm { c o s } \theta \mathrm { d } \theta } \\ { \displaystyle = \mathrm { s i n } \theta _ { g } + \mathrm { s i n } \theta } \end{array}
339
+ $$
340
+
341
+ Combining Eq. (7) and Eq. (8), we have:
342
+
343
+ $$
344
+ \| \nabla _ { \pmb { x } _ { s } } \ell ( f _ { p } ( \pmb { x } ) , y ) \| < \| \nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) \| \cdot ( \mathrm { s i n } \theta _ { g } + \mathrm { s i n } \theta )
345
+ $$
346
+
347
+ Recalling the defition of $\begin{array} { r } { \gamma : = \frac { \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| } { \| \nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) \| } } \end{array}$ and combining Eq. (4), Eq. (5), Eq. (6), Eq. (9) complete the proof.
348
+
349
+ # B.2 PROOF OF LEMMA 2
350
+
351
+ Lemma 2. Let  be the attack budget, $\theta$ be the angle between $\nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y )$ and $\nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) ,$ $\gamma$ be $\frac { | | \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , \pmb { y } ) | | } { | | \nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , \pmb { y } ) | | }$ , and the loss function $\ell : \mathcal { V } \times \mathcal { V } \mathbb { R }$ be $\lambda$ -smooth, twice differentiable, we have
352
+
353
+ $$
354
+ \begin{array} { l } { \displaystyle \epsilon \cdot \| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \| \cdot ( 1 - \frac { 1 } { \gamma } \cdot \mathrm { c o s } \theta ) - \lambda \cdot \epsilon ^ { 2 } \leq \ell _ { t r a n s } ( f _ { g } , f _ { p } , x , y ) } \\ { \displaystyle \leq \epsilon \cdot \| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \| \cdot ( 1 - \frac { 1 } { \gamma } \cdot \mathrm { c o s } \theta ) + \lambda \cdot \epsilon ^ { 2 } } \end{array}
355
+ $$
356
+
357
+ Proof. Under the definition of the adversarial perturbation, it is easy to see that δf, = · ∇x\`(f(x),y)k∇x\`(f(x),y)k and $\delta _ { f , \epsilon }$ increases the loss by:
358
+
359
+ $$
360
+ \begin{array} { r l r } & { } & { \ell ( f _ { g } ( { \pmb x } + \delta _ { f _ { g } , \epsilon } ) , { y } ) - \ell ( f _ { g } ( { \pmb x } ) , { y } ) = \delta _ { f _ { g } , \epsilon } \nabla _ { \pmb x } \ell ( f _ { g } ( { \pmb x } ) , { y } ) + \displaystyle \frac { 1 } { 2 } \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \tilde { \pmb x } _ { g } } ^ { 2 } \ell ( f _ { g } ( \tilde { \pmb x } _ { g } ) , { y } ) \delta _ { f _ { g } , \epsilon } } \\ & { } & { = \epsilon \cdot \| \nabla _ { \pmb x } \ell ( f _ { g } ( { \pmb x } ) , { y } ) \| + \displaystyle \frac { 1 } { 2 } \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \tilde { \pmb x } _ { g } } ^ { 2 } \ell ( f _ { g } ( \tilde { \pmb x } _ { g } ) , { y } ) \delta _ { f _ { g } , \epsilon } } \end{array}
361
+ $$
362
+
363
+ where $\tilde { \mathbf { { x } } } _ { g }$ is a linear interpolation between $_ { \textbf { \em x } }$ and $\boldsymbol { x } + \delta _ { f _ { g } , \epsilon }$ , by the Lagrange’s mean-value theorem. Similarly, for a transferable adversarial example from $f _ { g }$ applies to $f _ { p } , \delta _ { f _ { g } , \epsilon }$ could increase the loss of $f _ { p }$ by:
364
+
365
+ $$
366
+ \begin{array} { r l } & { \ell ( f _ { p } ( x + \delta _ { f _ { g } , \epsilon } ) , y ) - \ell ( f _ { p } ( x ) , y ) = \delta _ { f _ { g } , \epsilon } \nabla _ { \mathbf x } \ell ( f _ { p } ( \mathbf x ) , y ) + \displaystyle \frac 1 2 \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \tilde { \mathbf x } _ { p } } ^ { 2 } \ell ( f _ { p } ( \tilde { \mathbf x } _ { p } ) , y ) \delta _ { f _ { g } , \epsilon } } \\ & { \quad \quad \quad \quad \quad = \epsilon \cdot \| \nabla _ { \mathbf x } \ell ( f _ { p } ( \mathbf x ) , y ) \| \cdot \mathrm { c o s } \theta + \frac 1 2 \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \tilde { \mathbf x } _ { p } } ^ { 2 } \ell ( f _ { p } ( \tilde { \mathbf x } _ { p } ) , y ) \delta _ { f _ { g } , \epsilon } } \end{array}
367
+ $$
368
+
369
+ where $\begin{array} { r } { \mathrm { c o s } \theta = \frac { \nabla _ { \mathbf { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \cdot \nabla _ { \mathbf { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) } { \| \nabla _ { \mathbf { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| \| \nabla _ { \mathbf { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) \| } } \end{array}$ . Plugging the approximations above to the adversarial transferability loss, we have:
370
+
371
+ $$
372
+ \begin{array} { l } { \tiny { \mathrm { \tiny \mathrm { \Gamma } } } _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , y ) = \Big ( \ell ( f _ { g } ( \pmb { x } + \delta _ { f _ { g } , \epsilon } ) , y ) - \ell ( f _ { g } ( \pmb { x } ) , y ) \Big ) - \Big ( \ell ( f _ { p } ( \pmb { x } + \delta _ { f _ { g } , \epsilon } ) , y ) - \ell ( f _ { p } ( \pmb { x } ) , y ) \Big ) } \\ { = \epsilon \cdot \big \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \big \| - \epsilon \cdot \big \| \nabla _ { \pmb { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) \big \| \cdot \cos \theta } \\ { \quad \Big . \Big . \Big . \Big . \Big . \Big . \Big . \Big . + \frac { 1 } { 2 } \cdot \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \tilde { \pmb { x } } _ { g } } ^ { 2 } \ell ( f _ { g } ( \tilde { \pmb { x } } _ { g } ) , y ) \delta _ { f _ { g } , \epsilon } - \frac { 1 } { 2 } \cdot \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \tilde { \pmb { x } } _ { g } } ^ { 2 } \ell ( f _ { p } ( \tilde { \pmb { x } } _ { p } ) , y ) \delta _ { f _ { g } , \epsilon } } \end{array}
373
+ $$
374
+
375
+ Under the $\lambda$ -smooth assumption on the loss function, the spectral norms of the Hessian metrics are bounded. Therefore, we could bound the norm of the deviate between the quadratic terms (Nesterov, 2003, Proof of Theorem 2.1.5) in the adversarial transferability loss:
376
+
377
+ $$
378
+ \begin{array} { r } { \| \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \bar { x } _ { g } } ^ { 2 } \ell ( f _ { g } ( \tilde { x } _ { g } ) , y ) \delta _ { f _ { g } , \epsilon } - \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \bar { x } _ { p } } ^ { 2 } \ell ( f _ { p } ( \tilde { x } _ { p } ) , y ) \delta _ { f _ { g } , \epsilon } \| \leq 2 \lambda \cdot \delta _ { f _ { g } , \epsilon } ^ { \top } \delta _ { f _ { g } , \epsilon } = 2 \lambda \cdot \epsilon ^ { 2 } } \end{array}
379
+ $$
380
+
381
+ Since the quadratic terms in Eq. (10) are scalars, we have:
382
+
383
+ $$
384
+ - 2 \lambda \cdot \epsilon ^ { 2 } \le \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \tilde { x } _ { g } } ^ { 2 } \ell ( f _ { g } ( \tilde { x } _ { g } ) , y ) \delta _ { f _ { g } , \epsilon } - \delta _ { f _ { g } , \epsilon } ^ { \top } \nabla _ { \tilde { x } _ { p } } ^ { 2 } \ell ( f _ { p } ( \tilde { x } _ { p } ) , y ) \delta _ { f _ { g } , \epsilon } \le 2 \lambda \cdot \epsilon ^ { 2 }
385
+ $$
386
+
387
+ Plugging Eq. (11) and the definition of $\gamma$ to $\ell _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , y )$ completes the proof.
388
+
389
+ # B.3 PROOF OF THEOREM 3
390
+
391
+ Theorem 3. Let $\gamma _ { \mathrm { m i n } }$ be the minimum of $\gamma _ { i }$ , under Assumptions $^ { l }$ and Lemmas 1-2, we have:
392
+
393
+ $$
394
+ \begin{array} { l } { \displaystyle \mathcal { L } ( f _ { p } , \mathcal { D } _ { b c } ) - \mathcal { L } ( f _ { p } , \mathcal { D } _ { b } ) < \sqrt { d _ { s } } \cdot \Big ( ( \frac { \sin \theta _ { g } + \sqrt { 2 } } { \gamma _ { \mathrm { m i n } } } - 1 ) \cdot \mathbb { E } _ { ( { \pmb x } , { y } ) \sim \mathcal { D } _ { b } } [ \| \nabla _ { \pmb x } \ell ( f _ { g } ( { \pmb x } ) , { y } ) \| ] } \\ { \displaystyle \qquad + \frac { 1 } { \epsilon } \cdot \mathbb { E } _ { ( { \pmb x } , { y } ) \sim \mathcal { D } _ { b } } [ \ell _ { t r a n s } ( f _ { g } , f _ { p } , { \pmb x } , { y } ) ] + \lambda \cdot \epsilon \Big ) } \end{array}
395
+ $$
396
+
397
+ Proof. According to Lemma 2, we know:
398
+
399
+ $$
400
+ \ell _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , y ) \ge \epsilon \cdot \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| \cdot ( 1 - \frac { 1 } { \gamma } \cdot \mathrm { c o s } \theta ) - \lambda \cdot \epsilon ^ { 2 }
401
+ $$
402
+
403
+ where $\begin{array} { r } { \mathrm { c o s } \theta = \frac { \nabla _ { \mathbf { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \nabla _ { \mathbf { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) } { \| \nabla _ { \mathbf { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| \| \nabla _ { \mathbf { x } } \ell ( f _ { p } ( \pmb { x } ) , y ) \| } } \end{array}$ . Then, we derive an upper bound of $\| \nabla _ { x } \ell ( f _ { g } ( \pmb { x } ) , y ) \|$ · $\mathrm { s i n } \theta$ from $\ell _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , y )$ . It is easy to see that $\theta \in [ 0 , \frac { \pi } { 4 } ]$ . Therefore, we have:
404
+
405
+ $$
406
+ \begin{array} { r l } & { \varepsilon _ { \mathrm { C O } } ( \varepsilon _ { 3 } , t , \varepsilon _ { 1 } , \varepsilon _ { 2 } , \varepsilon _ { 3 } ) } \\ & { = \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 2 } , \varepsilon _ { 3 } ) } \\ & { = \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { = \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 2 } , \varepsilon _ { 3 } ) } \\ & { - \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { - \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { - \varepsilon _ { 1 } ( \varepsilon _ { 4 } , t , \varepsilon _ { 4 } ) } \\ & { = \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 4 } ) } \\ & { - \varepsilon _ { 1 } ( \varepsilon _ { 4 } , t , \varepsilon _ { 4 } ) } \\ & { \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 4 } ) } \\ & { + \varepsilon _ { 1 } ( \varepsilon _ { 4 } , t , \varepsilon _ { 5 } ) } \\ & { \qquad \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 5 } ) } \\ & { \qquad \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 1 } ) } \\ & { \qquad \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 2 } ) } \\ & { \qquad \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { \qquad \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 4 } ) } \\ & { \qquad \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 2 } ) } \\ & { \qquad \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { \qquad \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { \qquad \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { \qquad \varepsilon _ { 1 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 2 } ) } \\ & { \qquad \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { \qquad \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & { \qquad \varepsilon _ { 2 } ( \varepsilon _ { 3 } , t , \varepsilon _ { 3 } ) } \\ & \qquad \varepsilon _ { 1 } ( \varepsilon _ 3 \end{array}
407
+ $$
408
+
409
+ Moving $\| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| \cdot \mathrm { s i n } \theta$ to the left hand side (LHS):
410
+
411
+ $$
412
+ \begin{array} { r l } & { \| \nabla _ { \mathbf x } \ell ( f _ { g } ( { \boldsymbol x } ) , { \boldsymbol y } ) \| \cdot \sin \theta } \\ & { \qquad \le \frac { \gamma } \epsilon \ell _ { t r a n s } ( f _ { g } , f _ { p } , { \boldsymbol x } , { \boldsymbol y } ) + ( \sqrt 2 - \gamma ) \cdot \| \nabla _ { \mathbf x } \ell ( f _ { g } ( { \boldsymbol x } ) , { \boldsymbol y } ) \| + \gamma \cdot \lambda \cdot \epsilon } \end{array}
413
+ $$
414
+
415
+ According to Lemma 1, we know:
416
+
417
+ $$
418
+ \begin{array} { r l } & { \mathcal { L } \big ( f _ { p } , \mathcal { D } _ { b c } \big ) - \mathcal { L } \big ( f _ { p } , \mathcal { D } _ { b } \big ) = \mathbb { E } _ { ( \boldsymbol { x } , \boldsymbol { y } ) \sim \mathcal { D } _ { b } , \Delta \sim \mathcal { D } _ { \Delta | \alpha } } [ \int _ { \alpha = 0 } ^ { 1 } \langle \nabla _ { \boldsymbol { x } _ { s } } \ell \big ( f _ { p } ( \boldsymbol { x } + \boldsymbol { \alpha } \cdot \Delta ) , \boldsymbol { y } \big ) , \mathbf { 1 } \rangle \mathrm { d } \alpha ] } \\ & { \quad \quad \quad \quad < \mathbb { E } _ { ( \boldsymbol { x } , \boldsymbol { y } ) \sim \mathcal { D } _ { b } } [ \frac { \sqrt { d _ { s } } } { \gamma } \cdot \| \nabla _ { \boldsymbol { x } } \ell \big ( f _ { g } ( \boldsymbol { x } ) , \boldsymbol { y } \big ) \| \cdot ( \mathrm { s i n } \theta _ { g } + \mathrm { s i n } \theta ) ] } \end{array}
419
+ $$
420
+
421
+ Combining Eq. (13) and Eq. (12), and taking expectation of $x , y$ over $\mathcal { D } _ { b }$ :
422
+
423
+ $$
424
+ \begin{array} { r l } & { \mathbb { E } _ { \alpha \sim \mathcal { D } _ { b } } [ \frac { \sqrt { d _ { s } } } { \gamma } \cdot \| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \| \cdot ( \sin \theta _ { g } + \sin \theta ) ] } \\ & { \quad \le \frac { \sqrt { d _ { s } } } { \gamma } \cdot \Big ( \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { b } } [ \| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \| \cdot \sin \theta _ { g } ] + \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { b } } [ \frac { \gamma } { \epsilon } \cdot \ell _ { t r a n s } ( f _ { g } , f _ { p } , x , y ) ] } \\ & { \quad \quad + \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { b } } [ ( \sqrt { 2 } - \gamma ) \cdot \| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \| ] + \gamma \cdot \lambda \cdot \epsilon \Big ) } \\ & { \quad \le \sqrt { d _ { s } } \cdot \Big ( ( \frac { \sin \theta _ { g } + \sqrt { 2 } } { \gamma \operatorname* { m i n } } - 1 ) \cdot \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { b } } [ \| \nabla _ { x } \ell ( f _ { g } ( x ) , y ) \| ] } \\ & { \quad \quad + \frac { 1 } { \epsilon } \cdot \mathbb { E } _ { ( \alpha , y ) \sim \mathcal { D } _ { b } } [ \ell _ { t r a n s } ( f _ { g } , f _ { p } , x , y ) ] + \lambda \cdot \epsilon \Big ) } \end{array}
425
+ $$
426
+
427
+ Plugging Eq. (14) back to Eq. (13) completes the proof.
428
+
429
+ # C MORE EXPERIMENTAL SETTING
430
+
431
+ # C.1 DATA PARTITION
432
+
433
+ We distribute the MNIST and Coil20 dataset across 50 clients. Each client has data from 5 different classes. The local dataset on each client is further partitioned to train/validation/test set with a ratio of 72:8:20, following prior work (Li et al., 2021). The test set here is biased. We alternate the spurious features in biased test sets by recoloring the data to create a bias-conflicting test set. For the CelebA dataset, we consider two partitions. In the first partition (CelebA R), each client represents 20 celebrities. One celebrity only appears on one client. The blond male images in the biased test sets are copied to bias-conflicting test sets. We use all clients for training the global model. In the personalization step, we select the clients who have more than 5 blond female training samples and more than 5 blond male test samples. We select these clients because they provide enough samples to create spurious correlations and bias-conflicting test sets. Although the first partition on CelebA is real, the number (161) of blond male images is small. To make the result clearer, we create another synthetic CelebA partition. In the second partition (CelebA S), there are 650 blond male images, which achieve a similar bias-conflicting test set size as prior works Sagawa et al. (2020); Liu et al. (2021). The 650 images are distributed to 3 clients with 2350 other images. The rest of the images are distributed in the same way as the first partition. Tables 3, 4, and 5 provide more details about the 3 clients.
434
+
435
+ Table 3: Number of Train and Validation Samples in CelebA S
436
+
437
+ <table><tr><td>Client ID</td><td>Non-blond Female</td><td>Non-Blond Male</td><td>Blond Female</td><td>Blond Male</td></tr><tr><td>0</td><td>55</td><td>31</td><td>12</td><td>2</td></tr><tr><td>1</td><td>30</td><td>68</td><td>0</td><td>2</td></tr><tr><td>2</td><td>59</td><td>28</td><td>11</td><td>2</td></tr></table>
438
+
439
+ Table 4: Number of Biased Test Samples in CelebA S
440
+
441
+ <table><tr><td>Client ID</td><td>Non-blond Female</td><td>Non-Blond Male</td><td>Blond Female</td><td>Blond Male</td></tr><tr><td>0</td><td>115</td><td>60</td><td>45</td><td>2</td></tr><tr><td>1</td><td>60</td><td>75</td><td>79</td><td>0</td></tr><tr><td>2</td><td>86</td><td>111</td><td>14</td><td>0</td></tr></table>
442
+
443
+ Table 5: Number of Biased-Conflicting Test Samples in CelebA S
444
+
445
+ <table><tr><td>Client ID1</td><td>Non-blond FemaleNon-Blond Male</td><td></td><td>Blond Female </td><td>Blond Male</td></tr><tr><td>0</td><td>0</td><td>0</td><td>0</td><td>200</td></tr><tr><td>1</td><td>0</td><td>0</td><td>0</td><td>203</td></tr><tr><td>2</td><td>0</td><td>0</td><td>0</td><td>204</td></tr></table>
446
+
447
+ # C.2 HYPER-PARAMETERS
448
+
449
+ We use Adam optimizer (Kingma & Ba, 2015) throughout our experiments with learning rate 1e-4. Although stochastic gradient descent (SGD) optimizer is more common in vision-related tasks, we find that the Adam optimizer always leads to lower accuracy disparity. We train the global model for 500 rounds. 5 clients are selected per round, and each performs 5 epochs of local updates. We tune the coefficients of the adversarial transferability and $L _ { 2 }$ regularization terms from $\{ \bar { 0 . 0 1 } , 0 . 1 , 1 . 0 , 1 0 . 0 \}$ and select the largest value that does not decrease the validation accuracy during penalization. We start the attack budget at 0.031 and gradually decrease it such that $3 0 \% - 5 0 \%$ of the attack succeeds. A large budget will make the attack too strong and push the adversarial examples far across the decision boundary, making the regularization method less effective. We configure $\epsilon$ to $0 . 0 3 1 / 0 . 0 1 / 0 . 0 1 5$ for MNIST/CelebA/Coil20, respectively. We fine-tune the global model for 5 epochs on MNIST and
450
+
451
+ 10 epochs on CelebA/Coil20, which are sufficient for the personalized models to converge. The clients with the most data samples fine-tune the penalized models for a total of 80/40/30 batches on MNIST/CelebA/Coil20 datasets. Note that we may not select the personalized model with the most fine-tuning batches for reporting. In the just train twice (JTT) method, we up-sample the residuel by a factor of 50. In Ditto, we tune its $\lambda$ from $\lbrace 0 . 1 , 1 . 0 \rbrace$ .
452
+
453
+ # C.3 NEURAL NETWORK ARCHITECTURE
454
+
455
+ We use CNN $2 8 \mathbf { x } 2 8$ for MNIST dataset and CNN 64x64 for CelebA and Coil20 datasets.
456
+
457
+ Table 6: Neural Network Architecture
458
+
459
+ <table><tr><td>CNN 28x28</td><td>CNN 64x64</td></tr><tr><td>Input: R3.28-28</td><td>Input: R3-64.64</td></tr><tr><td>4·4 conv, 64 BN LReLU, stride 2</td><td>4·4 conv, 64 BN LReLU, stride 2</td></tr><tr><td>4·4 conv, 128 BN LReLU, stride 2</td><td>4·4 conv, 64 BN LReLU, stride 2</td></tr><tr><td>FC4096ReLU</td><td>FC4096ReLU</td></tr><tr><td>FC10</td><td>FC10</td></tr></table>
460
+
461
+ # D MORE EXPERIMENTAL RESULTS
462
+
463
+ # D.1 FIRST-ORDER APPROXIMATION OF ADVERSARIAL TRANSFERABILITY LOSS
464
+
465
+ To explore the impact of the $\lambda$ term in Lemma 2 and Theorem 3, we measure the relative difference between $\ell _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , y )$ and $\begin{array} { r } { \epsilon \cdot \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| \cdot ( 1 - \frac { 1 } { \gamma } \cdot \mathrm { c o s } \theta ) } \end{array}$ . In other words, we measured the accuracy of a first-order approximation of $\ell _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , y )$ . If the approximation is accuracy is high, it implies that the impact of $\lambda \cdot \epsilon ^ { 2 }$ is low. Specifically, we compute an approximation error:
466
+
467
+ $$
468
+ \mathbb { E } _ { ( \pmb { x } , \pmb { y } ) \sim \mathcal { D } _ { b } } \Big [ \Big | \frac { \ell _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , \pmb { y } ) - \epsilon \cdot \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , \pmb { y } ) \| \cdot ( 1 - \frac { 1 } { \gamma } \cdot \mathrm { c o s } \theta ) } { \ell _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , \pmb { y } ) } \Big | \Big ] .
469
+ $$
470
+
471
+ On MNIST, CelebA and Coil20 datasets, we find that the approximation error is 0.019, 0.058, 0.084, respectively. These results suggests that using $\begin{array} { r } { \epsilon \cdot \| \nabla _ { \pmb { x } } \ell ( f _ { g } ( \pmb { x } ) , y ) \| \cdot ( 1 - \frac { 1 } { \gamma } \cdot \mathrm { c o s } \theta ) } \end{array}$ to approximate $\ell _ { t r a n s } ( f _ { g } , f _ { p } , \pmb { x } , y )$ results in a decent accuracy and the impact of $\lambda \cdot \epsilon ^ { 2 }$ is low. The possible reason is that the attack budget $\epsilon$ is usually small (e.g., 0.031), such that the gradient of a function changes little in a small neighborhood defined by $\epsilon$ .
472
+
473
+ # D.2 EFFECTIVENESS OF $L _ { 2 }$ REGULARIZATION TERM
474
+
475
+ Figure 7 shows the distribution of $\gamma$ before and after applying the $L _ { 2 }$ regularization term on the CelebA dataset. Here, the $\gamma$ is computed once per data sample. We keep the global model fixed and fine-tune the personalized model for 1 epoch.
476
+
477
+ ![](images/a426ec5307f3f0d205674c7700f41b5e5c571a21eee3acea8b55f7738fa13c10.jpg)
478
+ Figure 7: With the $L _ { 2 }$ regularization term, the distribution of $\gamma$ is centered around 1, with a small variance. The minimum of $\gamma$ is closer to 1.
479
+
480
+ # D.3 DIVERSITY OF BIAS-CONFLICTING SAMPLES IMPACTS DEBIASING
481
+
482
+ To explore the impact of the diversity of bias-conflicting samples on debiasing, we vary the diversity of bias-conflicting samples and adjust the up-weighting factors accordingly. Specifically, we sample a factor of 0.02, 0.025, 0.033, 0.05, and 0.1 biased data samples from the MNIST dataset and re-color them to become bias-conflicting. The factor in the sampling step is called sampling factor. Then, we up-weight the bias-conflicting samples by a factor of 50, 40, 30, 20, 10, respectively, keeping the total number of bias-conflicting samples consistent. Here, the bias-conflicting samples have less diversity if generated by a small number of biased data samples with a large up-weighting factor. Experimental results in Figure 8 show that, as the diversity reduces, the accuracy disparity of personalized model on the biased dataset and bias-conflicting dataset increases, supporting our analysis. Therefore, our method is applicable in the scarcity of bias-conflicting samples while the up-weighting method fails.
483
+
484
+ ![](images/2c1224b82f19d0ecce4a94c61256458ead2f6ada0ecec8ce9d6a145fd76eb884.jpg)
485
+ Figure 8: The up-weighting method is less effective, resulting in large accuracy disparity of personalized model on biased dataset and bias-conflicting dataset, if the bias-conflicting samples is generated by a small number of biased data samples using a small sampling factor and a large up-weighting factor. The up-weighting factor is set to be the reciprocal of the sampling factor.
md/dev/TCl7CbQ29hH/TCl7CbQ29hH.md ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CPT: COLORFUL PROMPT TUNING FOR PRE-TRAINED VISION-LANGUAGE MODELS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Pre-Trained Vision-Language Models (VL-PTMs) have shown promising capabilities in grounding natural language in image data, facilitating a broad variety of cross-modal tasks. However, we note that there exists a significant gap between the objective forms of model pre-training and fine-tuning, resulting in a need for large amounts of labeled data to stimulate the visual grounding capability of VLPTMs for downstream tasks. To address the challenge, we present Cross-modal Prompt Tuning (CPT, alternatively, Colorful Prompt Tuning), a novel paradigm for tuning VL-PTMs, which reformulates visual grounding into a fill-in-the-blank problem with color-based co-referential markers in image and text, maximally mitigating the gap. In this way, CPT enables strong few-shot and even zero-shot visual grounding capabilities of VL-PTMs. Comprehensive experimental results show that the prompt-tuned VL-PTMs outperform their fine-tuned counterparts by a large margin (e.g., $1 7 . 3 \%$ absolute accuracy improvement, and $7 3 . 8 \%$ relative standard deviation reduction on average with one shot in RefCOCO evaluation). All the data and codes will be available to facilitate future research.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Grounding natural language in fine-grained image regions is essential for a broad variety of visionlanguage tasks, such as robotic navigation (Tellex et al., 2011; Anderson et al., 2018b), visual question answering (Antol et al., 2015; Anderson et al., 2018a), visual dialogue (Das et al., 2017), and visual commonsense reasoning (Zellers et al., 2019). Recently Pre-Trained Vision-Language Models (VL-PTMs) have shown promising capabilities in visual grounding. Typically, generic cross-modal representations are first pre-trained on large-scale image-caption data in a self-supervised fashion, and then fine-tuned to adapt to downstream tasks (Lu et al., 2019; Su et al., 2019; Li et al., 2020; Radford et al., 2021). This pre-training-then-fine-tuning paradigm of VL-PTMs has greatly pushed forward the state-of-the-art of many cross-modal tasks.
12
+
13
+ Despite the success, we note that there exists a significant gap between the objective forms of pretraining and fine-tuning of VL-PTMs. As illustrated in Figure 1, during pre-training, most VL-PTMs are optimized based on the masked language modeling objective, trying to recover the masked token from the cross-modal context. However, during fine-tuning, downstream tasks are usually conducted by classifying unmasked token representations into semantic labels, where task-specific parameters are typically introduced. The gap hinders the effective adaptation of VL-PTMs to downstream tasks. As a result, a large amount of labeled data is typically required to stimulate the visual grounding capabilities of VL-PTMs for downstream tasks.
14
+
15
+ In this work, inspired by recent progress in pre-trained language models in natural language processing (Brown et al., 2020; Schick & Schutze, 2021a; Liu et al., 2021), we present Cross-modal ¨ Prompt Tuning (CPT, alternatively, Colorful Prompt Tuning), a novel paradigm for tuning VLPTMs. The key insight is that by adding color-based co-referential markers in both image and text, visual grounding can be reformulated into a fill-in-the-blank problem, maximally mitigating the gap between pre-training and fine-tuning. As shown in Figure 1, to ground natural language expressions in image data, CPT consists of two components: (1) a visual sub-prompt that uniquely marks image regions with colored blocks or segmentation masks, and (2) a textual sub-prompt that puts the query text into a color-based query template. Explicit grounding to the target image region can then be achieved by recovering the corresponding color text from the masked token in the query template. In addition, we present a principled method to search for high-quality cross-modal prompt configurations (i.e., visual appearances and texts of colors) for CPT.
16
+
17
+ ![](images/0c06701dc550421e7ed6cde9a9ceb8b8b45158d8ee3fa0a4623bc5c191b75dd5.jpg)
18
+ Figure 1: Illustration of (a) pre-training for VL-PTMs with masked language modeling (MLM) head, (b) vanilla fine-tuning with new classification (CLS) head, and (c) our colorful cross-modal prompt tuning (CPT) framework that reformulates visual grounding into a fill-in-the-blank problem with reused MLM head. Only square parts of relevant image regions are shown for illustration.
19
+
20
+ By mitigating the gap from pre-training, CPT enables strong few-shot and even zero-shot visual grounding capabilities of VL-PTMs. Experimental results show that the prompt-tuned VL-PTMs outperform their fine-tuned counterparts by a large margin. For example, using colored blocks as visual sub-prompts, CPT achieves $1 7 . 3 \%$ absolute accuracy improvement, and $7 3 . 8 \%$ relative standard deviation reduction on average with one shot in RefCOCO evaluation. In the same setting, when equipped with colored segmentation masks as visual sub-prompts, CPT can further achieve $2 0 . 0 \%$ absolute accuracy improvement, and $7 6 . 2 \%$ relative standard deviation reduction than the vanilla fine-tuning approach.
21
+
22
+ Our contributions are summarized as threefold: (1) We present a novel cross-modal prompt tuning paradigm for VL-PTMs. To the best of our knowledge, this is the first attempt in both cross-modal prompt tuning for VL-PTMs, and zero- and few-shot visual grounding independent of object types. (2) We present a principled approach to search for high-quality cross-modal prompt configurations for CPT. (3) We conduct comprehensive experiments which demonstrate the effectiveness of CPT.
23
+
24
+ # 2 PRELIMINARY
25
+
26
+ In the literature, visual grounding is typically formulated as a referring expression comprehension (REC) problem (Plummer et al., 2015; Mao et al., 2016). Given an image $I$ and a query text of referring expression $q$ , REC aims to locate the target region in $I$ that corresponds to $q$ . In this section, we introduce the vanilla fine-tuning approach for VL-PTMs.
27
+
28
+ A common practice for REC is to first detect a set of region proposals $\{ v _ { 1 } , v _ { 2 } , \ldots , v _ { n } \}$ via object detectors, and then classify or rank the proposals to select the target region (Lu et al., 2019; Chen et al., 2020). Specifically, visual and textual inputs are first transformed into a sequence of input tokens $\left\{ \left[ \mathrm { I M G } \right] , v _ { 1 } , v _ { 2 } , \ldots , v _ { n } \right.$ , [CLS], $w _ { 1 } , w _ { 2 } , \ldots , w _ { m } , [ \mathrm { S E P } ] \}$ , where $\{ w _ { 1 } , w _ { 2 } , \ldots , w _ { m } \}$ are textual tokens of $q$ , and $\big [ \mathrm { I M G } \big ]$ , [CLS] and [SEP] are special tokens. To obtain input representations, the feature of image regions is extracted by visual encoders, and the embeddings of textual and special tokens are obtained by a lookup table. Then input representations are fed into the pre-trained transformers to produce the hidden representations $\{ \mathbf { h } _ { \scriptscriptstyle { [ \mathbb { T } \mathrm { M G } ] } } , \mathbf { h } _ { v } ^ { 1 } , \mathbf { h } _ { v } ^ { 2 } , \dots , \mathbf { h } _ { v } ^ { n } , \mathbf { h } _ { \scriptscriptstyle { [ \mathbb { C } \mathrm { L S } ] } } , \mathbf { h } _ { w } ^ { \mathrm { f } } , \mathbf { h } _ { w } ^ { 2 } , \dots , \mathbf { h } _ { w } ^ { m } , \mathbf { h } _ { \scriptscriptstyle { [ \mathbb { S } \mathrm { E } \mathrm { P } ] } } \} .$ . Finally the hidden representation of the target region is optimized against negative ones via classification or ranking loss, where new task-specific parameters are introduced. As a result, fine-tuned VL-PTMs need a large mount of labeled instances to stimulate the visual grounding capability.
29
+
30
+ # 3 CROSS-MODAL PROMPT TUNING (CPT)
31
+
32
+ In this section, we introduce the framework of CPT, and how to apply CPT to zero-shot, few-shot and fully supervised visual grounding.
33
+
34
+ # 3.1 OVERVIEW
35
+
36
+ The key to visual grounding is to establish fine-grained connections between image regions and textual expressions. Therefore, a good cross-modal prompt tuning framework should take full advantage of co-referential signals from both image and text, and maximally mitigate the gap between pre-training and tuning. To this end, CPT reformulates visual grounding into a fill-in-the-blank problem, as shown in Figure 1. Specifically, the CPT framework consists of two components: (1) a visual sub-prompt that uniquely marks the image regions with colored blocks or segmentation masks, and (2) a textual sub-prompt that puts the query text into a color-based query template. Equipped with CPT, it is then straightforward for VL-PTMs to ground the query text by filling the masked token with the color text of the target image region, where the objective form is identical to pre-training.
37
+
38
+ # 3.2 VISUAL SUB-PROMPT
39
+
40
+ Given an image $I$ and its region proposals $\mathcal { R } = \{ v _ { 1 } , v _ { 2 } , . . . , v _ { n } \}$ , visual sub-prompt aims to uniquely mark the image regions with natural visual makers. Interestingly, we note that colored bounding boxes are widely used to uniquely mark objects in images for visualization in the literature. Inspired by this, we bridge the image regions and query text through a set of colors $\mathcal { C }$ , where each color $c _ { i } = ( c _ { v } ^ { i } , c _ { w } ^ { i } ) \in \mathsf { \bar { C } }$ is defined by its visual appearance $c _ { v } ^ { i }$ (e.g., RGB (255, 0, 0)) and color text $c _ { w } ^ { i }$ (e.g., red). Then we mark each region proposal $v _ { i }$ in the image with a unique color $c _ { v } ^ { i }$ for grounding, resulting in a set of colored image proposals $\Psi ( \mathcal { R } ; \mathcal { C } )$ , where $\Psi ( \cdot )$ denotes visual sub-prompt.
41
+
42
+ As for the shape of the visual sub-prompt, in principle, there are multiple plausible choices to mark the regions with colors, including colored bounding boxes, solid blocks, or solid object segmentation masks. In our experiments, we find that coloring the object with solid blocks and segmentation masks yields better results than bounding boxes, since solid colors that fit the outlines of objects are more common in real-world images (e.g., red shirt and blue car). Note that the addition of visual sub-prompt to the raw image does not change the architecture or parameters of VL-PTMs.
43
+
44
+ # 3.3 TEXTUAL SUB-PROMPT
45
+
46
+ Textual sub-prompt aims to prompt VL-PTMs to establish the connections between the query text and image regions marked by visual sub-prompt. Specifically, the query text $q$ (e.g., “the horse watched by the woman”) is transformed into a fill-in-the-blank query using a template $\mathcal { T } _ { g } ( \cdot )$ as:
47
+
48
+ $$
49
+ \mathcal { T } _ { g } ( q ) = \left[ \mathbb { C } \mathrm { { L S } } \right] q \mathrm { i s } \mathrm { i n } \left[ \mathrm { M } \mathrm { { A S K } } \right] \mathrm { c o l o r } \ \left[ \mathrm { { S E P } } \right]
50
+ $$
51
+
52
+ In this way, VL-PTMs are prompted to decide the color of which region is more appropriate to fill in the mask (e.g., red or blue) as follows:
53
+
54
+ $$
55
+ P ( v = v _ { i } | \mathcal { R } , q ) = P ( \mathrm { \tiny ~ I M A S K } ] = c _ { w } ^ { i } | \Psi ( \mathcal { R } ; \mathcal { C } ) , \mathcal { T } _ { g } ( q ) ) = \frac { \exp ( { \bf h } _ { \mathrm { \tiny ~ I M A S K } } ^ { \top } { \bf c } _ { w } ^ { i } ) } { \sum _ { c _ { j } \in \mathcal { C } } \exp ( { \bf h } _ { \mathrm { \tiny ~ I M A S K } } ^ { \top } { \bf c } _ { w } ^ { j } ) } ,
56
+ $$
57
+
58
+ where $v$ is the target region, $\mathbf { c } _ { w } ^ { i }$ is the embedding of $c _ { w } ^ { i }$ in the pre-trained MLM head. Note that the procedure does not introduce any new parameters, and also mitigates the gap between pre-training and tuning, and therefore improves the data efficiency for tuning VL-PTMs.
59
+
60
+ # 3.4 TRAINING AND INFERENCE
61
+
62
+ Equipped with CPT, VL-PTMs can readily perform zero-shot visual grounding without any labeled data, since the cross-modal representations of colors and their composition with other concepts (e.g., objects, attributes and relations) have been well learned by VL-PTMs during pre-training. When a few or full labeled instances are available, VL-PTMs can be further tuned by CPT using the entropybased objective: L = − P(R,q,v?)∈Dtrain $\begin{array} { r } { \mathcal { L } = - \sum _ { ( \mathcal { R } , q , v ^ { \star } ) \in \mathcal { D } _ { \operatorname { t r a i n } } } \log P ( v ^ { \star } | \mathcal { R } , q ) } \end{array}$ , where $\mathcal { D } _ { \mathrm { t r a i n } }$ is the training set.
63
+
64
+ ![](images/63263fe4ea028b14e86218e0b34963adfbf79c51a7c78d0afeb1fedf128513e9.jpg)
65
+ Figure 2: CPT framework for predicate classification by filling-in-the-blank with reused MLM head.
66
+
67
+ Although it is appealing to bridge the image and text through a color-based prompt, we identify two key challenges in its design: (1) how to determine the configurations of the color set $\mathcal { C }$ , and (2) how to deal with the large number of image regions with limited pre-trained colors.
68
+
69
+ Cross-Modal Prompt Search. Previous works in textual prompt tuning show that prompt configurations (e.g., textual templates) have a significant influence on the performance (Jiang et al., 2020). In this work, we make the first investigation in searching the cross-modal prompt configuration (i.e., the color set $\mathcal { C }$ ). Intuitively, $\mathcal { C }$ should consist of colors to which VL-PTMs are the most sensitive. To obtain a color $c _ { i } = ( \hat { c _ { v } ^ { i } } , c _ { w } ^ { i } )$ , a naive approach is to adopt the most frequent color text in the pre-training text as $c _ { w } ^ { i }$ , and its standard RGB as $c _ { v } ^ { i }$ (e.g., $c _ { i } \bar { = } \left( ( 2 5 5 , 0 , 0 ) \bar { , } r e d ) \right)$ . However, this solution is sub-optimal, since it determines the color text without considering its visual appearance, and the visual appearance of a color in real-world images often differs from its standard RGB.
70
+
71
+ To address the challenge, we present a principled cross-modal prompt search (CPS) algorithm for CPT, which jointly considers visual and textual semantics in real-world cross-modal data. Specifically, we first identify a candidate set of color texts $\hat { \mathcal { C } } _ { w }$ and visual appearances $\hat { \mathcal { C } } _ { v }$ . For each visual appearance candidate $\hat { c _ { v } } \in \hat { { \mathcal C } } _ { v }$ , we feed into VL-PTMs a pseudo-data instance consisting of a pure colored block of $\hat { c _ { v } }$ and a text: “[CLS] a photo in [MASK] color [SEP]”. Then we compute the decoding score $s ( \hat { c _ { v } } , \hat { c _ { w } } )$ for each color text candidate $\hat { c _ { w } } \in \hat { { \mathcal { C } } _ { w } }$ as in Equation 1, where a larger decoding score indicates higher correlation between $\hat { c _ { v } }$ and $\hat { c _ { w } }$ . To select the color texts that are sensitive by VL-PTMs, we retain the color texts that achieve the largest decoding scores for visual appearance candidates: $\mathcal { C } _ { w } = \{ c _ { w } | c _ { w } = \arg \operatorname* { m a x } _ { \hat { c } _ { w } ^ { j } \in \hat { \mathcal { C } } _ { w } } s ( \hat { c } _ { v } ^ { i } , \hat { c } _ { w } ^ { j } ) , \hat { c } _ { v } ^ { i } \in \hat { \mathcal { C } } _ { v } \}$ . Similarly, we can obtain the visual appearances according to the largest decoding score, resulting in the color set: $\begin{array} { r } { \mathcal { C } = \{ ( c _ { v } , c _ { w } ) | c _ { v } \stackrel { } { = } \operatorname * { a r g m a x } _ { \hat { c } _ { v } ^ { i } \in \hat { \mathcal { C } } _ { v } } s ( \hat { c } _ { v } ^ { i } , c _ { w } ^ { j } ) , c _ { w } ^ { j } \stackrel { } { \in } \mathcal { C } _ { w } \} . } \end{array}$ . We refer readers to Section B for the pseudo-code of the algorithm. In experiments, we find that the resultant colors yield better results than the naive ones. To make the raw content of the colored image regions available to VL-PTMs, a transparency hyperparameter $\alpha \in ( 0 , 1 )$ is further applied to color visual appearances in practice.
72
+
73
+ Image Region Batching. In visual grounding, the number of region proposals in an image usually exceeds the size of $\mathcal { C }$ $( \sim 1 0 )$ . Besides, we observe that heavily overlapped colored blocks can hinder visual grounding. Therefore, we divide the image regions into batches, where each batch contains a handful of moderately overlapping image regions, and mark each batch with a visual sub-prompt respectively. To handle the batches that do not contain the target region, we further introduce a new candidate text none in the decoding vocabulary, to indicate that there is no target region in the batch.
74
+
75
+ # 3.5 CPT FOR PREDICATE CLASSIFICATION
76
+
77
+ In the previous sections, we introduced CPT for visual grounding. In fact, CPT can also be easily adapted to other cross-modal tasks, such as predicate classification. Given an object pair (including the categories and bounding boxes) in an image, predicate classification aims to classify the relation into a relation set $\mathcal { P }$ , providing structured image representations that can facilitate many cross-modal tasks (Johnson et al., 2015; Hudson & Manning, 2019; Shi et al., 2019). In the literature, since the ground-truth relations cannot be exhaustively annotated during evaluation, to avoid false negatives, previous works typically score the triplets and evaluate the recall of top-N triplets (Xu et al., 2017; Zellers et al., 2018; Chen et al., 2019; Tang et al., 2019).
78
+
79
+ Visual and Textual Sub-prompts. As shown in Figure 2, to perform predicate classification, CPT first marks the image regions with visual sub-prompt as in Section 3.2, and puts the object pair in the query template as follows:
80
+
81
+ $$
82
+ \mathcal { T } _ { r } ( s , o ) = [ \mathrm { C L S } ] \ \mathrm { T h e } \ s _ { w } \ \mathrm { i n } \ c _ { w } ^ { i } \ \mathrm { c o l o r \ i s \Gamma [ \mathrm { M A S K } ] \ t h e } \ o _ { w } \ \mathrm { i n } \ c _ { w } ^ { j } \ \mathrm { c o l o r \ [ \mathrm { S B } \mathrm { T } ] \ . }
83
+ $$
84
+
85
+ where $s _ { w }$ is the subject text, $o _ { w }$ is the object text, and $c _ { w } ^ { i }$ and $c _ { w } ^ { j }$ are the corresponding color texts. Then VL-PTMs are prompted to recover the relation texts from masked tokens in the template. To accommodate the varied number of tokens in relation texts (e.g., wearing, walking on, typically $1 { \sim } 3$ tokens), we introduce a variable $l$ indicating the number of tokens in a relation text (e.g., $l = 2$ for walking on). The template $\tau ( \cdot ; l )$ will have $l$ consecutive masked tokens for relation prediction. For each template $\tau ( \cdot ; l )$ , we introduce a special NA relation consisting of $l$ tokens, which indicates that there is no relation between the entity pair under $\tau ( \cdot ; l )$ . Specifically, in our experiments, the NA relation is irrelevant, no relation, no relation with for $l = { 1 , 2 , 3 }$ respectively.
86
+
87
+ Training. Given a relational triplet $( s , r , o )$ , after decorating the input image regions and the object pair with visual and textual sub-prompts, VL-PTMs are optimized with the MLM loss to recover the relational tokens. Specifically, denote the number of tokens in $r$ as $| r |$ . (1) For templates where $l = | r |$ , models are asked to reconstruct the ith masked token in $\mathcal { T } ( s , o ; l )$ with the ith relational token $r _ { i }$ using the MLM head. (2) For templates where $l \neq | r |$ , since there is no relation between $( s , o )$ under $\mathcal { T } ( s , o ; l )$ , models are asked to reconstruct the NA relation. For $( s , o )$ that do not have any relation in the image, models are asked to reconstruct the NA relation for all $\dot { \mathcal { T } } ( s , o ; l )$ .
88
+
89
+ Inference. During inference, given an object pair $( s , o )$ , we score the relations based on their fitness to the prompt context. Specifically, the score of each relation $r ~ \in ~ \mathcal { P } ~ \cup ~ \{ \mathrm { N A } \}$ is obtained by the aggregated MLM scores of its composing tokens under the corresponding template: $\begin{array} { r } { s ( r ) = { \frac { 1 } { l } } \sum _ { i = 1 } ^ { l } \log P ( \mathrm { \mathop { M A S K } } ] _ { i } = r _ { i } | { \mathcal T } ( s , o ; l ) ) } \end{array}$ , where $l = | r |$ . Intuitively, larger $s ( r )$ indicates that the relation $r$ better fits the prompt context. Finally, the triplets $( s , r , o )$ are ranked according to the relation score $s ( r )$ , where $r \in \mathcal { P }$ .
90
+
91
+ Compared with visual grounding that aims to locate image regions for ungrounded texts, predicate classification represents a different series of cross-modal tasks that aim to perform semantic recognition based on grounded inputs, such as object classification (Zhao et al., 2017) and scene graph classification ( $\mathrm { { X u } }$ et al., 2017). In addition to better data efficiency, a crucial advantage of using CPT is that the semantic labels can be produced from open-world vocabularies, instead of fixed label sets.
92
+
93
+ # 4 EXPERIMENTS
94
+
95
+ In this section, we empirically evaluate CPT in prompting VL-PTMs for visual grounding in different settings, including zero-shot, few-shot and fully supervised settings. We refer readers to Section C for the implementation details.
96
+
97
+ # 4.1 EXPERIMENTAL SETTINGS
98
+
99
+ We first introduce the experimental settings of the visual grounding task, including datasets, training settings, evaluation protocols and baseline models in our experiments.
100
+
101
+ Datasets. Following previous works (Rohrbach et al., 2016; Zhang et al., 2018), we adopt three widely used visual grounding datasets collected from MSCOCO images (Lin et al., 2014), including RefCOCO (Yu et al., 2016), RefCOCO $^ +$ (Yu et al., 2016) and RefCOCOg (Mao et al., 2016). We refer readers to Section D.2 for more dataset details.
102
+
103
+ Training Settings. We report experimental results of different training settings, including (1) zeroshot setting, where no training data is available, (2) few-shot setting, where $K$ training instances are available $\begin{array} { r } { K = 1 , 2 , 4 , 8 , 1 6 , } \end{array}$ , and (3) fully supervised setting, where the full training set is available.
104
+
105
+ Evaluation Protocols. (1) Evaluation metrics. Following Zhang et al. (2018); Lu et al. (2019), we adopt accuracy of the grounding results as the evaluation metrics. An expression is considered correctly grounded if the IoU of the top predicted region and the ground truth is greater than 0.5. (2) Model validation. To better approximate the few-shot scenario where only a few labeled instances are available, inspired by Gao et al. (2021), we use a few-shot validation set (consisting of 16 instances) for few-shot and zero-shot experiments, and use full validation set for fully supervised experiments. (3) Robust evaluation. Previous works have shown that model training on limited data can suffer from instability (Dodge et al., 2020; Gao et al., 2021). For a robust and comprehensive evaluation, we report mean results over 5 random training set splits, as well as the standard deviation. For fair comparisons, the training and validation sets are identical for our baselines and CPT.
106
+
107
+ Baselines. We evaluate two variants of CPT, including CPT using colored blocks (CPT-Blk) and colored segmentation masks (CPT-Seg). We adopt the widely used VinVL (Zhang et al., 2021)
108
+
109
+ Table 1: Main results. Accuracies $( \% )$ of grounding referring expressions in zero-shot, few-shot and fully supervised settings. We report mean and standard deviation performance over 5 random splits. ZS: zero-shot. Blk: colored block, Seg: colored segmentation mask.
110
+
111
+ <table><tr><td rowspan="2"></td><td rowspan="2">Shot</td><td rowspan="2">Model</td><td colspan="3">RefCOCO</td><td colspan="3">RefCOCO+</td><td colspan="3">RefCOCOg</td></tr><tr><td>val</td><td>testA</td><td>testB</td><td>val</td><td>testA</td><td>testB</td><td>val</td><td>test</td><td></td></tr><tr><td>S</td><td>0</td><td>Random CPT-Blk CPT-Seg</td><td>15.9 ± 0.2 26.9 32.2</td><td>19.4 ±0.6 27.5 36.1</td><td>13.4± 0.4 27.4 30.3</td><td>16.1 ± 0.1 25.4 31.9</td><td>13.3±0.6 25.0 35.2</td><td>20.0±0.2 27.0 28.8</td><td>18.8± 0.4 32.1 36.7</td><td></td><td>19.2 ± 0.3 32.3 36.5</td></tr><tr><td></td><td>1</td><td>Fine-tuning CPT-Blk CPT-Seg</td><td>16.5 ± 4.9 34.1 ± 1.3 37.2 ± 0.9 22.5 ± 4.5</td><td>12.0±6.6 37.7 ± 1.7 41.5 ± 1.5 21.0 ± 7.2</td><td>23.5 ±5.7 32.2 ± 1.5 33.2 ±1.7</td><td>22.2±7.6 35.9 ± 4.1 37.9 ± 4.0</td><td>20.6±9.3 40.4±5.4 42.3± 5.9</td><td>25.7±5.2 32.2±2.6 33.9±2.4</td><td>26.9± 8.4 39.7± 3.4 43.1± 2.9</td><td></td><td>26.9± 8.1 39.9 ± 3.0 43.4 ± 3.1</td></tr><tr><td></td><td>2</td><td>Fine-tuning CPT-Blk CPT-Seg</td><td>35.3±3.2 39.8 ±1.7</td><td>25.9 ±4.7 39.6±3.0 30.9 ± 1.7 45.6±3.2 33.9 ±0.4</td><td>27.0 ±3.1 33.3±3.6 38.6±3.6</td><td>27.8±4.2 37.5±4.8 44.5± 4.5</td><td>27.0±2.6 30.3±2.5 32.8±3.8</td><td>28.4±12.0 40.1± 5.1 44.7 ± 5.1</td><td></td><td>28.1 ± 11.3 40.0± 4.7</td><td>44.3± 4.8</td></tr><tr><td>Jtpp-eg</td><td>4</td><td>Fine-tuning CPT-Blk CPT-Seg</td><td>29.1 ±5.0 38.3 ± 2.1 40.7 ± 3.2</td><td>29.9 ±7.8 43.6 ± 3.3 47.4 ± 4.1</td><td>29.8±5.3 34.0 ± 1.6 35.3 ±1.8</td><td>34.2 ± 4.2 37.7 ± 5.2 38.8±3.8 40.3 ± 2.0 46.5 ± 3.1</td><td>30.5±3.3 44.4± 6.4 33.5 ± 1.5 34.5 ±1.5</td><td></td><td>34.0 ± 13.1 40.6± 7.9 44.4 ± 6.9</td><td>40.9 ± 7.9</td><td>33.7 ±12.8 44.4 ± 6.9</td></tr><tr><td></td><td>8</td><td>Fine-tuning CPT-Blk CPT-Seg</td><td>34.6± 4.8 41.0 ± 1.5 41.3 ± 2.6</td><td>37.8± 5.5 43.9 ± 1.7 48.2 ± 4.6</td><td>31.4 ± 5.1 35.8±2.2 35.7±2.5</td><td>36.2±3.6 39.3 ± 1.5 42.6 ± 2.9</td><td>40.1 ± 4.6 46.1 ± 1.8 49.3 ± 4.7</td><td>32.7±2.3 33.2 ±1.3 35.4 ±1.0</td><td>40.6 ± 11.2 43.4± 6.5 47.4 ± 3.5</td><td></td><td>40.4 ± 11.7 43.6± 6.4 47.4 ± 3.5</td></tr><tr><td></td><td>16</td><td>Fine-tuning CPT-Blk CPT-Seg</td><td>39.8 ± 4.2 44.8± 3.3 45.3 ±1.8</td><td>45.5± 5.0 51.4 ± 4.1 53.3± 3.0</td><td>34.9 ±3.0 38.2 ± 2.3 37.5 ±1.3</td><td>41.8 ±3.0 41.5 ± 1.3 44.8 ± 0.9</td><td>47.3 ± 3.1 48.2 ± 2.1 52.5±1.2</td><td>36.2 ±2.3 34.7±0.9 36.6 ± 1.2</td><td>47.5± 4.1 47.8± 2.1 51.0± 2.6</td><td></td><td>47.8± 4.7 48.2± 2.8 51.4 ± 2.8</td></tr><tr><td>Psnnr</td><td>VL-T5</td><td>MAttNet</td><td>76.7 1</td><td>81.1 1</td><td>70.0 1</td><td>65.3 1</td><td>71.6 1 78.5</td><td>52.0 二 62.6</td><td>66.6 71.2</td><td></td><td>67.3 71.3</td></tr><tr><td></td><td>|Dtrainl</td><td>ViLBERT VLBERT ERNIE-ViL UNITER Fine-tuning</td><td>二 一 81.2</td><td>二 一 一 86.5</td><td>二 1</td><td>72.3 71.6 74.0</td><td>77.7 80.3</td><td>61.0 64.7</td><td>1 二</td><td></td><td>1 二</td></tr></table>
112
+
113
+ as the CPT backbone. We compare CPT with a series of strong baselines that utilize detected proposals, including vanilla fine-tuning of $\mathrm { V i n V L }$ and other VL-PTMs (see Section D.1 for more baseline details). For fair comparisons, we adopt the base size for all VL-PTMs. We refer readers to Section A.1 for the results of large size VL-PTMs.
114
+
115
+ # 4.2 MAIN RESULTS
116
+
117
+ The main results are reported in Table 1, from which we observe that: (1) CPT outperforms the random baseline and the strong fine-tuning baseline by a large margin in zero-shot and few-shot settings. For example, using colored blocks as visual sub-prompts, CPT achieves $1 7 . 3 \%$ absolute accuracy improvement on average with one shot in RefCOCO evaluation. This indicates that CPT can effectively improve sample efficiency in tuning VL-PTMs. (2) Coloring objects with segmentation masks in visual sub-prompts (CPT-Seg) achieves even better results than blocks (CPT-Blk). The reason is that solid colors that fit the outlines of objects are more common in real-world images, making CPT-Seg more natural visual sub-prompts (despite requiring stronger annotation to train the segmentation tools). (3) Notably, CPT achieves significantly smaller standard deviation than fine-tuning. For example, CPT-Blk achieves $7 3 . 8 \%$ relative standard deviation reduction on average with one shot in RefCOCO evaluation. This shows that a coherent tuning approach from pre-training can lead to substantially more stable few-shot training, which is a crucial factor for evaluating few-shot learning models (Gao et al., 2021). (4) We note that CPT-Blk slightly underperforms fine-tuning with 16 shots in $\operatorname { R e f C O C O + }$ evaluation. The reason is that $\operatorname { R e f C O C O + }$ has more colorbased expressions (e.g., the person in red shirt and blue hat), which can disturb our color-based CPT. However, this problem can be alleviated with more tuning instances in the fully supervised scenario, where models can learn to better distinguish colors in the query text and prompt template. (5) CPT models achieve comparable performance to strong fine-tuned VL-PTMs in the fully supervised settings. This shows that CPT is a competitive tuning approach for VL-PTMs even in the fully supervised scenario. We note that CPT-Blk slightly outperforms CPT-Seg in the fully supervised setting, and we refer readers to Section A.3 for a detailed analysis. In summary, compared to the vanilla fine-tuning approach, CPT achieves superior/comparable, and more stable performance in zero-shot, few-shot and fully supervised visual grounding.
118
+
119
+ # 4.3 INFLUENCE OF COLORS IN CPT’S VISUAL GROUNDING
120
+
121
+ In our analysis, we first investigate the influence of colors—the key ingredients—in the visual grounding performance of CPT. Specifically, we compare colors obtained from the frequency-based baseline (Freq) (See Section 3.4) and our cross-modal prompt search method CPS (Ours) in two dimensions, including an overall evaluation of top-N colors and a zoom-in study of individual colors. Unless otherwise specified, all the following experiments are conducted based on CPT-Blk on the validation set of RefCOCO in $0 , 2 , 8$ shot settings.
122
+
123
+ Table 2: Top-6 colors from the frequency-based baseline and our CPS. Visual appearances and color texts are reported. Best viewed in color.
124
+
125
+ <table><tr><td>Model</td><td>Color #1</td><td>Color #2</td><td>Color #3</td><td>Color #4</td><td>Color #5</td><td>Color #6</td></tr><tr><td>Freq</td><td>1(255,0,0),red</td><td>■(0.0.0),black</td><td>■(0,0,255),blue</td><td>■ (0,255,0), green</td><td>■ (255,255,0),yellow</td><td>1(165,42,42),brown</td></tr><tr><td>Ours</td><td>1(240,0,30),red</td><td>(155,50,210), purple</td><td>(255,255,25),yellow</td><td>(0,10,255), blue</td><td>■ (255,170,230),pink</td><td>(0,255,0), green</td></tr></table>
126
+
127
+ Overall Evaluation of Top-N Colors. We first show the top-6 colors recommended by each approach in Table 2. To evaluate the overall performance of the top colors from different models, we evaluate CPT equipped with each color from the top-6 colors respectively, and report the mean accuracy and standard deviation over different colors. From the experimental results in Figure 3a, we observe that the top colors produced by CPS achieve both higher mean accuracy and lower standard deviation than the baseline method in different shot-settings. The reason is that CPS jointly considers visual and textual semantics in searching cross-modal prompts, and therefore is able to effectively adjust and rank the colors for more accurate and stable visual grounding.
128
+
129
+ ![](images/00d1c1c073c5dff76871fcddd8e5865999c6dd4c29f4672edc6192658ea28752.jpg)
130
+ Figure 3: Results of utilizing different colors for visual grounding, including (a) an overall evaluation of top-6 colors from different models, and (b) a zoom-in study of aligned individual colors.
131
+
132
+ Zoom-In Study of Individual Colors. To investigate the fine-grained influence of specific colors in CPT’s visual grounding, we further perform a zoom-in study of individual colors. To align the colors for comparison, we merge the top-6 colors from the baseline and CPS, and remove the colors that are not included in the models’ complete color sets (e.g., black $\not \in { \mathcal { C } }$ in CPS). We report the accuracies in Figure 3b, from which we observe that: (1) The performance of different colors varies greatly in prompting VL-PTMs in the same shot-settings, and the optimal colors are different in different shotsettings. The results indicate the large influence of cross-modal prompt configurations, consistent with the findings from recent studies in textual prompt tuning (Jiang et al., 2020; Gao et al., 2021). (2) Colors produced by CPS achieve comparable or superior performance compared to the baseline in individual colors. The results show that given the color texts, CPS can properly adjust the color visual appearance (i.e., RGB) to improve the visual grounding performance. (3) We note that in some cases, colors produced by CPS slightly underperform the baseline. We hypothesize the reason is that, CPS uses a single textual template to compute the decoding scores for color adjustment, which can be biased. The problem can potentially be addressed by ensembling templates as in Qin & Eisner (2021), which we leave for future work.
133
+
134
+ # 4.4 CASE STUDY
135
+
136
+ To provide a more intuitive understanding of CPT, we conduct a case study on the validation set of RefCOCO in 8-shot setting. From the results in Figure 4, we have the following observations: (1) CPT enables VL-PTMs to distinguish target objects distracted by the same of type objects using only a few training instances, while the fine-tuning method struggles to succeed (Figure 4a). (2) CPT can be distracted by hard candidates (e.g., objects of the same type as the target that requires complex reasoning to identify), but will typically produce reasonable predictions. For example, in Figure 4b, CPT predicts a nearby apple while the fine-tuning baseline predicts a bowl. The reason is that CPT maximally reuses the pre-trained parameters of VL-PTMs, which can help prevent outrageous predictions that typically happen in few-shot fine-tuning. (3) However, we find that CPT can be disturbed by colors in raw image regions and text. For example, it can be difficult for the model to identify a red bowl when the candidate regions are colored by red blocks (Figure 4c).
137
+
138
+ ![](images/ffe57b334355fb54678de8ce343179c291890bdcd5ff6750cc4c1e33e65c9b69.jpg)
139
+ Figure 4: Case study. The bounding boxes given by image region proposals (olive), ground-truth annotation (pink), CPT (green), and fine-tuning baseline (yellow) are highlighted accordingly.
140
+
141
+ Table 3: Predicate classification results on Visual Genome. ZS: zero-shot, FS: fully supervised. We report the mean and standard deviation performance over 2 random splits.
142
+
143
+ <table><tr><td rowspan="2">Shot</td><td rowspan="2"></td><td rowspan="2">Model</td><td colspan="4">Val</td><td colspan="4">Test</td></tr><tr><td>R@50</td><td>R@100</td><td>mR@50</td><td>mR@100</td><td>R@50</td><td>R@100</td><td>mR@50</td><td>mR@100</td></tr><tr><td>S</td><td>0</td><td>Random CPT-Blk</td><td>1.6 ± 0.2 33.6</td><td>1.8±0.2 34.7</td><td>1.1±0.2 14.8</td><td>1.3±0.1 15.5</td><td>1.5±0.0 29.3</td><td>1.8±0.1 30.5</td><td>1.2 ±0.1 13.0</td><td>1.6 ± 0.1 14.5</td></tr><tr><td rowspan="4">Fs-etr</td><td>1</td><td>Fine-tuning CPT-Blk</td><td>3.8±0.1 16.3 ± 2.0</td><td>4.2 ±0.1 17.5 ± 2.3</td><td>7.8±0.9 25.2 ±0.7</td><td>8.7±1.0 27.4 ± 0.8</td><td>4.1 ± 0.1 18.0 ± 2.8</td><td>4.7±0.0 20.0±3.0</td><td>6.7±0.3 23.9±0.3</td><td>7.6±0.4 26.3±0.3</td></tr><tr><td>4</td><td>Fine-tuning CPT-Blk</td><td>7.1±1.9 14.4 ± 0.4</td><td>7.6±2.0 15.4 ± 0.4</td><td>10.3±0.8 30.4 ± 1.5</td><td>11.7±0.8 32.8 ±1.6</td><td>7.3 ± 1.5 17.7 ± 0.6</td><td>7.9 ± 1.7 19.3 ± 0.6</td><td>11.8 ± 1.0 28.5±1.5</td><td>13.2 ±0.9 32.1 ± 1.0</td></tr><tr><td>16</td><td>Fine-tuning CPT-Blk</td><td>8.4±0.3 15.0 ± 0.6</td><td>8.9±0.3 16.0 ± 0.8</td><td>20.7±0.6 33.0±0.2</td><td>21.7±0.6 35.4 ± 0.6</td><td>10.4±0.7 18.4 ± 1.0</td><td>11.2±0.8 20.0 ± 1.1</td><td>19.7 ±0.1 32.5±0.5</td><td>21.7±0.1 36.1 ± 0.6</td></tr><tr><td>32</td><td>Fine-tuning CPT-Blk</td><td>9.7± 1.1 17.2 ± 0.4</td><td>10.2 ± 1.1 18.2 ± 0.4</td><td>21.9±0.6</td><td>22.9±0.2</td><td>11.7±0.2</td><td>12.4±0.3</td><td>22.0±0.1</td><td>24.1±0.0 37.7 ± 0.3</td></tr><tr><td rowspan="4">S</td><td rowspan="4">|Dtrainl</td><td>Neural Motif</td><td></td><td></td><td>34.6±0.2</td><td>37.9 ± 0.1</td><td>20.8±0.1</td><td>22.3 ± 0.1</td><td>34.0 ± 0.1</td><td></td></tr><tr><td>BGNN</td><td>=</td><td>=</td><td>=</td><td></td><td>65.2</td><td>67.0</td><td>14.8</td><td>16.1</td></tr><tr><td>PCPL</td><td></td><td></td><td></td><td></td><td>59.2 50.8</td><td>61.3 52.6</td><td>30.4 35.2</td><td>32.9</td></tr><tr><td>DT2-ACBS</td><td></td><td></td><td>=</td><td></td><td>23.3</td><td>25.6</td><td>35.9</td><td>37.8 39.7</td></tr></table>
144
+
145
+ # 4.5 EXPERIMENTS ON PREDICATE CLASSIFICATION
146
+
147
+ To investigate the generalization capability of CPT, we evaluate CPT on predicate classification task.
148
+
149
+ Experimental Settings. (1) Datasets. We adopt the popular Visual Genome dataset (Krishna et al., 2017), which contains 50 visual relations. We refer readers to Section D.2 for the dataset details. (2) Evaluation protocols. Following previous works ( $\mathrm { { X u } }$ et al., 2017; Chen et al., 2019), we use recall $@ \mathbf { N }$ $( \mathsf { R } \ @ \mathsf { N } )$ and mean recall $\textstyle { \mathfrak { Q } } \mathbf { N }$ $( \mathrm { m } \mathrm { R @ { N } } )$ as the evaluation metrics. During training, K labeled instances are provided for each relation. (3) Baselines. We adopt fine-tuning of VinVL as our most direct baseline model. Specifically, we feed the image regions and their categories into the model, and concatenate the visual hidden representations of the subject and object. Then the object pair representation is fed into a softmax classifier. All VL-PTMs are in base size. We also report the results of strong baselines that are tailored for the task, and are fully supervised with 315, 642 labeled triplets, including Neural Motif (Zellers et al., 2018), BGNN (Li et al., 2021a), PCPL (Yan et al., 2020) and DT2-ACBS (Desai et al., 2021).
150
+
151
+ Results. From the results in Table 3, we observe that: (1) CPT significantly outperforms the random baseline and the strong fine-tuning baseline in zero-shot and few-shot settings. For example, using 32 shots, CPT achieves a strong $\operatorname { m } \mathbf { R } \ @ 1 0 0$ of $3 7 . 7 \%$ , outperforming fine-tuning by $1 3 . 6 \%$ absolute points, and closely approaching state-of-the-art fully supervised DT2-ACBS. This indicates that CPT can improve sample efficiency in tuning VL-PTMs. (2) We note that while the macro performance of CPT monotonically increases as the shot number grows, the micro performance drops first in 1- and 4-shot settings. This is due to the distribution gap between the balanced training set (i.e., K shot for each relation) and the long-tail test set. Since the relations in the pre-training corpora also follow a long-tail distribution, CPT can achieve a high starting point for micro performance.
152
+
153
+ # 5 RELATED WORK
154
+
155
+ Pre-trained Vision-language Models. Existing VL-PTMs can be roughly divided into three categories according to their pre-training objectives and architectures: (1) Masked language modeling based VL-PTMs are mainly pre-trained to recover the masked tokens (Lu et al., 2019; Su et al., 2019; Tan & Bansal, 2019; Li et al., 2020; Yu et al., 2021); (2) Auto-regressive language modeling based VL-PTMs model image and text tokens with Transformer decoders auto-regressively (Ramesh et al., 2021; Wang et al., 2021); (3) Contrastive learning based VL-PTMs are pre-trained to holistically match image-text pairs (Radford et al., 2021; Li et al., 2021b). Note that our Cross-modal Prompt Tuning (CPT) framework is orthogonal to VL-PTM design. In this work, without loss of generality, we focus on prompting masked language modeling based VL-PTMs due to their prevalence and superior performance, while applying CPT to other VL-PTMs is also applicable.
156
+
157
+ Prompt Tuning for NLP. Prompt tuning for pre-trained language models is a rapidly emerging field in NLP (Raffel et al., 2019; Brown et al., 2020; Liu et al., 2021). Originally designed for probing knowledge in pre-trained language models (Petroni et al., 2019), prompt tuning has now been extended to handle a variety of NLP tasks, including language understanding (Schick & Schutze, ¨ 2021a;b) and generation (Li & Liang, 2021). To facilitate prompt engineering, Shin et al. (2020) propose to automatically generate prompt templates via gradient-based search. Most related to our work are Tsimpoukelli et al. (2021); Zhou et al. (2021); Wang et al. (2021) that present textual prompt tuning for VL-PTMs, achieving promising results on some vision-language tasks. However, similar to existing works in NLP, they focus on prompt engineering in text, keeping images untouched, and therefore can only perform holistic implicit visual grounding. In comparison, to the best of our knowledge, CPT is the first cross-modal prompt tuning framework tailored for both image and text, and is capable of explicitly grounding natural language to fine-grained image regions.
158
+
159
+ Visual Grounding. There is a general consensus that visual grounding plays an essential role in solving vision-language tasks (Karpathy & Fei-Fei, 2015; Plummer et al., 2015; Goodfellow et al., 2016; Krishna et al., 2017; Lu et al., 2019). Mao et al. (2016) propose the referring expression comprehension task to explicitly evaluate the visual grounding capability. To address the task, most models learn to classify or rank image region candidates based on the expressions in a fully supervised fashion (Mao et al., 2016; Zhang et al., 2018; Lu et al., 2019; Chen et al., 2020), requiring large amounts of costly human-annotated data. To alleviate reliance on human annotation, some works have investigated zero-/few-shot grounding of new object types (Sadhu et al., 2019; Blukis et al., 2020), whereas amounts of training data are still needed for existing object types. In comparison, we prompt general VL-PTMs for zero- and few-shot visual grounding in a reformulated fill-in-the-blank paradigm independent of specific object types.
160
+
161
+ # 6 CONCLUSION AND FUTURE WORK
162
+
163
+ In this work, we present the first Cross-modal Prompt Tuning (CPT) framework for VL-PTMs. To facilitate prompt engineering, we present a principled approach to search for cross-modal prompt configurations. Comprehensive experimental results demonstrate the effectiveness of CPT on zeroshot, few-shot and fully supervised visual grounding. In future, we plan to address the color disturbance and improve the computation efficiency of CPT, and also investigate the effectiveness of CPT on other vision-language tasks. As the first attempt in cross-modal prompt tuning, we propose a color-based framework as one of the possible prompt tuning solutions. We leave exploring other plausible prompt tuning approaches of VL-PTMs for future work.
164
+
165
+ # 7 ETHICS STATEMENT
166
+
167
+ In this section, we discuss the main ethical considerations of CPT: (1) Intellectual property protection. The codes and data adopted from previous works are granted for research-purpose usage. (2) Privacy. The data adopted in this work (i.e., the pre-training data and tuning data) is created by human annotators for research purposes, and should not cause privacy issues. (3) Potential problems. VL-PTMs may be biased towards some objects and attributes. There are increasing efforts to address the problem in the community (Ross et al., 2021; Zhao et al., 2021).
168
+
169
+ # 8 REPRODUCIBILITY STATEMENT
170
+
171
+ To maximize the reproducibility, we provide a clear description of the methodology in Section 3, the pseudo-code of the model in Section B, implementation details in Section C, and detailed data characteristics and evaluation protocols in Section 4.1. All the data and codes will be available to facilitate future research.
172
+
173
+ # REFERENCES
174
+
175
+ Peter Anderson, Xiaodong He, Chris Buehler, Damien Teney, Mark Johnson, Stephen Gould, and Lei Zhang. Bottom-up and top-down attention for image captioning and visual question answering. In Proceedings of CVPR, pp. 6077–6086, 2018a.
176
+
177
+ Peter Anderson, Qi Wu, Damien Teney, Jake Bruce, Mark Johnson, Niko Sunderhauf, Ian Reid, ¨ Stephen Gould, and Anton van den Hengel. Vision-and-language navigation: Interpreting visually-grounded navigation instructions in real environments. In Proceedings of CVPR, June 2018b.
178
+
179
+ Stanislaw Antol, Aishwarya Agrawal, Jiasen Lu, Margaret Mitchell, Dhruv Batra, C Lawrence Zitnick, and Devi Parikh. VQA: Visual question answering. In Proceedings of ICCV, pp. 2425–2433, 2015.
180
+
181
+ Valts Blukis, Ross A Knepper, and Yoav Artzi. Few-shot object grounding and mapping for natural language robot instruction following. arXiv preprint arXiv:2011.07384, 2020.
182
+
183
+ Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
184
+
185
+ Tianshui Chen, Weihao Yu, Riquan Chen, and Liang Lin. Knowledge-embedded routing network for scene graph generation. In Proceedings of CVPR, pp. 6163–6171, 2019.
186
+
187
+ Yen-Chun Chen, Linjie Li, Licheng Yu, Ahmed El Kholy, Faisal Ahmed, Zhe Gan, Yu Cheng, and Jingjing Liu. UNITER: Universal image-text representation learning. In Proceedings of ECCV, pp. 104–120. Springer, 2020.
188
+
189
+ Jaemin Cho, Jie Lei, Hao Tan, and Mohit Bansal. Unifying vision-and-language tasks via text generation. In Proceedings of ICML, PMLR, pp. 1931–1942, 2021.
190
+
191
+ Abhishek Das, Satwik Kottur, Khushi Gupta, Avi Singh, Deshraj Yadav, Jose MF Moura, Devi ´ Parikh, and Dhruv Batra. Visual dialog. In Proceedings of CVPR, pp. 326–335, 2017.
192
+
193
+ Alakh Desai, Tz-Ying Wu, Subarna Tripathi, and Nuno Vasconcelos. Learning of visual relations: The devil is in the tails. In Proceedings of ICCV, pp. 15404–15413, 2021.
194
+
195
+ Jesse Dodge, Gabriel Ilharco, Roy Schwartz, Ali Farhadi, Hannaneh Hajishirzi, and Noah Smith. Fine-tuning pretrained language models: Weight initializations, data orders, and early stopping. arXiv preprint arXiv:2002.06305, 2020.
196
+
197
+ Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. In Proceedings of ACL, 2021.
198
+
199
+ Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep learning. MIT press, 2016.
200
+
201
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of CVPR, pp. 770–778, 2016.
202
+
203
+ Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask R-CNN. In ´ Proceedings of the ICCV, pp. 2961–2969, 2017.
204
+
205
+ Drew A. Hudson and Christopher D. Manning. Learning by abstraction: The neural state machine. In Proceedings of NeurIPS, pp. 5901–5914, 2019.
206
+
207
+ Zhengbao Jiang, Frank F Xu, Jun Araki, and Graham Neubig. How can we know what language models know? TACL, 8:423–438, 2020.
208
+
209
+ Justin Johnson, Ranjay Krishna, Michael Stark, Li-Jia Li, David Shamma, Michael Bernstein, and Li Fei-Fei. Image retrieval using scene graphs. In Proceedings of CVPR, pp. 3668–3678, 2015.
210
+
211
+ Andrej Karpathy and Li Fei-Fei. Deep visual-semantic alignments for generating image descriptions. In Proceedings of CVPR, pp. 3128–3137, 2015.
212
+
213
+ Sahar Kazemzadeh, Vicente Ordonez, Mark Matten, and Tamara Berg. ReferitGame: Referring to objects in photographs of natural scenes. In Proceedings of EMNLP, pp. 787–798, 2014.
214
+
215
+ Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A Shamma, et al. Visual genome: Connecting language and vision using crowdsourced dense image annotations. IJCV, 123(1):32–73, 2017.
216
+
217
+ Rongjie Li, Songyang Zhang, Bo Wan, and Xuming He. Bipartite graph network with adaptive message passing for unbiased scene graph generation. In Proceedings of CVPR, pp. 11109– 11119, 2021a.
218
+
219
+ Wei Li, Can Gao, Guocheng Niu, Xinyan Xiao, Hao Liu, Jiachen Liu, Hua Wu, and Haifeng Wang. UNIMO: Towards unified-modal understanding and generation via cross-modal contrastive learning. In Proceedings of ACL, pp. 2592–2607. Association for Computational Linguistics, 2021b.
220
+
221
+ Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. arXiv preprint arXiv:2101.00190, 2021.
222
+
223
+ Xiujun Li, Xi Yin, Chunyuan Li, Pengchuan Zhang, Xiaowei Hu, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, et al. Oscar: Object-semantics aligned pre-training for vision-language tasks. In Proceedings of ECCV, pp. 121–137. Springer, 2020.
224
+
225
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C Lawrence Zitnick. Microsoft COCO: Common objects in context. In ´ Proceedings of ECCV, pp. 740–755. Springer, 2014.
226
+
227
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. Pretrain, prompt, and predict: A systematic survey of prompting methods in natural language processing. arXiv preprint arXiv:2107.13586, 2021.
228
+
229
+ Jiasen Lu, Dhruv Batra, Devi Parikh, and Stefan Lee. ViLBERT: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. Proceedings of NeurIPS, 32:13–23, 2019.
230
+
231
+ Junhua Mao, Jonathan Huang, Alexander Toshev, Oana Camburu, Alan L Yuille, and Kevin Murphy. Generation and comprehension of unambiguous object descriptions. In Proceedings of CVPR, pp. 11–20, 2016.
232
+
233
+ Fabio Petroni, Tim Rocktaschel, Sebastian Riedel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, and ¨ Alexander Miller. Language models as knowledge bases? In Proceedings of EMNLP-IJCNLP, pp. 2463–2473, 2019.
234
+
235
+ Bryan A Plummer, Liwei Wang, Chris M Cervantes, Juan C Caicedo, Julia Hockenmaier, and Svetlana Lazebnik. Flickr30k entities: Collecting region-to-phrase correspondences for richer imageto-sentence models. In Proceedings of ICCV, pp. 2641–2649, 2015.
236
+
237
+ Guanghui Qin and Jason Eisner. Learning how to ask: Querying LMs with mixtures of soft prompts. In Proceedings of NAACL, pp. 5203–5212, 2021.
238
+
239
+ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. arXiv preprint arXiv:2103.00020, 2021.
240
+
241
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.
242
+
243
+ Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. arXiv preprint arXiv:2102.12092, 2021.
244
+
245
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster R-CNN: Towards real-time object detection with region proposal networks. Proceedings of NeurIPS, 28:91–99, 2015.
246
+
247
+ Anna Rohrbach, Marcus Rohrbach, Ronghang Hu, Trevor Darrell, and Bernt Schiele. Grounding of textual phrases in images by reconstruction. In Proceedings of ECCV, pp. 817–834. Springer, 2016.
248
+
249
+ Candace Ross, Boris Katz, and Andrei Barbu. Measuring social biases in grounded vision and language embeddings. In Proceedings of NAACL, pp. 998–1008, 2021.
250
+
251
+ Arka Sadhu, Kan Chen, and Ram Nevatia. Zero-shot grounding of objects from natural language queries. In Proceedings of ICCV, pp. 4694–4703, 2019.
252
+
253
+ Timo Schick and Hinrich Schutze. It’s not just size that matters: Small language models are also ¨ few-shot learners. In Proceedings of NAACL, pp. 2339–2352. Association for Computational Linguistics, 2021a.
254
+
255
+ Timo Schick and Hinrich Schutze. Exploiting cloze-questions for few-shot text classification and ¨ natural language inference. In Proceedings of EACL, pp. 255–269, 2021b.
256
+
257
+ Jiaxin Shi, Hanwang Zhang, and Juanzi Li. Explainable and explicit visual reasoning over scene graphs. In Proceedings of CVPR, pp. 8376–8384, 2019.
258
+
259
+ Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. Eliciting knowledge from language models using automatically generated prompts. In Proceedings of EMNLP, pp. 4222–4235, 2020.
260
+
261
+ Weijie Su, Xizhou Zhu, Yue Cao, Bin Li, Lewei Lu, Furu Wei, and Jifeng Dai. VL-BERT: Pretraining of generic visual-linguistic representations. In Proceedings of ICLR, 2019.
262
+
263
+ Hao Tan and Mohit Bansal. LXMERT: Learning cross-modality encoder representations from transformers. In Proceedings of EMNLP-IJCNLP, pp. 5100–5111, 2019.
264
+
265
+ Kaihua Tang, Hanwang Zhang, Baoyuan Wu, Wenhan Luo, and Wei Liu. Learning to compose dynamic tree structures for visual contexts. In Proceedings of CVPR, pp. 6619–6628, 2019.
266
+
267
+ Stefanie Tellex, Thomas Kollar, Steven Dickerson, Matthew Walter, Ashis Banerjee, Seth Teller, and Nicholas Roy. Understanding natural language commands for robotic navigation and mobile manipulation. In Proceedings of AAAI, volume 25, 2011.
268
+
269
+ Maria Tsimpoukelli, Jacob Menick, Serkan Cabi, SM Eslami, Oriol Vinyals, and Felix Hill. Multimodal few-shot learning with frozen language models. arXiv preprint arXiv:2106.13884, 2021.
270
+
271
+ Zirui Wang, Jiahui Yu, Adams Wei Yu, Zihang Dai, Yulia Tsvetkov, and Yuan Cao. SimVLM: Simple visual language model pretraining with weak supervision. arXiv preprint arXiv:2108.10904, 2021.
272
+
273
+ Danfei Xu, Yuke Zhu, Christopher B Choy, and Li Fei-Fei. Scene graph generation by iterative message passing. In Proceedings of CVPR, pp. 5410–5419, 2017.
274
+
275
+ Shaotian Yan, Chen Shen, Zhongming Jin, Jianqiang Huang, Rongxin Jiang, Yaowu Chen, and XianSheng Hua. Pcpl: Predicate-correlation perception learning for unbiased scene graph generation. In Proceedings of ACM Multimedia, pp. 265–273, 2020.
276
+
277
+ Fei Yu, Jiji Tang, Weichong Yin, Yu Sun, Hao Tian, Hua Wu, and Haifeng Wang. ERNIE-ViL: Knowledge enhanced vision-language representations through scene graphs. In Proceedings of AAAI, volume 35, pp. 3208–3216, 2021.
278
+
279
+ Licheng Yu, Patrick Poirson, Shan Yang, Alexander C Berg, and Tamara L Berg. Modeling context in referring expressions. In Proceedings of ECCV, pp. 69–85. Springer, 2016.
280
+
281
+ Licheng Yu, Zhe Lin, Xiaohui Shen, Jimei Yang, Xin Lu, Mohit Bansal, and Tamara L Berg. MAttNet: Modular attention network for referring expression comprehension. In Proceedings of CVPR, pp. 1307–1315, 2018.
282
+
283
+ Rowan Zellers, Mark Yatskar, Sam Thomson, and Yejin Choi. Neural motifs: Scene graph parsing with global context. In Proceedings of CVPR, pp. 5831–5840, 2018.
284
+
285
+ Rowan Zellers, Yonatan Bisk, Ali Farhadi, and Yejin Choi. From recognition to cognition: Visual commonsense reasoning. In Proceedings of CVPR, pp. 6720–6731, 2019.
286
+
287
+ Hanwang Zhang, Yulei Niu, and Shih-Fu Chang. Grounding referring expressions in images by variational context. In Proceedings of CVPR, pp. 4158–4166, 2018.
288
+
289
+ Pengchuan Zhang, Xiujun Li, Xiaowei Hu, Jianwei Yang, Lei Zhang, Lijuan Wang, Yejin Choi, and Jianfeng Gao. VinVL: Revisiting visual representations in vision-language models. In Proceedings of CVPR, pp. 5579–5588, 2021.
290
+
291
+ Bo Zhao, Jiashi Feng, Xiao Wu, and Shuicheng Yan. A survey on deep learning-based fine-grained object classification and semantic segmentation. IJAC, 14(2):119–135, 2017.
292
+
293
+ Tony Z Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In Proceedings of the ICML, 2021.
294
+
295
+ Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for visionlanguage models. arXiv preprint arXiv:2109.01134, 2021.
296
+
297
+ # A SUPPLEMENTARY EXPERIMENTS
298
+
299
+ # A.1 RESULTS OF LARGE SIZE VL-PTMS
300
+
301
+ In this section, we report the experimental results of large size VL-PTMs, including vanilla finetuning of baseline VL-PTMs, CPT-Blk and CPT-Seg with large size backbone (i.e., $1 , 0 2 4$ dimensional hidden representations and 24 layers). From the experimental results in Table 4, we observe that compared with vanilla fine-tuning, CPT achieves significantly better and more stable performance in zero-shot and few-shot settings, and comparable results in the fully supervised settings, which is consistent with the conclusions of main experiments in Section 4.2. In summary, the results show that CPT can generalize to VL-PTMs of different sizes.
302
+
303
+ Table 4: Results of large size VL-PTMs. Accuracies $( \% )$ of grounding referring expressions in zeroshot, few-shot and fully supervised settings. We report mean and standard deviation performance over 5 random splits. ZS: zero-shot. Blk: colored block, Seg: colored segmentation mask.
304
+
305
+ <table><tr><td rowspan="2"></td><td rowspan="2">Shot</td><td rowspan="2">Model</td><td colspan="3">RefCOCO</td><td colspan="3">RefCOCO+</td><td colspan="2">RefCOCOg</td></tr><tr><td>val</td><td>testA</td><td>testB</td><td>val</td><td>testA</td><td>testB</td><td>val</td><td>test</td></tr><tr><td>sS</td><td>0</td><td>Random CPT-Blk CPT-Seg</td><td>15.9 ± 0.2 25.7 29.5</td><td>19.4± 0.6 25.4 30.6</td><td>13.4± 0.4 27.0 28.7</td><td>16.1± 0.1 25.9 28.8</td><td>13.3±0.6 25.8 30.3</td><td>20.0±0.2 25.7 27.4</td><td>18.8± 0.4 32.9 34.6</td><td>19.2 ± 0.3 32.6 34.8</td></tr><tr><td></td><td>1</td><td>Fine-tuning CPT-Blk CPT-Seg</td><td>18.5± 3.4 36.4± 3.5 39.3 ± 4.2</td><td>13.7 ± 4.8 39.1± 4.3 43.2 ± 5.6</td><td>25.0±3.7 34.3± 2.7 35.5± 2.4</td><td>23.0±6.5 34.4±3.8 35.9 ± 3.8</td><td>22.8±8.2 38.7±5.4 41.0 ± 5.0</td><td>23.6 ± 4.5 31.2 ± 2.5 31.2 ±2.8</td><td>30.6±7.3 38.7± 4.8 40.9 ± 6.0</td><td>31.5 ± 7.4 38.7± 4.6 41.0 ± 6.1</td></tr><tr><td></td><td>2</td><td>Fine-tuning CPT-Blk CPT-Seg</td><td>23.4±3.5 38.3±2.9 41.4 ± 1.5 27.8±4.8</td><td>21.1 ± 5.2 40.5 ± 4.2 45.8 ± 3.6</td><td>26.7 ± 4.5 35.3 ± 1.2 36.6 ± 2.0</td><td>28.3±2.3 36.2 ± 5.5 38.7 ± 3.8</td><td>30.1± 5.3 41.1 ± 7.6 44.7 ± 5.2</td><td>26.4±2.8 31.9 ±3.3 33.5 ± 2.6</td><td>33.1±8.3 40.6±5.9 43.2 ± 5.9</td><td>33.4±8.2 41.3 ± 6.1 43.4 ± 5.8</td></tr><tr><td>Paretr</td><td>4</td><td>Fine-tuning CPT-Blk CPT-Seg</td><td>40.9 ± 1.8 41.3 ± 5.2</td><td>26.0± 7.8 45.0± 2.0 45.9 ± 7.1</td><td>30.1 ± 3.4 36.6 ± 1.6 36.5 ± 3.7</td><td>33.4±3.5 37.2±3.6 39.8 ± 3.8</td><td>36.8±5.1 42.4± 5.4 45.7 ± 5.7</td><td>28.3±2.1 33.6± 2.3 34.1 ± 1.8</td><td>36.9 ±8.9 42.2±6.5 45.7 ± 7.3</td><td>37.2± 8.7 42.7±6.9</td></tr><tr><td rowspan="2"></td><td rowspan="2">8</td><td rowspan="2">Fine-tuning CPT-Blk CPT-Seg</td><td>33.3±4.2</td><td>35.6 ± 7.4</td><td>31.2 ± 2.7</td><td>38.1±3.7</td><td>43.5±3.9</td><td>31.2±3.8</td><td>41.9 ± 8.0</td><td>45.8 ± 7.6 42.5 ± 7.9</td></tr><tr><td>42.7 ± 4.1 45.2 ± 3.6</td><td>48.4± 5.7 51.4 ± 4.9</td><td>37.3± 2.4 38.7 ± 2.4</td><td>39.9 ± 2.2 42.4 ± 3.8</td><td>45.8 ±3.0 49.0 ± 4.9</td><td>34.6 ± 2.1 35.7 ± 1.8</td><td>44.8 ± 4.1 48.1 ± 5.4</td><td>45.5± 4.6</td></tr><tr><td rowspan="5">Pnrarssrans</td><td rowspan="2">16</td><td>Fine-tuning</td><td>38.4± 2.4</td><td>42.8±4.2</td><td>33.4±2.5</td><td>40.7±3.2</td><td>45.6±3.5</td><td>34.7± 2.8</td><td>48.7±3.5</td><td>48.6 ± 5.8 49.4± 3.5</td></tr><tr><td>CPT-Blk</td><td>45.7± 2.5</td><td>53.0±3.2</td><td>37.9 ± 1.5</td><td>41.8 ± 2.0</td><td>48.8±2.6</td><td>35.7 ± 1.4</td><td>47.7 ± 2.4</td><td>48.6± 2.8</td></tr><tr><td rowspan="9"></td><td rowspan="9">CPT-Seg MAttNet</td><td></td><td>55.9 ± 3.5</td><td>40.3±2.0</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>48.6 ± 3.1</td><td></td><td>43.8±2.0</td><td>50.9± 2.5</td><td>36.5 ± 1.3</td><td>50.8±3.6</td><td>51.6 ± 3.7</td></tr><tr><td>76.7</td><td>81.1</td><td>70.0</td><td>65.3</td><td>71.6</td><td>52.0</td><td>66.6</td><td>67.3</td></tr><tr><td>ViLBERT VLBERT</td><td>1</td><td>-</td><td>1</td><td>72.3</td><td>78.5</td><td>62.6</td><td>-</td></tr><tr><td>ERNIE-ViL |Dtrain]</td><td>1</td><td>-</td><td>-</td><td>72.6</td><td>78.6</td><td>62.3 66.9</td><td>1</td></tr><tr><td>UNITER</td><td>1</td><td>-</td><td>1</td><td>76.0</td><td>82.1</td><td>1 74.9</td><td>=</td></tr><tr><td>Fine-tuning</td><td>81.4</td><td>87.0</td><td>74.2</td><td>75.9</td><td>81.5</td><td>66.7</td><td>75.8</td></tr><tr><td>CPT-Blk</td><td>81.8</td><td>87.5</td><td>73.7 74.3</td><td>74.8 73.6</td><td>81.0 80.1</td><td>64.1 64.1</td><td>74.7 75.8 75.2</td></tr><tr><td>CPT-Seg</td><td>81.5 81.8</td><td>87.0 87.3</td><td>74.1</td><td>74.1</td><td>79.5</td><td>63.8</td><td>74.1 73.6</td></tr></table>
306
+
307
+ # A.2 EFFECT OF COLOR TRANSPARENCY
308
+
309
+ In practice, the color transparency is a crucial hyperparameter in CPT. Essentially, the choice of transparency is a trade-off between two factors: a small transparency can establish strong connections between color texts and visual appearances, but will undermine the visibility of the raw image region contents, and vice versa. To investigate the effect of color transparency, we evaluate CPT with different transparency of the default color (i.e., (240, 0, 30), red), with step size 0.1 in grid search. From the results in Figure 5, we observe that: (1) The performance peaks at moderate transparencies in different shot-settings, which is consistent with our analysis of the trade-off. (2) Interestingly, the optimal transparency increases as the number of training shots grows. The reason is that the bottleneck of visual grounding in low shot settings is to learn to utilize obvious colors in CPT to establish coarse-grained connections between images and text. In comparison, in many shot settings, with a better mastery of colors, fine-grained reading and understanding of image regions become more important to handle hard instances that require complex reasoning (e.g., composition of attributes and relations).
310
+
311
+ ![](images/1b06656849c0a2977287a873c254a28a0608ba06ffcdb6b6b136585e369e9b9a.jpg)
312
+ Figure 5: Experimental results with different color transparencies.
313
+
314
+ ![](images/f8764c4fe7f50af2d1ce9752342244a7a92e35d41941f8b4c90d8125b7f88431.jpg)
315
+ Figure 7: Visualization of grounding results. First row: zero-shot setting. Second row: fully supervised setting. FT: fine-tuning. The bounding boxes given by image region proposals (olive), ground-truth annotation (pink), CPT (green), and fine-tuning baseline (yellow) are highlighted accordingly. Some images are cropped for better visual effects.
316
+
317
+ # A.3 ANALYSIS OF VISUAL SUB-PROMPT SHAPE
318
+
319
+ In the main experimental results in Table 1, we note that although CPT-Seg significantly outperforms CPT-Blk in the zero-shot and few-shot settings, it slightly underperforms CPT-Blk in the fully supervised setting. To investigate the reason, we divide target objects in the validation set of RefCOCOg into disjoint bins according to the area of the bounding boxes, where each bin contains equal numbers of target objects (thus contributes equally to the overall result), and report the average performance of each bin in the fully supervised setting. From the results in Figure 6, we find that CPT-Seg outperforms CPTBlk on large objects, but is inferior in grounding small objects. We hypothesize the reason is that CPT-Seg changes the object outlines with imperfect colored segmentation masks, hindering the understanding and reasoning of objects to some extent. The problem is exacerbated in small objects, since compared with large objects, the segmentation error of small objects is essentially enlarged when the object feature maps are pooled into input features of the same size for Transformers.
320
+
321
+ ![](images/deec7c1b4877699d4d3a7a0fda01858a7a203b37c461f8883a433ddc70f75957.jpg)
322
+ Figure 6: Performance of CPT-Blk and CPT-Seg with base size in different box areas in the fully supervised setting.
323
+
324
+ # A.4 VISUALIZATION
325
+
326
+ The few-shot grounding results are visualized in Figure 4. In this section, we further visualize the grounding results in zero-shot and fully supervised settings, as shown in Figure 7. We find that
327
+
328
+ CPT can make reasonable zero-shot predictions. Moreover, we observe that the color disturbance problem is largely alleviated in the fully supervised setting, i.e., CPT is less disturbed by colors in raw image and text, as shown in Figure 7d. The reason is that a capable VL-PTM can learn to largely distinguish the colors of varying objects and pre-defined maker blocks.
329
+
330
+ # B PSEUDO-CODE OF CROSS-MODAL PROMPT SEARCH
331
+
332
+ Here we provide the pseudo-code of cross-modal prompt search. The algorithm aims to jointly consider visual and textual semantics in real-world cross-modal data to search for the color set $\mathcal { C }$ in CPT. The algorithm is simple in its design, and we leave exploring more advanced cross-modal prompt search methods for future work.
333
+
334
+ <table><tr><td>Algorithm1 Cross-modal Prompt Search</td></tr><tr><td>Require: P(·,·): VL-PTM with image regions R and query text q as input</td></tr><tr><td>Require: Cw: candidate color text set Require:Cy: candidate color RGB set</td></tr><tr><td>1: for c, in Cu do 2: R= {a pure color block ofc}</td></tr><tr><td>3: q=“[CLS] aphoto of[MASK] color[SEP]”</td></tr><tr><td>4: for c in Cw do 5: s(c,cw)=P([MASK]=Cu|R,q) 6: end for</td></tr></table>
335
+
336
+ # C IMPLEMENTATION DETAILS
337
+
338
+ In this section, we provide the implementation details about model training and inference, object detection and segmentation, as well as cross-modal prompt search.
339
+
340
+ Backbone. We adopt the widely used VinVL (Zhang et al., 2021) as the backbone, which achieves strong performance on many vision-language tasks. We use the $\mathrm { V i n V L _ { b a s e } }$ model in the main experiments, with 768 dimensional hidden representations and 12 encoding layers.
341
+
342
+ Object Detection and Segmentation. During training and inference, we use the region proposals predicted by the Faster-RCNN (Ren et al., 2015) and object segmentation masks predicted by the Mask-RCNN (He et al., 2017), which are provided by MAttNet (Yu et al., 2018). Both Faster-RCNN and Mask-RCNN are based on ResNet101 (He et al., 2016) with a region proposal network and a fully connected classifier for object detection. For Mask-RCNN, an additional mask branch is added to conduct multi-task learning. The Faster-RCNN and Mask-RCNN provided by MAttNet (Yu et al., 2018) achieve 34.1 and 30.7 average precision on the COCO test set respectively.
343
+
344
+ Visual Grounding. During training, an image region is considered as the target if its intersectionover-union (IoU) with the ground-truth region is greater than 0.5. During inference, we select the target region with the largest decoding score. All the hyperparameters and models are selected by grid search based on the performance on the few-shot/full validation set. The learning rate is 6e−5, and decreases linearly towards 0, which will be achieved at the end of the training (500 and 20, 000 steps for few-shot and fully supervised training respectively). The batch size is 32 and identical to shot size in fully supervised and few-shot settings respectively. The size of image region batch is 1.
345
+
346
+ Predicate Classification. The hyperparameters and models are selected by grid search on the validation set. The learning rate is 3e-5, and decreases linearly towards 0, which will be achieved at the end of the training (200 steps). The batch size is identical to shot size.
347
+
348
+ Table 5: Relations in Visual Genome dataset (Krishna et al., 2017). Some relations are renamed (shown in parentheses) to better fit the query template.
349
+
350
+ <table><tr><td>at</td><td>in</td><td>to</td><td>on</td><td>of</td><td>and</td><td>for</td><td>has (having)</td></tr><tr><td>says (saying)</td><td>over</td><td>from</td><td>with</td><td>near</td><td>wears (wearing)</td><td>under</td><td>above</td></tr><tr><td>using</td><td>along</td><td>behind</td><td>riding</td><td>across</td><td>eating</td><td>holding</td><td>wearing</td></tr><tr><td>between</td><td>against</td><td>playing</td><td>watching</td><td>carrying</td><td>covering</td><td>made of</td><td>part of</td></tr><tr><td>lying on</td><td>parked on</td><td>flying in</td><td>laying on</td><td>growing on</td><td>looking at</td><td>walking on</td><td>walking in</td></tr><tr><td>sitting on in front of</td><td>covered in on back of</td><td>mounted on</td><td>painted on</td><td>standing on</td><td>attached to</td><td>belonging to</td><td>hanging from</td></tr></table>
351
+
352
+ Cross-modal Prompt Search. The color text candidate set $\hat { \mathcal { C } } _ { w }$ is obtained from Wikipedia at en.wikipedia.org/wiki/Lists_of_colors. The color appearance candidate set $\hat { \mathcal { C } } _ { v }$ is obtained by grid searching RGB candidates around the standard RGBs of color texts in $\hat { \mathcal { C } } _ { w }$ . In grid searching RGB candidates, the range is $\pm 3 0$ around standard RGBs with step size 5 in each channel. Colors candidates are discarded if the decoding score is less than 0.8. The specific color choice from $\mathcal { C }$ is determined based on the performance on the few-shot/full validation set. The optimal color used in our experiments are $c = ( ( 2 4 0 , 0 , 3 0 ) , r e d )$ with transparency value 0.5 in zero-shot and few-shot settings, and $c = ( ( 2 5 5 , 1 7 0 , 2 3 0 ) , p i n k )$ with transparency value 0.45 in the fully supervised setting.
353
+
354
+ # D EXPERIMENT DETAILS
355
+
356
+ # D.1 BASELINE DETAILS
357
+
358
+ We provide baseline details for visual grounding. (1) Vanilla fine-tuning for VinVL (Zhang et al., 2021). This model adopts the same backbone as CPT, and serves as the most direct baseline in fewshot and fully supervised experiments. Following Chen et al. (2020), the logits for all regions are fed into a softmax layer, and the score of the target region is optimized using cross-entropy objective. (2) Vanilla fine-tuning for other VL-PTMs. For fully supervised experiments, we also report previous results of fine-tuning other VL-PTMs, including ViLBERT (Lu et al., 2019), VLBERT (Su et al., 2019), UNITER (Chen et al., 2020), ERNIE-ViL (Yu et al., 2021) and VL-T5 (Cho et al., 2021). (3) Visual grounding model. MAttNet (Yu et al., 2018) is a strong model tailored for visual grounding, and is compared in fully supervised setting. (4) Random baseline. For zero-shot experiments, we compare with a random baseline that randomly guesses the target region. For fair comparisons, we use the object proposals detected by MAttNet (Yu et al., 2018) for all baselines and CPT-Blk.
359
+
360
+ # D.2 DATASET DETAILS
361
+
362
+ Visual Grounding Datasets. (1) RefCOCO (Yu et al., 2016) is collected through a two-player referential game (Kazemzadeh et al., 2014), and contains 142,210 referential expressions for 50,000 object instances in 19,994 images. The dataset is split into train, validation, testA and testB sets, with 120,624, 10,834, 5,657 and 5,095 expression-object pairs respectively. TestA set only contains people as target objects, while testB set contains all other types of objects as targets. (2) RefCOCO $^ +$ (Yu et al., 2016) is also collected in an interactive way, and contains 141,564 referential expressions for 49,856 object instances in 19,992 images. The difference from RefCOCO is that RefCOCO $^ +$ focuses on distinguishing objects using appearance-based expressions, and excludes location-based expressions. The dataset is split into train, validation, testA and testB sets, with 120,191, 10,758, 5,726 and 4,889 expression-object pairs respectively. (3) RefCOCOg (Mao et al., 2016) is collected in a non-interactive way, and contains 95,010 referential expressions for 49,822 object instances in 25,799 images. The referential expressions in RefCOCOg are typically longer and more complex. The train, validation and test sets contain 80,512, 4,896 and 9,602 expression-object pairs.
363
+
364
+ Predicate Classification Datasets. We provide the relations of Visual Genome dataset in Table 5. The dataset contains 65, 651, 5, 000 and 32, 422 images in training, validation and test set respectively, where each image contains an average of 10.3 objects and 4.8 labeled relation instances. There are 150 distinct object categories and 50 relation categories in the dataset.
365
+
366
+ # E DISCUSSION AND OUTLOOK
367
+
368
+ In this section, we discuss the limitations of CPT and promising directions for future research.
369
+
370
+ Limitations. Despite its promising performance on visual grounding, we note that there are several limitations in CPT: (1) Color disturbance. CPT takes advantage of colors to bridge visual and textual semantics, by adding color-based sub-prompts in both images and text. As shown in Section 4.4, the color-based prompt can be disturbed by colors in raw images and text. (2) Computation efficiency. In our experiments, to maximally avoid color disturbance and account for the limited number of color candidates, we adopt small image region batch sizes. This means that a data instance needs to be fed into the model multiple times in order to obtain the result. We believe addressing these challenges are promising directions for improving CPT.
371
+
372
+ Outlook. In this work, we take visual grounding as a representative example to demonstrate the effectiveness of CPT. In fact, CPT can be easily adapted to other vision-language tasks. Here we discuss the promising directions, as illustrated in Figure 8. The visual and textual sub-prompts in CPT can well capture fine-grained object-level semantics for object-level tasks, such as: (1) Object classification. By coloring object proposals with visual sub-prompt, VL-PTMs can be prompted to produce object labels for object classification. (2) Scene graph classification. Moreover, by further decomposing textual sub-prompts, complex tasks involving different sub-tasks can be solved in a unified cross-modal prompt tuning framework. For example, VL-PTMs can be prompted to jointly produce object and predicate labels for challenging scene graph classification. In addition to data efficiency, a crucial advantage of using CPT is that the object/predicate labels can be produced from open-world vocabularies, instead of fixed label sets.
373
+
374
+ ![](images/bc891fe18e9936ad2a1d1bf0a54d0cbac4772e537ca0111143d607880d8b3695.jpg)
375
+ Figure 8: Outlook for adapting cross-modal prompt tuning (CPT) to other tasks.
md/dev/UKd6dpVGdu/UKd6dpVGdu.md ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Learning to Tokenize for Generative Retrieval
2
+
3
+ Weiwei $\mathbf { S u n } ^ { 1 }$ , Lingyong $\mathbf { Y a n } ^ { 2 }$ , Zheng Chen1, Shuaiqiang Wang2, Haichao $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 2 }$
4
+ Pengjie Ren1, Zhumin Chen1, Dawei $\mathbf { Y i n } ^ { 2 }$ , Maarten de Rijke3, Zhaochun $\mathbf { R e n ^ { 4 * } }$ 1Shandong University, China 2Baidu Inc., China
5
+ 3University of Amsterdam, The Netherlands 4Leiden University, The Netherlands {sunnweiwei,lingyongy}@gmail.com yindawei@acm.org m.derijke@uva.nl z.ren@liacs.leidenuniv.nl
6
+
7
+ # Abstract
8
+
9
+ As a new paradigm in information retrieval, generative retrieval directly generates a ranked list of document identifiers (docids) for a given query using generative language models (LMs). How to assign each document a unique docid (denoted as document tokenization) is a critical problem, because it determines whether the generative retrieval model can precisely retrieve any document by simply decoding its docid. Most existing methods adopt rule-based tokenization, which is ad-hoc and does not generalize well. In contrast, in this paper we propose a novel document tokenization learning method, GENRET, which learns to encode the complete document semantics into docids. GENRET learns to tokenize documents into short discrete representations (i.e., docids) via a discrete auto-encoding approach. We develop a progressive training scheme to capture the autoregressive nature of docids and diverse clustering techniques to stabilize the training process. Based on the semantic-embedded docids of any set of documents, the generative retrieval model can learn to generate the most relevant docid only according to the docids’ semantic relevance to the queries. We conduct experiments on the NQ320K, MS MARCO, and BEIR datasets. GENRET establishes the new state-of-the-art on the NQ320K dataset. Compared to generative retrieval baselines, GENRET can achieve significant improvements on unseen documents. Moreover, GENRET can also outperform comparable baselines on MS MARCO and BEIR, demonstrating the method’s generalizability.
10
+
11
+ # 1 Introduction
12
+
13
+ Document retrieval plays an essential role in web search applications and various downstream knowledge-intensive tasks by identifying relevant documents to satisfy users’ queries. Recently, generative retrieval has emerged as a new paradigm for document retrieval [1, 5, 37, 41, 46, 47] that directly generates a ranked list of document identifiers (docids) for a given query using generative language models (LMs). Unlike dense retrieval [9, 13, 23, 42], generative retrieval presents an end-to-end solution for document retrieval tasks [37]. It also offers a promising approach to better exploit the capabilities of recent large LMs [1, 41].
14
+
15
+ As shown in Figure 1, document tokenization aims to tokenize each document in the corpus as a sequence of discrete characters, i.e., docids. Document tokenization plays a crucial role in generative retrieval, as it defines how the document is distributed in the semantic space [37]. And it is still an open problem how to define docids. Most previous generative methods tend to employ rule-based document tokenizers, such as generating titles or URLs [5, 46], or clustering results from off-the-shelf document embeddings [37, 41]. Such rule-based methods are usually ad-hoc and do not generalize well. In particular, the tokenization results potentially perform well on retrieving documents that have been seen during training, but generalize poorly to unlabeled documents [17, 20].
16
+
17
+ ![](images/9376e3d55387499e592d3ca31bec0c42c1ee6f3616750bc00aa088c2036a1417.jpg)
18
+ Figure 1: An overview of our proposed method. The proposed method utilizes a document tokenization model to convert a given document into a sequence of discrete tokens, referred to as a docid. This tokenization process allows for the reconstruction of the original document through a reconstruction model. Subsequently, an autoregressive generation model is employed to retrieve documents through the generation of their respective docids.
19
+
20
+ To address the above problem, we propose GENRET, a document tokenization learning framework that learns to tokenize a document into semantic docids in a discrete auto-encoding scheme. GENRET consists of a shared sequence-to-sequence-based document tokenization model, a generative retrieval model, and a reconstruction model. In the proposed auto-encoding learning scheme, the tokenization model learns to convert documents to discrete docids, which are subsequently utilized by the reconstruction model to reconstruct the original document. The generative retrieval model is trained to generate docids in an autoregressive manner for a given query. The above three models are optimized in an end-to-end fashion to achieve seamless integration.
21
+
22
+ There are usually two challenges when using auto-encoding to optimize a generative retrieval model: (i) docids with an autoregressive nature, and (ii) docids with diversity. To address the first challenge and also to stabilize the training of GENRET, we devise a progressive training scheme. This training scheme allows for a stable training of the model by fixing optimized prefix docids $z _ { < t }$ . To optimize the docids at each step, three proposed losses are utilized: (i) a reconstruction loss for predicting the document using the generated docid, (ii) a commitment loss for committing the docid and avoiding forgetting, and (iii) a retrieval loss for optimizing the retrieval performance end-to-end. To address the second challenge, we propose a parameter initialization strategy and a re-assignment of the docid based on a diverse clustering technique to increase the diversity of the generated docids.
23
+
24
+ We conduct extensive experiments on three well-known document retrieval benchmark datasets, NQ320K [15, 37], MS MARCO [4, 46], and BEIR [38]. GENRET attains superior retrieval performance against state-of-the-art generative retrieval models on NQ320K. GENRET achieves $+ 1 4 \%$ relative improvements on the unseen test set of NQ320K over the best generative retrieval baseline. Experiments on MS MARCO and six BEIR datasets also show that GENRET outperforms existing generative methods and achieves competitive results compared to popular dense retrieval models. Experiments on retrieving new documents, analytical experiments, and an efficiency analysis confirm the effectiveness of the proposed model.
25
+
26
+ We summarize our contributions as follows: (i) We propose GENRET, a generative retrieval model that represents documents as discrete semantic docids. To the best of our knowledge, this is the first tokenization learning method for document retrieval. (ii) We propose an auto-encoding approach, where the docids generated by our tokenization model are reconstructed by a reconstruction model to ensure the docids capture the semantic information of the document. (iii) We devise a progressive training scheme to model the autoregressive nature of docids and stabilize the training process. (iv) Experimental results demonstrate that GENRET achieves significant improvements, especially on unseen documents, over generative retrieval baselines.2
27
+
28
+ # 2 Preliminaries
29
+
30
+ The document retrieval task can be formalized as the process of retrieving a relevant document $d$ for a search query $q$ from a collection of documents $\mathcal { D }$ . Each document $d \in \mathcal { D }$ is assumed to be a plain text consisting of a sequence of tokens, denoted as $d = \{ d _ { 1 } , \dotsc , d _ { | d | } \}$ , where $| d |$ is the total number of tokens in the document. For generative retrieval models, it is usually challenging and computationally inefficient to directly generate original documents of typically long length. Therefore, most existing approaches rely on a technique named document tokenization, which represents a document $\bar { d } \bar { = } \{ d _ { 1 } , \ldots , \bar { d _ { | d | } } \}$ as a shorter sequence of discrete tokens (docid) $z = \{ z _ { 1 } , \ldots , z _ { t } , \ldots , z _ { M } \}$ , where each token $z _ { t }$ is as a $K$ -way categorical variable, with $z _ { t } \in [ 1 , 2 , \ldots , K ]$ , and $M$ is the length of the docid. See Figure 1 for an example of document tokenization with $M = 3$ and $K = 6 4$ .
31
+
32
+ As an alternative sequence of the original document, the tokenized docid $z$ should satisfy the following two properties: (i) different documents have short but different docids; and (ii) docids capture the semantics of their associated documents as much as possible [37]. Because $z$ is a sequence of a fixed length and usually shorter than the original document $d$ , the model’s training and inference can be simplified and more efficient. This paper employs a tokenization model $Q \colon d z$ to map $d$ to docid $z$ . More details about $Q$ are provided in Section 3.1. After tokenizing each document to docid $z$ , a generative retrieval model $P \colon q z$ learns to retrieve relevant documents by generating a query $q$ to a docid $z$ autoregressively [37].
33
+
34
+ # 3 Method
35
+
36
+ Conventionally, document tokenization is done by a fixed pre-processing step, such as using the title of a document or the results of hierarchical clustering obtained from BERT [5, 37]. However, it has been observed that such ad-hoc document tokenization methods often fail to capture the complete semantics of a document. For example, the title of a web page often does not exist or has low relevance to the content of the web page, and the use of clustering-based docids arbitrarily defines the document in discrete space.
37
+
38
+ In this paper, we propose GENRET, a novel tokenization learning method based on discrete autoencoding, to learn semantic docid in a fully end-to-end manner. Figure 1 gives an overview of the proposed method. The proposed GENRET comprises three main components: (i) a sequence-tosequence based retrieval model $P ( z \mid q )$ , (ii) a document tokenization model $Q ( z \mid d )$ , and (iii) a reconstruction model $R ( d \mid z )$ . The document tokenization model tokenizes a document $d$ into unique discrete variables $z$ , and the retrieval model is trained to generate the latent variables $z$ for a given query $q$ . In addition, the reconstruction model is used to re-generate the original document from $z$ to ensure $z$ captures the semantics of the original document as much as possible.
39
+
40
+ # 3.1 Model architecture
41
+
42
+ Following DSI [37], we employ an encoder-decoder Transformer to implement the generative retrieval model. Specifically, given an input text $d ^ { 3 }$ , the T5-based tokenization model encodes $d$ and a prefix of docid $z _ { < t }$ and continuously produces latent representation $\mathbf { d } _ { t }$ of $d$ at time step $t$ :
43
+
44
+ $$
45
+ \mathbf { d } _ { t } = { \mathrm { D e c o d e r } } ( { \mathrm { E n c o d e r } } ( d ) , z _ { < t } ) \in \mathbb { R } ^ { D } ,
46
+ $$
47
+
48
+ where $D$ denotes the hidden size of the model. Encoder $( d )$ denotes the output of the Encoder.
49
+
50
+ Then, the tokenization model generates a token for each document based on $\mathbf { d } _ { t }$ . At each timestep $t$ we define an external embedding matrix named codebook $\mathbf { E } _ { t } \in \mathbb { R } ^ { K \times D }$ , where $K$ is the size of the discrete latent space. There are $K$ embedding vectors $\mathbf { e } _ { t , j } \in \mathbb { R } ^ { D } , j \in [ K ]$ , and each vector $\mathbf { e } _ { t , j }$ can be regarded as the centroid of a segmentation.
51
+
52
+ Based on the codebook $\mathbf { E } _ { t }$ , the discrete latent variable $z _ { t }$ at timestep $t$ is calculated by a dot-product look-up using the codebook $\mathbf { E } _ { t }$ :
53
+
54
+ $$
55
+ Q ( z _ { t } = j \mid z _ { < t } , d ) = \operatorname { S o f t m a x } _ { j } ( \mathbf { d } _ { t } \cdot \mathbf { E } _ { t } ^ { \top } ) ,
56
+ $$
57
+
58
+ where $Q ( z _ { t } = j \mid z _ { < t } , d )$ denotes the probability of tokenizing $d$ to a particular value $j \in [ K ]$ at timestep $t$ , $\operatorname { S o f t m a x } _ { j }$ is a softmax function to output the probability of axis $j$ .
59
+
60
+ Document reconstruction model. The docid generated by the tokenization model $Q$ is required to capture the semantic information of the document. To this end, we propose an auto-encoding training scheme, where a reconstruction model $R \colon z \to d$ that predicts $d$ using $z$ is designed to force the tokenization model $Q \colon d z$ to reproduce a docid $z$ that can be reconstructed back-to-the original document.
61
+
62
+ The input of the reconstruction model is docid $z$ , and the output is its associated document $d$ . We first embed $z$ into representation matrix $\mathbf { z } = \{ \mathbf { z } _ { 1 } , \hdots , \mathbf { z } _ { M } \} \stackrel { * } { \in } \mathbb { R } ^ { M \times D }$ using the codebook of the tokenization model:
63
+
64
+ $$
65
+ \mathbf { z } = \{ \mathbf { e } _ { 1 , z _ { 1 } } , \mathbf { e } _ { 2 , z _ { 2 } } , \ldots , \mathbf { e } _ { M , z _ { M } } \} \in \mathbb { R } ^ { M \times D } ,
66
+ $$
67
+
68
+ where each $t \in [ M ] , \mathbf { z } _ { t } = \mathbf { e } _ { t , z _ { t } } \in \mathbb { R } ^ { D }$ is the embedding vector of $z _ { t }$ in the $t { \cdot }$ -step codebook $\mathbf { E } _ { t }$
69
+
70
+ We then devise a retrieval-based reconstruction model that predicts the target document $d$ by retrieving it from document collection $\mathcal { D }$ , based on the inputs $\mathbf { z }$ . The relevance score between the input docid $z$ and the target document $d$ is defined as follows:
71
+
72
+ $$
73
+ R ( d \mid \mathbf { z } ) = \prod _ { t = 1 } ^ { M } \frac { \exp ( \mathbf { z } _ { t } \cdot \mathbf { s g } ( \mathbf { d } _ { t } ^ { \top } ) ) } { \sum _ { d ^ { * } \in S ( z _ { < t } ) } \exp ( \mathbf { z } _ { t } \cdot \mathbf { s g } ( \mathbf { d } ^ { * } { } _ { t } ^ { \top } ) ) } ,
74
+ $$
75
+
76
+ where $S ( z _ { < t } )$ is a sub-collection of $\mathcal { D }$ consisting of documents that have a docid prefix that is the same as $z _ { < t }$ . $d ^ { * } \in S ( z _ { < t } )$ represents a document from the sub-collection $S ( z _ { < t } )$ . $\mathbf { d } _ { t }$ and $\mathbf { d } ^ { * } { } _ { t }$ are continuous representations of documents $d$ and $d ^ { * }$ , respectively, as defined in Eq. 1. The operator $\operatorname { s g } ( \cdot )$ is the stop gradient operator to prevent gradient back propagation. Intuitively, $R ( d { \bar { \mathbf { \theta } } } | { \mathbf { \theta } } \mathbf { z } )$ is designed to retrieve a specific document $d$ from a set of documents $S ( z _ { < t } )$ at each timestep $t$ . The set $S ( z _ { < t } )$ only includes those documents that are assigned the same docid prefix $z _ { < t }$ as the target document $d$ . By utilizing this loss function, at each step $t$ , the model is facilitated to learn the residual semantics of the documents not captured by the previous docid $z _ { < t }$ .
77
+
78
+ # 3.2 Model optimization
79
+
80
+ For the document tokenization model $Q ( z \mid d )$ , generative retrieval model $P ( z \mid q )$ , and reconstruction model $R ( d \mid z )$ , jointly optimizing these three models using auto-encoding is challenging due to the following reasons: (i) Learning docids in an autoregressive fashion. On one hand, the prediction of the $z _ { t }$ at time $t$ relies on previously predicted docids $z _ { < t }$ , which is often under-optimized at the beginning and rapidly changes during training, making it difficult to reach convergence. On the other hand, simultaneously optimizing $z$ makes it challenging to guarantee a unique docid assignment. Hence, to stabilize the training of GENRET, we devise a progressive training scheme (see Section 3.2.1). (ii) Generating docids with diversity. Optimizing the model using auto-encoding often leads to unbalanced docid assignment: a few major docids are assigned to a large number of documents and most other docids are rarely assigned. Such a sub-optimal distribution of docids affects the model distinguishability, which in turns triggers length increments of docids in order to distinguish conflicting documents. We introduce two diverse clustering techniques to ensure docid diversity (see Section 3.2.2).
81
+
82
+ # 3.2.1 Progressive training scheme
83
+
84
+ To optimize each of the three models listed above in an autoregressive manner, we propose a progressive autoencoding learning scheme, as illustrated in Figure 2. The whole learning scheme contains $M$ learning steps with respect to the final docid in $M$ -token. And the docid $z _ { T }$ at step $T \in [ M ]$ is learned and optimized at the corresponding learning step. Besides, at each step $T \in [ M ]$ the docid $z _ { T }$ and the model parameters associated with $z _ { T }$ generation are updated, while previously produced docids $z _ { < T }$ and other parameters are kept fixed. By progressively performing the above process, we can finally optimize and learn our models.
85
+
86
+ ![](images/a29a4818c2d798660c4bfa1140e60b39233a1da46f602255acd9078fcf835ed5.jpg)
87
+ Figure 2: Progressive training scheme. $z _ { t }$ (docid at timestep $t$ ) is optimized at the $t$ -th training step, while $z _ { < t }$ (docids before timestep $t$ ) are kept fixed.
88
+
89
+ At each optimization step, say the $T$ -step, we devise the learning objective for document tokenization consisting of three loss functions detailed below.
90
+
91
+ Reconstruction loss. We utilize the reconstruction model $R ( d \mid z )$ as an auxiliary model to learn to optimize the docid generation, whose main goal is capturing as much semantics in the docid as possible. Therefore, we define a reconstruction loss function of step $T$ as follows:
92
+
93
+ $$
94
+ \begin{array} { r l r } { \mathcal { L } _ { \mathrm { R e c } } = - \log R ( d \mid \hat { \mathbf { z } } _ { \le T } ) , } & { \mathrm { w h e r e ~ } \hat { \mathbf { z } } _ { \le T } = \left\{ \mathrm { s g } ( \mathbf { z } _ { 1 } ) , \dots , \mathrm { s g } ( \mathbf { z } _ { T - 1 } ) , \mathbf { z } _ { T } \right\} } & { \in \mathbb { R } ^ { T \times D } } \\ { \forall t \in [ T ] : \mathbf { z } _ { t } = \mathbf { e } _ { t , j ^ { * } } \in \mathbb { R } ^ { D } , } & { \mathrm { w h e r e ~ } j ^ { * } = \arg \operatorname* { m a x } Q ( z _ { t } = j \mid z _ { < t } , d ) , } \end{array}
95
+ $$
96
+
97
+ where $\scriptstyle { \hat { \mathbf { z } } } < { T }$ is the first $T$ representations of the $z$ , and only the variable $\mathbf { z } _ { T }$ is optimized in step $T$ $Q ( z _ { t } = \bar { j } \mid z _ { < t } , d )$ is defined in Eq. 2. And the document tokenization model $Q$ can therefore be optimized when minimizing $\mathcal { L } _ { \mathrm { R e c } }$ .
98
+
99
+ Of note, since the computation involves a non-differentiable operation $( \mathrm { a r g } \operatorname* { m a x } ( \cdot ) )$ , we apply straight-through gradient estimation to back-propagate the gradient from reconstruction loss to ${ \bf d } _ { T }$ following [39, 44], which copies the gradient of $\mathbf { z } _ { T }$ directly to ${ \bf d } _ { T }$ . Specifically, the gradients to document representation ${ \bf d } _ { T }$ are defined as $\begin{array} { r } { \frac { \partial \mathcal { L } _ { \mathrm { R e c } } } { \partial { \bf d } _ { T } } : = \frac { \partial \mathcal { L } _ { \mathrm { R e c } } } { \partial { \bf z } _ { T } } } \end{array}$ And the gradients to the codebook embedding $\mathbf { e } _ { T , j }$ are defined as $\begin{array} { r } { \frac { \partial \mathcal { L } _ { \mathrm { R e c } } } { \partial \mathbf { e } _ { T , j } } : = 1 _ { z _ { T } = j } \frac { \partial \dot { \mathcal { L } } _ { \mathrm { R e c } } } { \partial \mathbf { z } _ { T } } } \end{array}$
100
+
101
+ Commitment loss. In addition, to make sure the predicted docid commits to an embedding and to avoid models forgetting previous docid $z _ { < t }$ , we add a commitment loss as follows:
102
+
103
+ $$
104
+ \mathcal { L } _ { \mathrm { C o m } } = - \sum _ { t = 1 } ^ { T } \log Q ( z _ { t } \mid z _ { < t } , d ) .
105
+ $$
106
+
107
+ Retrieval loss. For the generative retrieval model $P$ , we jointly learn it together with the document tokenization model $Q$ , where $P$ learns to generate the docids of relevant documents $d$ given a query $q$ Specifically, suppose $( q , d )$ are a query and relevant document pair; we define the learning objective of retrieval model $P$ as:
108
+
109
+ $$
110
+ \mathcal { L } _ { \mathrm { R e t } } = - \log \frac { \exp ( \mathbf { q } _ { T } \cdot \mathbf { d } _ { T } ) } { \sum _ { d ^ { * } \sim B } \exp ( \mathbf { q } _ { T } \cdot \mathbf { d } ^ { * } _ { T } ) } - \sum _ { t = 1 } ^ { T } \log P ( z _ { t } \mid z _ { < t } , q ) ,
111
+ $$
112
+
113
+ where the first term is a ranking-oriented loss enhancing the model using $( q , d )$ pair; $d ^ { * }$ is an in-batch document sampled from the same training mini-batch $B$ ; $\mathbf { q } _ { T }$ and ${ \bf d } _ { T }$ denote the representation of $q$ and $d$ at timestep $T$ . The second term is the cross-entropy loss for generating docid $z$ based on $q$ .
114
+
115
+ The final loss we use at step- $\mathcal { T }$ is the sum of reconstruction loss, commitment loss, and retrieval loss:
116
+
117
+ $$
118
+ \begin{array} { r } { \mathcal { L } = \mathcal { L } _ { \mathrm { R e c } } + \mathcal { L } _ { \mathrm { C o m } } + \mathcal { L } _ { \mathrm { R e t } } . } \end{array}
119
+ $$
120
+
121
+ # 3.2.2 Diverse clustering techniques
122
+
123
+ To ensure diversity of generated docids, we adopt two diverse clustering techniques–codebook initialization and docid re-assignment at each progressive training step, where codebook initialization mainly aims to increase the balance of semantic space segmentation, and the docid re-assignment mainly aims to increase the balance of docid assignments.
124
+
125
+ Codebook initialization. In order to initialize the codebook for our model, we first warm-up the model by passing the continuous representation ${ \bf d } _ { T }$ to the reconstruction model instead of the docid representation $\mathbf { z } _ { T }$ as defined in Eq. 3. During this warm-up phase, we optimize the model using the reconstruction loss $\mathcal { L } _ { \mathrm { R e c } }$ and commitment loss ${ \mathcal { L } } _ { \mathrm { C o m } }$ . Next, we collect the continuous representations ${ \bf d } _ { T }$ of all documents in $\mathcal { D }$ , and cluster them into $K$ groups. The centroids of these clusters are then used as the initialized codebook $\mathbf { E } _ { T }$ . To balance the initialized docid distribution, we utilize a diverse constrained clustering algorithm, Constrained $K \cdot$ -Means, which first normalizes the embeddings of each prefix group, and modifies the cluster assignment step (E in EM) by formulating it as a minimum cost flow (MCF) linear network optimization problem [2].
126
+
127
+ Docid re-assignment. In order to assign docids to a batch of documents, we modify the dot-product look-up results in Eq. 2 by ensuring that the docid for different documents in the batch are distinct following the method described in [6, 44]. Specifically, let $\mathbf { D } _ { t } = \{ \mathbf { d } _ { t } ^ { ( 1 ) } , \dots , \mathbf { d } _ { t } ^ { ( B ) } \} \in \mathbb { R } ^ { B \times D }$ denote the continuous representation of a batch of documents with batch size of $B$ . The dot-product results are represented by $\mathbf { H } = \mathbf { D } _ { t } \cdot \mathbf { E } _ { t } ^ { \top } \in \mathbb { R } ^ { B \times K }$ . To obtain distinct docids, we calculate an alternative $\begin{array} { r } { \mathbf { H } ^ { * } = \mathrm { D i a g } ( \mathbf { u } ) \exp ( \frac { \mathbf { H } } { \epsilon } ) \mathrm { D i a g } ( \mathbf { v } ) } \end{array}$ , where $\mathbf { u }$ and $\mathbf { v }$ are re-normalization vectors in $\mathbb { R } ^ { K }$ and $\mathbb { R } ^ { B }$ , respectively. The re-normalization vectors are computed via the iterative Sinkhorn-Knopp algorithm [8]. Finally, $\mathbf { H } ^ { * }$ is used instead of $\mathbf { H }$ in the Softmax and arg max (Eq. 2) operations to obtain the docid $z _ { t }$ .
128
+
129
+ # 4 Experimental Setup
130
+
131
+ # 4.1 Datasets and evalutaion metrics
132
+
133
+ We conduct experiments on three well-known document retrieval datasets: NQ320K [15], MS MARCO [4], and BEIR [38]. We divide the test set of NQ320K into seen test and unseen test, based on whether the target documents of the query have annotated queries in the training data, to test the generalization ability of the model on unlabeled documents. More details about data pre-processing and data statistics are listed in the Appendix A.
134
+
135
+ On NQ320K, we use Recall $\ @ \left\{ 1 , 1 0 , 1 0 0 \right\}$ and Mean Reciprocal Rank (MRR) $@ 1 0 0$ as evaluation metrics, following [41]. On MS MARCO, we use Recall $ @ \{ 1 , 1 0 , 1 0 0 \}$ and MRR $@ 1 0$ as evaluation metrics, following [46]. On BEIR, we use nDCG $@ 1 0$ as the main metrics and calculate the average nDCG $@ 1 0$ values across multiple downstream sub-datasets as overall metrics.
136
+
137
+ # 4.2 Baselines
138
+
139
+ We consider three types of baselines: sparse retrieval methods, dense retrieval methods, and generative retrieval methods. The sparse retrieval baselines are: BM25 [32] and DocT5Query [24]. The dense retrieval baselines are: DPR [13], ANCE [42], Sentence-T5 [22], GTR [23], and Contriever [11]. The generative retrieval baselines are: GENRE [5], DSI [37], SEAL [1], CGR-Contra [17], DSIQG [47], NCI [41], and Ultron [46]. The following three baselines use the same pre-trained LM T5 as GENRET: (i) Sentence-T5 outputs continuous vectors, (ii) GENRE outputs document titles, and (iii) DSI-QG outputs clustering IDs, while GENRET outputs docids learned using the proposed tokenization method. See Appendix B for more details on the other baselines.
140
+
141
+ # 4.3 Implementation details
142
+
143
+ Hyper-parameters. In our experiments, we utilize the T5-Base model [27] as the base Transformer and initialize a new codebook embedding $\mathbf { E } _ { t }$ for each time step. The parameters of both the encoderdecoder and codebook are shared between the tokenization model and the retrieval model. We set the number of clusters to be $K = 5 1 2$ for all datasets, with the length of the docid $M$ being dependent on the number of documents present. For datasets containing a larger number of candidate documents, a larger value of $M$ is set to ensure that all documents are assigned unique document ids. In the docid re-assignment, the hyper-parameter $\epsilon$ is set to 1.0, and the Sinkhorn-Knopp algorithm is executed for 100 iterations.
144
+
145
+ Indexing with query generation. Following previous work [47, 41, 40], we use query generation models to generate synthetic (query, document) pairs for data augmentation. Specifically, we use the pre-trained query generation model from DocT5Query [24] to augment the NQ and MS MARCO datasets. In query generation, we use nucleus sampling with parameters $p = 0 . 8 , t = 0 . 8$ and generate five queries for each document in the collection. For the BEIR datasets, we use the queries generated by GPL [40]. GPL uses a DocT5Query [24] generator trained on MS MARCO to generate about 250K queries for each BEIR dataset. Note that the query generator used for BEIR is purely trained on MS MARCO (without using any training data of BEIR) and thus conforms to the zero-shot setting of BEIR [38, 40].
146
+
147
+ Training and inference. The proposed models and the reproduced baselines are implemented with PyTorch 1.7.1 and HuggingFace transformers 4.22.2. We optimize the model using AdamW and set the learning rate to $5 e - 4$ . The batch size is 256, and the model is optimized for up to $5 0 0 \mathrm { k }$ steps for each timestep. During training, we pre-gather documents which share the same docid prefix into a batch. Therefore, the reassignment strategy is applied to a batch, where we aim to have documents with as diverse IDs as possible. We add a factor of 0.1 to the reconstruction losses to balance the scale. In progressive training, we first warm up the model for 5K steps and then initialize the codebook using the clustering centroids as mentioned in Section 3.2.1. We use constrained clustering4 to obtain diverse clustering results. During inference, we use beam search with constrained decoding [5] and a beam size of 100.
148
+
149
+ Table 1: Results on Natural Questions (NQ320K). The results of the methods marked with † are from our own re-implementation, others are from their official implementation. \* and $^ { * * }$ indicate significant improvements over previous-best generative retrieval baselines with $\mathsf { p }$ -value $< 0 . 0 5$ and p-value $< 0 . 0 1$ , respectively. $\natural$ and $\sharp$ indicate significant improvements over previous-best dense retrieval baselines with $\boldsymbol { \mathrm { p } }$ -value $< 0 . 0 5$ and $\mathsf { p }$ -value $< 0 . 0 1$ , respectively. The best results for each metric are indicated in boldface.
150
+
151
+ <table><tr><td></td><td colspan="4">Full test</td><td colspan="4">Seen test</td><td colspan="4">Unseen test</td></tr><tr><td>Method</td><td></td><td></td><td>R@1 R@10 R@100</td><td></td><td></td><td>MRR R@1 R@10 R@100 MRR R@1 R@10 R@100 MRR</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Sparse retrieval</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>BM25[32]</td><td>29.7</td><td>60.3</td><td>82.1</td><td>40.2</td><td>29.1</td><td>59.8</td><td>82.4</td><td>39.5</td><td>32.3</td><td>61.9</td><td>81.2</td><td>42.7</td></tr><tr><td>DocT5Query [24]</td><td>38.0</td><td>69.3</td><td>86.1</td><td>48.9</td><td>35.1</td><td>68.3</td><td>86.4</td><td>46.7</td><td>48.5</td><td>72.9</td><td>85.0</td><td>57.0</td></tr><tr><td>Dense retrieval</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>DPR[13]</td><td>50.2</td><td>77.7</td><td>90.9</td><td>59.9</td><td>50.2</td><td>78.7</td><td>91.6</td><td>60.2</td><td>50.0</td><td>74.2</td><td>88.7</td><td>58.8</td></tr><tr><td>ANCE [42]</td><td>50.2</td><td>78.5</td><td>91.4</td><td>60.2</td><td>49.7</td><td>79.2</td><td>92.3</td><td>60.1</td><td>52.0</td><td>75.9</td><td>88.0</td><td>60.5</td></tr><tr><td>Sentence-T5† [22]</td><td>53.6</td><td>83.0</td><td>93.8</td><td>64.1</td><td>53.4</td><td>83.9</td><td>94.7</td><td>63.8</td><td>56.5</td><td>79.5</td><td>90.7</td><td>64.9</td></tr><tr><td>GTR-Base [23]</td><td>56.0</td><td>84.4</td><td>93.7</td><td>66.2</td><td>54.4</td><td>84.7</td><td>94.2</td><td>65.3</td><td>61.9</td><td>83.2</td><td>92.1</td><td>69.6</td></tr><tr><td>Generative retrieval</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>GENRE† [5]</td><td>55.2</td><td>67.3</td><td>75.4</td><td>59.9</td><td>69.5</td><td>83.7</td><td>90.4</td><td>75.0</td><td>6.0</td><td>10.4</td><td>23.4</td><td>7.8</td></tr><tr><td>DSI+ [37]</td><td>55.2</td><td>67.4</td><td>78.0</td><td>59.6</td><td>69.7</td><td>83.6</td><td>90.5</td><td>74.7</td><td>1.3</td><td>7.2</td><td>31.5</td><td>3.5</td></tr><tr><td>SEAL [1]</td><td>59.9</td><td>81.2</td><td>90.9</td><td>67.7</td><td>1</td><td>-</td><td>-</td><td>-</td><td>1</td><td>-</td><td>-</td><td>-</td></tr><tr><td>CGR-Contra [17]</td><td>63.4</td><td>81.1</td><td>-</td><td>-</td><td>1</td><td>1</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr><tr><td>DSI-QG+ [47]</td><td>63.1</td><td>80.7</td><td>88.0</td><td>69.5</td><td>68.0</td><td>85.0</td><td>91.4</td><td>74.3</td><td>45.9</td><td>65.8</td><td>76.3</td><td>52.8</td></tr><tr><td>NCI [41]</td><td>66.4</td><td>85.7</td><td>92.4</td><td>73.6</td><td>69.8</td><td>88.5</td><td>94.6</td><td>76.8</td><td>54.5</td><td>75.9</td><td>84.8</td><td>62.4</td></tr><tr><td>Ours</td><td>68.1*</td><td>88.8*日</td><td>95.2*</td><td>75.9*70.2#</td><td></td><td>90.3#</td><td>96.0</td><td>77.7#</td><td>62.5**</td><td>83.6**</td><td>92.5**</td><td>70.4*</td></tr></table>
152
+
153
+ # 5 Experimental results
154
+
155
+ # 5.1 Main results
156
+
157
+ Results on NQ320K. In Table 1, we list the results on NQ320K. GENRET outperforms both the strong pre-trained dense retrieval model, GTR, and the previous best generative retrieval method, NCI, thereby establishing a new state-of-the-art on the NQ320K dataset. Furthermore, our results reveal that existing generative retrieval methods perform well on the seen test but lag behind dense retrieval methods on the unseen test. For example, NCI obtains an MRR $@ 1 0 0$ of 76.8 on the seen test, which is higher than the MRR $@ 1 0 0$ of 65.3 obtained by GTR-Base. However, on unseen test data, NCI performs worse than GTR-Base. In contrast, GENRET performs well on both seen and unseen test data. This result highlights the ability of GENRET to combine the advantages of both dense and generative retrieval by learning discrete docids with semantics through end-to-end optimization.
158
+
159
+ Results on MS MARCO. Table 2 presents the results on the MS MARCO dataset. GENRET outperforms generative retrieval methods such as Ultron and dense retrieval baselines such as ANCE and Sentence-T5. Furthermore, previous generative retrieval methods (e.g., GENRE, Ultron) utilizing metadata such as the title and URL, while exhibiting decent performance on the NQ320K dataset, underperform in comparison to dense retrieval and sparse retrieval methods on the MS MARCO dataset. This may be because the NQ320K dataset retrieves Wikipedia documents, where metadata like the title effectively capture the semantics of the document. In the case of the MS MARCO dataset, which is a web search dataset, the metadata often does not adequately characterize the documents, resulting in a decline in performance of the generative retrieval model. In contrast, GENRET learns to generate semantic docids that effectively enhance the generative retrieval model.
160
+
161
+ Results on BEIR. Table 3 lists the results of the baselines and GENRET on six datasets of BEIR. These datasets represent a diverse range of information retrieval scenarios. On average, GENRET outperforms strong baselines including BM25 and ST5 GPL, and achieves competitive results compared to previous-best sparse and dense retrieval methods. Additionally, GENRET demonstrates a significant improvement over the previous generative retrieval model GENRE that utilizes titles as docids. Furthermore, GENRE performs poorly on some datasets, such as BEIR-Covid and BEIRSciDocs. This may be because the titles of the documents in these datasets do not adequately capture their semantic content.
162
+
163
+ Table 2: Results on MS MARCO. The results of the methods marked with † are from our own re-implementation, other results are cited from the original paper or implemented using official code. The best results are indicated in boldface.
164
+
165
+ <table><tr><td>Method R@1 R@10 R@100 MRR</td></tr><tr><td>Sparse retrieval BM25 [32] 39.1 69.1 86.2 48.6</td></tr><tr><td>DocT5Query [24] 46.7 76.5 90.4 56.2</td></tr><tr><td>Dense retrieval ANCE [42] 45.6 75.7 89.6 55.6</td></tr><tr><td>Sentence-T5t [22] 41.8 75.4 91.2 52.8</td></tr><tr><td>Generative retrieval</td></tr><tr><td>GENRE+ [5] 35.6 57.6 79.1 42.3 40.0</td></tr><tr><td>Ultron-URL [46] 29.6 67.8 -</td></tr><tr><td>Ultron-PQ [46] 31.6 73.1 45.4 -</td></tr><tr><td>Ultron-Atomic [46] 32.8 74.1 46.9 =</td></tr><tr><td>Ours 47.9 79.8 91.6 58.1</td></tr></table>
166
+
167
+ Table 3: nDCG $@ 1 0$ results on BEIR. The results of the methods marked with † are from our own re-implementation, other results are cited from the original paper or implemented using official code. ST5 GPL denotes Sentence-T5 trained on GPL datasets [40].
168
+
169
+ <table><tr><td>Method</td><td>Arg Covid NFC SciF. SciD.FiQA Avg.</td></tr><tr><td>Sparse retrieval BM25 [32]</td><td>29.1 58.9 33.5 67.4 14.8 23.6 37.8</td></tr><tr><td>DocT5Query [24]34.9 71.3 32.8 67.5 16.2 29.1 41.9 Dense retrieval</td><td></td></tr><tr><td>ST5 GPL+ [22] 32.1 74.4 30.1 58.6 12.7 26.0 39.0 Contriever [11] 40.0 68.8 33.5 61.4 16.3 30.7 41.8</td><td></td></tr><tr><td>Generative retrieval</td><td></td></tr><tr><td>GENRE† [47]</td><td></td></tr><tr><td></td><td>42.514.7 20.0 42.36.8 11.6 30.0</td></tr><tr><td>Ours</td><td>34.3 71.8 31.6 63.9 14.9 30.2 41.1</td></tr></table>
170
+
171
+ # 5.2 Analytical experiments
172
+
173
+ We further conduct analytical experiments to study the effectiveness of the proposed method.
174
+
175
+ In Figure 3 (left), we plot the frequencies of docids at the first timestep of various learning methods. We label each method using a box with a docid and a diversity metric $d$ , which is calculated by: $\begin{array} { r } { d = 1 - \frac { 1 } { 2 n } \sum _ { j = 1 } ^ { K } | n _ { j } - n _ { u } | } \end{array}$ , where $\left| \cdot \right|$ represents the absolute value, $n$ denotes the total number of documents, $n _ { j }$ denotes the number of documents that have a docid $= j$ , and $\begin{array} { r } { n _ { u } = \frac { n } { K } } \end{array}$ is the expected number of documents per docid under the uniform distribution.
176
+
177
+ The results demonstrate the superiority of GENRET (represented by the yellow line) in terms of distribution uniformity. It uses all the potential docid $k = 5 1 2$ and achieves the highest diversity metric with a value of $d = 0 . 9 0$ . The method without docid reassignment also yields a relatively balanced distribution, with a diversity metric of $d = 0 . 7 7$ . However, the distribution of the method without diverse codebook initialization is highly uneven, which could be due to the fact that most of the randomly initialized codebook embeddings are not selected by the model during the initial training phase, leading to a lack of update and further selection in subsequent training. Additionally, the models without diverse clustering tend to converge to a trivial solution where all documents are assigned the same docid.
178
+
179
+ In Figure 3 (right), the results of two ablated variants are presented. First, GENRET w/o learning is a generative model that has been trained directly using the final output docid from GENRET, without utilizing the proposed learning scheme. Its retrieval performance is comparable to that of GENRET on seen test data; however, it is significantly lower on unseen test data. This variant demonstrates that the generative retrieval model jointly trained with auto-encoding objectives can represent documents more sensibly based on semantics. This could enhance performance on the less-optimized documents. Contrarily, the parameters obtained via cross-entropy loss on docid generation tasks are less effective in conveying the semantic information of documents. Secondly, GENRET w/ T5-Small uses a small model, and its performance is inferior to that of GENRET using T5-Base. However, the gap between the performance on seen and unseen test data is smaller, which could be attributed to the limited fitting capacity of the small model.
180
+
181
+ In Appendix C, we evaluate the proposed model’s capacity to retrieve new documents and find that it performs well in adapting to new documents compared to existing document tokenization approaches. Additionally, in Appendix D, we analyze the efficiency of various retrieval models in comparison to the various baselines in terms of memory usage, offline, and online latency, and show the advantages of the proposed model.
182
+
183
+ ![](images/8d43b60d1d641a27c2dc33c3ddce1775bab85babe1d7de668aae761986bb9b0a.jpg)
184
+ Figure 3: Left: Docid distribution on NQ320K. The id are sorted by the assigned frequency. Right: Ablation study on NQ320K.
185
+
186
+ # 5.3 Qualitative analysis
187
+
188
+ Figure 4 (left) illustrates the document content (title) and the corresponding docid generated by GENRET on the NQ320K dataset. We observe that documents with more similar docids tend to have more relevant content. For example, documents with docids starting with 338-173 are related to Email, such as Email marketing, Mail merge, and Email address, while documents with docids starting with 338 relate to information exchange methods (e.g., Business letter, US Postal Service, and Postage stamps), representing a more generalized semantics than Email alone.
189
+
190
+ Figure 4 (right) illustrates a word cloud of documents grouped by docid prefixes. It is evident that documents within the same group are semantically related. For example, major words for documents with the docid prefix 338 are mail and stamp. When a second-level docid 173 is added, the corresponding documents become more specifically related to email. With the addition of a third-level docid 1, the document group becomes specifically associated with email marketing (docid: 338-173-1). Similar patterns can be observed in the other three cases. The case study shows that there is a hierarchical semantic structure within the learned docids.
191
+
192
+ Figure 5 in Appendix E visualizes the codebook embedding and document embedding. We see that the codebook embedding appears to distribute uniformly within the document representation space, producing meaningful clusters when documents are categorized by docids. We also find that the uniformity of the embedding distribution decreases with increasing docid-length. This may be due to the fact that uniform segmentation is more challenging as the semantic granularity becomes finer.
193
+
194
+ ![](images/31a018db51d7a4c69de694908e3660a85aa65391c0870460ed5899119292e225.jpg)
195
+ Figure 4: Left: Document titles along with their corresponding docids. It is observed that documents with similar docids tend to have more relevant content. Right: Word cloud representing documents grouped by docid prefixes. This illustrates that different positions of the docid correspond to different levels of information, and the semantics within each cluster are closely related.
196
+
197
+ # 6 Related work
198
+
199
+ Sparse and dense retrieval. Traditional sparse retrieval calculates the document score using term matching metrics such as TF-IDF [31], query likelihood [16], or BM25 [32]. Sparse retrieval is widely used in practice due to its efficiency, but often suffers from the lexical mismatches [18]. Dense retrieval (DR) addresses this by presenting queries and documents in dense vectors and calculating their similarities with the inner product or cosine similarity [13]. Various techniques have been proposed to improve DR models, such as hard negative mining [42, 26], late interaction [14, 34], knowledge distillation [10, 19], and pre-training [30, 23, 11]. Despite their success, DR approaches have several limitations [5, 21]: (i) DR models employ an index-retrieval pipeline with a fixed search procedure (MIPS), making it difficult to optimize the model end-to-end [37, 41]. (ii) Training DR models relies on contrastive learning [13] to distinguish positives from negatives, which is inconsistent with large LMs training objectives [3] and fails to fully utilize the capabilities of pretrained LMs [1, 35].
200
+
201
+ Generative retrieval. Generative retrieval is gaining attention. It retrieves documents by generating their docid using a generative model like T5. Generative retrieval presents an end-to-end solution for document retrieval tasks [37, 21] and allows for better exploitation of the capabilities of large generative LMs [1]. Cao et al. [5] first propose an autoregressive entity retrieval model to retrieve documents by generating titles. Tay et al. [37] propose a differentiable search index (DSI) and represent the document as atomic id, naive string, or semantic string. Bevilacqua et al. [1] suggest using arbitrary spans of a document as docids. Additionally, multiple-stage pre-training [7, 46], query generation [41, 47, 46], contextualized embedding [17], and continual learning [20], have been explored in recent studies. Recently, Tang et al. [36] introduce a query-based docid and the rehearsal-based document indexing to improve DSI. However, existing generative retrieval models have a limitation in that they rely on fixed document tokenization to produce docids, which often fails to capture the semantic information of a document [37]. It is an open question how one should define the docids. To further capture document semantics in the docid, we propose document tokenization learning methods. The semantic docid is generated by the proposed discrete auto-encoding learning scheme in an end-to-end manner. Concurrently, Rajput et al. [28] propose a RQ-VAE module to produce semantic docids for generative recommender systems. As a comparison, our proposed method jointly models the tokenization and retrieval tasks with shared parameters to better align the model’s representation of the two tasks and are optimized in an end-to-end manner.
202
+
203
+ Discrete representation learning. Learning discrete representations using neural networks is an important research area in machine learning. For images, Rolfe [33] proposes the discrete variational autoencoder, and VQ-VAE [39] learns quantized representations via vector quantization. DallE [29] uses an autoregressive model to generate discrete image representation for text-to-image generation. Recently, representation learning has attracted considerable attention in NLP tasks, for tasks such as machine translation [48], dialogue generation [45], and text classification [12, 43]. For document retrieval, RepCONC [44] uses a discrete representation learning method based on constrained clustering for vector compression. We propose a document tokenization learning method for generative retrieval, which captures the autoregressive nature of docids by progressive training and enhances the diversity of docids by diverse clustering techniques.
204
+
205
+ # 7 Conclusions
206
+
207
+ This paper has proposed a document tokenization learning method for generative retrieval, named GENRET. The proposed method learns to tokenize documents into short discrete representations (i.e., docids) via a discrete auto-encoding approach, which ensures the semantics of the generated docids. A progressive training method and two diverse clustering techniques have been proposed to enhance the model’s training. Empirical results on various document retrieval datasets have demonstrated the effectiveness of the proposed method. Especially, GENRET achieves outperformance on unseen documents and can be well generalized to multiple retrieval tasks.
208
+
209
+ The limitations of this work include experiments only on moderately sized datasets like NQ320K. The employed data are in sufficient quantity to validate the effectiveness of the proposed method, but application to larger-scale data may require more model parameters and computational resources. Another aspect for improvement is the generalization of the model to unoptimized document collections in different types or domains, as compared to continuous embedding approaches. We recognize this as an important research question for generative retrieval but believe that addressing this is beyond the scope of this paper. In future work, we would like to extend the approach to large document collections. We also plan to explore generative pre-training for document tokenization using large-scale language models. Additionally, we intend to investigate the dynamic adaptation of docid prefixes for progressive training.
210
+
211
+ # Acknowledgements
212
+
213
+ This work was supported by the Natural Science Foundation of China (62272274, 61972234, 62072279, 62102234, 62202271), the Natural Science Foundation of Shandong Province (ZR2021QF129, ZR2022QF004), the Key Scientific and Technological Innovation Program of Shandong Province (2019JZZY010129), the Fundamental Research Funds of Shandong University, the China Scholarship Council under grant nr. 202206220085, the Hybrid Intelligence Center, a 10-year program funded by the Dutch Ministry of Education, Culture and Science through the Netherlands Organisation for Scientific Research, https://hybrid-intelligence-centre.nl, and project LESSEN with project number NWA.1389.20.183 of the research program NWA ORC 2020/21, which is (partly) financed by the Dutch Research Council (NWO). All content represents the opinion of the authors, which is not necessarily shared or endorsed by their respective employers and/or sponsors.
214
+
215
+ # References
216
+
217
+ [1] Michele Bevilacqua, Giuseppe Ottaviano, Patrick Lewis, Wen tau Yih, Sebastian Riedel, and Fabio Petroni. Autoregressive search engines: Generating substrings as document identifiers. In NeurIPS 2022, 2022.
218
+ [2] Paul S. Bradley, Kristin P. Bennett, and Ayhan Demiriz. Constrained k-means clustering. Microsoft Research, 2000.
219
+ [3] 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, T. J. Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeff 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. In NeurIPS 2020, 2020.
220
+ [4] Daniel Fernando Campos, Tri Nguyen, Mir Rosenberg, Xia Song, Jianfeng Gao, Saurabh Tiwary, Rangan Majumder, Li Deng, and Bhaskar Mitra. MS MARCO: A Human Generated MAchine Reading COmprehension Dataset. ArXiv, abs/1611.09268, 2016.
221
+ [5] Nicola De Cao, Gautier Izacard, Sebastian Riedel, and Fabio Petroni. Autoregressive entity retrieval. In ICLR 2021, 2021.
222
+ [6] Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. ArXiv, abs/2006.09882, 2020.
223
+ [7] Jiangui Chen, Ruqing Zhang, Jiafeng Guo, Yiqun Liu, Yixing Fan, and Xueqi Cheng. CorpusBrain: Pre-train a generative retrieval model for knowledge-intensive language tasks. In CIKM 2022, 2022.
224
+ [8] Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. In NIPS 2013, 2013.
225
+ [9] Daniel Gillick, Alessandro Presta, and Gaurav Singh Tomar. End-to-end retrieval in continuous space. ArXiv, abs/1811.08008, 2018.
226
+ [10] Sebastian Hofstätter, Sheng-Chieh Lin, Jheng-Hong Yang, Jimmy J. Lin, and Allan Hanbury. Efficiently teaching an effective dense retriever with balanced topic aware sampling. In SIGIR 2021, 2021.
227
+ [11] Gautier Izacard, Mathilde Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand Joulin, and Edouard Grave. Unsupervised dense information retrieval with contrastive learning. In TMLR, 2022.
228
+ [12] Shuning Jin, Sam Wiseman, Karl Stratos, and Karen Livescu. Discrete latent variable representations for low-resource text classification. In ACL 2020, 2020.
229
+
230
+ [13] Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis, Ledell Yu Wu, Sergey Edunov, ˘ Danqi Chen, and Wen tau Yih. Dense passage retrieval for open-domain question answering. In EMNLP 2020, 2020.
231
+
232
+ [14] Omar Khattab and Matei Zaharia. ColBERT: Efficient and effective passage search via contextualized late interaction over BERT. In SIGIR 2020, 2020.
233
+
234
+ [15] Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur P. Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, Kristina Toutanova, Llion Jones, Matthew Kelcey, Ming-Wei Chang, Andrew M. Dai, Jakob Uszkoreit, Quoc V. Le, and Slav Petrov. Natural questions: A benchmark for question answering research. TACL, 7:453–466, 2019.
235
+
236
+ [16] John Lafferty and ChengXiang Zhai. Document language models, query models, and risk minimization for information retrieval. In SIGIR 2001, 2001.
237
+
238
+ [17] Hyunji Lee, Jaeyoung Kim, Hoyeon Chang, Hanseok Oh, Sohee Yang, Vladimir Karpukhin, Yi Lu, and Minjoon Seo. Nonparametric decoding for generative retrieval. In Findings of ACL 2023, 2023.
239
+
240
+ [18] Jimmy Lin, Rodrigo Nogueira, and Andrew Yates. Pretrained Transformers for Text Ranking: BERT and Beyond. Springer Nature, 2022.
241
+
242
+ [19] Yuxiang Lu, Yiding Liu, Jiaxiang Liu, Yunsheng Shi, Zhengjie Huang, Shi Feng, Yu Sun, Hao Tian, Hua Wu, Shuaiqiang Wang, Dawei Yin, and Haifeng Wang. ERNIE-Search: Bridging cross-encoder with dual-encoder via self on-the-fly distillation for dense passage retrieval. ArXiv, abs/2205.09153, 2022.
243
+
244
+ [20] Sanket Vaibhav Mehta, Jai Gupta, Yi Tay, Mostafa Dehghani, Vinh Quang Tran, Jinfeng Rao, Marc-Alexander Najork, Emma Strubell, and Donald Metzler. $\mathrm { D S I + + }$ : Updating transformer memory with new documents. ArXiv, abs/2212.09744, 2022.
245
+
246
+ [21] Donald Metzler, Yi Tay, and Dara Bahri. Rethinking search: Making domain experts out of dilettantes. In SIGIR 2021, 2021.
247
+
248
+ [22] Jianmo Ni, Gustavo Hernández Ábrego, Noah Constant, Ji Ma, Keith B. Hall, Daniel Matthew Cer, and Yinfei Yang. Sentence-T5: Scalable sentence encoders from pre-trained text-to-text models. In Findings of ACL 2022, 2022.
249
+
250
+ [23] Jianmo Ni, Chen Qu, Jing Lu, Zhuyun Dai, Gustavo Hernández Ábrego, Ji Ma, Vincent Zhao, Yi Luan, Keith B. Hall, Ming-Wei Chang, and Yinfei Yang. Large dual encoders are generalizable retrievers. In EMNLP, 2022.
251
+
252
+ [24] Rodrigo Nogueira1 and Jimmy Lin. From doc2query to doctttttquery. https://cs. uwaterloo.ca/\~jimmylin/publications/Nogueira_Lin_2019_docTTTTTquery-v2. pdf, 2019.
253
+
254
+ [25] Fabio Petroni, Aleksandra Piktus, Angela Fan, Patrick Lewis, Majid Yazdani, Nicola De Cao, James Thorne, Yacine Jernite, Vassilis Plachouras, Tim Rocktaschel, and Sebastian Riedel. KILT: A benchmark for knowledge intensive language tasks. In NAACL 2021, 2021.
255
+
256
+ [26] Yingqi Qu, Yuchen Ding, Jing Liu, Kai Liu, Ruiyang Ren, Xin Zhao, Daxiang Dong, Hua Wu, and Haifeng Wang. RocketQA: An optimized training approach to dense passage retrieval for open-domain question answering. In NAACL 2021, 2021.
257
+
258
+ [27] Colin Raffel, Noam M. Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. JMLR, 2020.
259
+
260
+ [28] Shashank Rajput, Nikhil Mehta, Anima Singh, Raghunandan H. Keshavan, Trung Hieu Vu, Lukasz Heldt, Lichan Hong, Yi Tay, Vinh Q. Tran, Jonah Samost, Maciej Kula, Ed H. Chi, and Maheswaran Sathiamoorthy. Recommender systems with generative retrieval. In NeurIPS 2023, 2023.
261
+
262
+ [29] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In ICML 2020, 2020.
263
+ [30] Nils Reimers and Iryna Gurevych. Sentence-bert: Sentence embeddings using siamese bertnetworks. In EMNLP 2019, 2019.
264
+ [31] Stephen E. Robertson and Steve Walker. On relevance weights with little relevance information. In SIGIR 1997, 1997.
265
+ [32] Stephen E. Robertson and Hugo Zaragoza. The probabilistic relevance framework: BM25 and beyond. Found. Trends Inf. Retr., 2009.
266
+ [33] Jason Tyler Rolfe. Discrete variational autoencoders. In ICLR 2017, 2017.
267
+ [34] Keshav Santhanam, Omar Khattab, Jon Saad-Falcon, Christopher Potts, and Matei Zaharia. ColBERTv2: Effective and efficient retrieval via lightweight late interaction. In NAACL 2022, 2022.
268
+ [35] Weiwei Sun, Lingyong Yan, Xinyu Ma, Shuaiqiang Wang, Pengjie Ren, Zhumin Chen, Dawei Yin, and Zhaochun Ren. Is ChatGPT good at search? Investigating large language models as re-ranking agents. In EMNLP 2023, 2023.
269
+ [36] Yubao Tang, Ruqing Zhang, Jiangui Guo, Jiangui Chen, Zuowei Zhu, Shuaiqiang Wang, Dawei Yin, and Xueqi Cheng. Semantic-enhanced differentiable search index inspired by learning strategies. In SIGIR 2023, 2023.
270
+ [37] Yi Tay, Vinh Quang Tran, Mostafa Dehghani, Jianmo Ni, Dara Bahri, Harsh Mehta, Zhen Qin, Kai Hui, Zhe Zhao, Jai Gupta, Tal Schuster, William W. Cohen, and Donald Metzler. Transformer memory as a differentiable search index. In NeurIPS 2022, 2022.
271
+ [38] Nandan Thakur, Nils Reimers, Andreas Ruckl’e, Abhishek Srivastava, and Iryna Gurevych. Beir: A heterogenous benchmark for zero-shot evaluation of information retrieval models. In NeurIPS 2021, 2021.
272
+ [39] Aäron van den Oord, Oriol Vinyals, and Koray Kavukcuoglu. Neural discrete representation learning. In NIPS 2017, 2017.
273
+ [40] Kexin Wang, Nandan Thakur, Nils Reimers, and Iryna Gurevych. GPL: Generative pseudo labeling for unsupervised domain adaptation of dense retrieval. In NAACL 2022, 2022.
274
+ [41] Yujing Wang, Ying Hou, Hong Wang, Ziming Miao, Shibin Wu, Hao Sun, Qi Chen, Yuqing Xia, Chengmin Chi, Guoshuai Zhao, Zheng Liu, Xing Xie, Hao Sun, Weiwei Deng, Qi Zhang, and Mao Yang. A neural corpus indexer for document retrieval. In NeurIPS 2022, 2022.
275
+ [42] Lee Xiong, Chenyan Xiong, Ye Li, Kwok-Fung Tang, Jialin Liu, Paul Bennett, Junaid Ahmed, and Arnold Overwijk. Approximate nearest neighbor negative contrastive learning for dense text retrieval. In ICLR 2021, 2021.
276
+ [43] Erxin Yu, Lan Du, Yuan Jin, Zhepei Wei, and Yi Chang. Learning semantic textual similarity via topic-informed discrete latent variables. In EMNLP 2022, 2022.
277
+ [44] Jingtao Zhan, Jiaxin Mao, Yiqun Liu, Jiafeng Guo, Min Zhang, and Shaoping Ma. Learning discrete representations via constrained clustering for effective and efficient dense retrieval. In WSDM 2022, 2022.
278
+ [45] Tiancheng Zhao, Kyusong Lee, and Maxine Eskénazi. Unsupervised discrete sentence representation learning for interpretable neural dialog generation. In ACL 2018, 2018.
279
+ [46] Yujia Zhou, Jing Yao, Zhicheng Dou, Ledell Yu Wu, Peitian Zhang, and Ji rong Wen. Ultron: An ultimate retriever on corpus with a model-based indexer. ArXiv, abs/2208.09257, 2022.
280
+ [47] Shengyao Zhuang, Houxing Ren, Linjun Shou, Jian Pei, Ming Gong, Guido Zuccon, and Daxin Jiang. Bridging the gap between indexing and retrieval for differentiable search index with query generation. ArXiv, abs/2206.10128, 2022.
281
+ [48] Łukasz Kaiser, Aurko Roy, Ashish Vaswani, Niki Parmar, Samy Bengio, Jakob Uszkoreit, and Noam M. Shazeer. Fast decoding in sequence models using discrete latent variables. In ICML 2018, 2018.
282
+
283
+ # A Datasets details
284
+
285
+ Table 4: Statistics of datasets used in our experiments. The three values split by / on # Test queries denote the number of queries in the full, seen subset, and unseen subset, respectively. In BEIR, all queries in the test set are unseen.
286
+
287
+ <table><tr><td>Dataset</td><td>#Docs</td><td># Test queries</td><td># Train pairs</td></tr><tr><td>NQ320K MS MARCO</td><td>323,569 5,187 /</td><td>109,739 7,830 / 6,075 /1,755 807 /4,380</td><td>307,373 366,235</td></tr><tr><td></td><td></td><td>1,406</td><td></td></tr><tr><td>BEIR-Arg BEIR-Covid</td><td>8,674</td><td>50</td><td></td></tr><tr><td>BEIR-NFC</td><td>171,332 3.633</td><td>323</td><td></td></tr><tr><td>BEIR-SciFact</td><td>5,183</td><td>300</td><td></td></tr><tr><td>BEIR-SciDocs</td><td>25,657</td><td>1,000</td><td></td></tr><tr><td>BEIR-FiQA</td><td></td><td></td><td></td></tr><tr><td></td><td>57,638</td><td>648</td><td></td></tr></table>
288
+
289
+ We conduct experiments on three document5 retrieval datasets: NQ320K, MS MARCO, and BEIR.
290
+
291
+ NQ320K. NQ320K is a popular dataset for evaluating generative retrieval models [37, 41]. It is based on the Natural Questions (NQ) dataset proposed by Google [15]. NQ320K consists of $3 2 0 \mathrm { k }$ query-document pairs, where the documents are gathered from Wikipedia pages, and the queries are natural language questions. We follow the evaluation setup in NCI [41] and further split the test set into two subsets: seen test, in which the annotated target documents of the queries are included in the training set; and unseen test, in which no labeled document is included in the training set.
292
+
293
+ Note that the NQ320K dataset we utilized has been pre-processed based on the NCI [41] and includes approximately 100k documents. This differs from the DSI approach [37], which processed a version of the NQ320K dataset containing about $2 0 0 \mathrm { k }$ documents. The distinction lies in the method used to remove duplicate documents. In our case, we eliminated duplicates by comparing document titles, whereas DSI employed URLs. For example, pages https://en.wikipedia.org//w/index. php?title $=$ Statue_of_Liberty&amp;oldid $\underset { . } { = }$ 804877528 and https://en.wikipedia.org/ /w/index.php?title $=$ Statue_of_Liberty&amp;oldid $\underset { . } { = }$ 834310497 are two versions of entity “Statue of Liberty”. DSI NQ320K treats them as separate documents, whereas our implementation considers them as a single document. We have found that the content of different versions of the same entity’s pages is usually almost identical, with only minor variations, often occurring in later parts of the document. Consequently, we believe that distinguishing between different versions of an entity is beyond the model’s capabilities, and that using different versions of the same entity as negative examples in training may hurt model performance.
294
+
295
+ MS MARCO. MS MARCO is a collection of queries and web pages from Bing search. To create the document collections, akin to NQ320k and following [46], we sample a subset of original documents by retaining the top-1 document for each query. We evaluate the models on the queries of the MS MARCO dev set and retrieval on the sampled document subset. We did not split the dev set into seen and unseen because $84 \%$ of the queries in the MS MARCO dev set are unseen.
296
+
297
+ BEIR. BEIR is a collection of datasets for heterogeneous retrieval tasks. In this paper, we evaluate the models on 6 BEIR datasets, which include distinct retrieval tasks and document collections from NQ and MS MARCO: (i) BEIR-Arg retrieves a counterargument to an argument; (ii) BEIRCovid retrieves scientific articles about the COVID-19 pandemic; (iii) BEIR-NFC retrieves medical documents from PubMed; (iv) BEIR-SciFact retrieves scientific papers for fact-checking; (v) BEIRSciDocs retrieves citations for scientific papers; (vi) BEIR-FiQA retrieves financial documents. All the queries in BEIR test set are unseen [38].
298
+
299
+ We summarize the statistics of above datasets in Table 4.
300
+
301
+ # B Baselines
302
+
303
+ The sparse retrieval baselines are as follows:
304
+
305
+ • BM25, uses the tf-idf feature to measure term weights; we use the implementation from http://pyserini.io/.
306
+ • DocT5Query, expands a document with possible queries predicted by a finetuned T5 with this document as the input.
307
+
308
+ The dense retrieval baselines are as follows:
309
+
310
+ • DPR [13], a dual-encoder model using the representation of the [CLS] token of BERT.
311
+ • ANCE [42], an asynchronously updated ANN indexer is utilized to mine hard negatives for training a RoBERTa-based dual-encoder model.
312
+ • Sentence-T5 [22], a dual-encoder model that uses T5 to produce continuous sentence embeddings. We reproduce Sentence-T5 (ST5 for short) on our datasets, the model is based on T5-Base EncDec model and is trained with in-batch negatives.
313
+ • GTR [23], a state-of-the-art dense retrieval model that pre-trains sentence-T5 on billions of paired data using contrastive learning.
314
+ • Contriever [11], a dual-encoder model pre-trained using unsupervised contrastive learning with independent cropping and inverse cloze task.
315
+
316
+ And the generative retrieval baselines are as follows:
317
+
318
+ GENRE [5], an autoregressive retrieval model that generates the document’s title. The original GENRE is trained on the KILT dataset [25] using BART, and we reproduce GENRE on our datasets using T5 for a fair comparison. For datasets without title, we use the first 32 tokens of the document as pseudo-title.
319
+ DSI [37], which represents documents using hierarchical K-means clustering results, and indexes documents using the first 32 tokens as pseudo-queries. As the original code is not open source, we reproduce DSI using T5-base and the docids of NCI [41].
320
+ • SEAL [1] uses arbitrary n-grams in documents as docids, and retrieves documents under the constraint of a pre-built FM-indexer. We refer to the results reported by Wang et al. [41].
321
+ • CGR-Contra [17], a title generation model with a contextualized vocabulary embedding and a contrastive learning loss.
322
+ DSI-QG [47], uses a query generation model to augment the document collection. We reproduce the DSI-QG results using T5 and our dataset.
323
+ NCI [41], uses a prefix-aware weight-adaptive decoder and various query generation strategies, including DocAsQuery and DocT5Query. In particular, NCI augments training data by generating 15 queries for each document.
324
+ • Ultron [46], uses a three-stage training pipeline and represents the document as three types of identifiers, including URL, PQ, and Atomic.
325
+
326
+ # C Performance on retrieving new documents
327
+
328
+ In this experiment, we investigate the impact of various document tokenization techniques on the ability of generative retrieval models to retrieve new documents. The generative models with different tokenization methods are trained on NQ320K data, excluding unseen documents, and are evaluated on NQ320K Unseen test set and BEIR-{Arg, NFC, SciDocs} datasets. For the baseline methods, which use rule-based document tokenization methods, the docids are generated for the target document collection using their respective tokenization techniques. In contrast, our proposed method uses a tokenization model to tokenize the documents in the target collection, producing the docids. However, our method may result in duplicate docids. In such cases, all corresponding documents are retrieved and shuffled in an arbitrary order. The results of this evaluation are summarized in Table 5.
329
+
330
+ Table 5: Zero-shot evaluation on retrieving new documents with different document tokenization methods. The second column indicates the type of docid, where BERT-HC denotes BERTHierarchical-Clustering [37], Prefix-HC denotes Prefix-aware BERT-Hierarchical-Clustering [41], and dAE denotes discrete auto-encoding.
331
+
332
+ <table><tr><td></td><td></td><td>NQ (R@1)</td><td colspan="3">BEIR (nDCG@ 10)</td></tr><tr><td>Method</td><td>Docid</td><td>Unseen</td><td>Arg</td><td>NFC</td><td>SciDocs</td></tr><tr><td>DSI-Naive† [37]</td><td>Naive String</td><td>0.0</td><td>0.1</td><td>1.0</td><td>0.1</td></tr><tr><td>DSI-Atomic† [37]</td><td>Atomic</td><td>0.0</td><td>0.2</td><td>0.8</td><td>0.1</td></tr><tr><td>GENRE† [5]</td><td>Title</td><td>6.0</td><td>0.0</td><td>2.4</td><td>0.6</td></tr><tr><td>DSIt [37]</td><td>BERT-HC</td><td>1.3</td><td>1.8</td><td>11.1</td><td>5.9</td></tr><tr><td>NCI [41]</td><td>Prefix-HC</td><td>15.5</td><td>0.9</td><td>4.3</td><td>1.2</td></tr><tr><td>Ours</td><td>dAE</td><td>34.2</td><td>12.1</td><td>12.1</td><td>12.3</td></tr></table>
333
+
334
+ Document tokenization methods that do not consider the semantic information of the documents, such as Naive String and Atomic, are ineffective in retrieving new documents without model updating. Methods that consider the semantic information of the documents, such as those based on title or BERT clustering, show some improvement. Our proposed document tokenization method significantly improves over these existing rule-based document tokenization methods. For instance, when the model trained on NQ – a factoid QA data based on Wikipedia documents – is applied to a distinct retrieval task on a different document collection, BEIR-SciDocs, a citation retrieval task on a collection of scientific articles, our proposed document tokenization model still showed promising results with an nDCG $@ 1 0$ of 12.3, which is comparable to those models trained on the target document collection. This suggests that our proposed method effectively encodes the semantic information of documents in the docid and leads to a better fit between the docid and the generative retrieval model.
335
+
336
+ Table 6: Efficiency analysis.
337
+
338
+ <table><tr><td>Method</td><td>Memory</td><td>Time ( (Offline)</td><td>Top-K</td><td>Time (Online)</td></tr><tr><td>ANCE</td><td>1160MB</td><td>145min</td><td>100</td><td>0.69s</td></tr><tr><td>GTR-Base</td><td>1430MB</td><td>140min</td><td>100</td><td>1.97s</td></tr><tr><td rowspan="2">GENRE</td><td rowspan="2">851MB</td><td rowspan="2">0min</td><td>100</td><td>1.41s</td></tr><tr><td>10</td><td>0.69s</td></tr><tr><td rowspan="2">DSI</td><td rowspan="2">851MB</td><td rowspan="2">310min</td><td>100</td><td>0.32s</td></tr><tr><td>10</td><td>0.21s</td></tr><tr><td rowspan="2">Ours</td><td rowspan="2">860MB</td><td rowspan="2">220min</td><td>100</td><td>0.16s</td></tr><tr><td>10</td><td>0.10s</td></tr></table>
339
+
340
+ # D Efficiency analysis
341
+
342
+ In Table 6, we compare GENRET with baseline models on MS MARCO (323,569 documents) in terms of memory footprint, offline indexing time (not including the time for neural network training), and online retrieval latency for different Top-K values. We have four observations: (i) The memory footprint of generative retrieval models (GENRE, DSI-QG, and the proposed model) is smaller than of dense and sparse retrieval methods. The memory footprint of generative retrieval models is only dependent on the model parameters, whereas dense and sparse retrieval methods require additional storage space for document embeddings, which increases linearly with the size of the document collection. (ii) DSI and GENRET take a longer time for offline indexing, as DSI involves encoding and clustering documents using BERT, while GENRET requires tokenizing documents using a tokenization model. Dense retrieval’s offline time consumption comes from document encoding; GENRE uses titles hence no offline computation. (iii) The online retrieval latency of the generative retrieval model is associated with the beam size (i.e., Top-K) and the length of the docid. GENRET utilizes diverse clustering to generate a shorter docid, resulting in improved online retrieval speed compared to DSI and GENRE.
343
+
344
+ # E Embedding visualization
345
+
346
+ ![](images/ae2f3029bc824157a42797d372c22ad43ae6c635a3a216a5bad894b75cf0d816.jpg)
347
+ Figure 5: t-SNE visualization of the codebook embedding and document embedding on the NQ320K dataset. The codebook embedding is uniformly scattered in the document representation space.
md/dev/VAeAUWHNrty/VAeAUWHNrty.md ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Shape, Light, and Material Decomposition from Images using Monte Carlo Rendering and Denoising
2
+
3
+ Jon Hasselgren NVIDIA
4
+
5
+ Nikolai Hofmann NVIDIA
6
+
7
+ Jacob Munkberg NVIDIA
8
+
9
+ # Abstract
10
+
11
+ Recent advances in differentiable rendering have enabled high-quality reconstruction of 3D scenes from multi-view images. Most methods rely on simple rendering algorithms: pre-filtered direct lighting or learned representations of irradiance. We show that a more realistic shading model, incorporating ray tracing and Monte Carlo integration, substantially improves decomposition into shape, materials & lighting. Unfortunately, Monte Carlo integration provides estimates with significant noise, even at large sample counts, which makes gradient-based inverse rendering very challenging. To address this, we incorporate multiple importance sampling and denoising in a novel inverse rendering pipeline. This improves convergence and enables gradient-based optimization at low sample counts. We present an efficient method to jointly reconstruct geometry (explicit triangle meshes), materials, and lighting, which substantially improves material and light separation compared to previous work. We argue that denoising can become an integral part of high quality inverse rendering pipelines.
12
+
13
+ # 1 Introduction
14
+
15
+ Differentiable rendering shows great promise for accurate multi-view 3D reconstruction from image observations. NeRF [39] use differentiable volume rendering to create high quality view interpolation through neural, density-based light-fields. Surface-based methods apply signed distance fields [43, 47, 68, 62, 73] or triangle meshes [41, 54] to capture high quality geometry. Recent work [6, 41, 75] further decompose these representations into geometry, material, and environment light.
16
+
17
+ Most aforementioned methods rely on appearance baked into neural light fields or apply simple shading models. Typically, direct lighting without shadows is considered, combined with pre-filtered representations of environment lighting [41, 73]. Some methods account for shadowing and indirect illumination [6, 75, 77], but often lock the geometry optimization when sampling the shadow term, or rely on learned representations of irradiance. While results are impressive, the deviations from physically-based shading models makes it harder for these methods to plausibly disentangle shape, material and lighting, as shown in Figure 1.
18
+
19
+ In theory, it is straightforward to replace the rendering engines of these 3D reconstruction methods with photorealistic differentiable renderers [31, 36, 46, 45, 71, 72] and optimize in a setting with more accurate light simulation, including global illumination effects. In practice, however, the noise in multi-bounce Monte Carlo rendering makes gradient-based optimization challenging. Very high sample counts are required, which result in intractable iteration times.
20
+
21
+ In this paper, we bridge the gap between current multi-view 3D reconstruction and physicallybased differentiable rendering, and demonstrate high-quality reconstructions at competitive runtime performance. We attack the challenging case of extracting explicit triangle meshes, PBR materials and environment lighting from a set of multi-view images, in a format directly compatible with current DCC tools and game engines. For improved visual fidelity, we compute direct illumination using Monte Carlo integration with ray tracing, and add several techniques to combat the increased noise levels. By carefully trading variance for bias, we enable efficient gradient-based optimization in a physically-based inverse rendering pipeline. Compared to previous 3D reconstruction methods, our formulation primarily improves material and light separation.
22
+
23
+ ![](images/47ea2d2e5e7670ebe38a496aa6088058d49c366dd3e7ee69ce206d5732e39c6b.jpg)
24
+ Figure 1: NVDIFFREC [41] successfully reconstructs complex geometry from multi-view images, but struggles with the material & light separation. In the top row, we visualize split-screens of the rendered reconstruction and the diffuse albedo texture. Note that NVDIFFREC bakes most of the lighting in the albedo texture, which hurts quality in relighting scenarios (shown in the bottom row). In contrast, by leveraging a more advanced renderer, we successfully disentangle material and lighting (note the lack of shading in the albedo texture), and improve relighting quality. The dataset consists of 200 views of the Rollercoaster from LDraw resources [29] (CC BY-2.0).
25
+
26
+ Concretely, we reduce variance by combining multiple importance sampling [58] and differentiable denoisers. We evaluate both neural denoisers [2, 10, 22] and cross-bilateral filters [52] in our pipeline. Furthermore, we decompose the rendering equation into albedo, demodulated diffuse lighting and specular lighting, which enable precise regularization to improve light and material separation.
27
+
28
+ # 2 Previous Work
29
+
30
+ Neural methods for multi-view reconstruction These methods fall in two categories: implicit or explicit scene representations. NeRF [39] and follow-ups [38, 42, 49, 74, 64, 15, 40, 50, 69, 66], use volumetric representations and compute radiance by ray marching through a neurally encoded 5D light field. While achieving impressive results on novel view synthesis, geometric quality suffers from the ambiguity of volume rendering [74]. Surface-based rendering methods [43, 47, 68, 62] optimizing the underlying surface directly using implicit differentiation, or gradually morph from a volumetric representation into a surface representation. Methods with explicit representation estimate 3D meshes from images, where most approaches assume a given mesh topology [35, 11, 12], but recent work also include topology optimization [34, 14, 54, 41].
31
+
32
+ BRDF and lighting estimation To estimate surface radiometric properties from images, previous work on BTF and SVBRDF estimation rely on special viewing configurations, lighting patterns or complex capturing setups [30, 16, 17, 18, 65, 5, 8, 53, 20]. Recent methods exploit neural networks to predict BRDFs from images [13, 19, 32, 33, 44, 37]. Differentiable rendering methods [35, 11, 76, 12, 21] learn to predict geometry, SVBRDF and, in some cases, lighting via photometric loss.
33
+
34
+ Most related to our work are neural 3D reconstruction methods with intrinsic decomposition of shape, materials, and lighting from images [6, 7, 41, 73, 75, 77]. Illumination is represented using mixtures of spherical Gaussians [6, 41, 73, 77], pre-filtered approximations [7, 41], or low resolution environment maps [75]. When the shadowing term is accounted for [75], optimization is split into two passes where geometry is locked before the shadow term is sampled. Other approaches represent indirect illumination with neural networks [63, 77].
35
+
36
+ ![](images/91c47de1fb4b2f37145ebf88a6912e35876a2dceae51ca98089865af21006e08.jpg)
37
+ Figure 2: We extend NVDIFFREC [41] with a differentiable Monte Carlo renderer for direct illumination. Additionally, to reduce variance, we add a differentiable denoiser. These novel steps are highlighted in green. Following NVDIFFREC, the topology is parameterized using an SDF, and a triangular surface mesh is extracted in each iteration using DMTet [54], combined with spatially-varying PBR materials and HDR environment lighting. The system is supervised using only photometric loss on the rendered, denoised image compared to a reference, and gradients are back-propagated to the denoiser, shape, materials, and lighting parameters. All parameters are optimized jointly.
38
+
39
+ Image denoisers Denoisers are essential tools in both real-time- and production renderers. Traditionally, variants of cross-bilateral filters are used [78], which require scene-specific manual adjustments. More recently, neural denoisers [2, 10, 22] trained on large datasets have shown impressive quality without the need for manual tuning, and are now incorporated in most production renderers. We directly incorporate differentiable versions of these denoisers in our pipeline. We are currently unaware of image denoisers applied in differentiable rendering, but we see a lot of potential for denoisers in physically-based inverse rendering going forward.
40
+
41
+ # 3 System
42
+
43
+ We target the challenging task of joint optimization of shape, material and environment lighting from a set of multi-view images with known foreground segmentation masks and camera poses. Our goal is to use physically-based rendering techniques to improve the intrinsic decomposition of lighting and materials, producing assets that can be relit, edited, animated, or used in simulation. As a proofof-concept, we extend a recent approach, NVDIFFREC [41], which targets the same optimization task (shape, materials and environment lighting). Notably, they directly optimize a triangular 3D model, which has obvious benefits: it is easy to import and modify the reconstructed models in existing DCC tools, and a triangular representation can exploit hardware-accelerated differentiable rasterization [28]. In our setting, triangular 3D models also means we can leverage hardware-accelerated ray-tracing for efficient shadow tests. NVDIFFREC reports competitive results on view interpolation, material reconstruction, and relighting, and we will use their pipeline as a baseline in our evaluations.
44
+
45
+ Our system is summarized in Figure 2. A triangular mesh with arbitrary topology is optimized from a set of images through 2D supervision. Geometry is represented by a signed distance field defined on a three-dimensional grid and reduced to a triangular surface mesh through deep marching tetrahedra (DMTet) [54]. Next, the extracted surface mesh is rendered in a differentiable renderer, using the physically-based (PBR) material model from Disney [9]. This material model combines a diffuse term with an isotropic, specular GGX lobe [61]. A tangent space normal map is also included to capture high frequency shading detail. Finally, the rendered image is evaluated against a reference image using a photometric loss. In contrast to NVDIFFREC, which uses a simple renderer with deferred shading and the split-sum approximation for direct lighting (without shadows), we instead leverage a renderer which evaluates the direct lighting integral using Monte Carlo integration and ray tracing (shadow rays). We represent the scene lighting using a high dynamic range light probe stored as a floating point texture, typically at a resolution of $2 5 6 \times 2 5 6$ texels. Finally, to combat the inherent variance that comes with Monte Carlo integration, we leverage differentiable image denoising and multiple importance sampling.
46
+
47
+ ![](images/2419df7cec34b53f2d33921985f613cf306f619486d881b304c4a4fe9b96f563.jpg)
48
+ Figure 3: Visualization of the optimization process. Note that the initial guess for topology are randomized SDF values on the grid. After 1000 iterations, we already have a high quality topology and plausible materials and lighting for this complicated asset. Synthetic dataset with 200 frames, generated from a part of the Apollo capsule, courtesy of the Smithsonian [55] (CC0-1.0).
49
+
50
+ Optimization task Let $\phi$ denote the optimization parameters (shape, spatially varying materials and light probe). For a given camera pose, $c$ , our differentiable renderer produces an image $I _ { \phi } ( c )$ . Given that we use Monte Carlo integration during rendering, this image inherently includes noise, and we apply a differentiable image denoiser, $D _ { \theta }$ , with parameters, $\theta$ , to reduce the variance, $I _ { \phi } ^ { \mathrm { d e n o i s e d } } ( \stackrel { \cdot } { c } ) \stackrel { \cdot } { = } D _ { \theta } ( I _ { \phi } ( c ) )$ . The reference image $I _ { \mathrm { r e f } } ( c )$ is a view from the same camera. Given a photometric loss function $L$ , we minimize the empirical risk
51
+
52
+ $$
53
+ \underset { \phi , \theta } { \mathrm { a r g m i n } } \ : \mathbb { E } _ { c } \big [ L \big ( D _ { \theta } ( I _ { \phi } ( c ) ) , I _ { \mathrm { r e f } } ( c ) \big ) \big ]
54
+ $$
55
+
56
+ using Adam [26] based on gradients w.r.t. the optimization parameters, $\partial L / \partial \phi$ , and $\partial L / \partial \theta$ , which are obtained through differentiable rendering. We use the same loss function as NVDIFFREC. An example of the optimization process is illustrated in Figure 3.
57
+
58
+ # 3.1 Direct Illumination
59
+
60
+ The outgoing radiance $L ( \omega _ { o } )$ in direction $\omega _ { o }$ can be expressed using the rendering equation [24] as:
61
+
62
+ $$
63
+ L ( \omega _ { o } ) = \int _ { \Omega } L _ { i } ( \omega _ { i } ) f ( \omega _ { i } , \omega _ { o } ) ( \omega _ { i } \cdot \mathbf { n } ) d \omega _ { i } .
64
+ $$
65
+
66
+ This is an integral of the product of the incident radiance, $L _ { i } ( \omega _ { i } )$ from direction $\omega _ { i }$ and the BSDF $f ( \omega _ { i } , \omega _ { o } )$ . The integration domain is the hemisphere $\Omega$ around the surface normal, $\mathbf { n }$ .
67
+
68
+ Spherical Harmonics (SH) [11] or Spherical Gaussians (SG) [6, 73] are often used as efficient approximations of direct illumination, but only work well for low- to medium-frequency lighting. In contrast, the split sum approximation [25, 41] captures all-frequency image based lighting, but does not incorporate shadows. Our goal is all-frequency lighting including shadows, which we tackle by evaluating the rendering equation using Monte Carlo integration:
69
+
70
+ $$
71
+ L ( \omega _ { o } ) \approx \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \frac { L _ { i } ( \omega _ { i } ) f ( \omega _ { i } , \omega _ { o } ) ( \omega _ { i } \cdot \mathbf { n } ) } { p ( \omega _ { i } ) } ,
72
+ $$
73
+
74
+ with samples drawn from some distribution $p ( \omega _ { i } )$ . Note that $L _ { i } ( \omega _ { i } )$ includes a visibility test, which can be evaluated by tracing a shadow ray in direction $\omega _ { i }$ . Unfortunately, the variance levels in Monte Carlo integration with low number of samples makes gradient-based optimization hard, particularly with complex lighting. In Section 4 we propose several variance reduction techniques, which enable an inverse rendering pipeline that efficiently reconstructs complex geometry, a wide range of lighting conditions and spatially-varying BSDFs.
75
+
76
+ Shadow gradients In single view optimization [60], shape from shadows [57], or direct optimization of the position/direction of analytical light sources, shadow ray visibility gradients [36, 3] are highly beneficial. However, in our multi-view setting $5 0 +$ views), similar to Loubet et al. [36], we observed that gradients of diffuse scattering are negligible compared to the gradients of primary visibility. Hence, for performance reasons, in the experiment presented in this paper, the shadow ray visibility gradients are detached when evaluating the hemisphere integral, and shape optimization is driven by primary visibility gradients, obtained from nvdiffrast [28].
77
+
78
+ # 4 Variance Reduction
79
+
80
+ We evaluate direct illumination with high frequency environment map lighting combined with a wide range of materials (diffuse, dielectrics, and metals). Strong directional sunlight, highly specular, mirror-like materials, and the visibility component can all introduce significant levels of noise. To enable optimization in an inverse rendering setting at practical sample counts, we carefully sample each of these contributing factors to obtain a signal with low variance. Below, we describe how we combat noise by using multiple importance sampling and denoising.
81
+
82
+ # 4.1 Multiple Importance Sampling
83
+
84
+ We leverage multiple importance sampling [58] (MIS), a framework to weigh a set of different sampling techniques to reduce variance in Monte Carlo integration. Given a set of sampling techniques, each with a sampling distribution $p _ { i }$ , the Monte Carlo estimator for an integral $\textstyle \int _ { \Omega } { \bar { g } } ( x ) d x$ given by MIS is
85
+
86
+ $$
87
+ \sum _ { i = 1 } ^ { n } { \frac { 1 } { n _ { i } } } \sum _ { j = 1 } ^ { n _ { i } } w _ { i } ( X _ { i , j } ) { \frac { g ( X _ { i , j } ) } { p _ { i } ( X _ { i , j } ) } } , \quad w _ { i } ( x ) = { \frac { n _ { i } p _ { i } ( x ) } { \sum _ { k } n _ { k } p _ { k } ( x ) } } .
88
+ $$
89
+
90
+ The weighting functions $w _ { i } ( x )$ are chosen using the balance heuristic. Please refer to Veach’s thesis [58] or the excellent PBRT book [48] for further details.
91
+
92
+ In our case, we apply MIS with three sampling techniques: light importance sampling, $p _ { \mathrm { l i g h t } } ( \omega )$ , using a piecewise-constant 2D distribution sampling technique [48], cosine sampling, $p _ { \mathrm { d i f f u s e } } ( \omega )$ , for the diffuse lobe, and GGX importance sampling [23], $p _ { \mathrm { s p e c u l a r } } ( \omega )$ , for the specular lobe. Unlike in forward rendering with known materials and lights, our material and light parameters are optimization variables. Thus, the sampling distributions, $p _ { i }$ , are recomputed in each optimization iteration. Following the taxonomy of differentiable Monte Carlo estimators of Zeltner et al. [71], our importance sampling is detached, i.e., we do not back-propagate gradients to the scene parameters in the sampling step, only in the material evaluation. Please refer to Zeltner et al. for a careful analysis of Monte Carlo estimators for differentiable light transport.
93
+
94
+ MIS is unbiased, but chaining multiple iterations of our algorithm exhibits bias, as the current, importance sampled, iteration dictates the sampling distributions used in the next iteration. Light probe intensities, for example, are optimized based on an importance sampled image, which are then used to construct the sampling distribution for the subsequent pass. For unbiased rendering, the sampling distribution must be estimated using a second set of uncorrelated samples instead. Furthermore, we explicitly re-use the random seed from the forward pass during gradient backpropagation to scatter gradients to the exact same set of parameters that contributed to the forward rendering. This approach is clearly biased [59], but we empirically note that this is very effective in reducing variance, and in our setting this variance-bias trade-off works in our favor.
95
+
96
+ # 4.2 Denoising
97
+
98
+ For differentiable rendering, the benefits of denoising are twofold. First, it improves the image quality of the rendering in the forward pass, reducing the optimization error and the gradient noise introduced in the image loss. Second, as gradients back-propagate through the denoiser’s spatial filter kernel, gradient sharing between neighboring pixels is enabled. To see this, let’s consider a simple denoiser, $O = X \circledast F$ , where the noisy rendered image $X$ is filtered by a low-pass filter, $F$ ( $\circledast$ represents an image sprenderer are on). Given a loss gradient, , which applies the same lo $\frac { \partial L } { \partial O }$ , the gradients propagated back to thess filter in case the filter is rotationally $\begin{array} { r } { \frac { \partial L } { \partial X } = \frac { \partial L } { \partial O } \circledast F ^ { T } } \end{array}$ symmetric ${ \boldsymbol { \mathbf { \mathit { F } } } } = { \boldsymbol { \mathbf { \mathit { F } } } } ^ { T }$ ). In other words, the renderer sees filtered loss gradients in a local spatial footprint. While denoisers inherently trade a reduction in variance for increased bias, we empirically note that denoising significantly helps convergence at lower sample counts, and help to reconstruct higher frequency environment lighting. We show an illustrative example in Figure 9.
99
+
100
+ Following previous work in denoising for production rendering [2], Figure 4 shows how we separate lighting into diffuse, $\mathbf { c } _ { d }$ , and specular, $\mathbf { c } _ { s }$ terms. This lets us denoise each term separately, creating denoised buffers, $D _ { \theta } ( \mathbf { c } _ { d } )$ , and $D _ { \theta } ( \mathbf { c } _ { s } )$ . More importantly, we can use demodulated diffuse lighting, which means that the lighting term has not yet been multiplied by material diffuse albedo, $\mathbf { k } _ { d }$ . In forward rendering, this is important as it decorrelates the noisy lighting from material textures, thus selectively denoising the noisy Monte-Carlo estimates and avoiding to low-pass filter high-frequent texture information. In inverse rendering, we can additionally use it to improve material and light decomposition by adding regularization on the lighting terms, as disucussed in Section 5. We compose the final image as $\mathbf { c } = \mathbf { \bar { k } } _ { d } \cdot D _ { \theta } ( \mathbf { c } _ { d } ) + D _ { \theta } ( \mathbf { c } _ { s } )$ . We currently do not demodulate specular lighting because of the view dependent Fresnel term, but expect this to be improved in future work.
101
+
102
+ ![](images/283a33b23d88c33d5590bb26a18b59e257ddc201ed11592b81a00922ffdd78ee.jpg)
103
+ Figure 4: We separate lighting into diffuse lighting, $\mathbf { c } _ { d }$ , diffuse reflectance, $\mathbf { k } _ { d }$ , and specular lighting, $\mathbf { c } _ { s }$ . This enables fine-grained regularization and denoising without smearing texture detail.
104
+
105
+ ![](images/b8546280f6b4bfb0fec776a0a0dfcf28c33412ea8e88d0c46ddce1d9705ae3ac.jpg)
106
+ Figure 5: Ablation study on the effect of using different denoising algorithms during optimization at low sample counts on three different scenes of increasing complexity (from left to right). We plot averaged PSNR scores over 200 novel views, rendered without denoising, using high sample counts. In this experiment, we used decorrelated samples in the backward pass to highlight the effect of denoising. The most complex scene (Porsche) failed to converge at $8 \ \mathrm { s p p }$ without denoising.
107
+
108
+ Cross-bilateral filters Cross-bilateral filters are commonly used to remove noise in rendered images [78]. To evaluate this family of denoisers in our inverse pipeline, we adapted Spatio-temporal Variance-Guided Filtering [52] (SVGF), which is a popular cross-bilateral filter using surface normals and per-pixel depth as edge-stopping guides. The denoiser is applied to demodulated diffuse lighting, to avoid smearing texture detail. We disabled the temporal component of SVGF, as we focus on single frame rendering, and implemented the filter as a differentiable module to allow for loss gradients to propagate back to our scene parameters.
109
+
110
+ Neural denoisers As a representative neural denoiser, we deploy the Open Image Denoiser (OIDN) [1], which is a U-Net [51] pre-trained on a large corpus of rendered images. The denoiser is applied to the rendered image before computing the image space loss. As the network model is fully convolutional, it is trivially differentiable, and we can propagate gradients from the image space loss, through the denoiser back to the renderer.
111
+
112
+ In Figure 5, we provide an overview on the effect of denoisers during 3D scene reconstruction. We observe that denoising is especially helpful at low sample counts, where we obtain similar reconstruction results at 8 spp with denoising, compared to $3 2 { \mathrm { ~ s p p } }$ without a denoiser. At higher sample counts, however, the benefit from denoising diminishes, as variance in the Monte-Carlo estimates decreases. Given that denoisers enable significantly faster iteration times, we consider it a valuable tool for saving computational resources when fine-tuning model parameters for subsequent runs with high sample counts. Additionally, we empirically found that using a denoiser during reconstruction yields higher quality light probes, as can be seen in Figure 9, both at low and high sample counts.
113
+
114
+ We can also jointly optimize the denoiser parameters, $\theta$ , with the 3D scene reconstruction task. i.e., the denoiser is fine-tuned for the current scene. Unfortunately, this approach has undesirable side-effects: Features tend to get baked into the denoiser network weights instead of the materials or light probe. This is especially apparent with the OIDN [1] denoiser, which produced color shifts due to lack of regularization on the output. We got notably better results with the hierarchical kernel prediction architecture from Hasselgren et al. [22], which is more constrained. However, the results still lagged behind denoisers with locked weights. We refer to the supplemental material for details.
115
+
116
+ # 5 Priors
117
+
118
+ In our setting: 3D reconstruction from multi-view images with constant lighting, regularization is essential in order to disentangle lighting and materials. Following previous work [75, 41], we apply smoothness priors for albedo, specular, and normal map textures. Taking the albedo as an example, if $k _ { d } \left( \mathbf { x } \right)$ denotes the diffuse albedo at world space position, $\mathbf { x }$ , and $\epsilon$ is a small random displacement vector, we define the smoothness prior for albedo as:
119
+
120
+ $$
121
+ L _ { { \pmb k } _ { d } } = \sum _ { { \bf x } _ { \mathrm { s u r f } } } | { \pmb k } _ { d } ( { \bf x } _ { \mathrm { s u r f } } ) - { \pmb k } _ { d } ( { \bf x } _ { \mathrm { s u r f } } + \epsilon ) | ,
122
+ $$
123
+
124
+ where $\mathbf { x } _ { \mathrm { s u r f } }$ are the world space positions at the primary hit point on the object. We note that the smoothness prior is not sufficient to disentangle material parameters and light, especially for scenes with high frequency lighting and sharp shadows. Optimization tends to bake shadows into the albedo texture (easy) rather than reconstruct a high intensity, small area in the environment map (hard). To enable high quality relighting, we explicitly want to enforce shading detail represented by lighting, and only bake remaining details into the material textures. We propose a novel regularizer term that is surprisingly effective. We compute a monochrome image loss between the demodulated lighting terms and the reference image:
125
+
126
+ $$
127
+ L _ { \mathrm { l i g h t } } = \left| \mathrm { Y } \left( \mathbf { c } _ { d } + \mathbf { c } _ { s } \right) - \mathrm { V } \left( I _ { \mathrm { r e f } } \right) \right| .
128
+ $$
129
+
130
+ Here, $Y \left( \mathbf { x } \right) = \left( \mathbf { x } _ { r } + \mathbf { x } _ { g } + \mathbf { x } _ { b } \right) / 3$ is a simple luminance operator, and $V \left( \mathbf { x } \right) = \operatorname* { m a x } \left( \mathbf { x } _ { r } , \mathbf { x } _ { g } , \mathbf { x } _ { b } \right)$ is the HSV value component. The rationale for using HSV-value for the reference image is that the max operation approximates demodulation, e.g., a red and white pixel have identical values. We assume that the demodulated lighting is mostly monochrome, in which case $Y \left( \mathbf { x } \right) \sim V \left( \mathbf { x } \right)$ , and given that we need to propagate gradients to $\mathbf { c } _ { d }$ and $\mathbf { c } _ { s }$ , $Y$ avoids discontinuities. This regularizer is limited by our inability to demodulate the reference image. The HSV-value ignores chrominance, but we cannot separate a shadow from a darker material. This has not been a problem in our tests, but could interfere with optimization if the regularizer is given too much weight. Please refer to the supplemental materials for complete regularizer details.
131
+
132
+ # 6 Experiments
133
+
134
+ In our experiments, we use NVDIFFREC [41] as a baseline, and refer to their work for thorough comparisons against related work. We focus the evaluation on the quality of material and light separation. At test time, all view interpolation results are generated without denoising at 2k spp. All relighting results are rendered in Blender Cycles at 64 spp with denoising [1]. Table 1 shows a quantitative comparison with NVDIFFREC and NeRFactor [75] on the NeRFactor relighting setup. Note that there is an indeterminate scale factor between material reflectance (e.g., albedo) and the light intensity. This is accounted for by scaling each image to match the average luminance of the reference for the corresponding scene. The same methodology is applied for all algorithms in our comparisons. We outperform previous work, providing better material reconstruction. Figure 6 shows visual examples.
135
+
136
+ Table 1: Summarized relighting results for NeRFactor (CC-BY-3.0), NeRF (CC-BY-3.0) and our synthetic datasets. The NeRFactor dataset contains four scenes, each scene has eight validation views and eight different light probes (256 validation images). For the NeRF dataset (which contain higher frequency lighting), we use the Chair, Hotdog, Lego, Materials and Mic scenes, with eight validation views and four light probe configurations (160 validation images). Our dataset contains a variation of high and low frequency lighting with geometrically complex objects. The image metric scores are arithmetic means over all images.
137
+
138
+ <table><tr><td></td><td colspan="3">NeRFactor synthetic</td><td colspan="3"> Nerf synthetic</td><td colspan="3"> Our synthetic</td></tr><tr><td></td><td>PSNR↑</td><td>SSIM↑</td><td>LPIPS↓</td><td>PSNR↑</td><td>SSIM↑</td><td>LPIPS↓</td><td>PSNR↑</td><td>SSIM↑</td><td>LPIPS↓</td></tr><tr><td>Our</td><td>26.0 dB</td><td>0.924</td><td>0.060</td><td>26.5 dB</td><td>0.932</td><td>0.055</td><td>27.1 dB</td><td>0.950</td><td>0.027</td></tr><tr><td>NVDIFFREC</td><td>24.8 dB</td><td>0.910</td><td>0.063</td><td>23.3 dB</td><td>0.889</td><td>0.076</td><td>23.7 dB</td><td>0.925</td><td>0.049</td></tr><tr><td>NERFACTOR</td><td>22.2 dB</td><td>0.896</td><td>0.087</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr></table>
139
+
140
+ ![](images/35884a9c33fcc799367a6a0c7c9b1793217f50583f96542beb50097245edd04b.jpg)
141
+ Figure 6: Relighting examples from the NeRFactor and NeRF synthetic datasets. The NeRF dataset contains high frequency lighting and global illumination, and is substantially more challenging than the NeRFactor version, which uses downsampled probes. Our results contain visible artifacts, but outperform the material separation of previous work.
142
+
143
+ ![](images/e91892ed9ba10d5afd333b972f1f32cbd88aa43e66702fa11ff2f07524195826.jpg)
144
+ Figure 7: Manipulations of our extracted 3D model of the Family dataset in Blender. This scene is part of the Tanks&Temples [27] dataset (CC BY-NC-SA 3.0). Tree and bird models from TurboSquid.
145
+
146
+ We additionally perform relighting on the synthetic NeRF dataset, which is substantially more challenging than the NeRFactor variant, due to high frequency lighting and global illumination effects. NVDIFFREC produces severe artifacts, as exemplified by the Hotdog scene in Figure 6. Table 1 shows a significant increase in image quality for our approach. The visual examples show that our results are plausible, though not without artifacts. Finally, we constructed a novel synthetic dataset with three scenes with highly complex geometry to stress-test the system. Each scene contains 200 training views and 200 novel views for evaluation. The three scenes are shown in Figures 1 , 3 ,and 9. Quantitatively we outperform previous work by a larger margin, and Figure 1 shows very little shading in the albedo textures.
147
+
148
+ ![](images/84d044833044b9f768181b41cf6d3502c7290e61bf6f5705cdf1603728bc9290.jpg)
149
+ Figure 8: We show explicit decomposition of shape, materials and lighting, directly from photos with known poses. Character is part of the BlendedMVS [67] dataset (CC BY-4.0) and Gold Cape is part of the NeRD [6] dataset (CC BY-NC-SA 4.0).
150
+
151
+ ![](images/c7a2346b85695890d65a89b941613b49d6745d8a9b503b5a25a98d21cc5d994d.jpg)
152
+ Figure 9: We show the benefits of denoising on the Porsche scene from LDraw resources [29] (CC BY-2.0). At low sample counts, denoising helps both with geometric reconstruction (in the cockpit) and to capture specular highlights. Even at $1 2 8 ~ \mathrm { s p p }$ , denoising improves specular highlight and high frequency lighting details.
153
+
154
+ In Figures 7 and 8, we apply our method to datasets with real photos. These sets are more difficult, due to inaccuracies in foreground segmentation masks and camera poses. We extract triangle meshes that can be trivially edited in 3D modeling software, and in Figure 7 we use Blender to perform scene editing, material editing, and relighting. Note that the results look plausible with the inserted object being properly shaded and casting shadows on the statue, material editing works well with the learned environment lighting and relighting interacts properly with the learned materials. Figure 8 shows a breakdown of geometry, material parameters and environment light.
155
+
156
+ To study the impact of denoising, we optimized the Porsche scene w/ and w/o denoising. As shown in Figure 9, denoising improves both visual quality and environment lighting detail at equal sample counts. The noise levels varies throughout the scene, and we note that denoising is particularly helpful in regions with complex lighting or occlusion, such as the specular highlight and cockpit.
157
+
158
+ Neural light-fields, e.g. Mip-NeRF [4] excel at view interpolation. We enforce material/light separation through additional regularization, which slightly degrades view interpolation results, as shown in Table 2. Our scores are slightly below NVDIFFREC, but, as shown above, we provide considerably better material and lighting separation.
159
+
160
+ Table 2: View interpolation results. For reference, the NERFACTOR scores are 26.9 dB PSNR and SSIM of 0.930 on the NerFactor synthetic dataset, and Mip-NeRF has 35.0 dB PSNR and SSIM 0.978 on the Nerf synthetic dataset. The image metric scores are arithmetic means over all test images.
161
+
162
+ <table><tr><td></td><td colspan="2">NeRFactor synthetic</td><td colspan="2"> Nerf synthetic</td><td colspan="2"> Our synthetic</td><td colspan="2">Real-world</td></tr><tr><td></td><td>PSNR↑</td><td>SSIM↑</td><td>PSNR↑</td><td>SSIM↑</td><td>PSNR↑</td><td>SSIM↑</td><td>PSNR↑</td><td>SSIM↑</td></tr><tr><td>Our</td><td>29.6 dB</td><td>0.951</td><td>28.4 dB</td><td>0.938</td><td>25.6 dB</td><td>0.934</td><td>25.29 dB</td><td>0.899</td></tr><tr><td>NVDIFFREC</td><td>31.7 dB</td><td>0.967</td><td>30.4 dB</td><td>0.958</td><td>25.8 dB</td><td>0.944</td><td>26.58 dB</td><td>0.918</td></tr></table>
163
+
164
+ Compute resources Tracing rays to evaluate the direct illumination is considerably more expensive than pre-filtered environment light approaches. We leverage hardware-accelerated ray intersections, but note that our implementation is far from fully optimized. Our method scales linearly with sample count, which gives us a simple way to trade quality for performance. With a batch size 8 at a rendering resolution of $5 1 2 \times 5 1 2$ , we get the following iteration times on a single NVIDIA A6000 GPU.
165
+
166
+ <table><tr><td></td><td>NVDIFFREC</td><td>Our 2 spp</td><td>Our 8 spp</td><td>Our 32 spp</td><td>Our 128 spp</td><td>Our 288 spp</td></tr><tr><td>Iteration time</td><td>340 ms</td><td>280 ms</td><td>285 ms</td><td>300 ms</td><td>360 ms</td><td>450 ms</td></tr></table>
167
+
168
+ Our denoising strategies enable optimization at low sample counts. Unless otherwise mentioned, for the results presented in the paper, we use high quality settings of $1 2 8 +$ rays per pixel with $5 0 0 0 \times 2$ iterations (second pass with fixed topology and 2D textures), which takes ${ \sim } 4$ hours (A6000).
169
+
170
+ # 7 Conclusions
171
+
172
+ Our restriction to direct illumination shows up in scenes with global illumination. Similarly, we do not handle specular chains (geometry seen through a glass window). For this, we need to integrate multibounce path tracing, which is a clear avenue for future work, but comes with additional challenges in increased noise-levels, visibility gradients through specular chains, and drastically increased iteration times. Our renderer is intentionally biased to improve optimization times, but unbiased rendering could expect to generate better results for very high sample counts. Other limitations include lack of efficient regularization of material specular parameters and reliance on a foreground segmentation mask. Our approach is computationally intense, requiring a high-end GPU for optimization runs.
173
+
174
+ To summarize, we have shown that differentiable Monte-Carlo rendering combined with variancereduction techniques is practical and applicable to multi-view 3D object reconstruction of explicit triangular 3D models. Our physically-based renderer clearly improves material and light reconstruction over previous work. By leveraging hardware accelerated ray-tracing and differentiable image denoisers, we remain competitive to previous work in terms of optimization time.
175
+
176
+ # References
177
+
178
+ [1] Attila T. Afra. Open Image Denoise, 2022. ´ https://www.openimagedenoise.org/.
179
+ [2] Steve Bako, Thijs Vogels, Brian McWilliams, Mark Meyer, Jan Novak, Alex Harvill, Pradeep Sen, Tony ´ DeRose, and Fabrice Rousselle. Kernel-Predicting Convolutional Networks for Denoising Monte Carlo Renderings. ACM Trans. Graph., 36(4):97:1–97:14, 2017.
180
+ [3] Sai Bangaru, Tzu-Mao Li, and Fredo Durand. Unbiased Warped-Area Sampling for Differentiable ´ Rendering. ACM Trans. Graph., 39(6):245:1–245:18, 2020.
181
+ [4] Jonathan T. Barron, Ben Mildenhall, Matthew Tancik, Peter Hedman, Ricardo Martin-Brualla, and Pratul P. Srinivasan. Mip-NeRF: A Multiscale Representation for Anti-Aliasing Neural Radiance Fields. In International Conference on Computer Vision (ICCV), pages 5855–5864, 2021.
182
+ [5] Sai Bi, Zexiang Xu, Pratul Srinivasan, Ben Mildenhall, Kalyan Sunkavalli, Milos Ha ˇ san, Yannick Hold- ˇ Geoffroy, David Kriegman, and Ravi Ramamoorthi. Neural Reflectance Fields for Appearance Acquisition. arXiv:2008.03824, 2020.
183
+ [6] Mark Boss, Raphael Braun, Varun Jampani, Jonathan T. Barron, Ce Liu, and Hendrik P.A. Lensch. NeRD: Neural Reflectance Decomposition from Image Collections. In International Conference on Computer Vision (ICCV), pages 5855–5864, 2021.
184
+ [7] Mark Boss, Varun Jampani, Raphael Braun, Ce Liu, Jonathan T. Barron, and Hendrik P.A. Lensch. NeuralPIL: Neural Pre-Integrated Lighting for Reflectance Decomposition. In Advances in Neural Information Processing Systems (NeurIPS), pages 10691–10704, 2021.
185
+ [8] Mark Boss, Varun Jampani, Kihwan Kim, Hendrik Lensch, and Jan Kautz. Two-shot spatially-varying BRDF and shape estimation. In Proc. of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 3982–3991, 2020.
186
+ [9] Brent Burley. Physically Based Shading at Disney. In SIGGRAPH Courses: Practical Physically Based Shading in Film and Game Production, 2012.
187
+ [10] Chakravarty R. Alla Chaitanya, Anton S. Kaplanyan, Christoph Schied, Marco Salvi, Aaron Lefohn, Derek Nowrouzezahrai, and Timo Aila. Interactive Reconstruction of Monte Carlo Image Sequences Using a Recurrent Denoising Autoencoder. ACM Trans. Graph., 36(4):98:1–98:12, 2017.
188
+ [11] Wenzheng Chen, Jun Gao, Huan Ling, Edward Smith, Jaakko Lehtinen, Alec Jacobson, and Sanja Fidler. Learning to predict 3d objects with an interpolation-based differentiable renderer. In Advances In Neural Information Processing Systems (NeurIPS), 2019.
189
+ [12] Wenzheng Chen, Joey Litalien, Jun Gao, Zian Wang, Clement Fuji Tsang, Sameh Khalis, Or Litany, and Sanja Fidler. DIB- $\mathbf { R } { + } { + }$ : Learning to Predict Lighting and Material with a Hybrid Differentiable Renderer. In Advances in Neural Information Processing Systems (NeurIPS), pages 22834–22848, 2021.
190
+ [13] Duan Gao, Xiao Li, Yue Dong, Pieter Peers, Kun Xu, and Xin Tong. Deep Inverse Rendering for HighResolution SVBRDF Estimation from an Arbitrary Number of Images. ACM Trans. Graph., 38(4):134:1– 134:15, 2019.
191
+ [14] Jun Gao, Wenzheng Chen, Tommy Xiang, Clement Fuji Tsang, Alec Jacobson, Morgan McGuire, and Sanja Fidler. Learning Deformable Tetrahedral Meshes for 3D Reconstruction. In Advances in Neural Information Processing Systems (NeurIPS), pages 9936–9947, 2020.
192
+ [15] Stephan J Garbin, Marek Kowalski, Matthew Johnson, Jamie Shotton, and Julien Valentin. FastNeRF: High-Fidelity Neural Rendering at 200FPS. arXiv:2103.10380, 2021.
193
+ [16] Andrew Gardner, Chris Tchou, Tim Hawkins, and Paul Debevec. Linear Light Source Reflectometry. ACM Trans. Graph., 22(3):749–758, 2003.
194
+ [17] Abhijeet Ghosh, Tongbo Chen, Pieter Peers, Cyrus A. Wilson, and Paul Debevec. Estimating Specular Roughness and Anisotropy from Second Order Spherical Gradient Illumination. Computer Graphics Forum, 28(4):1161–1170, 2009.
195
+ [18] D. Guarnera, G. C. Guarnera, A. Ghosh, C. Denk, and M. Glencross. BRDF Representation and Acquisition. In Proceedings of the 37th Annual Conference of the European Association for Computer Graphics: State of the Art Reports, pages 625–650, 2016.
196
+ [19] Yu Guo, Cameron Smith, Milos Ha ˇ san, Kalyan Sunkavalli, and Shuang Zhao. MaterialGAN: Reflectance ˇ Capture Using a Generative SVBRDF Model. ACM Trans. Graph., 39(6):254:1–254:13, 2020.
197
+ [20] M. Haindl and J. Filip. Visual Texture. Springer-Verlag, 2013.
198
+ [21] Jon Hasselgren, Jacob Munkberg, Jaakko Lehtinen, Miika Aittala, and Samuli Laine. Appearance-driven automatic 3d model simplification. In Eurographics Symposium on Rendering, 2021.
199
+ [22] Jon Hasselgren, Jacob Munkberg, Anjul Patney, Marco Salvi, and Aaron Lefohn. Neural Temporal Adaptive Sampling and Denoising. Computer Graphics Forum, 39(2):147–155, 2020.
200
+ [23] Eric Heitz. Sampling the GGX Distribution of Visible Normals. Journal of Computer Graphics Techniques (JCGT), 7(4):1–13, 2018.
201
+ [24] James T. Kajiya. The rendering equation. In Proceedings of the 13th annual conference on Computer graphics and interactive techniques - SIGGRAPH’86. ACM Press, 1986.
202
+ [25] Brian Karis. Real shading in unreal engine 4. SIGGRAPH 2013 Course: Physically Based Shading in Theory and Practice, 2013.
203
+ [26] Diederik P. Kingma and Jimmy Ba. Adam: A Method for Stochastic Optimization. In Proceedings of the 3rd International Conference for Learning Representations, 2015.
204
+ [27] Arno Knapitsch, Jaesik Park, Qian-Yi Zhou, and Vladlen Koltun. Tanks and temples: Benchmarking large-scale scene reconstruction. ACM Trans. Graph., 36(4):78:1–78:13, 2017.
205
+ [28] Samuli Laine, Janne Hellsten, Tero Karras, Yeongho Seol, Jaakko Lehtinen, and Timo Aila. Modular primitives for high-performance differentiable rendering. ACM Trans. Graph., 39(6):194:1–194:14, 2020.
206
+ [29] Gerald Lasser. LDraw.org, 2022. https://www.ldraw.org/.
207
+ [30] Hendrik P.A. Lensch, Jochen Lang, Asla M. Sa, and Hans-Peter Seidel. Planned sampling of spatially varying BRDFs. Computer Graphics Forum, 22(3):473–482, 2003.
208
+ [31] Tzu-Mao Li, Miika Aittala, Fredo Durand, and Jaakko Lehtinen. Differentiable Monte Carlo Ray Tracing ´ through Edge Sampling. ACM Trans. Graph., 37(6):222:1–222:11, 2018.
209
+ [32] Zhengqin Li, Mohammad Shafiei, Ravi Ramamoorthi, Kalyan Sunkavalli, and Manmohan Chandraker. Inverse rendering for complex indoor scenes: Shape, spatially-varying lighting and svbrdf from a single image. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2475–2484, 2020.
210
+
211
+ to Reconstruct Shape and Spatially-Varying Reflectance from a Single Image. ACM Trans. Graph., 37(6):269:1–269:11, 2018. [34] Yiyi Liao, Simon Donne, and Andreas Geiger. Deep Marching Cubes: Learning Explicit Surface Rep- ´ resentations. In Conference on Computer Vision and Pattern Recognition (CVPR), pages 2916–2925, 2018. [35] Shichen Liu, Tianye Li, Weikai Chen, and Hao Li. Soft Rasterizer: A Differentiable Renderer for Image-based 3D Reasoning. In International Conference on Computer Vision (ICCV), pages 7707–7716, 2019. [36] Guillaume Loubet, Nicolas Holzschuch, and Wenzel Jakob. Reparameterizing Discontinuous Integrands for Differentiable Rendering. ACM Trans. Graph., 38(6):228:1–228:14, 2019. [37] Fujun Luan, Shuang Zhao, Kavita Bala, and Zhao Dong. Unified Shape and SVBRDF Recovery using Differentiable Monte Carlo Rendering. arXiv:2103.15208, 2021. [38] Ricardo Martin-Brualla, Noha Radwan, Mehdi SM Sajjadi, Jonathan T Barron, Alexey Dosovitskiy, and Daniel Duckworth. Nerf in the wild: Neural radiance fields for unconstrained photo collections. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 7210–7219, 2021. [39] Ben Mildenhall, Pratul P. Srinivasan, Matthew Tancik, Jonathan T. Barron, Ravi Ramamoorthi, and Ren Ng. NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis. In ECCV, 2020. [40] Thomas Muller, Alex Evans, Christoph Schied, and Alexander Keller. Instant neural graphics primitives ¨ with a multiresolution hash encoding. ACM Trans. Graph., 41(4):102:1–102:15, 2022. [41] Jacob Munkberg, Jon Hasselgren, Tianchang Shen, Jun Gao, Wenzheng Chen, Alex Evans, Thomas Mueller, and Sanja Fidler. Extracting Triangular 3D Models, Materials, and Lighting From Images. In 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 8270–8280, 2022. [42] Michael Niemeyer and Andreas Geiger. Giraffe: Representing scenes as compositional generative neural feature fields. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11453–11464, 2021. [43] Michael Niemeyer, Lars Mescheder, Michael Oechsle, and Andreas Geiger. Differentiable volumetric rendering: Learning implicit 3d representations without 3d supervision. In Proceedings IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2020. [44] Merlin Nimier-David, Zhao Dong, Wenzel Jakob, and Anton Kaplanyan. Material and Lighting Reconstruction for Complex Indoor Scenes with Texture-space Differentiable Rendering. In Eurographics Symposium on Rendering – DL-only Track, 2021. [45] Merlin Nimier-David, Sebastien Speierer, Beno ´ ˆıt Ruiz, and Wenzel Jakob. Radiative Backpropagation: An Adjoint Method for Lightning-Fast Differentiable Rendering. ACM Trans. Graph., 39(4):146:1–146:15, 2020. [46] Merlin Nimier-David, Delio Vicini, Tizian Zeltner, and Wenzel Jakob. Mitsuba 2: A retargetable forward and inverse renderer. ACM Trans. Graph., 38(6):203:1–203:17, 2019. [47] Michael Oechsle, Songyou Peng, and Andreas Geiger. UNISURF: Unifying Neural Implicit Surfaces and Radiance Fields for Multi-View Reconstruction. In International Conference on Computer Vision (ICCV), pages 5589–5599, 2021. [48] Matt Pharr and Greg Humphreys. Physically Based Rendering, Second Edition: From Theory To Implementation. Morgan Kaufmann Publishers Inc., 2nd edition, 2010. [49] Albert Pumarola, Enric Corona, Gerard Pons-Moll, and Francesc Moreno-Noguer. D-nerf: Neural radiance fields for dynamic scenes. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10318–10327, 2021. [50] Christian Reiser, Songyou Peng, Yiyi Liao, and Andreas Geiger. KiloNeRF: Speeding up Neural Radiance Fields with Thousands of Tiny MLPs. arXiv:2103.13744, 2021. [51] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation. In Medical Image Computing and Computer-Assisted Intervention – MICCAI 2015, pages 234–241, 2015. [52] Christoph Schied, Anton Kaplanyan, Chris Wyman, Anjul Patney, Chakravarty R. Alla Chaitanya, John Burgess, Shiqiu Liu, Carsten Dachsbacher, Aaron Lefohn, and Marco Salvi. Spatiotemporal Varianceguided Filtering: Real-time Reconstruction for Path-traced Global Illumination. In Proceedings of High Performance Graphics, pages 2:1–2:12, 2017. [53] Carolin Schmitt, Simon Donne, Gernot Riegler, Vladlen Koltun, and Andreas Geiger. On Joint Estimation of Pose, Geometry and svBRDF from a Handheld Scanner. In Proc. of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2020. [54] Tianchang Shen, Jun Gao, Kangxue Yin, Ming-Yu Liu, and Sanja Fidler. Deep Marching Tetrahedra: a Hybrid Representation for High-Resolution 3D Shape Synthesis. In Advances in Neural Information Processing Systems (NeurIPS), pages 6087–6101, 2021. [55] Smithsonian. Smithsonian 3D Digitization, 2018. https://3d.si.edu/.
212
+
213
+ [56] Michael Stokes, Matthew Anderson, Srinivasan Chandrasekar, and Ricardo Motta. A Standard Default Color Space for the Internet - sRGB, 1996.
214
+ [57] Kushagra Tiwary, Tzofi Klinghoffer, and Ramesh Raskar. Towards learning neural representations from shadows. arXiv:2203.15946, 2022.
215
+ [58] Eric Veach and Leonidas J. Guibas. Optimally Combining Sampling Techniques for Monte Carlo Rendering. In Proceedings of the 22nd Annual Conference on Computer Graphics and Interactive Techniques, page 419–428, 1995.
216
+ [59] Delio Vicini, Sebastien Speierer, and Wenzel Jakob. Path replay backpropagation: differentiating light ´ paths using constant memory and linear time. ACM Trans. Graph., 40(4):108:1–108:14, 2021.
217
+ [60] Delio Vicini, Sebastien Speierer, and Wenzel Jakob. Differentiable Signed Distance Function Rendering. ´ ACM Trans. Graph., 41(4):125:1–125:18, 2022.
218
+ [61] Bruce Walter, Stephen R. Marschner, Hongsong Li, and Kenneth E. Torrance. Microfacet Models for Refraction through Rough Surfaces. In Proceedings of the 18th Eurographics Conference on Rendering Techniques, page 195–206, 2007.
219
+ [62] Peng Wang, Lingjie Liu, Yuan Liu, Christian Theobalt, Taku Komura, and Wenping Wang. Neus: Learning neural implicit surfaces by volume rendering for multi-view reconstruction. In Advances in Neural Information Processing Systems (NeurIPS), pages 27171–27183, 2021.
220
+ [63] Zian Wang, Jonah Philion, Sanja Fidler, and Jan Kautz. Learning indoor inverse rendering with 3d spatially-varying lighting. In Proceedings of International Conference on Computer Vision (ICCV), 2021.
221
+ [64] Zirui Wang, Shangzhe Wu, Weidi Xie, Min Chen, and Victor Adrian Prisacariu. NeRF−−: Neural radiance fields without known camera parameters. arXiv:2102.07064, 2021.
222
+ [65] Michael Weinmann and Reinhard Klein. Advances in Geometry and Reflectance Acquisition (Course Notes). In SIGGRAPH Asia 2015 Courses, 2015.
223
+ [66] Suttisak Wizadwongsa, Pakkapon Phongthawee, Jiraphon Yenphraphai, and Supasorn Suwajanakorn. NeX: Real-time View Synthesis with Neural Basis Expansion. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 8534–8543, 2021.
224
+ [67] Yao Yao, Zixin Luo, Shiwei Li, Jingyang Zhang, Yufan Ren, Lei Zhou, Tian Fang, and Long Quan. BlendedMVS: A Large-scale Dataset for Generalized Multi-view Stereo Networks. Computer Vision and Pattern Recognition (CVPR), 2020.
225
+ [68] Lior Yariv, Yoni Kasten, Dror Moran, Meirav Galun, Matan Atzmon, Basri Ronen, and Yaron Lipman. Multiview neural surface reconstruction by disentangling geometry and appearance. Advances in Neural Information Processing Systems, 33, 2020.
226
+ [69] Alex Yu, Ruilong Li, Matthew Tancik, Hao Li, Ren Ng, and Angjoo Kanazawa. PlenOctrees for Real-time Rendering of Neural Radiance Fields. In International Conference on Computer Vision (ICCV), pages 5752–5761, 2021.
227
+ [70] Greg Zaal. polyhaven, 2021. https://polyhaven.com/hdris.
228
+ [71] Tizian Zeltner, Sebastien Speierer, Iliyan Georgiev, and Wenzel Jakob. Monte Carlo Estimators for ´ Differential Light Transport. ACM Trans. Graph., 40(4):78:1–78:16, 2021.
229
+ [72] Cheng Zhang, Bailey Miller, Kai Yan, Ioannis Gkioulekas, and Shuang Zhao. Path-Space Differentiable Rendering. ACM Trans. Graph., 39(4):143:1–143:19, 2020.
230
+ [73] Kai Zhang, Fujun Luan, Qianqian Wang, Kavita Bala, and Noah Snavely. PhySG: Inverse Rendering with Spherical Gaussians for Physics-based Material Editing and Relighting. In The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
231
+ [74] Kai Zhang, Gernot Riegler, Noah Snavely, and Vladlen Koltun. Nerf++: Analyzing and improving neural radiance fields. arXiv:2010.07492, 2020.
232
+ [75] Xiuming Zhang, Pratul P. Srinivasan, Boyang Deng, Paul Debevec, William T. Freeman, and Jonathan T. Barron. NeRFactor: Neural Factorization of Shape and Reflectance under an Unknown Illumination. ACM Trans. Graph., 40(6):237:1–237:18, 2021.
233
+ [76] Yuxuan Zhang, Wenzheng Chen, Huan Ling, Jun Gao, Yinan Zhang, Antonio Torralba, and Sanja Fidler. Image GANs meet Differentiable Rendering for Inverse Graphics and Interpretable 3D Neural Rendering. In International Conference on Learning Representations, 2021.
234
+ [77] Yuanqing Zhang, Jiaming Sun, Xingyi He, Huan Fu, Rongfei Jia, and Xiaowei Zhou. Modeling Indirect Illumination for Inverse Rendering. arXiv:2204.06837, 2022.
235
+ [78] Matthias Zwicker, Wojciech Jarosz, Jaakko Lehtinen, Bochang Moon, Ravi Ramamoorthi, Fabrice Rousselle, Pradeep Sen, Cyril Soler, and Sung-Eui Yoon. Recent Advances in Adaptive Sampling and Reconstruction for Monte Carlo Rendering. Computer Graphics Forum, 34(2):667–681, 2015.
236
+
237
+ # Checklist
238
+
239
+ 1. For all authors...
240
+
241
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
242
+
243
+ (b) Did you describe the limitations of your work? [Yes] See Section 7
244
+ (c) Did you discuss any potential negative societal impacts of your work? [No] There is no negative societal impacts particular to this work. While it shares the problem of deepfakes with all other multi-view 3D object reconstruction methods, we do not think it warrants a discussion in particular to this paper.
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]
254
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] While it is impossible to detail everything in a large system, we describe the significant updates from NVDIFFREC [41]. Details about regularization and optimization scheduling is included in supplemental work due to limited space.
255
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] While interesting, the optimization time of 3D reconstruction algorithms (our and previous work) is too significant for such detailed analysis.
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] Optimization performance / compute resources are described in Section 6.
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]
261
+ (b) Did you mention the license of the assets? [Yes] The synthetic NeRFactor dataset does not specify a license. It is tightly based on the synthetic NeRF dataset (CC-BY-3.0), and based on the No additional restrictions clause we assume CC-BY-3.0 for NeRFactor as well.
262
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
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/dev/WcZUevpX3H3/WcZUevpX3H3.md ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PERSONALIZED NEURAL ARCHITECTURE SEARCH FOR FEDERATED LEARNING
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Federated Learning (FL) is a recently proposed learning paradigm for decentralized devices to collaboratively train a predictive model without exchanging private data. Existing FL frameworks, however, assume a one-size-fit-all model architecture to be collectively trained by local devices, which is determined prior to observing their data. Even with good engineering acumen, this often falls apart when local tasks are different and require diverging choices of architecture modelling to learn effectively. This motivates us to develop a novel personalized neural architecture search (NAS) algorithm for FL. Our algorithm, FEDPNAS, learns a base architecture that can be structurally personalized for quick adaptation to each local task. We empirically show that FEDPNAS significantly outperforms other NAS and FL benchmarks on several real-world datasets.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Federated Learning (FL) (McMahan et al., 2017) is a variant of distributed learning where the objective function can be decomposed into a linear combination of $M$ local objective functions. Each function depends on its private data hosted by a local client and a set of shared parameters $w$ ,
12
+
13
+ $$
14
+ \underset { w } { \mathrm { a r g m i n } } \ : \mathcal { L } ( w ) \equiv \underset { w } { \mathrm { a r g m i n } } \ : \sum _ { i = 1 } ^ { M } \mathcal { L } _ { i } ( w \mid \mathcal { D } _ { i } ) ,
15
+ $$
16
+
17
+ where $\mathcal { D } _ { i }$ denotes the $i ^ { \mathrm { t h } }$ local training dataset comprising input-output tuples $( x , y )$ . In a standard supervised learning task where the predictive model is modeled as a fixed deep neural network $\psi$ with learnable weights $w$ , let $\ell ( x , y )$ denote the loss incurred by predicting $\psi ( x ; w )$ when the true output is $y$ . The expected loss of $\psi ( x ; w )$ on $\mathcal { D } _ { i }$ is given as
18
+
19
+ $$
20
+ \begin{array} { r l r } { \mathcal { L } _ { i } ( w \mid \mathcal { D } _ { i } ) } & { = } & { \mathbb { E } _ { ( x , y ) \sim \mathcal { D } _ { i } } \Big [ \ell ( x , y ; \psi ) \Big ] ~ . } \end{array}
21
+ $$
22
+
23
+ This is not applicable to scenarios where local models are expected to solve different tasks which are similar in broad sense yet diverge in finer details. For example, consider the task of recognizing the outcome of a coin flip given images collected by two clients: one capture the coin from above, the other from below. This setting implies that when the same input image is provided by both clients, the correct classifications must be the opposite of one another. However, since existing FL methods converge on a single model architecture and weight, there can only be one predictive outcome which cannot satisfy both tasks.
24
+
25
+ To relax this constraint, the recent work of Fallah et al. (2020) extends FL by incorporating ideas from meta learning (Finn et al., 2017) which results in a new framework of personalized FL. The new framework can accommodate for such task heterogeneity but still requires all client models to agree on a single architecture beforehand, which is sub-optimal. To address this shortcoming, one naive idea is to adopt existing ideas in Neural Architecture Search (NAS) via Reinforcement Learning (Zoph and Le, 2016; Pham et al., 2018) which act as an outer loop to the existing FL routine.
26
+
27
+ However, this simple approach does not allow client models to adapt to local tasks on an architecture level and is often not preferred due to the cost of repeated FL training. This paper proposes a novel personalized NAS algorithm for federated learning, which generalizes ideas in respective areas of NAS (Zoph and Le, 2016; Pham et al., 2018) originally developed for single-task scenarios, and
28
+
29
+ FL (Fallah et al., 2020) under a unified len of federated personalized neural architecture search (FEDPNAS).
30
+
31
+ In particular, to customize the model architecture for each task in the FL workflow, FEDPNAS first represents the model architecture for each task as a sub-network sampled from a large, overparameterized network. The sampling distribution is (collaboratively) learned along with the parameters of the sampled network via a generalization of the recently proposed Discrete Stochastic NAS (DSNAS) method (Hu et al., 2020). Unlike DSNAS, which lacks the ability to customize architecture for individual tasks, our generalized FEDPNAS incorporates model personalization on an architecture level. Our contributions include:
32
+
33
+ 1. A novel architecture that factorizes into a base component (shared across tasks) and a personalizable component, which respectively capture the task-agnostic and task-specific information (Section 3.2).
34
+
35
+ 2. A context-aware sampling distribution conditioned on specific task instance, which captures taskspecific information and naturally incorporates personalization into architecture search (Section 3.4).
36
+
37
+ 3. An FL algorithm that optimizes for a common architecture, followed by a personalization phase where each client subsequently adapts only the personalized component to fit its own task via finetuning with local data (Section 3.1). To ensure that the common architecture distribution converges at a vantage point that is relevant and beneficial to all clients, we generalize the vanilla FL objective in Eq. equation 1 such that local gradient steps directly optimize for expected improvement resulting from future fine-tuning (Section 3.3).
38
+
39
+ 4. A theoretical perspective on our FL objective (Section 3.5 and thorough empirical analysis showing significant performance gain compared to state-of-the-art FL and NAS methods (Section 4).
40
+
41
+ # 2 RELATED WORKS
42
+
43
+ # 2.1 TWO-STAGE NEURAL ARCHITECTURE SEARCH
44
+
45
+ Most existing NAS frameworks separately optimize for the optimal architecture and its parameters in two stages: searching and evaluation. The former stage usually employs evolutionary-based strategies (Floreano et al., 2008; Real et al., 2019), Bayesian optimization surrogates (Bergstra et al., 2013; Hu et al., 2018) or Reinforcement Learning controllers (Baker et al., 2016; Zoph and Le, 2016; Pham et al., 2018) to propose candidate architectures based on random mutations and/or observed experience; while the latter optimizes the parameters of these architectures given task data and provide feedback to improve the search agent. Naturally, an extension of such methods to the FL setting is through distributing the evaluation workload over many clients, which does not require exposing private data. In practice, however, two-stage federated NAS frameworks are generally not suitable for the personalized FL setting for two reasons: (a) the clients often lack the computational capacity to repeatedly optimize the parameters for many candidate architectures; and (b) the clients have to converge on a single architecture proposed by the central search agent.
46
+
47
+ # 2.2 DISCRETE STOCHASTIC NEURAL ARCHITECTURE SEARCH
48
+
49
+ Discrete stochastic neural architecture search (DSNAS) (Hu et al., 2020) addresses the computational issue of two-stage NAS by jointly optimizing the optimal architecture and its weight in an end-to-end fashion, which allows users to continually train a single network on demand over time as opposed to performing full parameter optimization for every candidate until a good architecture is discovered.
50
+
51
+ The main idea of DSNAS is to combine weight training for an over-parameterized master architecture with discrete computational path sampling. DSNAS parameterizes the master architecture as a stack of modular cells: $\psi ( x ) \bar { = } \psi _ { C } \circ \bar { \psi } _ { C - 1 } \cdot \cdot \cdot \circ \psi _ { 1 } ( \bar { x } ) ^ { 1 }$ , where $x$ is an arbitrary input, $C$ is the number of cells, $\psi _ { t }$ denotes the $t ^ { \mathrm { t h } }$ cell in the stack, and $\circ$ denotes the compositional operator. The inner computation of $\psi _ { t }$ is in turn characterized by a directed acyclic graph (DAG) with $V$ nodes $\{ v _ { i } \} _ { i = 1 } ^ { | V | }$ , where each node represents some intermediate feature map. For each directed edge $( v _ { i } , v _ { j } )$
52
+
53
+ ![](images/718e70d9fa976c50deca97062d523901e363ff96a3953e515fd8e35fb90486f0.jpg)
54
+ Figure 1: Our proposed method FEDPNAS consists of (1) a federated learning phase, where each client updates both the base component $( \psi ^ { b } )$ and the personalized component $( \psi _ { p } )$ the architecture using the FEDPNAS update (Section 3.3) and sends its parameters to the central server for aggregation; and (2) a fine-tune phase, where each client updates only the personalized component of the architecture using standard gradient update.
55
+
56
+ there is an associated list of $D$ possible network operations $\mathbf O _ { i j } = \left[ o _ { i j } ^ { 1 } , o _ { i j } ^ { 2 } \ldots o _ { i j } ^ { D } \right] ^ { 2 }$ where each operainput on w $o _ { i j } ^ { k }$ rms ). W $v _ { i }$ to rec $v _ { j }$ . Here, ively de $v _ { 1 }$ corresponds to the oe intermediate nodes $\psi _ { t - 1 }$ (orhere $x$ $t = 1$ $\begin{array} { r } { v _ { j } = \sum _ { i = 1 } ^ { j - 1 } \mathbf { Z } _ { i j } ^ { \top } \mathbf { O } _ { i j } ( v _ { i } ) } \end{array}$ distribution learnable. E $\mathbf { O } _ { i j } ( v _ { i } ) \triangleq \big [ o _ { i j } ^ { 1 } ( v _ { i } ) , o _ { i j } ^ { 2 } ( v _ { i } ) \dots o _ { i j } ^ { D } ( v _ { i } ) \big ]$ $p ( \mathbf { Z } \mid \mathbf { \pi } \mathbf { \Pi } \mathbf { \Pi } )$ where the event probabi learning the distribution and $\mathbf { Z } _ { i j }$ is a one-hot vector sampled from the categorical $\mathbf { H } = \{ \pi _ { 1 } , \pi _ { 2 } , . . . , \pi _ { D } \mid \sum _ { i = 1 } ^ { D } \pi _ { i } = 1 \}$ ares or $p ( \mathbf { Z } )$
57
+ sub-graphs of the original DAG that correspond to high-performing, compact architecture from the over-parameterized master network. Sampling discrete random variables from $p ( \mathbf { Z } )$ , however, does not result in a gradient amenable to back-propagation. To sidestep this issue, DSNAS adopts the straight-through Gumbel-softmax trick (Jang et al., 2016), which re-parameterizes the $k ^ { \mathrm { t h } }$ index of the one-hot variable as $\mathbf { Z } _ { i j } [ k ] = \mathbb { I } \left( k \triangleq { \arg \operatorname* { m a x } _ { t } } \Big [ g _ { t } + \log \pi _ { t } \Big ] \right)$ , where $g _ { t } \sim \mathrm { G u m b e l } ( 0 , 1 )$ . While this forward computation does not have a gradient by itself, we can estimate the gradient through a proxy during the backward pass:
58
+
59
+ $$
60
+ \nabla { \mathbf Z } _ { i j } [ k ] ~ \simeq ~ \nabla \tilde { \mathbf Z } _ { i j } [ k ] ~ \triangleq ~ \nabla \left( \frac { \exp \big ( \big ( g _ { k } + \log \pi _ { k } \big ) / \tau \big ) } { \sum _ { t = 1 } ^ { D } \exp \big ( \big ( g _ { t } + \log \pi _ { t } \big ) / \tau \big ) } \right)
61
+ $$
62
+
63
+ which is unbiased when converged as the temperature $\tau$ is steadily annealed to 0 (Jang et al., 2016). This formulation, however, is not easily extended to the FL setting, especially when local tasks are not homogeneous. The key challenges in doing so are described in Section 3, together with our proposed approaches.
64
+
65
+ # 3 PERSONALIZED NAS FOR FEDERATED LEARNING
66
+
67
+ # 3.1 FEDERATED LEARNING OF DSNAS
68
+
69
+ Let W denote the concatenated weights of all network operations in the network architecture. The set up above of DSNAS (Jang et al., 2016) is then naïvely extendable to a $\mathrm { F L }$ setting via the following objective formulation:
70
+
71
+ $$
72
+ \underset { \mathbf { W } , \mathbf { \Pi } } { \arg \operatorname* { m i n } } \mathcal { L } ( \mathbf { W } , \mathbf { \Pi } \mathbf { I } ) \equiv \underset { \mathbf { W } , \mathbf { \Pi } \mathbf { \Pi } } { \arg \operatorname* { m i n } } \frac { 1 } { M } \sum _ { i = 1 } ^ { M } \mathcal { L } _ { i } ( \mathbf { W } , \mathbf { \Pi } \mathbf { I } \mid \mathcal { D } _ { i } ) .
73
+ $$
74
+
75
+ McMahan et al. (2017) optimizes this objective by alternating between (a) central agent broadcasting aggregated weights to local clients and (b) local clients sending gradient descent updated weights (given local data) to the central agent for aggregation. This, however, implies that after the last central aggregation step, all clients will follow the same architecture distribution induced by the final broadcasted copy of W and Π. As previously argued, this is not optimal in a heterogenous task setting which requires task-specific adaptation for local clients to achieve good performance.
76
+
77
+ Furthermore, having the same sampling distribution $p ( \mathbf { Z } )$ regardless of context (i.e., feature maps received as cell input) limits the architecture discovery to those that perform reasonably on average over the entire dataset. However, we remark that restricting the architecture to be the same for every input samples is unnecessary and undermines the expressiveness of an over-parameterized search space. On the other hand, letting the architecture be determined on a per-sample basis makes better use of the search space and potentially improves the predictive performance.
78
+
79
+ The focus of this work is therefore to incorporate both task-wise and context-wise personalization to federated neural architecture search in multitask scenarios, which is achieved through our proposed algorithm FEDPNAS. In general, FEDPNAS functions similarly to the vanilla FEDDSNAS algorithm described above, with an addition of a fine-tuning phase at each local client after the FL phase to adapt the aggregated common model for local task data, as shown in Fig. 1. To make this work, however, we need to address the following key challenges:
80
+
81
+ C1. First, as previously argued in Section 1, tasks across federated clients tend to share similarities in broad sense, and diverge in finer details. A good federated personalization search space, therefore, need to capture this fundamental observation through design and appropriate resource distribution. We address this challenge in Section 3.2.
82
+
83
+ C2. Second, a major advantage of having an over-parameterized architecture search space is the flexibility of having specific computation paths for different samples, which is not exploited by DSNAS as reflected in its choice of context-independent sampling distribution $p ( \mathbf { Z } )$ . To address this, Section 3.4 proposes a novel parameterization of $p ( \mathbf { Z } )$ to incorporate context information into operator sampling.
84
+
85
+ C3. Last, while the fine-tuning phase is designed to incorporate task-personalization, there is no guarantee that the common model can be quickly adapted to client tasks (Fallah et al., 2020). The common model may end up in a localization that favors one client over another, which makes it difficult for the latter to fine-tune. To address this concern, Section 3.3 proposes a new personalized federated NAS objective inspired by Finn et al. (2017) to optimize the common model in anticipation of further fine-tuning by the client models.
86
+
87
+ # 3.2 PERSONALIZABLE ARCHITECTURE SEARCH SPACE
88
+
89
+ Similar to DSNAS (Hu et al., 2020), our framework adopts a cell-based representation (Section 2.2) to trade-off search space expressiveness for efficiency, which is extremely suitable for FL where clients tend to have low-end computational capacity. Unlike the original design which assumes similar role for every cell in the architecture stack (i.e., as reflected by their choice of fully factorizable path sampling distribution $p ( \mathbf { Z } ) ,$ , we instead split our cell stack into two components with separate metaroles catering to the ftask: (a) a base stack $\psi _ { \mathrm { b } } = \{ \dot { \psi } _ { 1 } ^ { b } , \psi _ { 2 } ^ { b } \cdot \hdots \psi _ { C _ { b } } ^ { b } \}$ which aims to capture the broad commonalities of data samples across client tasks; and (b) personalized stack $\psi _ { \mathrm { { p } } } ~ = ~ \{ \psi _ { 1 } ^ { p } , \psi _ { 2 } ^ { p } \ldots \psi _ { C _ { p } } ^ { p } \}$ which will be fine-tuned with local data to capture task-specific details.
90
+
91
+ ![](images/3116f74b935bbe36c806df305e40cbbc96cf386169136d98b85b7351797e33ce.jpg)
92
+ Figure 2: Feature mapping down the component stacks of our architecture space. Every base cell takes as inputs (a) the outputs from its immediate predecessor and (b) the one before it through a skip-ahead connection. On the other hand, every personalization cell takes as input only the output from the previous cell.
93
+
94
+ We explain the main difference between these components to account for different level of expressiveness requirements below:
95
+
96
+ Base stack. Every cell $\psi _ { t } ^ { b }$ in the base stack takes as inputs the outputs of its previous two cells $\psi _ { t - 1 } ^ { b }$ and $\psi _ { t - 2 } ^ { b }$ (replaced with raw input $x$ when necessary for $t \leq 2$ ). The output of the skip-ahead cell $\psi _ { t - 2 } ^ { b }$ is additionally passed through a $1 \times 1$ convolution layer as a cost-effective way to control the number of channels. Additionally, the operators available to the base cell include large convolution layers with size $5 \times 5$ and $7 \times 7$ . To compensate for the growing number of channels, we periodically employ a reduction convolution (with stride larger than 1) similar to DSNAS (Hu et al., 2020) to reduce the feature dimension down the stack.
97
+
98
+ Personalized stack. As opposed to the design of the base cells above, every cell $\psi _ { t } ^ { p }$ in the personalized stack has minimal expressiveness. That is, $\psi _ { t } ^ { p }$ excludes large operators and only takes as input the output of its immediate predecessor $\psi _ { t - 1 } ^ { p }$ (or $\dot { \psi } _ { C _ { b } } ^ { b }$ when $t = 1$ ). There are two reasons for this choice. First, as the fine-tuning phase has access to fewer data samples than the federated phase, having a more compact fine-tuning space helps to improve the rate of convergence. Second, as we will discuss in Section 3.4 below, our personalized FL objective requires the Hessian of the personalized parameters, which is computationally expensive. As such, we only restrict the personalization to happen on the more compact personalized stack.
99
+
100
+ # 3.3 PERSONALIZED FEDERATED LEARNING OBJECTIVE
101
+
102
+ Unlike FEDAVERAGING (McMahan et al., 2017), which assumes the clients will follow the consensus base model obtained after the federated phase, FEDPNAS expects clients to further personalize the base model with local task data. That said, while the base model is trained to work well in the expected sense over the task distribution, there is no guarantee that it is a good initial point for every client model to improve upon via fine-tuning. To address this, we adopt the concept of training in anticipation of future adaptation introduced by MAML (Finn et al., 2017). That is, during client update, instead of optimizing the loss with respect to the same consensus weight, each client will instead optimize the weight perturbed by a small gradient step in the fine-tuning direction.
103
+
104
+ # Algorithm 1 FEDPNAS - FEDERATED PHASE
105
+
106
+ 1: CENTRALAGGREGATION:
107
+ 2: $\theta _ { 0 } \gets$ INITIALIZEPARAMETER
108
+ 3: for $t = 1 , 2 \dots T _ { s }$ do
109
+ 4: for $k = 1 , 2 \dots M$ in parallel do
110
+ 5: $\theta _ { t } ^ { k } \gets \mathrm { C L I E N T U P D A T E } ( k , \theta _ { t - 1 } )$
111
+ $\begin{array} { r } { \theta _ { t } \sum _ { k = 1 } ^ { M } \frac { 1 } { M } \theta _ { t } ^ { k } } \end{array}$
112
+ 7: CLIENTUPDATE $( k , \theta )$ :
113
+ 8: for $t = 1 , 2 \dots T _ { \mathrm { c } }$ do
114
+ 9: for batch $( x , y ) \in \mathcal { D } _ { k }$ do
115
+ 10: $\mathcal { L } _ { k }$ $\mathrm { , } \nabla \mathcal { L } _ { k } \gets \mathrm { E v A L } ( x , y ; \theta _ { b } , \theta _ { p } )$
116
+ 11: $ { \widetilde { \theta } } _ { p } \gets { \mathrm { G R A D U P D A T E } } \big ( \nabla _ { { \widetilde { \theta } } _ { p } } \mathcal { L } _ { k } \big )$
117
+ 12: $\tilde { \mathcal { L } } _ { k } , \nabla \tilde { \mathcal { L } } _ { k } \gets \mathrm { E v A L } ( x , y ; \theta _ { b } , \tilde { \theta } _ { p } )$
118
+ 13: $\nabla _ { \boldsymbol { \theta } _ { p } } \tilde { \mathcal { L } } _ { k } \gets \mathrm { E Q } . \mathrm { 5 }$
119
+ 14: θb, θp ← GRADUPDATE(∇θb,θpL˜k)
120
+ 15: return $\theta$ to central server
121
+
122
+ # Algorithm 2 FEDPNAS - EVAL
123
+
124
+ 1: Input: x, y, θ
125
+ 2: SKIP, PREV ← x, x
126
+ 3: W,Π ← θ
127
+ 4: for CELL $\psi \in \psi$ do
128
+ 5: Z ← SAMPLEOPS $( x , { \mathrm { P R E V } } ; \mathbf { I I } )$
129
+ 6: ψ ← EXTRACTCHILDNET $( \mathbf { Z } , \mathbf { W } )$
130
+ 7: if $\psi \in \psi _ { b }$ then
131
+ 8: OUTPUT $ \psi ( \mathrm { P R E V } , \mathrm { S K I P } )$
132
+ 9: else if $\psi \in \psi _ { p }$ then
133
+ 10: $\mathrm { O U T P U T } \psi ( \mathrm { P R E V } )$
134
+ 11: $\mathbf { S K I P } \mathbf { P R E V }$
135
+ 12: PREV $\gets$ OUTPUT
136
+ 13: $\mathcal { L } \gets \mathrm { L o s s } ( \mathbf { O u T P U T } , y )$
137
+ 14: $\nabla { \mathcal { L } } \gets \mathbf { B A C K P R O P } ( { \mathcal { L } } )$
138
+ 15: return L, ∇L
139
+
140
+ For simplicity, let $\theta = \{ \theta _ { b } , \theta _ { p } \}$ respectively denote all trainable parameters of the base stack and the personalized stack, i.e., $\partial _ { b } = \mathbf { \bar { \{ W } } _ { b } , \mathbf { \bar { \Pi } } _ { b } \} , \boldsymbol { \hat { \theta _ { p } } } = \{ \mathbf { W } _ { p } , \mathbf { \Pi } _ { \Pi _ { p } } \}$ . The personalized $\mathrm { F L }$ objective at client $i$ is then given by $\tilde { \mathcal { L } } _ { i } ( \theta _ { b } , \theta _ { p } ) \triangleq \mathcal { L } _ { i } ( \theta _ { b } , \tilde { \theta } _ { p } )$ where $\tilde { \theta } _ { p } \triangleq \tilde { \theta } _ { p } - \eta \nabla _ { \theta _ { p } } \mathcal { L } _ { i } ( \theta _ { b } , \theta _ { p } )$ adjusts the parameters of the personalized component to account for a small fine-tuning gradient step. The adjusted local loss only depends on the respective client data and is amenable to federated learning. The local update gradient, however, involves a Hessian term whose computation is expensive to repeat over many epochs. To circumvent this problem, we use the first-order Taylor approximation to estimate the Hessian term by the outer product of Jacobian, which results in a gradient that requires exactly two forward/backward passes to compute:
141
+
142
+ $$
143
+ \begin{array} { r c l } { \nabla _ { \theta _ { p } } \tilde { \mathcal { L } } _ { i } } & { = } & { \left( \nabla _ { \theta _ { p } } \tilde { \theta } _ { p } \right) \left( \nabla _ { \tilde { \theta } _ { p } } \tilde { \mathcal { L } } _ { i } \right) } \\ & { = } & { \left( \mathbf { I } - \eta \nabla _ { \theta _ { p } } ^ { 2 } \mathcal { L } _ { i } \right) \left( \nabla _ { \tilde { \theta } _ { p } } \tilde { \mathcal { L } } _ { i } \right) } \\ & { \simeq } & { \left( \mathbf { I } - \eta \nabla _ { \theta _ { p } } ^ { \top } \mathcal { L } _ { i } \nabla _ { \theta _ { p } } \mathcal { L } _ { i } \right) \left( \nabla _ { \tilde { \theta } _ { p } } \tilde { \mathcal { L } } _ { i } \right) } \end{array}
144
+ $$
145
+
146
+ where $\mathcal { L } _ { i }$ and $\tilde { \mathcal { L } } _ { i }$ are short-hands for $\mathcal { L } _ { i } ( \theta _ { b } , \theta _ { p } )$ and $\tilde { \mathcal { L } } _ { i } ( \theta _ { b } , \theta _ { p } )$ respectively. The FL phase of our FEDPNAS framework is detailed in Alg. 1. An instance of FEDPNAS’s forward and backward pass which sequentially unrolls down the component stacks, alternating between sampling and evaluation, is in turn given in Alg. 2.
147
+
148
+ # 3.4 CONTEXT-AWARE OPERATOR SAMPLER
149
+
150
+ The choice of a fully factorizable sampling distribution $p ( \mathbf { Z } )$ in DSNAS follows that of SNAS (Xie et al., 2018), which argues that the Markov assumption for $p ( \mathbf { Z } )$ is not necessary because NAS has fully delayed rewards in a deterministic environment. However, this generally only holds for two-stage NAS (Section 2.1) and does not apply to end-to-end frameworks such as SNAS and DSNAS. We instead to take advantage of the over-parameterized architecture via factorizing the conditional $p ( \mathbf { Z } \mid x )$ , which takes into account the temporal dependency of structural decisions:
151
+
152
+ $$
153
+ \begin{array} { l l l } { { p ( { \bf Z } \mid x ) } } & { { = } } & { { \displaystyle p ( { \bf Z } _ { 1 } \mid x ) \prod _ { t = 2 } ^ { C } p ( { \bf Z } _ { t } \mid { \bf Z } _ { t - 1 } \dots { \bf Z } _ { 1 } , x ) } } \\ { { } } & { { } } & { { } } \\ { { \displaystyle } } & { { \simeq } } & { { \displaystyle p ( { \bf Z } _ { 1 } \mid x ) \prod _ { t = 2 } ^ { C } p ( { \bf Z } _ { t } \mid v _ { 1 } ^ { t } , x ) } } \\ { { } } & { { } } & { { } } \\ { { \displaystyle } } & { { = } } & { { \displaystyle p ( { \bf Z } _ { 1 } \mid x ) \prod _ { t = 2 } ^ { C } \prod _ { ( i , j ) } p ( { \bf Z } _ { i j } ^ { t } \mid v _ { 1 } ^ { t } , x ) , } } \end{array}
154
+ $$
155
+
156
+ where $\mathbf { Z } _ { t }$ , $\mathbf { Z } _ { i j } ^ { t }$ and $v _ { 1 } ^ { t }$ respectively denote all the samples, the sample at edge $( i , j )$ and the input at cell $\psi _ { t }$ . We have also assumed a single stack setting since the parameterization of $p ( \mathbf { Z } )$ does not differ between base and personalized cells.
157
+
158
+ To reduce computational complexity, instead of conditioning the samples of subsequent cells on previous $\mathbf { Z }$ samples, we approximate $p ( \mathbf { Z } _ { t } \mid \mathbf { Z } _ { t - 1 } \ldots \mathbf { Z } _ { 1 } , x ) \bumpeq p ( \mathbf { Z } _ { t } \mid v _ { 1 } ^ { t } , x )$ by the assumption that the cell contents are conditionally independent given the immediate cell input and the original input. Finally, we assume that $p ( \mathbf { Z } _ { t } \mid v _ { 1 } ^ { t } , x )$ is fully factorizable across edges in the same cell and parameterize $p ( \mathbf { Z } _ { i j } ^ { t } \mid v _ { 1 } ^ { t } , x ) = \phi ^ { ( i , j ) } ( v _ { 1 } ^ { t } , x )$ where $\phi$ is a deep classification network whose output dimension equal the number of edges in cell $\psi _ { t }$ . Samples of $\mathbf { Z } _ { i j } ^ { t }$ can then be generated using the straight-through Gumbel-softmax reparameterization similar to Jang et al. (2016).
159
+
160
+ # 3.5 THEORETICAL CONNECTION TO STANDARD GRADIENT UPDATE
161
+
162
+ Finally, we analyze the connection of our gradient update framework to the standard gradient update, and explain why it is critical in achieving a vantage point that improves average objective value without compromising any local objective. First, we note that the gradient update Eq. 5 in Section 3.3 at the $t$ -th iteration can be written as:
163
+
164
+ $$
165
+ \begin{array} { r c l } { \displaystyle \theta _ { p } ^ { t + 1 } } & { = } & { \displaystyle \theta _ { p } ^ { t } - \frac { \eta _ { 2 } } { M } \sum _ { i = 1 } ^ { M } \nabla _ { \theta _ { p } } \mathcal { L } _ { i } \big ( \theta _ { b } ^ { t } , \tilde { \theta } _ { p , i } ^ { t } \big ) + \frac { \eta _ { 1 } \eta _ { 2 } } { M } \sum _ { i = 1 } ^ { M } \alpha _ { i } \nabla _ { \theta _ { p } } \mathcal { L } _ { i } \big ( \theta _ { b } ^ { t } , \theta _ { p } ^ { t } \big ) , } \\ { \displaystyle \theta _ { b } ^ { t + 1 } } & { = } & { \displaystyle \theta _ { b } ^ { t } - \frac { \eta _ { 2 } } { M } \sum _ { i = 1 } ^ { M } \nabla _ { \theta _ { b } } \mathcal { L } _ { i } \big ( \theta _ { b } ^ { t } , \tilde { \theta } _ { p , i } ^ { t } \big ) , } \end{array}
166
+ $$
167
+
168
+ where $\tilde { \theta } _ { p , i } ^ { t }$ denotes the $i$ -th local personalized parameters; $\eta _ { 1 }$ and $\eta _ { 2 }$ are two separate learning rates and $\boldsymbol { \alpha } _ { i } \triangleq \nabla _ { \boldsymbol { \theta } _ { p } } ^ { \intercal } \mathcal { L } ( \boldsymbol { \theta } _ { b } ^ { t } , \boldsymbol { \theta } _ { p , i } ^ { t } ) \nabla _ { \boldsymbol { \theta } _ { p , i } } \mathcal { L } ( \boldsymbol { \theta } _ { b } ^ { t } , \tilde { \boldsymbol { \theta } } _ { p , i } ^ { t } )$ (See Appendix A for detailed derivation). This implies that our federated personalize update corresponds to a federated update scheme with three gradient steps: (1) $\theta _ { p }$ takes a local gradient (w.r.t. locally updated parameters) step of size $\eta _ { 1 }$ ; (2) Both $\theta _ { b }$ and $\theta _ { p }$ take a federated gradient (w.r.t. server-wide parameters averaging) step of size $\eta _ { 2 }$ ; $( 3 ) \theta _ { p }$ takes a weighted federated gradient step of size $\eta _ { 1 } \eta _ { 2 }$ , where the weight of client $i$ is given by $\alpha _ { i }$ .
169
+
170
+ Explicitly, Step 1 and 2 together comprise a special instance of FEDAVERAGING (McMahan et al., 2017), where $\theta _ { b }$ take one gradient step for every two gradient steps taken by $\theta _ { p }$ . Step 3, on the other hand, takes the information of the two gradient steps of $\theta _ { p }$ and adjust the magnitude of the local gradient step (whose direction is given by $\nabla _ { \theta _ { p } } \mathcal { L } _ { i } ( \theta _ { b } ^ { t } , \bar { \theta } _ { p } ^ { t } ) )$ accordingly to trade-off between preserving local objective value and improving average objective value. We then theorize the scenario in which such an update is beneficial and state the following assumption to lay the foundation of our analysis:
171
+
172
+ Assumption 1 For a fixed instance of $\theta _ { b }$ , let $\tilde { \theta } _ { p , i } = \theta _ { p , i } - \eta \nabla _ { \theta _ { p } } \mathcal { L } ( \theta _ { b } , \theta _ { p , i } )$ denote the personalized parameters after a local update step (i.e., step $^ { l }$ above) at client $i$ , then there exists a distribution $s$ on matrix $\mathbf { S } \in \mathbb { R } ^ { k \times | \theta _ { p } | }$ that satisfies
173
+
174
+ $$
175
+ \forall \mathbf { x } \in \mathbb { R } ^ { n } , \| \mathbf { x } \| _ { 2 } = 1 : \mathbb { E } _ { \mathbf { S } \sim { \mathcal { S } } } \left[ | \| \mathbf { S } \mathbf { x } \| _ { 2 } ^ { 2 } - 1 | ^ { \ell } \right] \ \leq \ \epsilon ^ { \ell } \cdot \delta ,
176
+ $$
177
+
178
+ $$
179
+ \operatorname* { P r } _ { \mathbf { S } \in \mathcal { S } } \left( \Big | \nabla _ { \theta _ { p } } \mathcal { L } \big ( \theta _ { b } , \tilde { \theta } _ { p , i } \big ) - \mathbf { S } ^ { \top } \mathbf { S } \Big ( \frac { 1 } { M } \sum _ { i = 1 } ^ { M } \nabla _ { \theta _ { p } } \mathcal { L } \big ( \theta _ { b } , \tilde { \theta } _ { p , i } \big ) \Big ) \Big | \leq \sqrt { \frac { 6 } { k \delta } } \right) ~ \geq ~ 1 - \delta
180
+ $$
181
+
182
+ where $k = \mathcal { O } \left( C \| \theta _ { b } - \theta _ { b } ^ { * } \| _ { 2 } ^ { - 2 } \right)$ for some constant $C > 0$ and $\theta _ { b } ^ { * }$ denotes the optimal base parameters.
183
+
184
+ The above assumption implies that, as $\theta _ { b }$ improves and better captures the broad similarity across tasks, the local personalized components will diverge to capture the differences. It then becomes less likely for the FEDAVG personalized gradient to capture all these differences simultaneously. That is, suppose there exists an affine transformation to reconstruct the local component $\nabla _ { \boldsymbol { \theta } _ { p } } \mathcal { L } _ { i } \dot { ( \theta _ { b } ^ { t } , \tilde { \theta } _ { p } ^ { t } ) }$ from the federated gradient 1M PMi=1 ∇θp Li(θtb, ˜θtp), then the rank of this affine transformation would be inversely proportionate to $\lVert \theta _ { b } - \theta _ { b } ^ { * } \rVert _ { 2 }$ .
185
+
186
+ Finally, Proposition 1 below shows that when this assumption holds and $\theta _ { b }$ converges to the optimal parameter $\theta _ { b } ^ { * }$ (i.e., the error term tends to 0), then with very high probability, the coefficient $\alpha _ { i }$ of the weighted federated gradient step (i.e., step 3 above) accurately captures the cosine similarity between the local gradient (step 1) and the federated gradient (step 2).
187
+
188
+ Proposition 1 Suppose assumption $^ { l }$ holds, then with probability at least $1 - 2 \delta$ and normalized gradients, we have:
189
+
190
+ $$
191
+ \begin{array} { r l r } { \bigg | \alpha _ { i } - \nabla _ { \theta _ { p } } ^ { \top } \mathcal { L } _ { i } ( \theta _ { b } ^ { t } , \theta _ { p } ^ { t } ) \mathbf { L } \bigg | } & { = } & { \mathcal { O } ( \| \theta _ { b } - \theta _ { b } ^ { * } \| / \delta ) } \end{array}
192
+ $$
193
+
194
+ Proof. See Appendix B
195
+
196
+ This result has strong implication with respect to the scenario with multiple heterogeneous tasks, whose local gradients contradict in directions. Per this setting, we expect a standard federated gradient update scheme to encourage parameters drifting in the general direction of the majority (i.e., captured by the federated gradient), thus worsening the performance of tasks that are in the minority. Proposition 1, however, implies that whenever the local gradient contradicts the federated gradient, $\alpha _ { i }$ will be close to the cosine similarity term, which is negative. This in turn results in a dampening effect on the federated gradient and helps to preserve the client performance on its own local task.
197
+
198
+ # 4 EXPERIMENTS
199
+
200
+ This section describes our experiments to showcase the performance of FEDPNAS compared to different NAS and FL benchmarks on various scenarios. All of our empirical studies are conducted on two image recognition datasets: (a) the CIFAR-10 dataset (Krizhevsky et al., 2009) which aims to predict image labels from 10 classes given a train/test set of 50000/10000 colour images of dimension $3 2 \times 3 2$ pixels; and (b) the MNIST dataset (LeCun et al., 2010) which aims to predict handwritten digits (i.e. 0 to 9) given a train/test set of 60000/10000 grayscale images of dimension $2 8 \times 2 8$ pixels. Our search space entails $2 ^ { 4 0 }$ possible architectures, which is detailed in Appendix D. We compare two variants of our framework, CA-FEDPNAS (with context-aware operation sampler) and FEDPNAS (without the operation sampler), against: (a) FEDAVERAGING of a fixed architecture to justify the need for NAS in FL; (b) FEDDSNAS - the federated extension of DSNAS (Section 3.1) to show the effectiveness of our proposed context-aware sampler on NAS performance; and finally (c) CA-FEDDSNAS, which extends FEDDSNAS with our context-aware sampler.
201
+
202
+ On simulate heterogenous predictive tasks. To simulate this scenario, we first distribute the data i.i.d across clients (10000/2000 and 12000/2000 training/test images per client for CIFAR-10 and MNIST datasets respectively). Then, we independently apply a different transformation to each partitioned dataset. Input images within the same train/test set is subject to the same transformation. In both our experiments, the client datasets are subjected to rotations of $- 3 0 ^ { \circ }$ , $- 1 5 ^ { \circ } , 0 ^ { \circ }$ , $1 5 ^ { \circ }$ and $3 0 ^ { \circ }$ respectively. This data generation protocol reflects a realistic and frequently seen scenario where independently collected data of the same phenomenon might contain systematic bias due to measurement errors and/or different collection protocols. Fig. 3 below shows the performance of all the methods in comparison, plotted against number of search epochs and averaged over the above rotated variants of CIFAR-10 and MNIST datasets.
203
+
204
+ ![](images/08d3fd76b4111ac26e3461c4df7498289f564056a7c3a605aede072b6240b1a0.jpg)
205
+ Figure 3: Plotting average classification accuracy of various methods against no. training epochs on heterogeneous tasks derived from (a) MNIST dataset; and (b) CIFAR-10 dataset. Figure (c) compares cumulative running time of various methods against no. training epochs on CIFAR-10 dataset.
206
+
207
+ On the MNIST dataset (Fig. 3b), all methods eventually converge to a similar performance. Among the NAS benchmarks, FEDPNAS and FEDDSNAS both converge slower than FEDAVG and start off with worse performance in early iterations, which is expected since FEDAVG does not have to search for the architecture and it is likely that the default architecture is sufficient for the MNIST task. On the other hand, we observe that both CA-FEDPNAS and CA-FEDDSNAS converge much faster than their counterparts without the context-aware operation sampler component. This shows that making use of contextual information helps to quickly locate regions of high-performing architectures, especially on similar inputs.
208
+
209
+ On the CIFAR-10 dataset (Fig. 3a), we instead observe significant gaps between the worst performing FEDAVG and other NAS methods. This is likely because the default architecture does not have sufficient learning capability, which confirms the need for customizing solutions. Among the NAS benchmarks, we again observe that both CA-FEDPNAS and CA-FEDDSNAS outperform their counterparts without our operation sampler, which confirms the intuition above. Most remarkably, our proposed framework CA-FEDPNAS achieves the best performance (0.8) and significantly outperformed both variants of federated DSNAS (0.71 for CA-FEDDSNAS and 0.63 for FEDDSNAS).
210
+
211
+ Lastly, Fig. 3c shows the runtime comparison between three methods on the CIFAR-10 experiment. In terms of sampling time, we observe that there is negligible overhead incurred by using our context-aware sampler (CA-FEDDSNAS vs. FEDDSNAS). The time incurred by our update (CA-FEDPNAS) scales by a constant factor compared to CA-FEDDSNAS since we use exactly one extra forward/backward pass per update.
212
+
213
+ On objectives with varying heterogeneity. We expand the above study by investigating respective performance of CA-FEDPNAS and FEDDSNAS on tasks with varying levels of heterogeneity. At low level of heterogeneity, we deploy these methods on 5 sets of slightly rotated MNIST images. At high level of heterogeneity, we employ a more diverse set of transformations on MNIST images, such as hue jitter and large angle rotations of $9 0 ^ { \circ }$ and $- 9 0 ^ { \circ }$ . Table 1 show the respective result of each task from these two settings. We observe that our method CA-FEDPNAS achieves better performance on most tasks and the performance gaps on tasks with higher heterogeneity are more pronounced (i.e., up to $7 \%$ improvement on ROTATE 90 task). This clearly shows the importance of architecture personalization when the training tasks are significantly different and justifies our research goal.
214
+
215
+ Table 1: Predictive accuracy of CA-FEDPNAS FEDDSNAS on tasks with varying heterogeneity levels. ROTATE X denotes a rotation transformation of $\mathbf { X } ^ { \circ }$ on client data; VANILLA denotes the original MNIST images; and HUEJITTER X denotes a hue jitter transformation of training images by a factor of X. The best performance in each row is in bold font.
216
+
217
+ <table><tr><td rowspan=1 colspan=1>HETEROGENEITY</td><td rowspan=1 colspan=1>TASKDESCRIPTION</td><td rowspan=1 colspan=1>FEDDSNAS</td><td rowspan=1 colspan=1>CA-FEDPNAS</td></tr><tr><td rowspan=5 colspan=1>Low</td><td rowspan=1 colspan=1>ROTATE -30</td><td rowspan=1 colspan=1>0.947</td><td rowspan=1 colspan=1>0.978</td></tr><tr><td rowspan=1 colspan=1>ROTATE -15</td><td rowspan=1 colspan=1>0.973</td><td rowspan=1 colspan=1>0.976</td></tr><tr><td rowspan=1 colspan=1>VANILLA</td><td rowspan=1 colspan=1>0.988</td><td rowspan=1 colspan=1>0.985</td></tr><tr><td rowspan=1 colspan=1>ROTATE 15</td><td rowspan=1 colspan=1>0.986</td><td rowspan=1 colspan=1>0.987</td></tr><tr><td rowspan=1 colspan=1>ROTATE 30</td><td rowspan=1 colspan=1>0.972</td><td rowspan=1 colspan=1>0.981</td></tr><tr><td rowspan=5 colspan=1>HIGH</td><td rowspan=1 colspan=1>HUEJITTER-0.5</td><td rowspan=1 colspan=1>0.966</td><td rowspan=1 colspan=1>0.978</td></tr><tr><td rowspan=1 colspan=1>HUEJITTER 0.5</td><td rowspan=1 colspan=1>0.967</td><td rowspan=1 colspan=1>0.972</td></tr><tr><td rowspan=1 colspan=1>VANILLA</td><td rowspan=1 colspan=1>0.988</td><td rowspan=1 colspan=1>0.989</td></tr><tr><td rowspan=1 colspan=1>ROTATE -90</td><td rowspan=1 colspan=1>0.892</td><td rowspan=1 colspan=1>0.932</td></tr><tr><td rowspan=1 colspan=1>ROTATE 90</td><td rowspan=1 colspan=1>0.866</td><td rowspan=1 colspan=1>0.932</td></tr></table>
218
+
219
+ On knowledge transfer to completely new tasks. Finally, we investigate a scenario where the architecture distributions discovered by CA-FEDPNAS and FEDDSNAS are required to generalize to completely unseen tasks. Particularly, we train both methods on five clients whose local data consist of 12000 slightly rotated CIFAR-10 images (i.e., in the range of $\pm 3 0 ^ { \circ }$ ), similar to the setting of the first experiment. During testing, however, we supply each local client with 2000 test images subjected to related but completely unseen transformations (i.e., $9 0 °$ and $- 9 0 ^ { \circ }$ rotations).
220
+
221
+ Our results are summarized in Table 2. First, we measure the performance of CA-FEDPNAS and FEDDSNAS without any weight retraining. When received no additional information from the unseen tasks, both methods perform poorly as expected. While CA-FEDPNAS achieves better predictive accuracy, the performance gap in this scenario is negligible. To provide additional clues for adaptation, albeit minimal, we retrain the weights of each local model with 200 images rotated according to respective unseen task description. Here, the parameters of our operator sampler component, (and respectively, FEDDSNAS’s categorical distribution parameters), are frozen to gauge the quality of the learned architecture distributions. Our results show that, with only 100 retraining iterations on limited data, CA-FEDPSNAS already outperforms FEDDSNAS $5 \%$ and $8 \%$ improvement respectively on two unseen tasks). This implies that CA-FEDPNAS has more accurately capture the broad similarity of the task spectrum through the personalized architecture distribution, which requires minimal additional information to successfully adapt to unseen tasks.
222
+
223
+ Table 2: Predictive accuracy (averaged over 5 clients) and standard deviation of CA-FEDPNAS and FEDDSNAS on two unseen tasks (CIFAR-10). The best performance in each row is in bold font.
224
+
225
+ <table><tr><td rowspan=1 colspan=1>UNSEEN TASKDESCRIPTION</td><td rowspan=1 colspan=1>FEDDSNAS</td><td rowspan=1 colspan=1>CA-FEDPNAS</td><td rowspan=1 colspan=1>FEDDSNAS(RETRAINED)</td><td rowspan=1 colspan=1>CA-FEDPNAS(RETRAINED)</td></tr><tr><td rowspan=1 colspan=1>ROTATE -90</td><td rowspan=1 colspan=1>0.545 ± 0.04</td><td rowspan=1 colspan=1>0.578 ± 0.09</td><td rowspan=1 colspan=1>0.699± 0.12</td><td rowspan=1 colspan=1>0.734 ± 0.17</td></tr><tr><td rowspan=1 colspan=1>ROTATE 90</td><td rowspan=1 colspan=1>0.553 ± 0.12</td><td rowspan=1 colspan=1>0.569 ± 0.06</td><td rowspan=1 colspan=1>0.673 ± 0.13</td><td rowspan=1 colspan=1>0.727 ± 0.22</td></tr></table>
226
+
227
+ # 5 CONCLUSION
228
+
229
+ We demonstrate that federated learning for multi-task scenarios requires extensive personalization on the architecture level to obtain good predictive performance. This paper identifies two potential sources of model personalization: (1) task-personalization, which aims to select architectures best suited for specific learning objectives; and (2) context-personalization, which aims to select architectures best suited for specific input samples. To incorporate these aspects of personalization into Federated NAS, we propose FEDPNAS which consists of two main components: (1) a context-aware operator sampler which learns a sampling distribution for feature maps along a master architecture; and (2) a personalized federated learning objective which anticipates client fine-tuning and guides the federated model update to regions that tolerate future local updates.
230
+
231
+ # 6 REPRODUCIBILITY & ETHIC STATEMENT
232
+
233
+ This work contributes to the literature of Federated Learning through improving the state-of-theart performance. As such, it could have significant broader impact by allowing users to more accurately solve practical problems. While applications of our work to real data could result in ethical considerations, this is an indirect (and unpredictable) side-effect of our work. Our experimental work uses publicly available datasets to evaluate the performance of our algorithms; no ethical considerations are raised. Our implementation code is published anonymously at https://github.com/icml2021fedpnas/fedpnas. All proofs and details of various architectures are included in the Appendix of this paper.
234
+
235
+ # REFERENCES
236
+
237
+ B. Baker, O. Gupta, N. Naik, and R. Raskar. Designing neural network architectures using reinforcement learning. arXiv preprint arXiv:1611.02167, 2016.
238
+ J. Bergstra, D. Yamins, and D. Cox. Making a science of model search: Hyperparameter optimization in hundreds of dimensions for vision architectures. In International conference on machine learning, pages 115–123. PMLR, 2013.
239
+ A. Fallah, A. Mokhtari, and A. Ozdaglar. Personalized federated learning: Model-agnostic metalearning approach. In Proc. NeurIPS, 2020.
240
+ C. Finn, P. Abbeel, and S. Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In Proc. ICML, pages 1126–1135, 2017.
241
+ D. Floreano, P. Dürr, and C. Mattiussi. Neuroevolution: from architectures to learning. Evolutionary Intelligence, 1(1):47–62, 2008.
242
+ J. Hu, L. Shen, and G. Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7132–7141, 2018.
243
+ S. Hu, S. Xie, H. Zheng, C. Liu, J. Shi, X. Liu, and D. Lin. DSNAS: Direct neural architecture search without parameter retraining. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12084–12092, 2020.
244
+ E. Jang, S. Gu, and B. Poole. Categorical reparameterization with gumbel-softmax. arXiv preprint arXiv:1611.01144, 2016.
245
+ A. Krizhevsky et al. Learning multiple layers of features from tiny images. Citeseer, 2009.
246
+ Y. LeCun, C. Cortes, and C. Burges. Mnist handwritten digit database. ATT Labs [Online]. Available: http://yann. lecun. com/exdb/mnist, 2, 2010.
247
+ H. B. McMahan, E. Moore, D. Ramage, S. Hampson, and B. A. y Arcas. Communication-efficient learning of deep networks from decentralized data. In Proc. AISTATS, pages 1273–1282, 2017.
248
+ H. Pham, M. Y. Guan, B. Zoph, Q. V. Le, and J. Dean. Efficient neural architecture search via parameter sharing. arXiv preprint arXiv:1802.03268, 2018.
249
+ E. Real, A. Aggarwal, Y. Huang, and Q. V. Le. Regularized evolution for image classifier architecture search. In Proceedings of the AAAI conference on Artificial Intelligence, volume 33, pages 4780–4789, 2019.
250
+ S. Xie, H. Zheng, C. Liu, and L. Lin. SNAS: stochastic neural architecture search. arXiv preprint arXiv:1812.09926, 2018.
251
+ B. Zoph and Q. V. Le. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578, 2016.
md/dev/XrGEkCOREX2/XrGEkCOREX2.md ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MEMO: Test Time Robustness via Adaptation and Augmentation
2
+
3
+ Marvin Zhang1, Sergey Levine1, Chelsea Finn2 1UC Berkeley 2Stanford University
4
+
5
+ # Abstract
6
+
7
+ While deep neural networks can attain good accuracy on in-distribution test points, many applications require robustness even in the face of unexpected perturbations in the input, changes in the domain, or other sources of distribution shift. We study the problem of test time robustification, i.e., using the test input to improve model robustness. Recent prior works have proposed methods for test time adaptation, however, they each introduce additional assumptions, such as access to multiple test points, that prevent widespread adoption. In this work, we aim to study and devise methods that make no assumptions about the model training process and are broadly applicable at test time. We propose a simple approach that can be used in any test setting where the model is probabilistic and adaptable: when presented with a test example, perform different data augmentations on the data point, and then adapt (all of) the model parameters by minimizing the entropy of the model’s average, or marginal, output distribution across the augmentations. Intuitively, this objective encourages the model to make the same prediction across different augmentations, thus enforcing the invariances encoded in these augmentations, while also maintaining confidence in its predictions. In our experiments, we evaluate two baseline ResNet models, two robust ResNet-50 models, and a robust vision transformer model, and we demonstrate that this approach achieves accuracy gains of $1 \%$ over standard model evaluation and also generally outperforms prior augmentation and adaptation strategies. For the setting in which only one test point is available, we achieve state-of-the-art results on the ImageNet-C, ImageNet-R, and, among ResNet-50 models, ImageNet-A distribution shift benchmarks.
8
+
9
+ # 1 Introduction
10
+
11
+ Deep neural network models have achieved excellent performance on many machine learning problems, such as image classification, but are often brittle and susceptible to issues stemming from distribution shift. For example, deep image classifiers may degrade precipitously in accuracy when encountering input perturbations, such as noise or changes in lighting $[ \hat { \left| 1 2 \right| } ]$ or domain shifts which occur naturally in real world applications $\mathbb { \left| \mathbb { Z } \right\| }$ . Therefore, robustification of deep models against these test shifts is an important and active area of study.
12
+
13
+ Most prior works in this area have focused on techniques for training time robustification, including utilizing larger models and datasets $\pmb { \mathbb { B 4 } }$ , various forms of adversarial training $\mathbb { B 9 } \mathbb { H 8 }$ , and aggressive data augmentation [51, 13, 24, 14]. Employing these techniques requires modifying the training process, which may not be feasible if, e.g., it involves heavy computation or non public data. Furthermore, these techniques do not rely on any information about the test points that the model must predict on, even though these test points may provide significant information for improving model robustness. Recently, several works have proposed methods for improving accuracy via adaptation after seeing the test data, typically by updating a subset of the model’s weights [44, 45, 18], normalization statistics [40], or both [46, 52]. Though effective at handling test shifts, these methods sometimes still require specialized training procedures, and they typically rely on extracting information via batches or even entire sets of test inputs, thus introducing additional assumptions.
14
+
15
+ ![](images/695fdc8d76523d7ae12f1252c94b960f4f9aeeee940045c10e43759d62a658f6.jpg)
16
+ Figure 1: Left: at test time, as detailed in $\mathsf { \overline { { S e c t i o n 3 } } } ,$ we have a single test input $\mathbf { x }$ , a set of data augmentation functions $\{ a _ { 1 } , \dotsc , a _ { M } \}$ , and a trained model that outputs a probabilistic predictive distribution and has adaptable parameters $\theta$ . We perform different augmentations on $\mathbf { x }$ and pass these augmented inputs to the model in order to estimate the marginal output distribution averaged over augmentations. Right: we perform a gradient update on the model to minimize the entropy of this marginal distribution, thus encouraging the model predictions to be invariant across different augmentations while maintaining confident predictions. The final prediction is then made on the original data point, i.e., the predictive distribution in the top right of the schematic.
17
+
18
+ In this work, we focus on methods for test time robustness, in which the specific test input may be leveraged in order to improve the model’s prediction on that point. We are interested in studying and devising methods for improving model robustness that are “plug and play”, i.e., they can be readily used with a wide variety of pretrained models and test settings. We also want methods that synergize with other robustification techniques, in order to achieve greater performance than using either in isolation. With these goals in mind, we devise a novel test time robustness method based on adaptation and augmentation. As illustrated in $\mathbb { F i g u r e 1 } ,$ when presented with a test point, we adapt the model by augmenting the test point in different ways while encouraging the model to make consistent predictions, thus respecting the invariances encoded in the data augmentations. We further encourage the model to make confident predictions, thus arriving at the proposed method: minimize the marginal entropy of the model’s predictions across the augmented versions of the test point.
19
+
20
+ We refer to the proposed method as marginal entropy minimization with one test point (MEMO), and this is the primary contribution of our work. MEMO makes direct use of pretrained models without any assumptions about their particular training procedure or architecture, while requiring only a single test input for adaptation. In Section 4, we demonstrate empirically that MEMO consistently improves the performance of ResNet [11] and vision transformer $\mathbb { \overline { { | \overline { { \mathbb { Z } } | } } } }$ models on several challenging ImageNet distribution shift benchmarks, achieving several new state-of-the-art results for these models in the setting in which only one test point is available. MEMO consistently outperforms non adaptive marginal distribution predictions (between $1 - 1 0 \%$ improvement) on the ImageNet-C [12] and ImageNet-R [14] test sets, indicating that adaptation plays a crucial role in improving predictive accuracy. MEMO encourages both invariance across augmentations and confident predictions, and an ablation study in Section 4 shows that both components are important for maximal performance gains. Also, MEMO is, to the best of our knowledge, the first adaptation method to improve performance (by $1 \%$ over standard model evaluation) on the ImageNet-A test set $\mathbb { \lVert 1 5 \rVert }$ .
21
+
22
+ # 2 Related work
23
+
24
+ Distribution shift has been studied under a number of frameworks $\pmb { \mathbb { B } } 6 \|$ , including domain adaptation [41, 6, 47], domain generalization [5, 32, 9], and distributionally robust optimization [4, 16, 39]. These frameworks typically leverage additional training or test assumptions in order to make the distribution shift problem more tractable. Largely separate from these frameworks, various empirical methods have also been proposed for dealing with shift, such as increasing the model and training dataset size or using heavy training augmentations [34, 51, 14]. The focus of this work is complementary to these efforts: MEMO is applicable to a wide range of pretrained models, including those trained via robustness methods, and can achieve further performance gains via test time adaptation.
25
+
26
+ Prior test time adaptation methods generally either make significant training or test time assumptions. Some methods update the model using batches or even entire datasets of test inputs, such as by computing batch normalization (BN) statistics on the test set [25, 19, 33, 40], computing class prototypes $\mathbb { \lVert \rVert }$ , or minimizing the (conditional) entropy of model predictions across a batch of test data $\lVert \overline { { 4 6 } } \rVert$ . The latter approach is closely related to MEMO. The differences are that MEMO minimizes marginal entropy using single test points and data augmentation and adapts all of the model parameters rather than just those associated with normalization layers, thus not requiring multiple test points or specific model architectures. Other test time adaptation methods can be applied to single test points but require specific training procedures or models [44, 17, 40, 1, 3]. Test time training (TTT) $\underline { { \lVert \varPsi \ 4 \rVert } }$ requires a specialized model with a rotation prediction head and a different procedure for training this model. Schneider et al. [40] show that BN adaptation can be effective even with only one test point. As we discuss in Section 3, MEMO synergizes well with this technique of “single point” BN adaptation. Mao et al. [29] propose a test time adaptation method based on input perturbations for robustness to adversarial attacks. Concurrently with our work, Sivaprasad and Fleuret $\mathbb { \lVert \rVert 3 \rVert }$ propose a similar method for test time adaptation by encouraging invariance to data augmentations, and they test their method on the corrupted CIFAR and VisDA [35] datasets.
27
+
28
+ A number of works have noted that varying forms of strong data augmentation on the training set can improve the resulting model’s robustness [51, 13, 24, 14]. Data augmentations are also sometimes used on the test data directly by averaging the model’s outputs across augmented copies of the test point $\mathbb { \left| \overline { { 2 3 } } \right| \overline { { \sharp 2 } } }$ , i.e., predicting according to the model’s marginal output distribution. When using cropping as the augmentation, this technique is often referred to as multicrop evaluation $\pmb { \mathbb { Z } } 2 \mathbf { l }$ . We instead use the term test time augmentation (TTA), as we use additional augmentations beyond cropping $\mathbb { \lVert \lambda \rVert }$ . TTA has been shown to be useful both for improving model accuracy and calibration $\pmb { \left. 2 \right. }$ as well as handling distribution shift [31]. We take this idea one step further by explicitly adapting the model such that its marginal output distribution has low entropy. This extracts an additional learning signal for improving the model, and furthermore, the adapted model can then make its final prediction on the clean test point rather than the augmented copies. We empirically show in Section 4 that these differences lead to improved performance over this non adaptive TTA baseline.
29
+
30
+ # 3 Augmenting and Adapting at Test Time
31
+
32
+ Data augmentations are typically used to train the model to respect certain invariances – e.g., changes in lighting or viewpoint do not change the underlying class label – but, especially when faced with distribution shift, the model is not guaranteed to obey the same invariances at test time. In this section, we introduce MEMO, a method for test time robustness that adapts the model such that it respects these invariances on the test input. We use “test time robustness” specifically to refer to techniques that operate directly on pretrained models and single test inputs – single point BN adaptation and TTA, as described in $\overline { { \mathsf { S e c t i o n 2 } } }$ are examples of prior test time robustness methods.
33
+
34
+ In the test time robustness setting, we are given a trained model $f _ { \theta }$ with parameters $\theta \in \Theta$ . We do not require any special training procedure and do not make any assumptions about the model, except that $\theta$ is adaptable and that $f _ { \theta }$ produces a conditional output distribution $p _ { \boldsymbol { \theta } } ( y | \mathbf { x } )$ that is differentiable with respect to $\theta . ^ { 1 }$ All standard deep neural network models satisfy these assumptions. A single point $\mathbf { x } \in \mathcal { X }$ is presented to $f _ { \theta }$ , for which it must predict a label $\hat { y } \in \mathcal { V }$ immediately. Note that this is precisely identical to the standard test time inference procedure for regular supervised learning models – in effect, we are simply modifying how inference is done, without any additional assumptions on the training process or on test time data availability. This makes test time robustness methods a simple “slot-in” replacement for the ubiquitous and standard test time inference process. We assume sampling access to a set of augmentation functions $\mathcal { A } \triangleq \{ a _ { 1 } , \ldots , a _ { M } \}$ that can be applied to the test point $\mathbf { x }$ . We use these augmentations and the self-supervised objective detailed below to adapt the model before it predicts on $\mathbf { x }$ . When given a set of test inputs, the model adapts and predicts on each test point independently. We do not assume access to any ground truth labels.
35
+
36
+ Require: trained model $f _ { \theta }$ , test point $\mathbf { x }$ , number of augmentations $B$ , learning rate $\eta$ , update rule $G$
37
+ 1: Sample $a _ { 1 } , \dots , a _ { B } \overset { \mathrm { i . i . d . } } { \sim } \mathcal { U } ( A )$ and produce augmented points $\tilde { \mathbf { x } } _ { i } = a _ { i } ( \mathbf { x } )$ for $i \in \{ 1 , \ldots , B \}$
38
+ 2: Compute estimate $\begin{array} { r } { \tilde { p } = \frac { 1 } { B } \sum _ { i = 1 } ^ { B } p _ { \theta } ( y | \tilde { \mathbf { x } } _ { i } ) \approx \bar { p } _ { \theta } ( y | \mathbf { x } ) } \end{array}$ and $\tilde { \ell } = H ( \tilde { p } ) \approx \ell ( \theta ; { \mathbf x } )$ , i.e., Eq. 2
39
+ 3: Adapt parameters via update rule $\theta ^ { \prime } G ( \theta , \eta , \tilde { \ell } )$
40
+ 4: Predict $\hat { y } \triangleq \arg \operatorname* { m a x } _ { y } p _ { \theta ^ { \prime } } ( y | \mathbf { x } )$
41
+
42
+ # 3.1 Marginal Entropy Minimization with One test point
43
+
44
+ Given a test point $\mathbf { x }$ and set of augmentation functions $\mathcal { A }$ , we sample $B$ augmentations from $\mathcal { A }$ and apply them to $\mathbf { x }$ in order to produce a batch of augmented data $\tilde { \mathbf { x } } _ { 1 } , \ldots , \tilde { \mathbf { x } } _ { B }$ . The model’s average, or marginal, output distribution with respect to the augmented points is given by
45
+
46
+ $$
47
+ \bar { p } _ { \theta } ( y | \mathbf { x } ) \triangleq \mathbb { E } _ { \mathcal { U } ( \mathcal { A } ) } \left[ p _ { \theta } ( y | a ( \mathbf { x } ) ) \right] \approx \frac { 1 } { B } \sum _ { i = 1 } ^ { B } p _ { \theta } ( y | \tilde { \mathbf { x } } _ { i } ) ,
48
+ $$
49
+
50
+ where the expectation is with respect to uniformly sampled augmentations $a \sim \mathcal { U } ( A )$ .
51
+
52
+ What properties do we desire from this marginal distribution? To answer this question, consider the role that data augmentation typically serves during training. For each training point $\left( { \bf x } ^ { \mathrm { t r a i n } } , y ^ { \mathrm { t r a i n } } \right)$ , the model $f _ { \theta }$ is trained using multiple augmented forms of the input $\tilde { \mathbf { x } } _ { 1 } ^ { \mathrm { t r a i n } } , \ldots , \tilde { \mathbf { x } } _ { E } ^ { \mathrm { t r a i n } }$ . $f$ is trained to obey the invariances between the augmentations and the label – no matter the augmentation on $\mathbf { x } ^ { \mathrm { t r a i n } }$ , $f$ should predict, with confidence, the same label $y ^ { \mathrm { t r a i n } }$ . We seek to devise a similar learning signal during test time, without any ground truth labels. That is, after adapting:
53
+
54
+ (1) the model $f _ { \theta }$ predictions should be invariant across augmented versions of the test point, and (2) the model $f _ { \theta }$ should be confident in its predictions, even for heavily augmented versions of the test point, since all versions have the same underlying label.
55
+
56
+ Optimizing the model for more confident predictions can be justified from the assumption that the true underlying decision boundaries between classes lie in low density regions of the data space $\textcircled { 8 }$ . With these two goals in mind, we propose to adapt the model using the entropy of its marginal output distribution over augmentations $\underline { { \operatorname { d } \dot { \operatorname { E q . } } \dot { 1 } ) } }$ , i.e.,
57
+
58
+ $$
59
+ \ell ( \theta ; \mathbf { x } ) \triangleq H \left( \bar { p } _ { \theta } ( \cdot | \mathbf { x } ) \right) = - \sum _ { y \in \mathcal { Y } } \bar { p } _ { \theta } ( y | \mathbf { x } ) \log \bar { p } _ { \theta } ( y | \mathbf { x } ) .
60
+ $$
61
+
62
+ Note that this objective is not the same as optimizing the average conditional entropy of the model’s predictive distributions across augmentations, i.e.,
63
+
64
+ $$
65
+ \ell _ { \mathrm { { C E } } } ( \boldsymbol { \theta } ; \mathbf { x } ) \triangleq \frac { 1 } { B } \sum _ { i = 1 } ^ { B } H ( p _ { \boldsymbol { \theta } } ( \cdot | \widetilde { \mathbf { x } } _ { i } ) ) .
66
+ $$
67
+
68
+ A model which predicts confidently but differently across augmentations would minimize $\operatorname { E q . 3 }$ but not $\boxed { \mathrm { E q . ~ } 2 }$ Optimizing $\operatorname { E q } . 2$ encourages both confidence and invariance, since the entropy of $\bar { p } _ { \theta } ( \cdot | \mathbf { x } )$ is minimized when the model outputs the same (confident) prediction regardless of the augmentation.
69
+
70
+ Algorithm 1 presents the overall method MEMO for test time adaptation. Though prior test time adaptation methods must carefully choose which parameters to adapt in order to avoid degenerate solutions $\lVert \overline { { 4 6 } } \rVert$ , our adaptation procedure simply adapts all of the model’s parameters $\theta$ (line 3). Given that $p _ { \boldsymbol { \theta } } ( \boldsymbol { y } | \mathbf { x } )$ is differentiable with respect to $\theta$ , we can directly use gradient based optimization to adapt $\theta$ according to $\mathbb { E } { \mathsf { q } } . 2 \mathbb { Z }$ We use only one gradient step per test point, because empirically we found this to be sufficient for improved performance while being more computationally efficient. After this step, we use the adapted model $f _ { \theta ^ { \prime } }$ to predict on the original test input $\mathbf { x }$ (line 4).
71
+
72
+ # 3.2 Composing MEMO with Prior Methods
73
+
74
+ An additional benefit of MEMO is that it synergizes with other approaches for handling distribution shift. In particular, MEMO can be composed with prior methods for training robust models and adapting model statistics, thus leveraging the performance improvements of each technique.
75
+
76
+ ![](images/6ecb312275c8b833a76347f6c7ba3d2b80f52b0b71a12da6610da54a844f0e30.jpg)
77
+ Figure 2: We visualize augmentations of a randomly chosen data point from the “Gaussian Noise level 3” ImageNet-C test set. Even for a robust model trained with heavy data augmentations [14], both its predictive accuracy and confidence (as shown in the top two rows) drop sharply when encountering test shift. As shown in the bottom two rows, these drops can be remedied via MEMO adaptation.
78
+
79
+ Pretrained robust models. Since MEMO makes no assumptions about, or modifications to, the model training procedure, performing adaptation on top of pretrained robust models, such as those trained with heavy data augmentations, is as simple as using any other pretrained model. Crucially, we find that, in practice, the set of test augmentations $\mathcal { A }$ does not have to match the augmentations that were used to train the model. For simplicity and efficiency, we use augmentations that can be easily sampled and are applied directly to the model input x. These properties do not hold for, e.g., data augmentation techniques based on image translation models, such as DeepAugment $\textcircled { 1 1 4 } \textcircled { 1 }$ , or feature mixing, such as moment exchange $\checkmark$ . However, we can still use models trained with these data augmentation techniques as our starting point for adaptation, thus allowing us to improve upon their state-of-the-art results. As noted above, using pretrained models is not as easily accomplished for adaptation methods which require complicated or specialized training procedures and model architectures, such as TTT $\mathbb { H } 4 4 \mathbb { I }$ or ARM $[ \bar { 1 } \bar { 5 } 2 ]$ . In our experiments, we use AugMix as our set of augmentations $\mathbb { \lVert \rVert 3 \rVert }$ , as it satisfies the above properties and still yields significant diversity when applied, as depicted in $\mathbb { F i g u r e 2 } $ Note that AugMix explicitly does not use augmentations that are similar to the corruptions in the CIFAR-10-C and ImageNet-C test sets [12, 13].
80
+
81
+ Adapting BN statistics. Schneider et al. $\mathbb { \left[ \left. 4 0 \right] \right. }$ showed that, even when presented with just a single test point, partially adapting the estimated mean and variance of the activations in each batch normalization (BN) layer of the model can still be effective in some cases for handling distribution shift. In this setting, to prevent overfitting to the test point, the channelwise mean and variance $[ \mu _ { \mathrm { t e s t } } , \sigma _ { \mathrm { t e s t } } ^ { 2 } ]$ estimated from this point are mixed with the the mean and variance $[ \mu _ { \mathrm { t r a i n } } , \sigma _ { \mathrm { t r a i n } } ^ { 2 } ]$ computed during training according to a prior strength $N$ . That is, for $\pmb { \nu } \in \{ \mu , \sigma ^ { 2 } \}$ ,
82
+
83
+ $$
84
+ \pmb { \nu } \triangleq \frac { N } { N + 1 } \pmb { \nu } _ { \mathrm { t r a i n } } + \frac { 1 } { N + 1 } \pmb { \nu } _ { \mathrm { t e s t } } .
85
+ $$
86
+
87
+ This technique is also straightforward to combine with MEMO: we simply use the adapted BN statistics whenever computing the model’s output distribution. We find in our experiments that this technique never degrades, and generally improves, the performance of test time adaptation, thus we combine MEMO with this technique by default whenever applicable. Following the suggestion in Schneider et al. $\mathbb { \left[ \left| 4 0 \right| \right] }$ , we set $N = 1 6$ for all of our experiments in the next section.
88
+
89
+ # 4 Experiments
90
+
91
+ Our experiments aim to answer the following questions:
92
+
93
+ (1) How does MEMO compare to prior methods for test time adaptation and test time robustness? (2) Can MEMO be combined with a wide range of model architectures and pretraining methods? (3) Which aspect of MEMO, the adaptation or augmentation, is the most important?
94
+
95
+ We evaluate MEMO on a total of five distribution shift benchmarks. We conduct CIFAR-10 [22] experiments on the CIFAR-10-C [12] and CIFAR-10.1 [37] test sets, and we conduct ImageNet [38] experiments on the ImageNet-C [12], ImageNet-R [14], and ImageNet-A [15] test sets.
96
+
97
+ To answer question (1), we compare to test time training (TTT) [44] in the CIFAR-10 experiments, for which we train ResNet-26 models following their protocol and specialized architecture. We do not compare to TTT for the ImageNet experiments due to the computational demands of training state-of-the-art models and because Sun et al. [44] do not report competitive ImageNet results. For the ImageNet experiments, we compare to Tent $[ \overline { { | 4 6 | } }$ and BN adaptation, which can be used with pretrained models but require multiple test inputs (or even the entire test set) for adaptation. We provide BN adaptation with 256 test inputs at a time and set the prior strength $N = 2 5 6$ [40].
98
+
99
+ For Tent, we use test batch sizes of 64 and, for ResNet-50 models, test both “online” adaptation – where the model adapts continually through the entire evaluation – and “episodic” adaptation – where the model is reset after each test batch $\overline { { \lVert \textcircled { 4 6 } \rVert } }$ . Note that the evaluation protocols are different for these two methods: whereas MEMO is tasked with predicting on each test point immediately after adaptation, BN adaptation predicts on a batch of 256 test points after computing BN statistics on the batch, and Tent predicts on a batch of 64 inputs after adaptation but also, in the online setting, continually adapts throughout evaluation. In all experiments, we further compare to single point BN adaptation $\mathbb { \left[ \left| 4 0 \right| \right] }$ and the TTA baseline that simply predicts according to $\bar { p } _ { \boldsymbol { \theta } } ( y | \mathbf { \bar { x } } )$ (Eq. 1) [23, 2]. Full details on our experimental protocol are provided in Appendix A.
100
+
101
+ To answer question (2), we apply MEMO on top of multiple pretrained models with different architectures, trained via several different procedures. For CIFAR-10, we train our own ResNet26 [11] models. For ImageNet, we use the best performing ResNet-50 robust models from prior work, which includes those trained with DeepAugment and AugMix augmentations $[ \textcircled { 1 4 } ]$ as well as those trained with moment exchange and CutMix $\pmb { \Vert 2 4 \Vert }$ . To evaluate the generality of prior test time robustness methods and MEMO, we also evaluate the small robust vision transformer $\mathrm { R V T ^ { * } }$ -small), which provides superior performance on all three ImageNet distribution shift benchmarks compared to the robust ResNet-50 models $\pmb { \mathbb { B } } \pmb { \mathrm { 0 } }$ . Finally, we evaluate ResNext-101 models [50, 28] on ImageNet-A, as these models previously achieved the strongest results for this test set [14].
102
+
103
+ Finally, to answer (3), we conduct ablative studies in subsection 4.2: first to determine the relative importance of maximizing confidence (via entropy minimization) versus enforcing invariant predictions across augmented copies of each test point, second to determine the importance of the particular augmentation functions used, and third to determine the required number of augmented samples per inference. The comparison to the non adaptive TTA baseline also helps determine whether simply augmenting the test point is sufficient or if adaptation is additionally helpful. In Appendix B, we provide further experiments ablating the augmentation component specifically.
104
+
105
+ # 4.1 Main Results
106
+
107
+ We summarize results for CIFAR-10, CIFAR-10.1, and CIFAR-10-C in Table 1, with full CIFAR-10- C results in Appendix C. We use indentations to indicate composition, e.g., TTT is performed at test time on top of their specialized joint training procedure. Across all corruption types in CIFAR-10-C, MEMO consistently improves test error compared to the baselines, non adaptive TTA, and TTT. MEMO also provides a larger performance gain on CIFAR-10.1 compared to TTT. We find that the non adaptive TTA baseline is competitive for these relatively simple test sets, though it is worse than MEMO for CIFAR-10-C. Of these three test sets, CIFAR-10-C is the only benchmark that explicitly introduces distribution shift, which suggests that adaptation is useful when the test shifts are more prominent. Both TTA and MEMO are also effective at improving performance for the original CIFAR-10 test set where there is no distribution shift, providing further support for the widespread use of augmentations in standard evaluation protocols [23, 2].
108
+
109
+ Table 1: Results for CIFAR-10, CIFAR-10.1, and CIFAR-10-C. ?Results from Sun et al. [44].
110
+
111
+ <table><tr><td></td><td>CIFAR-10 Error (%)</td><td>CIFAR-10.1 Error (%)</td><td>CIFAR-10-C Average Error (%)</td></tr><tr><td>ResNet-26 □</td><td>9.2</td><td>18.4</td><td>22.5</td></tr><tr><td>+TTA</td><td>7.3 (-1.9)</td><td>14.8 (-3.6)</td><td>19.9 (-2.6)</td></tr><tr><td>+ MEMO (ours)</td><td>7.3 (-1.9)</td><td>14.7 (-3.7)</td><td>19.6 (-2.9)</td></tr><tr><td>+ Joint training* 国</td><td>8.1</td><td>16.7</td><td>22.8</td></tr><tr><td>+ TTT* 因</td><td>7.9 (-0.2)</td><td>15.9 (-0.8)</td><td>21.5 (-1.3)</td></tr></table>
112
+
113
+ Table 2: Test results for the ImageNet test sets. MEMO achieves new state-of-the-art performance on each benchmark for ResNet-50 models for the single test point setting. For $\mathbf { R V T ^ { * } }$ -small, MEMO improves performance across all benchmarks and reaches a new state of the art for ImageNet-C and ImageNet-R. Compared to prior approaches, MEMO offers more consistent improvements.
114
+
115
+ <table><tr><td></td><td>ImageNet-C mCE↓</td><td>ImageNet-R Error (%)</td><td>ImageNet-A Error (%)</td></tr><tr><td>Baseline ResNet-50 自</td><td>76.7</td><td>63.9</td><td>100.0</td></tr><tr><td>+ TTA</td><td>77.9 (+1.2)</td><td>61.3 (-2.6)</td><td>98.4 (-1.6)</td></tr><tr><td>+ Single point BN</td><td>71.4 (-5.3)</td><td>61.1 (-2.8)</td><td>99.4 (-0.6)</td></tr><tr><td>+ MEMO (ours)</td><td>69.9 (-6.8)</td><td>58.8 (-5.1)</td><td>99.1 (-0.9)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>61.6 (-15.1)</td><td>59.7 (-4.2)</td><td>99.8 3(-0.2)</td></tr><tr><td>+ Tent (online) [ 46</td><td>54.4 (−22.3)</td><td>57.7 (-6.2)</td><td>99.8 (-0.2)</td></tr><tr><td>+ Tent (episodic)</td><td>64.7 (−12.0)</td><td>61.0 (-2.9)</td><td>99.7 ( (-0.3)</td></tr><tr><td> + DeepAugment+AugMix [14]</td><td>53.6</td><td>53.2</td><td>96.1</td></tr><tr><td>+ TTA</td><td>55.2 (+1.6)</td><td>51.0 (-2.2)</td><td>93.5 (-2.6)</td></tr><tr><td>+ Single point BN</td><td>51.3 (-2.3)</td><td>51.2 (-2.0)</td><td>95.4 (-0.7)</td></tr><tr><td>+ MEMO (ours)</td><td>49.8 (-3.8)</td><td>49.2 (-4.0)</td><td>94.8 (-1.3)</td></tr><tr><td>+ BN(N = 256,n = 256)</td><td>45.4 (−8.2)</td><td>48.8 (-4.4)</td><td>96.8 (+0.7)</td></tr><tr><td>+ Tent (online)</td><td>43.5 (-10.1)</td><td>46.9 (-6.3)</td><td>96.7 (+0.6)</td></tr><tr><td> + Tent (episodic)</td><td>47.1 (-6.5)</td><td>50.1 (-3.1)</td><td>96.6 (+0.5)</td></tr><tr><td>+ MoEx+CutMix 2</td><td>74.8</td><td>64.5</td><td>91.9</td></tr><tr><td>+ TTA</td><td>75.7 (+0.9)</td><td>62.7 (-1.8)</td><td>89.5 (-2.4)</td></tr><tr><td>+ Single point BN</td><td>71.0 (-3.8)</td><td>62.6 (−1.9)</td><td>91.1 (-0.8)</td></tr><tr><td>+ MEMO (ours)</td><td>69.1 (-5.7)</td><td>59.4 (-3.3)</td><td>89.0 (-2.9)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>60.9 (-13.9)</td><td>61.6 (-2.9)</td><td>93.9 (+2.0)</td></tr><tr><td>+ Tent (online)</td><td>54.0 (-20.8)</td><td>58.7 (-5.8)</td><td>94.4 (+2.5)</td></tr><tr><td>+ Tent (episodic)</td><td>66.2 (-8.6)</td><td>63.9 (-0.6)</td><td>94.7 (+2.8)</td></tr><tr><td>RVT*-small □</td><td>49.4</td><td>52.3</td><td>73.9</td></tr><tr><td>+ TTA</td><td>53.0 (+3.6)</td><td>49.0 (-3.3)</td><td>68.9 (-5.0)</td></tr><tr><td>+ Single point BN</td><td>48.0 (-1.4)</td><td>51.1 (-1.2)</td><td>74.4 (+0.5)</td></tr><tr><td>+ MEMO (ours)</td><td>40.6 (-8.8)</td><td>43.8 (-8.5)</td><td>69.8 (-4.1)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>44.3 (-5.1)</td><td>51.0 ( (-1.3)</td><td>78.3 (+4.4)</td></tr><tr><td>+ Tent (online)</td><td>46.8 (-2.6)</td><td> 50.7 (-1.6)</td><td>82.1 (+8.2)</td></tr><tr><td>+ Tent (adapt all)</td><td>44.7 (-4.7)</td><td>74.1 (+21.8)</td><td>81.1 (+7.2)</td></tr></table>
116
+
117
+ We summarize results for ImageNet-C, ImageNet-R, and ImageNet-A in Table 2, with complete ImageNet-C results in $\boxed { \mathrm { A p p e n d i x ~ C } }$ We again use indentations to indicate composition, e.g., the best results on ImageNet-C for our setting are attained through a combination of starting from a model trained with DeepAugment and AugMix [14] and using MEMO on top. For both ImageNet-C and ImageNet-R, and for both the ResNet-50 and $\mathbf { R V T ^ { * } }$ -small models, combining MEMO with robust training techniques leads to new state-of-the-art performance among methods that observe only one test point at a time. We highlight in gray the methods that require multiple test points for adaptation, and we list in bold the best results from these methods which outperform the test time robustness methods. As Table 2 and prior work both show [40, 46], accessing multiple test points can be powerful for benchmarks such as ImageNet-C and ImageNet-R, in which inferred statistics from the test input distribution may aid in prediction. However, these methods do not help, and oftentimes even hurt, for ImageNet-A. Furthermore, we find that these methods are less effective with the $\mathrm { R V T ^ { * } }$ -small model, which may indicate their sensitivity to model architecture choices. Therefore, for this model, we also test a modification of Tent which adapts all parameters, and we find that this version of Tent works better for ImageNet-C but is significantly worse for ImageNet-R.
118
+
119
+ MEMO also results in substantial improvement for ImageNet-A. No prior test time adaptation methods have reported improvements on ImageNet-A, and some have reported explicit negative results $\mathbb { H O }$ . As discussed, it is reasonable for adaptation methods that rely on multiple test points to achieve greater success on other benchmarks such as ImageNet-C, in which a batch of inputs provides significant information about the specific corruption that must be dealt with. In contrast, ImageNet-A does not have such obvious characteristics associated with the input distribution, as it is simply a collection of images that are difficult to classify. As MEMO instead extracts a learning signal from single test points, it is, to the best of our knowledge, the first test time adaptation method to report successful results on this testbed. We view the consistency with which MEMO outperforms the best prior methods, which change across different test sets, as a major advantage of the proposed method.
120
+
121
+ TTA is the most competitive prior method for ImageNet-A, e.g., it results in larger improvements than MEMO for the $\mathbf { R V T ^ { * } }$ -small model. MEMO, however, achieves state-of-the-art performance among ResNet-50 models. To further compare MEMO to TTA, in Table 3, we evaluate whether MEMO can successfully adapt ResNext-101 models $ { \Vert 5 0 \Vert }$ and further improve performance on this challenging test set. We evaluate both a ResNext-101 (32x8d) baseline model pretrained on ImageNet, as well as the same model pretrained with weakly supervised learning (WSL) on billions of Instagram images $\bar { \left\| 2 8 \right\| }$ . For the
122
+
123
+ Table 3: ImageNet-A results for the ResNext-101s.
124
+
125
+ <table><tr><td colspan="2">ImageNet-A Error (%)</td></tr><tr><td>ResNext-101 ⑤0</td><td>90.0</td></tr><tr><td>+ TTA</td><td>83.2 (-6.8)</td></tr><tr><td>+ Single point BN</td><td>88.8 (-1.2)</td></tr><tr><td>+ MEMO (ours)</td><td>84.3 (-5.7)</td></tr><tr><td>+ WSL [28]</td><td>54.9</td></tr><tr><td>+ TTA</td><td>49.1 (-5.8)</td></tr><tr><td>+ Single point BN</td><td>58.9 (+4.0)</td></tr><tr><td>+ MEMO (ours)</td><td>43.2 (−11.7)</td></tr></table>
126
+
127
+ WSL model, we did not use single point BN adaptation for MEMO as we found this technique to be actually harmful to performance, and this corroborates previous findings $\mathbb { H O }$ . From the results, we can see that, although both TTA and MEMO significantly improve upon the baseline model evaluation, MEMO ultimately achieves the best accuracy by a significant margin as it is more successful at adapting the WSL model. This suggests that MEMO may synergize well with large scale pretraining, and further exploring this combination is an interesting direction for future work.
128
+
129
+ # 4.2 Ablative Study
130
+
131
+ MEMO uses both adaptation and augmentations. In this section, we ablate the adaptation procedure and the number of augmentations, and in Appendix B we ablate the choice of augmentations.
132
+
133
+ Adaptation procedure. From the results above, we conclude that adaptation generally provides additional benefits beyond simply using TTA to predict via the marginal output distribution $\bar { p } _ { \boldsymbol { \theta } } ( y | \mathbf { x } )$ . However, we can disentangle two distinct self-supervised learning signals that may be effective for adaptation: encouraging invariant predictions across different augmentations of the test point, and encouraging confidence via entropy minimization. The marginal entropy objective in $\operatorname { \bar { E } q } . 2$ encapsulates both of these learning signals, but it cannot easily be decomposed into these pieces. We instead use two ablative adaptation methods that each only make use of one of these learning signals.
134
+
135
+ First, we consider optimizing the pairwise cross entropy between each pair of augmented points, i.e.,
136
+
137
+ $$
138
+ \ell _ { \mathrm { P C E } } ( \boldsymbol { \theta } ; \mathbf { x } ) \triangleq \frac { 1 } { B \times ( B - 1 ) } \sum _ { i = 1 } ^ { B } \sum _ { j \neq i } H ( p _ { \boldsymbol { \theta } } ( \cdot | \widetilde { \mathbf { x } } _ { i } ) , p _ { \boldsymbol { \theta } } ( \cdot | \widetilde { \mathbf { x } } _ { j } ) ) ,
139
+ $$
140
+
141
+ Where $\tilde { \mathbf { x } } _ { i }$ again refers to the $i$ -th sampled augmentation applied to $\mathbf { x }$ . Intuitively, this loss function encourages the model to adapt such that it produces the same predictive distribution for all augmentations of the test point, but it does not encourage the model to produce confident predictions.
142
+
143
+ Table 4: Ablating the adaptation objective to test pairwise cross entropy and conditional entropy (CE) based adaptation. MEMO generally performs the best, indicating that both encouraging invariance across augmentations and confidence are helpful in adapting the model.
144
+
145
+ <table><tr><td></td><td>CIFAR-10 Error (%)</td><td>CIFAR-10.1 Error (%)</td><td>CIFAR-10-C Average Error (%)</td></tr><tr><td>ResNet-26 []</td><td>9.2</td><td>18.4</td><td>22.5</td></tr><tr><td>+ MEMO (ours)</td><td>7.3 (-1.9)</td><td>14.7 (-3.7)</td><td>19.6 (-2.9)</td></tr><tr><td>l (Eq. 2) )+lPCE 一</td><td>7.6 (-1.6)</td><td>15.3 (-3.1)</td><td>20.0 (-2.5)</td></tr><tr><td>Eq.2) + lcE</td><td>7.6 (-1.6)</td><td>14.7 (-3.7)</td><td>20.0 (-2.5)</td></tr><tr><td></td><td>ImageNet-C mCE↓</td><td>ImageNet-R Error (%)</td><td>ImageNet-A Error (%)</td></tr><tr><td>RVT*-small [30]</td><td>49.4</td><td>52.3</td><td>73.9</td></tr><tr><td>+ MEMO (ours)</td><td>40.6 (-8.8)</td><td>43.8 (-8.5)</td><td>69.8 (-4.1)</td></tr><tr><td>-l (Eq. 2) + lcE</td><td>41.2 (-8.2)</td><td>44.2 (−8.1)</td><td>69.7 (-4.2)</td></tr></table>
146
+
147
+ ![](images/5eaa7e18247da47c2425c9985f500a9780838964f166482db468111dd95d274c.jpg)
148
+ Figure 3: Plotting MEMO efficiency as seconds per evaluation $\mathbf { \dot { x } }$ axis) and $\%$ test error on ImageNet-R (y axis) for the ResNet-50 models (left) and $\mathrm { R V T ^ { * } }$ -small (right) while varying $B = \{ 1 , 2 , 4 , 8 , 1 6 , 3 2 , 6 4 , 1 2 8 \}$ . Note the log scale on the $\mathbf { X }$ axis.
149
+
150
+ Conversely, as an objective that encourages confidence but not invariance, we also consider optimizing the conditional entropy objective detailed in Eq. 3. This ablation is effectively a version of the episodic variant of Tent $[ \overline { { | 4 6 | } }$ that produces augmented copies of a single test point rather than assuming access to a test batch. We first evaluate these ablations on the CIFAR-10 test sets. We use the same adaptation procedure and hyperparameters, with $\ell$ replaced with the above objectives.
151
+
152
+ The results are presented in Table 4. We see that MEMO, i.e., marginal entropy minimization, generally performs better than adaptation with either of the alternative objectives. This supports the hypothesis that both invariance across, and confidence on, the augmentations are important learning signals for self-supervised adaptation. When faced with CIFAR-10.1, we see poor performance from the pairwise cross entropy based adaptation method. On the original CIFAR-10 test set and CIFAR-10- C, the ablations perform nearly identically and uniformly worse than MEMO. To further test the $\ell _ { \mathrm { C E } }$ ablation, which is the stronger of the two ablations, we also evaluate it on the ImageNet test sets for the $\mathrm { R V T ^ { * } }$ -small model. We find that, similarly, minimizing conditional entropy generally improves performance compared to the baseline evaluation. MEMO is more performant for ImageNet-C and ImageNet-R. Adaptation via $\ell _ { \mathrm { C E } }$ performs slightly better for ImageNet-A, though for this problem and model, TTA is still the best method. Thus, MEMO results in relatively small, but consistent, performance gains compared to only maximizing confidence on the augmentations.
153
+
154
+ Number of augmentations. In Figure 3, we analyze the $\%$ test error of MEMO adaptation on ImageNet-R as a function of the efficiency of adaptation, measured in seconds per evaluation. We achieve various tradeoffs by varying the number of augmented copies $B \ =$ $\{ 1 , 2 , 4 , 8 , 1 6 , 3 2 , 6 4 , 1 2 8 \}$ . We note that small values of $B$ such as 4 and 8 can already provide significant performance gains, thus a practical tradeoff between efficiency and accuracy is possible.
155
+
156
+ For large $B$ , the wall clock time is dominated by computing the augmentations. For the baseline ResNet-50 model, single point BN adaptation requires an average of 0.0252 seconds per test point. TTA and MEMO with $B = 6 4$ are much slower – 0.7742 and 0.9746 seconds, respectively, per test point – but can be made significantly more efficient by using $B = 4$ augmented samples – 0.0631 and 0.1037 seconds, respectively. In our implementation, we do not compute augmentations in parallel, though in principle this is possible for AugMix and should drastically improve efficiency overall. These experiments used four Intel Xeon Skylake 6130 CPUs and one NVIDIA TITAN RTX GPU.
157
+
158
+ # 5 Discussion
159
+
160
+ We presented MEMO, a method for test time robustification again distribution shift via adaptation and augmentation. MEMO does not require access or changes to the model training procedure and is thus broadly applicable for a wide range of model architectures pretrained in a number of different ways. Furthermore, MEMO adapts at test time using single test inputs, thus it does not assume access to multiple test points as in several recent methods for test time adaptation $\mathbb { H O } \mathbb { H } \mathbb { H }$ . On a range of CIFAR-10 and ImageNet distribution shift benchmarks, and for ResNet, vision transformer, and, to an extent, ResNext models, MEMO consistently improves performance at test time and achieves several new state-of-the-art results for these models in the single test point setting.
161
+
162
+ Inference via MEMO is more computationally expensive than standard model inference due to its augmentation and adaptation procedure – though, as the experiments above show, more favorable tradeoffs between efficiency and accuracy are possible with smaller values of $B$ , the number of augmentations per test point. One interesting direction for future work is to develop techniques for selectively determining when to adapt the model in order to achieve more efficient inference. For example, with well calibrated models $[ \mathbb { 1 0 } ]$ , we may run simple “feedforward” inference when the prediction confidence is over a certain threshold, thus achieving better efficiency. Additionally, it would be interesting to explore MEMO in the test setting where the model is allowed to continually adapt as more test data is observed. In our preliminary experiments in this setting, MEMO tended to lead to degenerate solutions, e.g., the model predicting a constant label with maximal confidence regardless of the input. This failure mode may potentially be rectified by carefully choosing which parameters to adapt, such as only adapting the parameters in BN layers $\boxed { \boxplus 6 }$ , or regularizing the model such that it does not change too drastically from the pretrained model [26].
163
+
164
+ # Acknowledgments and Disclosure of Funding
165
+
166
+ We thank members of the Robotic AI and Learning Lab and Berkeley AI Research for helpful discussions and feedback. MZ was supported in part by an NDSEG fellowship. CF is a CIFAR fellow. This research was partially supported by ARL DCIST CRA W911NF-17-2-0181 and ARO W911NF-21-1-0097.
167
+
168
+ # References
169
+
170
+ [1] F. Alet, M. Bauza, K. Kawaguchi, N. Kuru, T. Lozano-Pérez, and L. Kaelbling. Tailoring: Encoding inductive biases by optimizing unsupervised objectives at prediction time. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
171
+ [2] A. Ashukha, A. Lyzhov, D. Molchanov, and D. Vetrov. Pitfalls of in-domain uncertainty estimation and ensembling in deep learning. In International Conference on Learning Representations (ICLR), 2020.
172
+ [3] A. Bartler, A. Bühler, F. Wiewel, M. Döbler, and B. Yang. MT3: Meta test-time training for self-supervised test-time adaption. In International Conference on Artificial Intelligence and Statistics (AISTATS), 2022.
173
+ [4] A. Ben-Tal, D. den Hertog, A. De Waegenaere, B. Melenberg, and G. Rennen. Robust solutions of optimization problems affected by uncertain probabilities. Management Science, 2013. [5] G. Blanchard, G. Lee, and C. Scott. Generalizing from several related classification tasks to a new unlabeled sample. In Advances in Neural Information Processing Systems (NIPS), 2011. [6] G. Csurka. Domain adaptation for visual applications: A comprehensive survey. arXiv preprint arXiv:1702.05374, 2017. [7] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit, and N. Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021. [8] Y. Grandvalet and Y. Bengio. Semi-supervised learning by entropy minimization. In Advances in Neural Information Processing Systems (NIPS), 2005. [9] I. Gulrajani and D. Lopez-Paz. In search of lost domain generalization. In International Conference on Learning Representations (ICLR), 2021.
174
+ [10] C. Guo, G. Pleiss, Y. Sun, and K. Weinberger. On calibration of modern neural networks. In International Conference on Machine Learning (ICML), 2017.
175
+ [11] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
176
+ [12] D. Hendrycks and T. Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations (ICLR), 2019.
177
+ [13] D. Hendrycks, N. Mu, E. Cubuk, B. Zoph, J. Gilmer, and B. Lakshminarayanan. AugMix: A simple data processing method to improve robustness and uncertainty. In International Conference on Learning Representations (ICLR), 2020.
178
+ [14] D. Hendrycks, S. Basart, N. Mu, S. Kadavath, F. Wang, E. Dorundo, R. Desai, T. Zhu, S. Parajuli, M. Guo, D. Song, J. Steinhardt, and J. Gilmer. The many faces of robustness: A critical analysis of out-of-distribution generalization. In IEEE International Conference on Computer Vision (ICCV), 2021.
179
+ [15] D. Hendrycks, K. Zhao, S. Basart, J. Steinhardt, and D. Song. Natural adversarial examples. In Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
180
+ [16] W. Hu, G. Niu, I. Sato, and M. Sugiyama. Does distributionally robust supervised learning give robust classifiers? In International Conference on Machine Learning (ICML), 2018.
181
+ [17] Y. Huang, J. Gornet, S. Dai, Z. Yu, T. Nguyen, D. Tsao, and A. Anandkumar. Neural networks with recurrent generative feedback. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
182
+ [18] Y. Iwasawa and Y. Matsuo. Test-time classifier adjustment module for model-agnostic domain generalization. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
183
+ [19] A. Kaku, S. Mohan, A. Parnandi, H. Schambra, and C. Fernandez-Granda. Be like water: Robustness to extraneous variables via adaptive feature normalization. arXiv preprint arXiv:2002.04019, 2020.
184
+ [20] D. Kingma and J. Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015.
185
+ [21] P. Koh, S. Sagawa, H. Marklund, S. Xie, M. Zhang, A. Balsubramani, W. Hu, M. Yasunaga, R. Phillips, I. Gao, T. Lee, E. David, I. Stavness, W. Guo, B. Earnshaw, I. Haque, S. Beery, J. Leskovec, A. Kundaje, E. Pierson, S. Levine, C. Finn, and P. Liang. WILDS: A benchmark of in-the-wild distribution shifts. In International Conference on Machine Learning (ICML), 2021.
186
+ [22] A. Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
187
+ [23] A. Krizhevsky, I. Sutskever, and G. Hinton. ImageNet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems (NIPS), 2012.
188
+ [24] B. Li, F. Wu, S. Lim, S. Belongie, and K. Weinberger. On feature normalization and data augmentation. In Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
189
+ [25] Y. Li, N. Wang, J. Shi, J. Liu, and X. Hou. Revisiting batch normalization for practical domain adaptation. In International Conference on Learning Representations Workshop (ICLRW), 2017.
190
+ [26] Y. Liu, P. Kothari, B. van Delft, B. Bellot-Gurlet, T. Mordan, and A. Alahi. $\mathrm { T T T } { + } { + }$ : When does self-supervised test-time training fail or thrive? In Advances in Neural Information Processing Systems (NeurIPS), 2021.
191
+ [27] I. Loshchilov and F. Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019.
192
+ [28] D. Mahajan, R. Girshick, V. Ramanathan, K. He, M. Paluri, Y. Li, A. Bharambe, and L. van der Maaten. Exploring the limits of weakly supervised pretraining. In European Conference on Computer Vision (ECCV), 2018.
193
+ [29] C. Mao, M. Chiquier, H. Wang, J. Yang, and C. Vondrick. Adversarial attacks are reversible with natural supervision. In IEEE International Conference on Computer Vision (ICCV), 2021.
194
+ [30] X. Mao, G. Qi, Y. Chen, X. Li, R. Duan, S. Ye, Y. He, and H. Xue. Towards robust vision transformer. In Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
195
+ [31] D. Molchanov, A. Lyzhov, Y. Molchanova, A. Ashukha, and D. Vetrov. Greedy policy search: A simple baseline for learnable test-time augmentation. In Conference on Uncertainty in Artificial Intelligence (UAI), 2020.
196
+ [32] K. Muandet, D. Balduzzi, and B. Schölkopf. Domain generalization via invariant feature representation. In International Conference on Machine Learning (ICML), 2013.
197
+ [33] Z. Nado, S. Padhy, D. Sculley, A. D’Amour, B. Lakshminarayanan, and J. Snoek. Evaluating prediction-time batch normalization for robustness under covariate shift. arXiv preprint arXiv:2006.10963, 2020.
198
+ [34] A. Orhan. Robustness properties of Facebook’s ResNeXt WSL models. arXiv preprint arXiv:1907.07640, 2019.
199
+ [35] X. Peng, B. Usman, N. Kaushik, J. Hoffman, D. Wang, and K. Saenko. VisDA: The visual domain adaptation challenge. arXiv preprint arXiv:1710.06924, 2017.
200
+ [36] J. Quiñonero Candela, M. Sugiyama, A. Schwaighofer, and N. Lawrence. Dataset Shift in Machine Learning. The MIT Press, 2009.
201
+ [37] B. Recht, R. Roelofs, L. Schmidt, and V. Shankar. Do CIFAR-10 classifiers generalize to CIFAR-10? arXiv preprint arXiv:1806.00451, 2018.
202
+ [38] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, A. Berg, and F. Li. Imagenet large scale visual recognition challenge. International Journal of Computer Vision (IJCV), 2015.
203
+ [39] S. Sagawa, P. Koh, T. Hashimoto, and P. Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. In International Conference on Learning Representations (ICLR), 2020.
204
+ [40] S. Schneider, E. Rusak, L. Eck, O. Bringmann, W. Brendel, and M. Bethge. Improving robustness against common corruptions by covariate shift adaptation. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
205
+ [41] H. Shimodaira. Improving predictive inference under covariate shift by weighting the loglikelihood function. Journal of Statistical Planning and Inference (JSPI), 2000.
206
+ [42] C. Shorten and T. Khoshgoftaar. A survey on image data augmentation for deep learning. Journal of Big Data, 2019.
207
+ [43] P. Sivaprasad and F. Fleuret. Test time adaptation through perturbation robustness. arXiv preprint arXiv:2110.10232, 2021.
208
+ [44] Y. Sun, X. Wang, Z. Liu, J. Miller, A. Efros, and M. Hardt. Test-time training with selfsupervision for generalization under distribution shifts. In International Conference on Machine Learning (ICML), 2020.
209
+ [45] T. Varsavsky, M. Orbes-Arteaga, C. Sudre, M. Graham, P. Nachev, and M. Cardoso. Test-time unsupervised domain adaptation. arXiv preprint arXiv:2010.01926, 2020.
210
+ [46] D. Wang, E. Shelhamer, S. Liu, B. Olshausen, and T. Darrell. Tent: Fully test-time adaptation by entropy minimization. In International Conference on Learning Representations (ICLR), 2021.
211
+ [47] G. Wilson and D. Cook. A survey of unsupervised deep domain adaptation. ACM Transactions on Intelligent Systems and Technology (TIST), 2020.
212
+ [48] E. Wong, L. Rice, and J. Kolter. Fast is better than free: Revisiting adversarial training. In International Conference on Learning Representations (ICLR), 2020.
213
+ [49] Y. Wu and K. He. Group normalization. In European Conference on Computer Vision (ECCV), 2018.
214
+ [50] S. Xie, R. Girshick, P. Dollár, Z. Tu, and K. He. Aggregated residual transformations for deep neural networks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
215
+ [51] D. Yin, R. Lopes, J. Shlens, E. Cubuk, and J. Gilmer. A Fourier perspective on model robustness in computer vision. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
216
+ [52] M. Zhang, H. Marklund, A. Gupta, S. Levine, and C. Finn. Adaptive risk minimization: Learning to adapt to domain shift. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
217
+
218
+ # Checklist
219
+
220
+ 1. For all authors...
221
+
222
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
223
+ (b) Did you describe the limitations of your work? [Yes] See Section 5.
224
+ (c) Did you discuss any potential negative societal impacts of your work? [No]
225
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
226
+
227
+ 2. If you are including theoretical results...
228
+
229
+ (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]
230
+
231
+ 3. If you ran experiments...
232
+
233
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See supplementary material.
234
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix A.
235
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
236
+ (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]
237
+
238
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
239
+
240
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
241
+ (b) Did you mention the license of the assets? [No] All assets are publicly and freely available.
242
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
243
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
244
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
245
+
246
+ 5. If you used crowdsourcing or conducted research with human subjects...
247
+
248
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
249
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
250
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/_XNtisL32jv/_XNtisL32jv.md ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TEMPORAL EFFICIENT TRAINING OF SPIKINGNEURAL NETWORK VIA GRADIENT RE-WEIGHTING
2
+
3
+ Shikuang Deng1,2, Yuhang $\mathbf { L i ^ { 3 } }$ , Shanghang Zhang4 & Shi $\mathbf { G u } ^ { 1 , 2 , 5 \boxtimes }$
4
+
5
+ 1University of Electronic Science and Technology of China,
6
+ 2Shenzhen Institute for Advanced Study, UESTC
7
+ 3Yale University, 4Peking University ,5Peng Cheng Laboratory
8
+ dengsk119@std.uestc.edu.cn, yuhang.li@yale.edu, gus@uestc.edu.cn
9
+
10
+ # ABSTRACT
11
+
12
+ Recently, brain-inspired spiking neuron networks (SNNs) have attracted widespread research interest because of their event-driven and energy-efficient characteristics. Still, it is difficult to efficiently train deep SNNs due to the nondifferentiability of its activation function, which disables the typically used gradient descent approaches for traditional artificial neural networks (ANNs). Although the adoption of surrogate gradient (SG) formally allows for the back-propagation of losses, the discrete spiking mechanism actually differentiates the loss landscape of SNNs from that of ANNs, failing the surrogate gradient methods to achieve comparable accuracy as for ANNs. In this paper, we first analyze why the current direct training approach with surrogate gradient results in SNNs with poor generalizability. Then we introduce the temporal efficient training (TET) approach to compensate for the loss of momentum in the gradient descent with SG so that the training process can converge into flatter minima with better generalizability. Meanwhile, we demonstrate that TET improves the temporal scalability of SNN and induces a temporal inheritable training for acceleration. Our method consistently outperforms the SOTA on all reported mainstream datasets, including CIFAR-10/100 and ImageNet. Remarkably on DVS-CIFAR10, we obtained $8 3 \%$ top-1 accuracy, over $\bar { 1 0 \% }$ improvement compared to existing state of the art. Codes are available at https://github.com/Gus-Lab/temporal_ efficient_training.
13
+
14
+ # 1 INTRODUCTION
15
+
16
+ The advantages of Spiking neuron networks (SNNs) lie in their energy-saving and fast-inference computation when embedded on neuromorphic hardware such as TrueNorth (DeBole et al., 2019) and Loihi (Davies et al., 2018). Such advantages originate from the biology-inspired binary spike transmitted mechanism, by which the networks avoid multiplication during inference. On the other hand, this mechanism also leads to difficulty in training very deep SNNs from scratch because the non-differentiable spike transmission hinders the powerful back-propagation approaches like gradient descents. Recently, many studies on converting artificial neuron networks (ANNs) to SNNs have demonstrated SNNs’ comparable power in feature representation as ANNs (Han & Roy, 2020; Deng & Gu, 2020; Li et al., 2021a). Nevertheless, it is commonly agreed that the direct training method for high-performance SNN is still crucial since it distinguishes SNNs from converted ANNs, especially on neuromorphic datasets.
17
+
18
+ The output layer’s spike frequency or the average membrane potential increment is commonly used as inference indicators in SNNs (Shrestha & Orchard, 2018; Kim et al., 2019). The current standard direct training (SDT) methods regard the SNN as RNN and optimize inference indicators’ distribution (Wu et al., 2018). They adopt surrogate gradients (SG) to relieve the non-differentiability (Lee et al., 2016; Wu et al., 2018; Zheng et al., 2021). However, the gradient descent with SG does not match with the loss landscape in SNN and is easy to get trapped in a local minimum with low generalizability. Although using suitable optimizers and weight decay help ease this problem, the performance of deep SNNs trained from scratch still suffers a big deficit compared to that of ANNs Deng et al. (2020). Another training issue is the memory and time consumption, which increases linearly with the simulation time. Rathi & Roy (2020) initializes the target network by a converted SNN to shorten the training epochs, indicating the possibility of high-performance SNN with limited activation time. The training problem due to the non-differentiable activation function has become the main obstruction of spiking neural network development.
19
+
20
+ ![](images/1c0df3e5e42eb5f12b364ae3e1b86c171367176d7d8e201b7cccf8c9ba08687d.jpg)
21
+ Figure 1: Workflow of temporal efficient training (TET). To obtain a more generalized SNN, we modify the optimization target to adjust each moment’s output distribution.
22
+
23
+ In this work, we examine the limitation of the traditional direct training approach with SG and propose the temporal efficient training (TET) algorithm. Instead of directly optimizing the integrated potential, TET optimizes every moment’s pre-synaptic inputs. As a result, it avoids the trap into local minima with low prediction error but a high second-order moment. Furthermore, since the TET applies optimization on each time point, the network naturally has more robust time scalability. Based on this characteristic, we propose the time inheritance training (TIT), which reduces the training time by initializing the SNN with a smaller simulation length. With the help of TET, the performance of SNNs has improved on both static datasets and neuromorphic datasets. Figure 1 depicts the workflow of our approach.
24
+
25
+ The following summarizes our main contributions:
26
+
27
+ • We analyze the problem of training SNN with SG and propose the TET method, a new loss and gradient descent regime that succeeds in obtaining more generalizable SNNs. • We analyze the feasibility of TET and picture the loss landscape under both the SDT and TET setups to demonstrate TET’s advantage in better generalization. • Our sufficient experiments on both static datasets and neuromorphic datasets prove the effectiveness of the TET method. Especially on DVS-CIFAR10, we report $8 3 . 1 \bar { 7 } \%$ top-1 accuracy for the first time, which is over $1 0 \%$ better than the current state-of-the-art result.
28
+
29
+ # 2 RELATED WORK
30
+
31
+ In recent years, SNNs have developed rapidly and received more and more attention from the research community. However, lots of challenging problems remain to be unsolved. In general, most works on SNN training have been carried out in two strategies: ANN-to-SNN conversion and direct training from scratch.
32
+
33
+ ANN-to-SNN Conversion. Conversion approaches avoid the training problem by trading high accuracy through high latency. They convert a high-performing ANN to SNN and adjust the SNN parameters w.r.t the ANN activation value layer-by-layer (Diehl et al., 2015; 2016). Some special techniques have been proposed to reduce the inference latency, such as the subtraction mechanism (Rueckauer et al., 2016; Han et al., 2020), robust normalization Rueckauer et al. (2016), spike-norm (Sengupta et al., 2018), and channel-wise normalization (Kim et al., 2019). Recently, Deng & Gu (2020) decompose the conversion error to each layer and reduce it by bias shift. Li et al. (2021a) suggest using adaptive threshold and layer-wise calibration to obtain high-performance SNNs that require a simulation length of less than 50. However, converted methods significantly extend the inference latency, and they are not suitable for neuromorphic data (Deng et al., 2020).
34
+
35
+ Direct training. In this area, SNNs are regarded as special RNNs and training with BPTT (Neftci et al., 2019). On the backpropagation process, The non-differentiable activation term is replaced with a surrogate gradient (Lee et al., 2016). Compared with ANN-to-SNN conversion, direct training achieves high accuracy with few time steps but suffers more training costs (Deng et al., 2020). Several studies suggest that surrogate gradient (SG) is helpful to obtain high-performance SNNs on both static datasets and neuromorphic datasets (Wu et al., 2019; Shrestha & Orchard, 2018; Li et al., 2021b). On the backpropagation process, SG replaces the Dirac function with various shapes of curves. Exceptionally, Wu et al. (2018) first propose the STBP method and train SNNs on the ANN programming platform, which significantly promotes direct training development. Zheng et al. (2021) further proposes the tdBN algorithm to smooth the loss function and first realize training a large-scale SNN on ImageNet. Zhang & Li (2020) proposes TSSL-BP to break down error backpropagation across two types of inter-neuron and intra-neuron dependencies and achieve low-latency and high accuracy SNNs. Recently, Yang et al. (2021) designed a neighborhood aggregation (NA) method to use the multiple perturbed membrane potential waveforms in the neighborhood to compute the finite difference gradients and guide the weight updates. They significantly decrease the required training iterations and improve the SNN performance.
36
+
37
+ # 3 PRELIMINARY
38
+
39
+ # 3.1 ITERATIVE LIF MODEL
40
+
41
+ We adopt the Leaky Integrate-and-Fire (LIF) model and translate it to an iterative expression with the Euler method (Wu et al., 2019). Mathematically, the membrane potential is updated as
42
+
43
+ $$
44
+ \begin{array} { r } { \pmb { u } ( t + 1 ) = \tau \pmb { u } ( t ) + \pmb { I } ( t ) , } \end{array}
45
+ $$
46
+
47
+ where $\tau$ is the constant leaky factor, ${ \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf { } \mathbf \mathbf \mathbf \Psi \Psi \mathbf { \mathbf } \mathbf \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf $ is the membrane potential at time $t$ , and $\mathbf { } I ( t )$ denotes the pre-synaptic inputs, which is the product of synaptic weight $\mathbf { W }$ and spiking input ${ \mathbf { } } x ( t )$ . Given a specific threshold $V _ { t h }$ , the neuron fires a spike and ${ \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \Psi \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf \Psi \Psi \mathbf \Psi \mathbf { \mathbf } \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf $ reset to 0 when the ${ \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \Psi \mathbf \Psi \mathbf { \Psi \mathbf } \mathbf \mathbf \Psi \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf $ exceeds the threshold. So the firing function and hard reset mechanism can be described as
48
+
49
+ $$
50
+ \pmb { a } ( t + 1 ) = \pmb { \Theta } ( \pmb { u } ( t + 1 ) - V _ { t h } )
51
+ $$
52
+
53
+ $$
54
+ \pmb { u } ( t + 1 ) = \pmb { u } ( t + 1 ) \cdot ( 1 - \pmb { a } ( t + 1 ) ) ,
55
+ $$
56
+
57
+ where $\Theta$ denotes the Heaviside step function. The output spike $\mathbf { \delta } \mathbf { \ } \mathbf { \em a } ( t + 1 )$ will become the post synaptic spike and propagate to the next layer. In this study, we set the starting membrane $\pmb { u } ( 0 )$ to 0, the threshold $V _ { t h }$ to 1, and the leaky factor $\tau$ to 0.5 for all experiments.
58
+
59
+ The last layer’s spike frequency is typically used as the final classification index. However, adopting the LIF model on the last layer will lose information on the membrane potential and damage the performance, especially on complex tasks (Kim et al., 2019). Instead, we integrate the pre-synaptic inputs $\mathbf { } I ( t )$ with no decay or firing (Rathi & Roy, 2020; Fang et al., 2021). Finally, we set the average membrane potential as the classification index and calculate the cross-entropy loss for training.
60
+
61
+ # 3.2 SURROGATE GRADIENT
62
+
63
+ Following the concept of direct training, we regard the SNN as RNN and calculate the gradients through spatial-temporal backpropagation (STBP) (Wu et al., 2018):
64
+
65
+ $$
66
+ \frac { \partial L } { \partial \mathbf { W } } = \sum _ { t } \frac { \partial L } { \partial \pmb { a } ( t ) } \frac { \partial \pmb { a } ( t ) } { \partial \pmb { a } ( t ) } \frac { \partial \pmb { u } ( t ) } { \partial \pmb { I } ( t ) } \frac { \partial \pmb { I } ( t ) } { \partial \mathbf { W } } ,
67
+ $$
68
+
69
+ where the term $\frac { \partial \pmb { a } ( t ) } { \partial \pmb { u } ( t ) }$ is the gradient of the non-differentiability step function involving the derivative of Dirac’s $\delta$ -function that is typically replaced by surrogate gradients with a derivable curve. So far,
70
+
71
+ there are various shapes of surrogate gradients, such as rectangular (Wu et al., 2018; 2019), triangle (Esser et al., 2016; Rathi & Roy, 2020), and exponential (Shrestha & Orchard, 2018) curve. In this work, we choose the surrogate gradients shaped like triangles. Mathematically, it can describe as
72
+
73
+ $$
74
+ \frac { \partial \pmb { a } ( t ) } { \partial \pmb { u } ( t ) } = \frac { 1 } { \gamma ^ { 2 } } \mathrm { m a x } ( 0 , \gamma - | \pmb { u } ( t ) - V _ { t h } | ) ,
75
+ $$
76
+
77
+ where the $\gamma$ denotes the constraint factor that determines the sample range to activate the gradient.
78
+
79
+ # 3.3 BATCH NORMALIZATION FOR SNN
80
+
81
+ Batch Normalization (BN) (Ioffe & Szegedy, 2015) is beneficial to accelerate training and increase performance since it can smooth the loss landscape during training (Santurkar et al., 2018). Zheng et al. (2021) modified the forward time loop form and proposed threshold-dependent Batch Normalization (tdBN) to normalize the pre-synaptic inputs $\pmb { I }$ in both spatial and temporal paradigms so that the BN can support spatial-temporal input. We adopt this setup with the extension of the time dimension to batch dimension 1. In the inference process, the BN layer will be merged into the pre-convolutional layer, thus the inference rule of SNN remain the same but with modified weight:
82
+
83
+ $$
84
+ \hat { \mathbf { W } } \gets \mathbf { W } \frac { \gamma } { \alpha } , \hat { \pmb { b } } \gets \beta + ( \pmb { b } - \mu ) \frac { \gamma } { \alpha } ,
85
+ $$
86
+
87
+ where $\mu , \alpha$ are the running mean and standard deviation on both spatial and temporal paradigm, $\gamma , \beta$ are the affine transformation parameters, and $\mathbf { W } , b$ are the parameters of the pre-convolutional layer.
88
+
89
+ # 4 METHODOLOGY
90
+
91
+ # 4.1 FORMULA OF TRAINING SNN WITH SURROGATE GRADIENTS
92
+
93
+ Standard Direct Training. We use $O ( t )$ to represent pre-synaptic input $\mathbf { } I ( t )$ of the output layer and calculate the cross-entropy loss. The loss function of standard direct training ${ \mathcal { L } } _ { \mathrm { S D T } }$ is:
94
+
95
+ $$
96
+ \mathcal { L } _ { \mathrm { S D T } } = \mathcal { L } _ { \mathrm { C E } } \big ( \frac { 1 } { T } \sum _ { t = 1 } ^ { T } O ( t ) , { \pmb y } \big ) ,
97
+ $$
98
+
99
+ where $T$ is the total simulation time, $\mathcal { L } _ { \mathrm { C E } }$ denotes the cross-entropy loss, and $\textbf { { y } }$ represents the target label. Following the chain rule, we obtain the gradient of $\mathbf { W }$ with softmax $S ( \cdot )$ inference function :
100
+
101
+ $$
102
+ \frac { \partial \mathcal { L } _ { \mathrm { S D T } } } { \partial { \bf W } } = \frac { 1 } { T } \sum _ { t = 1 } ^ { T } [ S ( O _ { \mathrm { m e a n } } ) - \hat { \pmb { y } } ] \frac { \partial O ( t ) } { \partial { \bf W } } ,
103
+ $$
104
+
105
+ where $O _ { \mathrm { m e a n } }$ denotes the average of the output $O ( t )$ over time, and $\hat { y }$ is the one-hot coding of $\textbf { { y } }$ .
106
+
107
+ Temporal Efficient Training. In this section, we come up with a new kind of loss function ${ \mathcal { L } } _ { \mathrm { T E T } }$ to realize temporal efficient training (TET). It constrains the output (pre-synaptic inputs) at each moment to be close to the target distribution. It is described as:
108
+
109
+ $$
110
+ \mathcal { L } _ { \mathrm { T E T } } = \frac { 1 } { T } \cdot \sum _ { t = 1 } ^ { T } \mathcal { L } _ { \mathrm { C E } } [ O ( t ) , { \pmb y } ] .
111
+ $$
112
+
113
+ Recalculate the gradient of weights under the loss function ${ \mathcal { L } } _ { \mathrm { T E T } }$ , and we have:
114
+
115
+ $$
116
+ \frac { \partial \mathcal { L } _ { \mathrm { T E T } } } { \partial { \bf W } } = \frac { 1 } { T } \sum _ { t = 1 } ^ { T } [ S ( \pmb { O } ( t ) ) - \pmb { \hat { y } } ] \cdot \frac { \partial \pmb { O } ( t ) } { \partial { \bf W } } .
117
+ $$
118
+
119
+ # 4.2 CONVERGENCE OF GRADIENT DESCENT FOR SDT V.S. TET
120
+
121
+ In the case of SDT, the gradient consists of two parts, the error term $( S ( O _ { \mathrm { m e a n } } ) - \hat { \pmb y } )$ and the partial derivative of output $\partial { \cal O } \bar { ( } t ) / \partial { \bf W }$ . When the training process reaches near a local minimum, the term $( S ( O _ { \mathrm { m e a n } } ) - \hat { \pmb y } )$ approximates 0 for all $t = 1 , . . . , T$ , ignorant of the term $\partial O ( t ) / \partial \mathbf { W }$ . For traditional ANNs, the accumulated momentum may help get out of the local minima (e.g. saddle point) that typically implies bad generalizability (Kingma & Ba, 2014; Kidambi et al., 2018). However, when the SNN is trained with surrogate gradients, the accumulated momentum could be extremely small, considering the mismatch of gradients and losses. The fact that the activation function is a step one while the SG is bounded with integral constraints. This mismatch dissipates the momentum around a local minimum and stops the SDT from searching for a flatter minimum that may suggest better generalizability.
122
+
123
+ In the case of TET, this issue of mismatch is relieved by reweighting the contribution of $\partial { \cal O } ( t ) / \partial { \bf W }$ . Indeed, considering the fact that the first term $( S ( O ( t ) ) - \hat { { \mathbf { y } } } )$ is impossible to be 0 at every moment of SNN since the early output accuracy on the training set is not $1 0 0 \%$ . So TET needs the second term $\partial { \cal O } ( t ) / \partial { \bf W }$ close to 0 to make the ${ \mathcal { L } } _ { \mathrm { T E T } }$ convergence. This mechanism increases the norm of gradients around sharp local minima and drives the TET to search for a flat local minimum where the disturbance of weight does not cause a huge change in $O ( t )$ .
124
+
125
+ Further, to ensure that the convergence with TET implies the convergence of SDT, we prove the following lemma:
126
+
127
+ Lemma 4.1. $\mathcal { L } _ { S D T }$ is upper bounded by $\mathcal { L } _ { T E T }$
128
+
129
+ Proof. Suppose $O _ { i } ( t )$ and $\hat { y } _ { i }$ denote the i-th component of $O ( t )$ and $\hat { y }$ , respectively. Expand Eqn.9, we have:
130
+
131
+ $$
132
+ \begin{array} { r l } & { \mathcal { L } _ { \mathrm { T E T } } = - \displaystyle \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \sum _ { i = 1 } ^ { n } \hat { y } _ { i } \log S ( \boldsymbol { O } _ { i } ( t ) ) = - \frac { 1 } { T } \sum _ { i = 1 } ^ { n } \hat { y } _ { i } \log ( \prod _ { t = 1 } ^ { T } S ( \boldsymbol { O } _ { i } ( t ) ) ) } \\ & { \quad \quad \quad = - \displaystyle \sum _ { i = 1 } ^ { n } \hat { y } _ { i } \log ( \prod _ { t = 1 } ^ { T } S ( \boldsymbol { O } _ { i } ( t ) ) ) ^ { \frac { 1 } { T } } \geq - \sum _ { i = 1 } ^ { n } \hat { y } _ { i } \log ( \frac { 1 } { T } \sum _ { t = 1 } ^ { T } S ( \boldsymbol { O } _ { i } ( t ) ) ) } \\ & { \quad \quad \quad \geq - \displaystyle \sum _ { i = 1 } ^ { n } \hat { y } _ { i } \log ( S ( \frac { 1 } { T } \sum _ { t = 1 } ^ { T } O _ { i } ( t ) ) ) = \mathcal { L } _ { \mathrm { S D T } } , } \end{array}
133
+ $$
134
+
135
+ where the first inequality is given by the Arithmetic Mean-Geometric Mean Inequality, and the second one is given by Jensen Inequality since the softmax function is convex. As a corollary, once the ${ \mathcal { L } } _ { \mathrm { T E T } }$ gets closed to zero, the original loss function ${ \mathcal { L } } _ { \mathrm { S D T } }$ also approaches zero. □
136
+
137
+ Furthermore, the network output $O ( t )$ at a particular time point may be a particular outlier that dramatically affects the total output since the output of the SNN has the same weight at every moment under the rule of integration. Thus it is necessary to add a regularization term like $\mathcal { L } _ { \mathrm { M S E } }$ loss to confine each moment’s output to reduce the risk of outliers:
138
+
139
+ $$
140
+ \mathcal { L } _ { \mathrm { M S E } } = \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \mathrm { M S E } ( \mathbf { O } ( t ) , \phi ) ,
141
+ $$
142
+
143
+ where $\phi$ is a constant used to regularize the membrane potential distribution. And we set $\phi = V _ { t h }$ in our experiments. In practice, we use a hyperparameter $\lambda$ to adjust the proportion of the regular term, we have:
144
+
145
+ $$
146
+ \mathcal { L } _ { \mathrm { T O T A L } } = ( 1 - \lambda ) \mathcal { L } _ { \mathrm { T E T } } + \lambda \mathcal { L } _ { \mathrm { M S E } } .
147
+ $$
148
+
149
+ It is worth noting that we only changed the loss function in the training process and did not change SNN’s inference rules in the testing phase for a fair comparison. This algorithm is detailed in Algo.1.
150
+
151
+ <table><tr><td>Algorithm1:Temporalefficienttrainingforoneepoch Input: SNN model; Simulation length: T; Threshold: Vth; Training dataset; Validation dataset;</td></tr><tr><td>total training iteration in one epoch: Itrain; total validation iteration in one epoch: Ival</td></tr><tr><td>for all i= 1,2,...Itrain iteration do Get mini-batch training data,and class label: Yi;</td></tr><tr><td>Compute the SNN output Oi(t) of eatch time step;</td></tr><tr><td>Calculate loss function: LTOTAL = (1-λ)LTET + 入LMSE =</td></tr><tr><td>(1-λ):¹∑t=1LcE(O²(t),Yi)+&gt;·¹∑t=1 MSE(Oi(t),𝜙);</td></tr><tr><td>Backpropagation and update model parameters;</td></tr><tr><td>end for all i= 1,2,..Ival iteration do</td></tr><tr><td>Get mini-batch validation data,and class label: Yi;</td></tr><tr><td>T</td></tr><tr><td>Compute the SNN average output Omean = ∑T=1 O(t) over al time step;</td></tr><tr><td>Compare the clasification factor Omean and Yi for classification; end</td></tr></table>
152
+
153
+ # 4.3 TIME INHERITANCE TRAINING
154
+
155
+ SNN demands simulation length long enough to obtain a satisfying performance, but the training time consumption will increase linearly as the simulation length grows. So how to shorten the training time is also an essential problem in the direct training field. Traditional loss function ${ \mathcal { L } } _ { \mathrm { S D T } }$ only optimizes the whole network output under a specific $T$ , so its temporal scalability is poor. Unlike the standard training, TET algorithm optimizes each moment’s output, enabling us to extend the simulation time naturally. We introduce Time Inheritance Training (TIT) to alleviate the training time problem. We first use long epochs to train an SNN with a short simulation time T, e.g., 2. Then, we increase the simulation time to the target value and retrain with short epochs. We discover that TIT performs better than training from scratch on accuracy and significantly saves the training time. Assuming that training an SNN with simulation length $T = 1$ cost $t s$ time per epoch, the SNN needs 300 epochs to train from scratch, and the TIT needs 50 epochs for finetuning. So we need $1 8 0 0 t s$ time to train an SNN with $T = 6$ from scratch, but following the TIT pipeline with the initial $T = 2$ only requires $9 0 0 t s$ . As a result, the TIT can reduce the training time cost by half.
156
+
157
+ # 5 EXPERIMENTS
158
+
159
+ We validate our proposed TET algorithm and compare it with existing works on both static and neuromorphic datasets. The network architectures in this paper include ResNet-19 (Zheng et al., 2021), Spiking-ResNet34 (Zheng et al., 2021), SEW-ResNet34 (Fang et al., 2021), SNN-5, and VGGSNN. SNN-5 (16C3-64C5-AP2-128C5-AP2-256C5-AP2-512C3-AP2-FC) is a simple convolutional SNN suitable for multiple runs to discover statistical rules (Figure A. 7). The architecture of VGGSNN (64C3-128C3-AP2-256C3-256C3-AP2-512C3-512C3-AP2-512C3-512C3-AP2- FC) is based on VGG11 with two fully connected layers removed as we found that additional fully connected layers were unnecessary for neuromorphic datasets.
160
+
161
+ # 5.1 MODEL VALIDATION AND ABLATION STUDY
162
+
163
+ Effectiveness of TET over SDT with SG. We first examine whether the mismatch between SG and loss causes the convergence problem. For this purpose, we set the simulation length to 4 and change the spike function $\Theta$ in Eqn.2 to Sigmoid $\sigma ( \bar { k } \cdot \mathrm { { i n p u t } } )$ . We find that the TET and SDT achieved similar accuracy (Table 2) when $k = 1 , 1 0 , 2 0$ . This indicates that both TET and SDT work when the gradient and loss function match each other. Next, we compare the results training with ${ \mathcal { L } } _ { \mathrm { S D T } }$ and ${ \mathcal { L } } _ { \mathrm { T E T } }$ on SNNs (ResNet-19 on CIFAR100) training with surrogate gradient for three runs. As shown in Table 1, our proposed new TET training strategy dramatically increases the accuracy by $3 . 2 5 \%$ when the simulation time is 4 and $3 . 5 3 \%$ when the simulation time is 6. These results quantitatively support the effectiveness of TET in solving the mismatch between gradient and loss in training SNNs with SG.
164
+
165
+ ![](images/aff831f07e0e329cffab78a14e6c6b9cb6a33fb6860a562c194fcda2f2064b92.jpg)
166
+ Figure 2: Loss landscape of VGGSNN. The 2D landscape of ${ \mathcal { L } } _ { \mathrm { S D T } }$ and ${ \mathcal { L } } _ { \mathrm { T E T } }$ from two different training methods.
167
+
168
+ Table 1: Comparison between SDT and TET. We adopt the SNN architecture ResNet-19 with SG on CIFAR100 and record the results with three different simulation lengths 2, 4, and 6.
169
+
170
+ <table><tr><td>Method</td><td>T=2</td><td>T=4</td><td>T=6</td></tr><tr><td>Direct training</td><td>69.41±0.08</td><td>70.86±0.22</td><td>71.12±0.57</td></tr><tr><td>TET</td><td>72.37±0.21</td><td>74.11±0.18</td><td>74.65±0.12</td></tr></table>
171
+
172
+ Table 2: Comparison of SDT and TET with sigmoid function $\sigma ( k { \cdot } \mathrm { i n p u t } )$ . We fix the simulation length to 4 and record the results of CNN-5 under three different $k$ on CIFAR10.
173
+
174
+ <table><tr><td>Method</td><td>k=1</td><td>k=10</td><td>k=20</td></tr><tr><td>Direct training</td><td>88.00±0.15</td><td>88.83±0.32</td><td>88.50±0.32</td></tr><tr><td>TET</td><td>87.63±0.38</td><td>89.31±0.15</td><td>88.64±0.28</td></tr></table>
175
+
176
+ Loss Landscape around Local Minima. We further inspect the 2D landscapes (Li et al., 2018) of $\mathcal { L } _ { \mathrm { S D T } }$ and ${ \mathcal { L } } _ { \mathrm { T E T } }$ around their local minima (see Figure. 2) to demonstrate why TET generalizes better than SDT and how TET helps the training process jump out of the sharp local minima typically found by SDT. First, comparing Figure. $2 \textrm { A }$ and C, we can see that although the values of local minima achieved by SDT and TET are similar in $\mathcal { L } _ { \mathrm { S D T } }$ , the local minima of TET (Figure. $2 \textrm { C }$ ) is flatter than that of SDT (Figure. $2 \mathrm { \ A }$ ). This indicates that the TET is effective in finding flatter minima that are typically more generalizable even w.r.t the original loss in TET. Next, we examine the two local minima under ${ \mathcal { L } } _ { \mathrm { T E T } }$ to see how it helps jump out the local minima found by SDT. When comparing Figure. 2 B and D, we observe that the local minima found by SDT (Figure. 2 B) is not only sharper than that found by TET (Figure. $2 \mathbf { D }$ ) under ${ \mathcal { L } } _ { \mathrm { S D T } }$ but also maintains a higher loss value. This supports our claim that TET loss cannot be easily minimized around sharp local minima (Figure. $2 \mathrm { \ B }$ ), thus preferable to converge into flatter local minima (Figure. $2 \mathrm { D }$ ). Put together, the results here provide evidence for our reasoning in Section 4.2.
177
+
178
+ Training from SDT to TET. In this part, we further validate the ability of TET to escape from the local minimum found by SDT. We adopt the VGGSNN with 300 epochs training on DVS-CIFAR10. First, we optimize ${ \mathcal { L } } _ { \mathrm { S D T } }$ for 200 epochs and then change the loss function to ${ \mathcal { L } } _ { \mathrm { T E T } }$ after epoch 200. Figure 3 demonstrates the accuracy and loss change on the test set. After 200 epochs training, SDT gets trapped into a local minimum, and the ${ \mathcal { L } } _ { \mathrm { S D T } }$ no longer decreases. The ${ \mathcal { L } } _ { \mathrm { T E T } }$ is much higher than $\mathcal { L } _ { \mathrm { S D T } }$ since SDT does not optimize it. Nevertheless, after we change the loss function to ${ \mathcal { L } } _ { \mathrm { T E T } }$ , the ${ \mathcal { L } } _ { \mathrm { T E T } }$ and $\mathcal { L } _ { \mathrm { S D T } }$ on the test set both have a rapid decline. This phenomenon illustrates the TET ability to help the SNN efficiently jump out of the local minimum with poor generalization and find another flatter local minimum.
179
+
180
+ ![](images/3337c633c01451316aa0cc30732fe1eaeb582425bcdf30fbe135431d8bf36214.jpg)
181
+ Figure 3: TET helps to jump out the local minimum point. We provide the test accuracy (A) and loss $( B )$ change after changing the SDT to TET at epoch 200. TET efficiently improves the test performance and reduces the two kinds of loss.
182
+
183
+ ![](images/086a43f62fe160235967e86bf1fd8d81f8153af1874a2e9a74e352d77d8e5e20.jpg)
184
+ Figure 4: Time scalability robustness and network efficiency of ResNet-19 on CIFAR100. (A) The comparison of training from scratch (dots) and inheriting from a small simulation length (lines). $( B )$ SNN network performance changes with energy consumption.
185
+
186
+ Time Scalability Robustness. Here, we study the time scalability robustness of SNNs trained with TET $( \mathcal { L } _ { \mathrm { T E T } } )$ . First, we use 300 epochs to train a small simulation length ResNet-19 on CIFAR100 as the initial SNN. Then, we directly change the simulation length from 2 to 8 without finetuning and report the network accuracy on the test set. Figure. 4. A displays the results after changing the simulation length. We use 2, 3, and 4, respectively, as the simulation length of the initial network. When we increase the simulation length, the accuracy of all networks gradually increases. After the simulation time reaches a certain value, the network performance will slightly decrease. Interestingly, SNNs trained from scratch ( $\mathrm { T } { = } 4$ and ${ \mathrm { T } } { = } 6$ ) are not as good as those trained following the TIT procedure.
187
+
188
+ Network Efficiency. In this section, we measure the relationship between energy consumption and network performance. SNN avoids multiplication on the inference since its binary activation and event-based operation. The addition operation in SNN costs $0 . 9 p J$ energy while multiplication operation consumes $4 . 6 p J$ measured in $4 5 \mathrm { n m }$ CMOS technology (Rathi & Roy, 2020). In our SNN model, the first layer has multiplication operations, while the other layers only have addition operations. Figure 4. B summarizes the results of different simulation times. In all cases, the SNN obtained by TET has higher efficiency.
189
+
190
+ # 5.2 COMPARISON TO EXITING WORKS
191
+
192
+ In this section, we compare our experimental results with previous works. We validate the full TIT algorithm $( \mathcal { L } _ { \mathrm { T O T A L } } )$ both on the static dataset and neuromorphic dataset. All of the experiment results are summarized in Table 5.2. We specify all the training details in the appendix A.1.
193
+
194
+ CIFAR. We apply TET and TIT algorithm on CIFAR (Krizhevsky et al., 2009), and report the mean and standard deviation of 3 runs under different random seeds. The $\lambda$ is set to 0.05. On CIFAR10, our TET method achieves the highest accuracy above all existing approaches. Even when $T = 2$ , there is a $1 . 8 2 \%$ increment compare to STBP-tdBN with simulation length $T = 6$ . It is worth noting that our method is only $0 . 4 7 \%$ lower than the ANN performance. TET algorithm demonstrates a more excellent ability on CIFAR100. It has an accuracy increase greater than $3 \%$ on all report simulation lengths. In addition, when $T = 6$ , the reported accuracy is only $0 . 6 3 \%$ lower than that of ANN. We can see that the proposed TET’s improvement is even higher on complex data like CIFAR100, where the generalizability of the model distinguishes a lot among minima with different flatness.
195
+
196
+ Table 3: Compare with existing works. Our method improves network performance across all tasks. \* denotes self-implementation results. † denotes data augmentation (Li et al., 2022).
197
+
198
+ <table><tr><td>Dataset</td><td>Model</td><td>Methods</td><td>Architecture</td><td>SimulationLength</td><td>Accuracy</td></tr><tr><td rowspan="10">CIFAR10</td><td>Rathi et al. (2019)</td><td>Hybrid training Diet-SNN</td><td>ResNet-20</td><td>250</td><td>92.22</td></tr><tr><td>Rathi &amp; Roy (2020)</td><td></td><td>ResNet-20</td><td>10</td><td>92.54</td></tr><tr><td>Wu et al. (2018)</td><td>STBP</td><td>CIFARNet</td><td>12</td><td>89.83</td></tr><tr><td>Wu et al. (2019)</td><td>STBP NeuNorm</td><td>CIFARNet</td><td>12</td><td>90.53</td></tr><tr><td>Zhang &amp; Li (2020)</td><td>TSSL-BP</td><td>CIFARNet</td><td>5</td><td>91.41</td></tr><tr><td>Zheng et al. (2021)</td><td>STBP-tdBN</td><td>ResNet-19</td><td>6 4</td><td>93.16 92.92</td></tr><tr><td rowspan="3">our model</td><td rowspan="3">TET</td><td rowspan="3"></td><td>2</td><td>92.34</td></tr><tr><td>6</td><td>94.50±0.07</td></tr><tr><td>4</td><td>94.44±0.08</td></tr><tr><td></td><td></td><td>ResNet-19</td><td>2</td><td>94.16±0.03</td></tr><tr><td rowspan="6">CIFAR100</td><td>ANN*</td><td>ANN</td><td>ResNet-19</td><td>1</td><td>94.97</td></tr><tr><td>Rathi et al. (2019) Rathi &amp; Roy (2020)</td><td>Hybrid training</td><td>VGG-11</td><td>125</td><td>67.87</td></tr><tr><td></td><td>Diet-SNN</td><td>ResNet-20</td><td>5</td><td>64.07 71.12±0.57</td></tr><tr><td rowspan="3">Zheng et al. (2021)*</td><td rowspan="3">STBP-tdBN</td><td rowspan="3">ResNet-19</td><td>6</td><td>70.86±0.22</td></tr><tr><td>4 2</td><td>69.41±0.08</td></tr><tr><td>6</td><td>74.72±0.28</td></tr><tr><td rowspan="5"></td><td>our model</td><td rowspan="2">TET</td><td rowspan="2">ResNet-19</td><td>4</td><td>74.47±0.15</td></tr><tr><td></td><td>2</td><td>72.87±0.10</td></tr><tr><td>ANN* Rathi etal. (2019)</td><td>ANN</td><td>ResNet-19</td><td>1</td><td>75.35</td></tr><tr><td></td><td>Hybrid training SPIKE-NORM</td><td>ResNet-34</td><td>250</td><td>61.48</td></tr><tr><td>Sengupta et al. (2018) Zheng et al. (2021)</td><td>STBP-tdBN</td><td>ResNet-34</td><td>2500</td><td>69.96</td></tr><tr><td rowspan="5">ImageNet</td><td>Fang et al. (2021)</td><td>SEWResNet</td><td>Spiking-ResNet-34</td><td>6</td><td>63.72</td></tr><tr><td></td><td>TET</td><td>SEW-ResNet-34 Spiking-ResNet-34</td><td>4</td><td>67.04 64.79</td></tr><tr><td>our model</td><td>TET</td><td>SEW-ResNet-34</td><td>6 4</td><td>68.00</td></tr><tr><td>Zheng et al. (2021)</td><td>STBP-tdBN</td><td>ResNet-19</td><td>10</td><td>67.8</td></tr><tr><td>Kugele et al. (2020)</td><td>Streaming Rollout</td><td>DenseNet</td><td>10</td><td>66.8</td></tr><tr><td rowspan="5">DVS-CIFAR10</td><td>Wu et al. (2021)</td><td>Conv3D</td><td>LIAF-Net</td><td></td><td>71.70</td></tr><tr><td>Wu et al. (2021)</td><td>LIAF</td><td>LIAF-Net</td><td>10 10</td><td>70.40</td></tr><tr><td rowspan="2">our model</td><td>TET</td><td>VGGSNN</td><td>10</td><td>77.33±0.21</td></tr><tr><td>TETt</td><td>VGGSNN</td><td></td><td>83.17±0.15</td></tr><tr><td></td><td></td><td></td><td>10</td><td></td></tr></table>
199
+
200
+ ImageNet. The training set of ImageNet (Krizhevsky et al., 2012) provides $1 . 2 8 \mathrm { k }$ training samples for each label. We choose the two most representative ResNet-34 to verify our algorithm on ImageNet with $\lambda = 0 . 0 0 1$ . SEW-ResNet34 is not a typical SNN since it adopts the IF model and modifies the Residual structure. Although we only train our model for 120 epochs, the TET algorithm achieves a $1 . 0 7 \%$ increment on Spiking-ResNet-34 and a $0 . 9 6 \%$ increment on SEW-ResNet34.
201
+
202
+ DVS-CIFAR10. The neuromorphic datasets suffer much more noise than static datasets. Thus the well-trained SNN is easier to overfit on these datasets than static datasets. DVS-CIFAR10 (Li et al., 2017), which provides each label with $0 . 9 \mathrm { k }$ training samples, is the most challenging mainstream neuromorphic dataset. Recent works prefer to deal with this dataset by complex architectures, which are more susceptible to overfitting and do not result in very high accuracy. Here, we adopt VGGSNN on the DVS-CIFAR10 dataset, set $\lambda = 0 . 0 0 1$ , and report the mean and standard deviation of 3 runs under different random seeds. Along with data augmentation methods, VGGSNN can achieve an accuracy of $7 7 . 4 \%$ . Then we apply the TET method to obtain a more generalizable optima. The accuracy rises to $8 3 . 1 7 \%$ . Our TET method outperforms existing state-of-the-art by $1 1 . 4 7 \%$ accuracy. Without data augmentation methods, VGGSNN obtains $7 \bar { 3 } . 3 \%$ accuracy by SDT and $7 7 . 3 \%$ accuracy by TET.
203
+
204
+ # 6 CONCLUSION
205
+
206
+ This paper focuses on the SNN generalization problem, which is described as the direct training SNN performs well on the training set but poor on the test set. We find this phenomenon is due to the incorrect SG that makes the SNN easily trapped into a local minimum with poor generalization. To solve this problem, we propose the temporal efficient training algorithm (TET). Extensive experiments verify that our proposed method consistently achieves better performance than the SDT process. Furthermore, TET significantly improves the time scalability robustness of SNN, which enables us to propose the time inheritance training (TIT) to significantly reduce the training time consumption by almost a half.
207
+
208
+ # 7 ACKNOWLEDGMENT
209
+
210
+ This project is supported by NSFC 61876032 and JCYJ20210324140807019. Y. Li completed this work during his prior research assistantship in UESTC.
211
+
212
+ # REFERENCES
213
+
214
+ Mike Davies, Narayan Srinivasa, Tsung-Han Lin, Gautham Chinya, Yongqiang Cao, Sri Harsha Choday, Georgios Dimou, Prasad Joshi, Nabil Imam, Shweta Jain, et al. Loihi: A neuromorphic manycore processor with on-chip learning. Ieee Micro, 38(1):82–99, 2018.
215
+
216
+ Michael V DeBole, Brian Taba, Arnon Amir, Filipp Akopyan, Alexander Andreopoulos, William P Risk, Jeff Kusnitz, Carlos Ortega Otero, Tapan K Nayak, Rathinakumar Appuswamy, et al. Truenorth: Accelerating from zero to 64 million neurons in 10 years. Computer, 52(5):20–29, 2019.
217
+
218
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
219
+
220
+ Lei Deng, Yujie Wu, Xing Hu, Ling Liang, Yufei Ding, Guoqi Li, Guangshe Zhao, Peng Li, and Yuan Xie. Rethinking the performance comparison between snns and anns. Neural Networks, 121:294 – 307, 2020.
221
+
222
+ Shikuang Deng and Shi Gu. Optimal conversion of conventional artificial neural networks to spiking neural networks. In International Conference on Learning Representations, 2020.
223
+
224
+ Peter U. Diehl, Daniel Neil, Jonathan Binas, Matthew Cook, and Shih Chii Liu. Fast-classifying, high-accuracy spiking deep networks through weight and threshold balancing. In Neural Networks (IJCNN), 2015 International Joint Conference on, 2015.
225
+
226
+ Peter U Diehl, Guido Zarrella, Andrew Cassidy, Bruno U Pedroni, and Emre Neftci. Conversion of artificial recurrent neural networks to spiking neural networks for low-power neuromorphic hardware. In 2016 IEEE International Conference on Rebooting Computing (ICRC), pp. 1–8. IEEE, 2016.
227
+
228
+ Steven K Esser, Paul A Merolla, John V Arthur, Andrew S Cassidy, Rathinakumar Appuswamy, Alexander Andreopoulos, David J Berg, Jeffrey L McKinstry, Timothy Melano, Davis R Barch, et al. Convolutional networks for fast, energy-efficient neuromorphic computing. Proceedings of the national academy of sciences, 113(41):11441–11446, 2016.
229
+
230
+ Wei Fang, Zhaofei Yu, Yanqi Chen, Tiejun Huang, Timothee Masquelier, and Yonghong Tian. Deep ´ residual learning in spiking neural networks. arXiv preprint arXiv:2102.04159, 2021.
231
+
232
+ 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.
233
+
234
+ Bing Han and Kaushik Roy. Deep spiking neural network: Energy efficiency through time based coding. In European Conference on Computer Vision, 2020.
235
+
236
+ Bing Han, Gopalakrishnan Srinivasan, and Kaushik Roy. Rmp-snn: Residual membrane potential neuron for enabling deeper high-accuracy and low-latency spiking neural network. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 13558–13567, 2020.
237
+
238
+ Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International conference on machine learning, pp. 448–456. PMLR, 2015.
239
+
240
+ Rahul Kidambi, Praneeth Netrapalli, Prateek Jain, and Sham Kakade. On the insufficiency of existing momentum schemes for stochastic optimization. In 2018 Information Theory and Applications Workshop (ITA), pp. 1–9. IEEE, 2018.
241
+
242
+ Seijoon Kim, Seongsik Park, Byunggook Na, and Sungroh Yoon. Spiking-yolo: Spiking neural network for energy-efficient object detection. arXiv preprint arXiv:1903.06530, 2019.
243
+
244
+ Youngeun Kim and Priyadarshini Panda. Visual explanations from spiking neural networks using inter-spike intervals. Scientific reports, 11(1):1–14, 2021.
245
+
246
+ Youngeun Kim, Yeshwanth Venkatesha, and Priyadarshini Panda. Privatesnn: Fully privacypreserving spiking neural networks. arXiv preprint arXiv:2104.03414, 2021.
247
+
248
+ Youngeun Kim, Yuhang Li, Hyoungseob Park, Yeshwanth Venkatesha, and Priyadarshini Panda. Neural architecture search for spiking neural networks. arXiv preprint arXiv:2201.10355, 2022.
249
+
250
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
251
+
252
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
253
+
254
+ Alex Krizhevsky, I. Sutskever, and G. Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 25(2), 2012.
255
+
256
+ Alexander Kugele, Thomas Pfeil, Michael Pfeiffer, and Elisabetta Chicca. Efficient processing of spatio-temporal data streams with spiking neural networks. Frontiers in Neuroscience, 14:439, 2020.
257
+
258
+ Jun Haeng Lee, Tobi Delbruck, and Michael Pfeiffer. Training deep spiking neural networks using backpropagation. Frontiers in neuroscience, 10:508, 2016.
259
+
260
+ Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein. Visualizing the loss landscape of neural nets. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, pp. 6391–6401, 2018.
261
+
262
+ Hongmin Li, Hanchao Liu, Xiangyang Ji, Guoqi Li, and Luping Shi. Cifar10-dvs: an event-stream dataset for object classification. Frontiers in neuroscience, 11:309, 2017.
263
+
264
+ Yuhang Li, Shikuang Deng, Xin Dong, Ruihao Gong, and Shi Gu. A free lunch from ann: Towards efficient, accurate spiking neural networks calibration. arXiv preprint arXiv:2106.06984, 2021a.
265
+
266
+ Yuhang Li, Yufei Guo, Shanghang Zhang, Shikuang Deng, Yongqing Hai, and Shi Gu. Differentiable spike: Rethinking gradient-descent for training spiking neural networks. Advances in Neural Information Processing Systems, 34, 2021b.
267
+
268
+ Yuhang Li, Youngeun Kim, Hyoungseob Park, Tamar Geller, and Priyadarshini Panda. Neuromorphic data augmentation for training spiking neural networks. arXiv preprint arXiv:2203.06145, 2022.
269
+
270
+ Emre O Neftci, Hesham Mostafa, and Friedemann Zenke. Surrogate gradient learning in spiking neural networks: Bringing the power of gradient-based optimization to spiking neural networks. IEEE Signal Processing Magazine, 36(6):51–63, 2019.
271
+
272
+ Nitin Rathi and Kaushik Roy. Diet-snn: Direct input encoding with leakage and threshold optimization in deep spiking neural networks. arXiv preprint arXiv:2008.03658, 2020.
273
+
274
+ Nitin Rathi, Gopalakrishnan Srinivasan, Priyadarshini Panda, and Kaushik Roy. Enabling deep spiking neural networks with hybrid conversion and spike timing dependent backpropagation. In International Conference on Learning Representations, 2019.
275
+
276
+ Bodo Rueckauer, Iulia-Alexandra Lungu, Yuhuang Hu, and Michael Pfeiffer. Theory and tools for the conversion of analog to spiking convolutional neural networks. arXiv: Statistics/Machine Learning, (1612.04052):0–0, 2016.
277
+
278
+ Ali Samadzadeh, Fatemeh Sadat Tabatabaei Far, Ali Javadi, Ahmad Nickabadi, and Morteza Haghir Chehreghani. Convolutional spiking neural networks for spatio-temporal feature extraction. arXiv preprint arXiv:2003.12346, 2020.
279
+
280
+ Shibani Santurkar, Dimitris Tsipras, Andrew Ilyas, and Aleksander Madry. How does batch normalization help optimization? In Proceedings of the 32nd international conference on neural information processing systems, pp. 2488–2498, 2018.
281
+
282
+ Abhronil Sengupta, Yuting Ye, Robert Wang, Chiao Liu, and Kaushik Roy. Going deeper in spiking neural networks: Vgg and residual architectures. Frontiers in Neuroence, 13, 2018.
283
+
284
+ Sumit Bam Shrestha and Garrick Orchard. Slayer: Spike layer error reassignment in time. In Advances in Neural Information Processing Systems, pp. 1412–1421, 2018.
285
+
286
+ Yujie Wu, Lei Deng, Guoqi Li, Jun Zhu, and Luping Shi. Spatio-temporal backpropagation for training high-performance spiking neural networks. Frontiers in neuroscience, 12:331, 2018.
287
+
288
+ Yujie Wu, Lei Deng, Guoqi Li, Jun Zhu, Yuan Xie, and Luping Shi. Direct training for spiking neural networks: Faster, larger, better. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 1311–1318, 2019.
289
+
290
+ Zhenzhi Wu, Hehui Zhang, Yihan Lin, Guoqi Li, Meng Wang, and Ye Tang. Liaf-net: Leaky integrate and analog fire network for lightweight and efficient spatiotemporal information processing. IEEE Transactions on Neural Networks and Learning Systems, 2021.
291
+
292
+ Yukun Yang, Wenrui Zhang, and Peng Li. Backpropagated neighborhood aggregation for accurate training of spiking neural networks. In International Conference on Machine Learning, pp. 11852–11862. PMLR, 2021.
293
+
294
+ Wenrui Zhang and Peng Li. Temporal spike sequence learning via backpropagation for deep spiking neural networks. arXiv preprint arXiv:2002.10085, 2020.
295
+
296
+ Hanle Zheng, Yujie Wu, Lei Deng, Yifan Hu, and Guoqi Li. Going deeper with directly-trained larger spiking neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 11062–11070, 2021.
297
+
298
+ # A APPENDIX
299
+
300
+ # A.1 DATASET AND TRAINING DETAIL
301
+
302
+ CIFAR. The CIFAR dataset (Krizhevsky et al., 2009) consists of 50k training images and 10k testing images with the size of $3 2 \times 3 2$ . We use ResNet-19 for both CIFAR10 and CIFAR100. Moreover, random horizontal flip and crop are applied to the training images the augmentation. First, we use 300 epoch to train the SNN with the simulation length $T = 2$ . We use an Adam optimizer with a learning rate of 0.01 and cosine decay to 0. Next, following the TIT algorithm, we increase the simulation time (to 4 and 6) and continue training the SNN for only 50 epochs, with the learning rate changing to $1 e - 4$ .
303
+
304
+ ImageNet. ImageNet (Deng et al., 2009) contains more than $1 2 5 0 \mathrm { k }$ training images and $5 0 \mathrm { k }$ validation images. We crop the images to $2 2 4 \times 2 2 4$ and using the standard augmentation for the training data. We use an SGD optimizer with 0.9 momentum and weight decay $4 e - 5$ . The learning rate is set to 0.1 and cosine decay to 0. We train the SEW-ResNet34 (Fang et al., 2021) with $T = 4$ for 120 epochs. As for the Spiking-ResNet34 (Zheng et al., 2021), we use TIT algorithm to train 90 epochs with $T = 4$ first, then change the simulation time to 6 and finetune the network for 30 epochs. We adopt an Adam optimizer on the finetune phase and change the learning rate to $1 e - 4$ . TIT algorithm significantly reduces the training time consumption since training the Spiking-ResNet34 is extremely slow.
305
+
306
+ DVS-CIFAR10. DVS-CIFAR10 (Li et al., 2017), the most challenging mainstream neuromorphic data set, is converted from CIFAR10. It has 10k images with the size $1 2 8 \times 1 2 8$ . Following Samadzadeh et al. (2020), we divide the data stream into 10 blocks by time and accumulate the spikes in each block. Then, we split the dataset into $9 \mathrm { k }$ training images and $1 \mathrm { k }$ test images and reduce the spatial resolution to $4 8 \times 4 8$ . Random horizontal flip and random roll within 5 pixels are taken as augmentation (Li et al., 2022). We adopt VGGSNN architecture with 300 epochs training on this classification task. And we use an Adam optimizer with the learning rate $1 e - 3$ and cosine decay to 0. As for the case that does not apply any augmentation, we add a weight decay of 5e-4 to the optimizer.
307
+
308
+ # A.2 LSDT LOSS LANDSCAPE OF RESNET-19
309
+
310
+ Here we compare the classification loss $( \mathcal { L } _ { \mathrm { S D T } } )$ landscapes of ResNet-19 on CIFAR100. The position around the local minimal value found by the SDT $( \mathcal { L } _ { \mathrm { { S D T } } } )$ is very sharp. However, the area around the local minimum found by TET $( \mathcal { L } _ { \mathrm { T E T } } )$ is much smoother (Figure 5), which indicates that TET effectively improves the network generalization. Such improvements could be further utilized to other techniques like privacy-preserving data generalization (Kim et al., 2021) and neural architecture search (Kim et al., 2022).
311
+
312
+ ![](images/ec3a5c919a88e624c8ee236df840321cb1292d402cae6ed2e4a7f134e697de42.jpg)
313
+ Figure 5: STD loss landscape of ResNet-19 on CIFAR100 from different training approaches.
314
+
315
+ # A.3 EFFECT OF $\mathcal { L } _ { \mathrm { M S E } }$
316
+
317
+ In this part, we examine the effect of the regular term $\mathcal { L } _ { \mathrm { M S E } }$ with 5 different levels of $\lambda$ . Figure 6 Summarizes the final results. The regular term $\mathcal { L } _ { \mathrm { M S E } }$ effectively increases the performance of both ResNet-19 on CIFAR100 and VGGSNN on DVS-CIFAR10. The static dataset CIFAR100 is more suitable for larger $\lambda$ , while smaller $\lambda$ is suitable for DVS-CIFAR10. Theoretically, it is hard to obtain satisfying performance at the early simulation moment due to the sparseness of neuromorphic datasets. So too large regular term $\mathcal { L } _ { \mathrm { M S E } }$ is not suitable for the neuromorphic dataset. Furthermore, we find that a high $\lambda$ may harm the early training phase on ImageNet, especially if zero-initialize (Goyal et al., 2017) is not performed. As a result, we set $\lambda$ to $5 e - 2$ for CIFAR10 and CIFAR100, $1 e - 3$ for ImageNet and DVS-CIFAR10.
318
+
319
+ ![](images/1dd2e09ae0d1ba0fa6f9db557415a2e61436ffe4627041352f5dae8ffd64e9b0.jpg)
320
+ Figure 6: The accuracy under different levels of $\lambda$ .
321
+
322
+ # A.4 STATISTICAL RESULTS
323
+
324
+ Here we provide statistical results (Figure 7) to prove that the total SNN accuracy is positively associated with every average of moment’s output test accuracy. We train CNN-5 on CIFAR10 for a total of 20 runs with SDT and 5 runs with TET.
325
+
326
+ ![](images/295735f1db530423a1bc9f14bdb244ee4d3157db65b06f1b197a62a8ce989d2a.jpg)
327
+ Figure 7: Statistical results. The overall performance of SNN is highly positively associated with the average accuracy of each moment. The standard training obtains the green dots, while the red dots are trained by the TET method.
328
+
329
+ # A.5 TIME SCALABILITY ROBUSTNESS OF SDT AND TET.
330
+
331
+ Here we first show the test accuracy (ResNet19 on CIFAR100) of the membrane potential increment at each moment instead of the integrated membrane potential. We set the initial simulation length of the SNNs to 3 or 4 and trained them for a full 300 epochs. Then we expand their simulation length to 8. As shown in table 4, TET $( \mathcal { L } _ { \mathrm { T E T } } )$ makes the membrane potential increment at each moment have a higher classification ability than SDT $( \mathcal { L } _ { \mathrm { { S D T } } } )$ . And TET (1.41 and 0.08) also acquires a low accuracy variance than SDT (3.81 and 4.04).
332
+
333
+ Then we compare the time scalability robustness between SDT $( \mathcal { L } _ { \mathrm { { S D T } } } )$ and TET $( \mathcal { L } _ { \mathrm { T E T } } )$ . We set the initial simulation length of ResNet19 SNNs to 2, 3, 4 and train with SDT or TET. Then we gradually increase SNN simulation length to 64 and record test accuracy of the integrated membrane potential.
334
+
335
+ ![](images/8be4907531399e22bedf40aaa0bdeff1ad93013af87033e52d12b9d582926cdd.jpg)
336
+ Figure 8: The accuracy after increasing the simulation length. We first train the SNN with TET (only use $\mathcal { L } _ { \mathrm { T E T } } ,$ ) and SDT ${ ( \mathcal { L } _ { \mathrm { { S D T } } } ) }$ with simulation length (T) is 2, 3, or 4. Then, we increase the simulation to 64 without finetuning and record the test the classification accuracy (A) and the accuracy relative growth rate (B) of the total SNN output (integrate membrane potential) at each simulation time.
337
+
338
+ As we increase the simulation length, all the SNNs’ accuracy will first increase and then be stable in a certain area. Meanwhile, TET (1.80) has a small accuracy variance than the SDT (11.13) after increasing the simulation length. This phenomenon indicates that the initialization steps of TIT only need a small simulation length SNN for TET but a sufficiently large simulation (or enough epochs for finetuning step) for SDT.
339
+
340
+ Table 4: Accuracy of each moment’s membrane potential increment. We use ${ \mathcal { L } } _ { \mathrm { S D T } }$ or ${ \mathcal { L } } _ { \mathrm { T E T } }$ to train the networks with simulation length 3 or 4. Then directly increase their simulation length to 8 and record each moment’s potential increment test accuracy.
341
+
342
+ <table><tr><td>Method</td><td>T=1</td><td>T=2</td><td>T=3</td><td>T=4</td><td>T=5</td><td>T=6</td><td>T=7</td><td>T=8</td></tr><tr><td>SDT (T=3)</td><td>55.61</td><td>57.95</td><td>56.87</td><td>55.09</td><td>57.56</td><td>53.54</td><td>57.72</td><td>54.04</td></tr><tr><td>SDT (T=4)</td><td>37.96</td><td>61.78</td><td>55.03</td><td>56.64</td><td>57.47</td><td>54.24</td><td>58.74</td><td>55.48</td></tr><tr><td>TET (T=3)</td><td>65.97</td><td>72.22</td><td>71.78</td><td>70.55</td><td>71.90</td><td>69.57</td><td>72.15</td><td>69.78</td></tr><tr><td>TET (T=4)</td><td>62.17</td><td>71.57</td><td>71.05</td><td>72.08</td><td>71.77</td><td>71.23</td><td>71.81</td><td>71.36</td></tr></table>
md/dev/aD7uesX1GF_/aD7uesX1GF_.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/bhUPJnS2g0X/bhUPJnS2g0X.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/ebSOK1nV2r/ebSOK1nV2r.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/ex60CCi5GS/ex60CCi5GS.md ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Debiasing Graph Neural Networks via Learning Disentangled Causal Substructure
2
+
3
+ Shaohua Fan1,2∗, Xiao Wang1, Yanhu $\mathbf { M o } ^ { 1 }$ , Chuan Shi1†, Jian Tang2,3,4 †
4
+
5
+ 1Beijing University of Posts and Telecommunications, China 2 Mila - Québec AI Institute, Canada 3 HEC Montréal, Canada 4 CIFAR AI Research Chair {fanshaohua, xiaowang, moyanhu, shichuan}@bupt.edu.cn, jian.tang@hec.ca
6
+
7
+ # Abstract
8
+
9
+ Most Graph Neural Networks (GNNs) predict the labels of unseen graphs by learning the correlation between the input graphs and labels. However, by presenting a graph classification investigation on the training graphs with severe bias, surprisingly, we discover that GNNs always tend to explore the spurious correlations to make decision, even if the causal correlation always exists. This implies that existing GNNs trained on such biased datasets will suffer from poor generalization capability. By analyzing this problem in a causal view, we find that disentangling and decorrelating the causal and bias latent variables from the biased graphs are both crucial for debiasing. Inspired by this, we propose a general disentangled GNN framework to learn the causal substructure and bias substructure, respectively. Particularly, we design a parameterized edge mask generator to explicitly split the input graph into causal and bias subgraphs. Then two GNN modules supervised by causal/bias-aware loss functions respectively are trained to encode causal and bias subgraphs into their corresponding representations. With the disentangled representations, we synthesize the counterfactual unbiased training samples to further decorrelate causal and bias variables. Moreover, to better benchmark the severe bias problem, we construct three new graph datasets, which have controllable bias degrees and are easier to visualize and explain. Experimental results well demonstrate that our approach achieves superior generalization performance over existing baselines. Furthermore, owing to the learned edge mask, the proposed model has appealing interpretability and transferability.3
10
+
11
+ # 1 Introduction
12
+
13
+ Graph Neural Networks (GNNs) have exhibited powerful performance on graph data with various applications [17, 35, 13, 9, 8]. One major category of applications are the graph classification task, such as molecular graph property prediction [15, 20, 44], superpixel graph classification [14], and social network category classification [46, 44]. It is well known that graph classification is usually determined by a relevant substructure, but not the whole graph structure [43, 26, 45]. For example, for MNIST superpixel graph classification task, the digit subgraphs are causal (i.e., deterministic) for labels [36]. The mutagenic property of a molecular graph depends on the functional groups (i.e., nitrogen dioxide $\left( \mathrm { N O } _ { 2 } \right)$ ), rather than the irrelevant patterns (i.e., carbon rings) [27]. Therefore, it is a fundamental requirement for GNNs to identify causal substructures, so as to make correct prediction.
14
+
15
+ Ideally, when the graphs are unbiased, i.e., only the causal substructures are related with the graph labels, the GNNs are able to utilize such substructure to predict the labels. However, due to the uncontrollable data collection process, the graphs are inevitably biased, i.e., existing meaningless substructures spuriously correlates with labels. Taking a colored MNIST superpixel graph dataset in Sec. 3.1 as an example (illustrated in Fig. 1(a)), each category of digit subgraphs mainly correspond to one kind of color background subgraphs, e.g., digit 0 subgraph is related with red background subgraph. Therefore, the color background subgraph will be treated as bias information, which highly correlates with labels but does not determines them in the training set. Under this situation, will GNNs still stably utilize the causal substructure to make decision?
16
+
17
+ To investigate the impact of bias on GNNs, we conduct an experimental investigation to demonstrate the impact of bias (especially in the severe bias scenarios) on the generalization capability of GNNs (Sec. 3.1). We find that GNNs actually utilize both bias and causal substructures to make prediction. However, with severer bias correlation, even bias substructure still could not exactly determine labels like causal substructure, GNNs majorly utilize bias substructure as shortcuts to make prediction, causing a large generalization performance degradation. Why this happens? We analyze the datagenerating process and model prediction mechanism behind the graph classification using a causal graph (Sec. 3.2). The casual graph illustrates that the observed graphs are generated by the causal and bias latent variables and existing GNNs could not distinguish the causal substructure from entangled graphs. How can we disentangle the causal and bias substructures from observed graphs, so that GNNs can only utilize the causal substructures to make stable prediction when severe bias appears?
18
+
19
+ To address the question, two challenges need to be faced. 1) How to identify the causal substructure and bias substructure in the severe biased graphs? In the severe bias scenarios, bias substructure will be “easier to learn” for GNNs and finally dominate the prediction. Using the normal cross-entropy loss, like DIR [39], could not fully capture such aggressive property of bias. 2) How to extract the causal substructure from an entangled graph? The statistically causal substructure is usually determined by the global property of the entire graph population, rather than a single graph. When extracting causal substructure from a graph, we need to establish the relations among all the graphs.
20
+
21
+ In this paper, we propose a novel debiasing framework for GNNs via learning Disentangled Causal substructure, called DisC. Given an input biased graph, we propose to explicitly filter edges into causal and bias subgraphs by a parameterized edge mask generator, whose parameters are shared across entire graph population. As a result, the edge masker is naturally capable to specify the importance for each edge and extract causal and bias subgraphs from a global view of the entire observations. Then, a “casual”-aware (weighted cross-entropy) loss and a “bias”-aware (generalized cross-entropy) loss are respectively utilized to supervise two functional GNN modules. Based on the supervision, the edge mask generator could generate corresponding subgraphs and the GNNs could encode corresponding subgraphs into their disentangled embeddings. With the disentangled embeddings, we randomly permute the latent vectors extracted from different graphs to generate more unbiased counterfactual samples in embedding space. The new generated samples still contain both causal and bias information, while their correlation has been decorrelated. In this time, there is only correlation between causal variables with labels, so that the model could concentrate on the true correlation between the causal subgraphs and labels. Our major contributions are as follows:
22
+
23
+ • To our knowledge, we first study the generalization problem of GNNs in a more challenging yet practical scenario, i.e., the graphs are with severe bias. We systematically analyze the bias impact on GNNs from both experimental study and causal analysis. We find that the bias substructure, compared with causal substructure, is much easier to dominate the training of GNNs. • To debias GNNs, we develop a novel GNN framework for disentangling causal substructure, which is flexible to build upon various GNNs for improving generalization ability while enjoying inherent interpretability, robustness and transferability. • We construct three new datasets with various properties and controllable bias degrees, which can better benchmark the new problem. Our model outperforms the corresponding base models with a large margin (from $4 . 4 7 \%$ to $1 6 9 . 1 7 \%$ average improvements). Various investigation studies demonstrate that our model could discover and leverage causal substructure for prediction.
24
+
25
+ # 2 Related Works
26
+
27
+ Generalization of GNNs in wild environments. Most existing GNN methods are proposed under the IID hypothesis, i.e., training and testing set are independently sampled from the identical distribution [34, 17, 35, 13, 24]. However, in reality, thus ideal assumption is hard to be satisfied. Recently, several methods have been proposed to improve the generalization ability of GNNs in wild OOD environments. Several works [29, 7, 38] study the OOD problem of node classification. For OOD graph classification task, StableGNN [6] propose to learn the stable causal relationship in graphs. OOD-GNN [22] propose to constrain each dimension of learned embedding to be independent. DIR [39] discovers the invariant rationales for generalizing GNNs. Although they have achieved better OOD performance, they are not designed for the datasets with severe bias, which is more challenging for guaranteeing the generalization ability of GNNs.
28
+
29
+ Disentangled graph neural networks. Recently, there are a couple of methods that study the disentangled GNNs. DisenGCN [28] utilizes neighbourhood routing mechanism to divide the neighbours of the node into several mutually exclusive parts. IPGDN [25] promotes DisenGCN by constraining the different parts of the embedding feature to be independent. DisenGCN and IPGDN are node-level disentanglement, thus FactorGCN [42] considers the whole graph information and disentangles the target graph into several factorized graphs. Despite results of the previous works, they do not consider disentangling the causal and bias information for graphs.
30
+
31
+ General debiasing methods. Recently, debiasing problem has drawn much attention in machine learning community [16, 23, 33, 1, 2, 11]. One category of these methods is pre-defining a certain bias type explicitly to mitigate [16, 23, 33, 1, 37]. For example, Wang et al. [37] and Bahng et al. [1] design a texture- and color-guided model to adversarially train a debiased neural network against the biased one. Instead of defining certain types of bias, recent approaches [30, 5, 21] rely on the straightforward assumption that models are prone to exploit the bias as shortcuts to make prediction [10]. In the line with the recent studies, our study belongs to the second category. However, most of existing methods are designed for image datasets and could not effectively extract causal substructure from graph data. Distinctly, we first study the severe bias problem on graph data, and our method could effectively extract causal substructure from graph data.
32
+
33
+ ![](images/c2cd979b0472bec0aeb4ad871bccbf93e7ecb651572210a690085fba8ecfe079.jpg)
34
+ Figure 1: Example graphs of CMNIST-75sp and the performance of GNNs on this dataset.
35
+
36
+ # 3 Preliminary Study and Analysis
37
+
38
+ In this section, we first illustrate the existing GNNs tend to exploit the bias substructure as shortcuts for prediction through a motivating experiment. Then we analyze the prediction process of GNNs in causal view. Based on this causal view, it motivates our solution to relieve the impact of bias.
39
+
40
+ # 3.1 Motivating Example
41
+
42
+ To measure the generalization ability of GNNs with the effect of bias, we construct a graph classification dataset with controllable bias degrees, called CMNIST-75sp. We first construct a biased MNIST image dataset like [1], where each category of digit highly correlates with a pre-defined color in their background. For example, in the training set, $90 \%$ of 0 digits are with red background (i.e., biased samples), and remaining $10 \%$ images are with random background color (i.e., unbiased samples), whose the bias degree is 0.9 in this situation. We consider four bias degrees $\{ 0 . 8 , 0 . 8 5 , 0 . 9 , \bar { 0 } . 9 5 \}$
43
+
44
+ For the testing set, we construct both biased testing set and unbiased testing set. The biased testing set has the same bias degree with training set, aiming to measure the extent of models relying on bias. The unbiased testing set, where the digit labels uncorrelate with the background colors, aims to test whether the model could utilize the inherent digit signals for prediction. Note that training set and testing set have the same pre-defined color set. Then, we convert the biased MNIST images into superpixel graphs with at most 75 nodes each graph using [18], where the edges are constructed by the KNN method based on the 2D coordinates of superpixels and node features are the concatenation of coordinates and average color of superpixels. Each graph is labeled by its digit class, so that its digital subgraph is deterministic for label and background subgraph is spuriously correlated with labels but not deterministic. The examples of graphs are illustrated in Fig. 1(a).
45
+
46
+ We perform three popular GNN methods: GCN [17], GIN [41], and GCNII [3] on CMNIST-75sp and the results are shown in Fig. 1(b). The same color of dashed line and solid line represent the results of the corresponding methods on the biased testing set and the unbiased testing set respectively. Overall, the GNNs achieve much better performance on biased testing set than unbiased testing set. The phenomenon indicates that although GNNs could still learn some causal signals for prediction, the unexpected bias information is also being utilized for prediction. More specifically, with bias degree becoming larger, the performance of GNNs on biased testing set is increased and the value of accuracy is nearly in line with the bias degree, while the performance on unbiased testing drops dramatically. Hence, although causal substructure could determine labels perfectly, in severe bias scenarios, the GNNs lean to utilize the easier to learn bias information to make prediction rather than the inherent causal signals, and bias substructure will finally dominate the prediction.
47
+
48
+ ![](images/67725338102b285105a9f763243a8f05b40474959212b3e04391679918f3ad6a.jpg)
49
+ (a) SCM of the union of the (b) SCM of our debiasing GNN data generation and the existing method. GNNs’ prediction process.
50
+
51
+ Figure 2: SCMs. Grey and white variables represent unobserved and observed variables, respectively.
52
+
53
+ # 3.2 Problem Analysis
54
+
55
+ Debiasing GNNs for unbiased prediction requires understanding the natural mechanisms of graph classification task. We present a causal view of the union of the data-generating process and the model prediction process behind the task. Here we formalize the causal view as a Structure Causal Model (SCM) or causal graph [12, 31] by inspecting on the causalities among five variables: unobserved causal variable $C$ , unobserved bias variable $B$ , observed graph $G$ , graph embedding $E$ , and ground truth label / prediction $Y ^ { 4 }$ . Fig. 2(a) illustrates the SCM, where each link denotes a causal relationship.
56
+
57
+ • $C \right. G \left. B$ . The observed graph data is generated by two unobserved latent variables: the causal variable $C$ and the bias variable $B$ , such as digit subgraphs and background subgraphs in the CMNIST-75sp dataset. And all bellow relations are illustrated by CMNIST-75sp. • $C Y$ . This link means that the causal variable $C$ is the only endogenous parent to determine the generation of ground-truth label $Y$ . For example, $C$ is the oracle digit subgraph, which exactly explains why the label is labeled as $Y$ . • $C \ \ B$ . This link indicates the spurious correlation between $C$ and $B$ . Such probabilistic dependencies is usually caused by the direct cause or unobserved confounder [32]. Here we do not distinguish these scenarios and only observe the spurious correlation between $B$ and $C$ , such as the spurious correlation between the color background subgraphs and digit subgraphs.
58
+
59
+ • $G E Y$ . Existing GNNs usually learn the graph embedding $E$ based on the observed graph $G$ and make the prediction $Y$ based on the learned embedding $E$ .
60
+
61
+ According to the SCM, GNNs will utilize both information to make prediction. As bias substructure (e.g., background subgraph) usually has simpler structure than meaningful causal substructure (e.g., digit subgraph), if GNN utilizes such simple substructure, it could achieve low loss very fast. Hence, GNN inclines to utilizes bias information when most graphs are biased. Based on the SCM in Fig. 2(a), according to $d$ -connection theory [31] (see App. A): two variables are dependent if they are connected by at least one unblocked path, we could find two paths that would induce the spurious correlation between the bias variable $B$ and label $Y$ : (1) $\mathbf { B } \mathbf { G } \mathbf { E } \mathbf { Y }$ and (2) $\mathbf { B } \left. \bar { \mathbf { C } } \right. \mathbf { Y }$ . To make the prediction $Y$ being uncorrelated with the bias $B$ , we need to intercept the two unblocked paths. For this purpose, we propose to debias GNNs in causal view, as in Fig. 2(b).
62
+
63
+ • $C \left. G \right. B$ and $C Y$ . To intercept the path (1), we should disentangle the latent variables $C$ and $B$ from the observed graph $G$ and make prediction only based on the causal variable $C$ . • $C \ l \ l \textsc { - } B$ . To intercept the path (2), as we cannot change the link between $C$ and $Y$ , one possible solution is to make $C$ and $B$ uncorrelated.
64
+
65
+ # 4 Methodology
66
+
67
+ Motivated by the above causal analysis, in this section, we present our proposed debiasing GNN framework DisC, to remove the spurious correlation. The overall framework is shown in Fig. 3. First, an edge mask generator is learnt to mask the edges of original input graphs into causal subgraphs and bias subgraphs. Second, two separate GNN modules with their corresponding masked subgraphs are trained to encode corresponding causal substructure and bias substructure into disentangled representations, respectively. Last, after the disentangled representations are well-trained, we permute the bias representations among the training graphs to generate counterfactual unbiased samples, so that the correlation between causal representations and bias representations is removed.
68
+
69
+ ![](images/bcb625f1dae058895f389fa7bde99c8f6e961d0b84a718b48473b2ff85e97e50.jpg)
70
+ Figure 3: The overall framework of DisC.
71
+
72
+ # 4.1 Causal and Bias Substructure Generator
73
+
74
+ Given a mini-batch of biased graphs ${ \mathcal { G } } = \{ G _ { 1 } , \cdots , G _ { n } \}$ , our idea is that: we take a collection of graph instances and design a generative probabilistic model to learn to mask the edges into causal subgraph or bias subgraph. Particularly, given a graph $G = \left\{ \mathbf { A } , \mathbf { X } \right\}$ , where $\mathbf { A }$ is the adjacency matrix and $\mathbf { X }$ is the node feature matrix, we utilize a multi-layer perceptron (MLP) upon the concatenation of node features $\mathbf { x } _ { i }$ of node $i$ and $\mathbf { x } _ { j }$ of node $j$ to measure the importance of edge $( i , j )$ for causal subgraph:
75
+
76
+ $$
77
+ \alpha _ { i j } = \mathbf { M L P } ( [ \mathbf { x } _ { i } , \mathbf { x } _ { j } ] ) .
78
+ $$
79
+
80
+ Then a sigmoid function $\sigma ( \cdot )$ is employed to project $\alpha _ { i j }$ into the range of (0,1), which indicates the probability of edge $( i , j )$ being the edge in the causal subgraph as follows:
81
+
82
+ $$
83
+ c _ { i j } = \sigma ( \alpha _ { i j } ) .
84
+ $$
85
+
86
+ Naturally, we could get the probability of edge $( i , j )$ being the edge in the bias subgraph by: $b _ { i j } = 1 - c _ { i j }$ . Now we could construct the causal edge mask $\mathbf { M } _ { c } \bar { \mathbf { \eta } } = \left[ c _ { i j } \right]$ and bias edge mask $\begin{array} { r } { \mathbf { M } _ { b } = [ b _ { i j } ] } \end{array}$ . Finally, we decompose the original graph $G$ into causal subgraph $G _ { c } = \{ \mathbf { M } _ { c } \odot \mathbf { A } , \mathbf { X } \}$ and bias subgraph $G _ { b } = \{ { \bf M } _ { b } \odot { \bf A } , { \bf X } \}$ . Intuitively, the edge mask could highlight different part of structure information of original graphs, thus GNNs built on the different subgraphs could encode different parts of graph information. Moreover, the mask generator has two advantages. (1) Global view: In individual graph level, the mask generator (i.e., MLP), whose parameters are shared by all the edges in a graph, take a global view of all the edges in a graph, which enables us to identify community in graph. It is well known that the effect of an edge cannot be judged independently, because edges usually collaborate with each other, forming a community, to make prediction. Thus, it is critical to evaluate an edge in a global view. In whole graph population level, the mask generator takes a global view of all the graphs in the training set, which enables us to identify causal/bias subgraph. Particularly, as the causal/bias is the statistical information in the population level, it is necessary to view all the graphs to identify the causal/bias substructure. Considering both such coalition effects and population-level statistical information, the generator is able to measure the importance of edges more accurately. (2) Generalization: The mask generator can generalize the mechanism of mask generation to new graphs without retraining, so it is capable and efficient to prune unseen graphs.
87
+
88
+ # 4.2 Learning Disentangled Graph Representations
89
+
90
+ Given $G _ { c }$ and $G _ { b }$ , how to ensure they are causal subgraph and bias subgraph, respectively? Inspired by [21], our approach simultaneously trains a pair of GNNs $( g _ { b } , g _ { c } )$ with linear classifiers $( C _ { b } ^ { - } , C _ { c } )$ as follows: (1) Motivated by the observation in Sec. 3.1 that bias substructure is easier to learn, we utilize a bias-aware loss to train a bias $\mathrm { G N N } g _ { b }$ and a bias classifier $C _ { b }$ and (2) in contrast, we train a causal $\mathrm { G N N } _ { g _ { c } }$ and a causal classifier $C _ { c }$ on the training graphs that the bias GNN struggles to learn. Next, we would present each component in detail.
91
+
92
+ As shown in Fig. 3, GNN $g _ { c }$ and $g _ { b }$ embed the corresponding subgraphs into causal embedding $z _ { c } = g _ { c } ( G _ { c } ; \gamma _ { c } )$ and bias embedding $z _ { b } = g _ { b } ( G _ { b } ; \gamma _ { b } )$ , respectively, where $\gamma$ is the parameters of GNNs. Subsequently, concatenated vector $z = \left[ z _ { c } ; z _ { b } \right]$ is fed into linear classifiers $C _ { c }$ and $C _ { b }$ to predict the target label $y$ . To train $g _ { b }$ and $C _ { b }$ as bias extractor, we utilize the generalized cross entropy (GCE) [47] loss to amplify the bias of the bias GNN and classifier:
93
+
94
+ $$
95
+ G C E ( C _ { b } ( z ; \alpha _ { b } ) , y ) = \frac { 1 - C _ { b } ^ { y } ( z ; \alpha _ { b } ) ^ { q } } { q } ,
96
+ $$
97
+
98
+ where $C _ { b } ( z ; \alpha _ { b } )$ and $C _ { b } ^ { y } ( z ; \alpha _ { b } )$ are softmax output of the bias classifier and its probability belonging to the target category $y$ , respectively, and $\alpha$ is the parameters of classifier. Here $q \in ( 0 , 1 ]$ is a hyperparameter that controls the degree of amplifying bias. Given $\theta _ { b } = [ \gamma _ { b } , \alpha _ { b } ]$ , the gradient of the GCE loss up-weights the gradient of the standard cross entropy (CE) loss for the samples with a high confidence $\dot { \boldsymbol { C } } _ { b } ^ { y }$ of predicting the correct target category as follows:
99
+
100
+ $$
101
+ \frac { \partial G C E ( C _ { b } ( z ; \alpha _ { b } ) , y ) } { \partial \theta _ { b } } = ( C _ { b } ^ { y } ) ^ { q } \frac { \partial C E ( C _ { b } ( z ; \alpha _ { b } ) , y ) } { \partial \theta _ { b } } .
102
+ $$
103
+
104
+ Therefore, compared with CE loss, GCE loss will amplify the gradients of $\theta _ { b }$ on samples by the confidence score $( C _ { b } ^ { y } ) ^ { q }$ . Based on our observation that the bias information is usually easier to be learned, so the biased graphs will have higher $( C _ { b } ^ { y } ) ^ { q }$ than unbiased graphs. Therefore, the model $g _ { b }$ and $C _ { b }$ trained by GCE loss will focus on bias information and finally get the bias subgraph. Note that, to ensure that $C _ { b }$ predicts target labels mainly based on this $z _ { b }$ , the loss from $C _ { b }$ is not backpropagated to $g _ { c }$ , i.e., only update $\theta _ { b }$ in Eq. (4), and vice versa.
105
+
106
+ Meanwhile, we also train a causal GNN simultaneously with the weighted CE loss. The graphs with high CE loss from $C _ { b }$ can be regarded as the unbiased samples compared with the samples with low CE loss. In this regard, we could obtain the unbias score of each graph as
107
+
108
+ $$
109
+ W ( z ) = \frac { C E ( C _ { b } ( z ) , y ) } { C E ( C _ { c } ( z ) , y ) + C E ( C _ { b } ( z ) , y ) } .
110
+ $$
111
+
112
+ Large value of $W$ implies the graph is an unbiased sample, hence we could use these weights to reweight the loss of these graphs to train $g _ { c }$ and $C _ { c }$ , enforcing them to learn the unbiased information. Thus, the objective function for learning disentangled representation is:
113
+
114
+ $$
115
+ L _ { D } = W ( z ) C E ( C _ { c } ( z ) , y ) + G C E ( C _ { b } ( z ) , y ) .
116
+ $$
117
+
118
+ # 4.3 Counterfactual Unbiased Sample Generation
119
+
120
+ Until now, we have achieved the first goal analyzed in Sec. 3.2 that is the disentanglement of causal and bias substructures. Next, we will show how to achieve the second goal that makes the causal variable $z _ { c }$ and bias variable $z _ { b }$ uncorrelated. Although we have disentangled causal and bias information, they are disentangled from the biased observed graphs. Hence, there will exist statistical correlation between causal and bias variables inheriting from the biased observed graphs. To further decorrelate $z _ { c }$ and $z _ { b }$ , according to the causal relation of data-generating process: $C \right. G \left. B$ , we propose to generate the counterfactual unbiased samples in embedding space by swapping $z _ { b }$ . More specifically, we randomly permute bias vectors in each mini-batch and obtain $z _ { u n b i a s e d } = [ z _ { c } ; \hat { z _ { b } } ] .$ where $\hat { z _ { b } }$ represents the randomly permuted bias vectors of $z _ { b }$ . As $z _ { c }$ and $\hat { z } _ { b }$ in $z _ { u n b i a s e d }$ are randomly combined from different graphs, they will have much less correlation than $\boldsymbol { z } = \left[ z _ { c } ; z _ { b } \right]$ where both are from the same graph. To make $g _ { b }$ and $C _ { b }$ still focus on the bias information, we also swap label $y$ as $\hat { y }$ along with $\hat { z _ { b } }$ , so that the spurious correlation between $\hat { z _ { b } }$ and $\hat { y }$ still exists. With the generated unbiased samples, we utilize the following loss function to train two GNN modules:
121
+
122
+ $$
123
+ { \cal L } _ { G } = W ( z ) C E ( C _ { c } ( z _ { u n b i a s e d } ) , y ) + G C E ( C _ { b } ( z _ { u n b i a s e d } ) , \hat { y } ) ,
124
+ $$
125
+
126
+ Together with the disentanglement loss, total loss function is defined as:
127
+
128
+ $$
129
+ { \cal L } = { \cal L } _ { D } + \lambda _ { G } { \cal L } _ { G } ,
130
+ $$
131
+
132
+ where $\lambda _ { G }$ is a hyperparameter for weighting the importance of generation component. Moreover, training with more diverse samples would also benefit with better generalization on unseen testing scenarios. Our approach is summarized in App. B. Note that, as we need well-disentangled representations to generate the high-quality unbiased samples, in the early stage of training, we only train the model with $L _ { D }$ . After certain epochs, we train the model with $L$ .
133
+
134
+ # 5 Experiment
135
+
136
+ Datasets. We construct three datasets with various properties and bias ratios to benchmark this new problem, where the datasets have clear causal subgraphs making the results explainable. Following CMNIST-75sp introduced in Sec. 3.1, we use the similar way to construct CFashion-75sp and CKuzushiji-75sp datasets based on the Fashion-MNIST [40] and Kuzushiji-MNIST [4] datasets. As the causal subgraphs of these two datasets are more complicated (fashion product and hiragana characters), they are more challenging. Due to the page limits, here we set bias degrees as $\{ 0 . 8 , 0 . 9 , 0 . 9 5 \}$ . We report the main results on unbiased test sets. Details are in App. C.1.
137
+
138
+ Baselines and experimental setup. As DisC is a general framework which could be built on various base GNN models, we select three popular GNNs: GCN [17], GIN [41], and GCNII [3]. The corresponding models are termed as $\mathrm { D i s C } _ { G C N }$ , $\mathrm { D i s C } _ { G I N }$ and $\mathrm { D i s C } _ { G C N I I }$ , respectively. Hence, base models are the most straight baselines. Another kind of baselines are the causal-inspired GNN method DIR [39] and StableGNN [6]. We also compare against a general debiasing method LDD [21] by replacing its encoder with GNNs. Graph Pooling method DiffPool [44] and graph disentangling method FactorGCN [42] are also compared. To keep fair comparison, our model uses the same GNN architecture and hyperparameters with the corresponding base model. All the experiments are run 4 times with different random seeds and we report the accuracy and the standard error. More details are in App. C.2.
139
+
140
+ # 5.1 Quantitative Evaluation
141
+
142
+ Main results. The overall results are summarized in Table 1, and we have following observations:
143
+
144
+ (1) DisC has much better generalization ability than base models. DisC outperforms the corresponding base model consistently with a large margin. With heavier biases, our model achieves larger improvements over base models. Specifically, for CMNIST-75sp, CFashion-75sp and CKuzushiji-75sp with smaller bias degree (i.e., 0.8), our model achieves $4 0 . 0 2 \%$ , $4 . 4 7 \%$ and $2 9 . 8 2 \%$ average improvements over corresponding base models, respectively. Surprisingly, with severer biases (0.9 and 0.95), DisC achieves $1 6 9 . 1 7 \%$ , $1 4 . 6 7 \%$ and $4 9 . 3 5 \%$ average improvements over base models on three datasets, respectively. It indicates that the proposed method is a general framework helping existing GNNs against the negative impact of bias.
145
+
146
+ (2) DisC significantly outperforms existing debiasing methods. We notice that DIR could not achieve satisfying results. The reason is that DIR utilizes CE loss to extract bias information, which could not fully capture the property of bias in severe bias scenarios. And DIR sets one fixed threshold to spilt subgraphs, which is suboptimal. StableGNN outperforms their base model DiffPool and achieve competitive results, indicating the effectiveness of their proposed causal variable distinguishing regularizer. However, their framework adjusts data distribution based on the original dataset, it is hard to generate unbiased distribution when the unbiased samples are scarce. DisC could generate more unbiased samples based on the disentangled representations. Moreover, LDD is a general debiasing method which is not designed for graph data. DisC outperforms corresponding LDD variants with average $2 3 . 1 5 \%$ , indicating that the seamless joint of global-population-aware edge masker with debiasing disentangle framework is very effective.
147
+
148
+ Table 1: Graph classification accuracy evaluated on unbiased testing sets, which have same color (bias) set with training set. The best performance within each base model variant is in bold.
149
+
150
+ <table><tr><td rowspan="2">Dataset Bias</td><td colspan="3">CMNIST-75sp</td><td colspan="3">CFashion-75sp</td><td colspan="3">CKuzushiji-75sp</td></tr><tr><td>0.8</td><td>0.9</td><td>0.95</td><td>0.8</td><td>0.9</td><td>0.95</td><td>0.8</td><td>0.9</td><td>0.95</td></tr><tr><td>FactorGCN [42]</td><td>72.30±1.18</td><td>62.35±5.07</td><td>42.50±4.91</td><td>61.23±1.11</td><td>53.50±1.29</td><td>45.78±2.40</td><td>42.87±1.19</td><td>32.35±2.79</td><td>23.87±0.12</td></tr><tr><td>DiffPool [44]</td><td>73.79±0.02</td><td>66.45±0.78</td><td>47.12±1.04</td><td>62.82±0.53</td><td>57.50±0.39</td><td>50.86±0.20</td><td>45.46±0.65</td><td>36.18±0.19</td><td>27.45±0.26</td></tr><tr><td>DIR [39]</td><td>9.98±0.33</td><td>9.96±0.23</td><td>10.03±0.27</td><td>13.02±1.92</td><td>12.80±1.67</td><td>11.98±1.41</td><td>10.35±0.32</td><td>10.72±0.27</td><td>10.59±0.46</td></tr><tr><td>StableGNN [6]</td><td>77.65±1.64</td><td>68.87±1.74</td><td>51.33±0.87</td><td>64.03±0.29</td><td>58.26±0.09</td><td>51.46±0.39</td><td>49.41±0.09</td><td>39.30±0.12</td><td>28.26±0.14</td></tr><tr><td>LDDGCN[21]</td><td>64.95±1.22</td><td>56.65±2.18</td><td>46.83±2.88</td><td>63.85±1.17</td><td>64.30±0.89</td><td>62.28±0.48</td><td>42.38±0.33</td><td>38.75±0.49</td><td>33.08±0.59</td></tr><tr><td>LDDGIN[21]</td><td>64.88±1.45</td><td>50.59±1.07</td><td>31.23±2.48</td><td>64.65±0.63</td><td>57.10±0.43</td><td>53.38±0.47</td><td>37.83±0.54</td><td>28.97±0.18</td><td>22.13±0.34</td></tr><tr><td>LDDGCNII [21]</td><td>78.03±0.66</td><td>69.53±0.96</td><td>51.05±3.87</td><td>50.63±1.79</td><td>54.09±2.54</td><td>57.93±0.88</td><td>48.70±1.98</td><td>41.59±1.07</td><td>33.93±0.71</td></tr><tr><td>GCN[17]</td><td>50.43±4.13</td><td>28.97±4.4</td><td>13.50±1.38</td><td>63.60±0.53</td><td>57.22±0.93</td><td>47.69±0.42</td><td>38.45±1.1</td><td>28.35±0.79</td><td>20.70±0.88</td></tr><tr><td>DisCGCN</td><td>82.60±0.93</td><td>78.14±2.14</td><td>63.47±5.65</td><td>66.85±1.11</td><td>65.33±4.70</td><td>63.93±1.50</td><td>55.53±2.29</td><td>48.13±2.59</td><td>36.63±1.73</td></tr><tr><td>GIN [41]</td><td>57.75±0.78</td><td>36.78±5.55</td><td>16.04±1.14</td><td>64.25±0.46</td><td>58.03±0.40</td><td>49.74±0.60</td><td>41.83±0.78</td><td>30.09±0.87</td><td>21.18±1.63</td></tr><tr><td>DisCGIN</td><td>82.10±1.50</td><td>74.90±1.81</td><td>58.58±4.24</td><td>67.10±1.07</td><td>59.90±1.31</td><td>55.80±0.36</td><td>55.18±1.00</td><td>41.75±0.81</td><td>30.25±1.63</td></tr><tr><td>GCNII [3]</td><td>69.70±1.73</td><td>57.68±1.68</td><td>41.00±3.75</td><td>66.68±0.59</td><td>60.58±0.28</td><td>53.18±0.08</td><td>48.53±0.25</td><td>36.23±0.20</td><td>25.60±0.76</td></tr><tr><td>DisCGCNII</td><td>79.50±2.48</td><td>76.00±1.90</td><td>60.54±5.33</td><td>66.47±1.77</td><td>65.48±0.70</td><td>61.75±0.27</td><td>54.90±1.30</td><td>44.73±1.55</td><td>36.95±0.70</td></tr></table>
151
+
152
+ Ablation studies. To validate the importance of each module in our method, in Fig. 4, we conduct ablation studies on our variants (w.o. G means without the sample generation module) and the related variants of LDD. The major difference between DisC/w.o. G with LDD /w.o. G is the edge mask module. In most cases, DisC/w.o. G significantly outperforms LDD /w.o. G, indicating the necessity of learning edge mask for graph data. And DisC which has counterfactual sample generation module could further boost the performances based on the disentangled embeddings of DisC/w.o. G. However, LDD seldomly outperforms LDD /w.o. G or even achieves worse performances. That is, generating high-quality counterfactual samples needs well-disentangled causal and bias embeddings. If embeddings are not well-disentangled, counterfactual samples may act as noisy samples, which would prevent models from achieving further improvement. The edge masker could help the model generate well-disentangled embeddings, which is crucial for overall performance.
153
+
154
+ ![](images/a0e110950764af9cb15bcd44f9149686964d2d2dbbc914f554282cc321f7d710.jpg)
155
+ Figure 4: Ablation studies of the DisC vs. LDD average over three bias degrees of each dataset.
156
+
157
+ Robustness on unseen bias. Table 2 reports the results of DisC compared with its corresponding base models on testing set with unseen bias, i.e., the pre-defined color (bias) sets of training set and testing set are disjoint. The performances of base models further drop compared with the results on seen bias scenario in Table 1. However, our model still achieves very stable performances, fully demonstrating the generalization ability of our model on agnostic bias scenario.
158
+
159
+ Hyperparameter experiments Fig. 5 is the hyperparameter experiments of the degree of amplifying bias $q$ in GCE loss and the importance of generation component $\lambda _ { G }$ . For $q$ , we fix $\lambda _ { G } = 1 0$ and vary $q$ from $\{ 0 . 1 , 0 . 3 , 0 . 5 , 0 . 7 , 0 . 9 \}$ . For $\lambda _ { G }$ , we fix $q = 0 . 7$ and vary $\lambda _ { G }$ from $\{ 1 , 5 , 1 0 , 1 5 \}$ . From the results, we can see that our model achieves stable performance across different values of $q$ and $\lambda _ { G }$ . When $q = 0 . 1$ , it means the GCE loss will nearly reduce to normal CE loss. We can see the performance of $\mathrm { D i s C } _ { G C N }$ is worse than other scenarios, demonstrating the effectiveness of utilizing GCE loss.
160
+
161
+ Table 2: The results on unseen unbiased testing sets, i.e., the color has not been seen in training set.
162
+
163
+ <table><tr><td rowspan="2">Dataset Bias</td><td colspan="3">CMNIST-75sp</td><td colspan="3">CFashion-75sp</td><td colspan="3">CKuzushiji-75sp</td></tr><tr><td>0.8</td><td>0.9</td><td>0.95</td><td>0.8</td><td>0.9</td><td>0.95</td><td>0.8</td><td>0.9</td><td>0.95</td></tr><tr><td>DIR</td><td>10.38±0.28</td><td>10.14±0.40</td><td>9.77±0.18</td><td>16.77±1.71</td><td>16.51±3.20</td><td>12.59±1.61</td><td>10.48±0.34</td><td>10.33±0.75</td><td>10.59±0.95</td></tr><tr><td>GCN</td><td>36.88±5.16</td><td>23.07±4.07</td><td>11.88±0.33</td><td>59.33±0.55</td><td>53.65±0.47</td><td>45.60±1.06</td><td>36.35±0.48</td><td>27.88±0.94</td><td>19.95±0.67</td></tr><tr><td>DisCGCN</td><td>82.73±1.31</td><td>77.70±0.87</td><td>65.48±0.76</td><td>67.9±1.45</td><td>68.28±0.18</td><td>63.77±1.37</td><td>57.80±2.38</td><td>51.60±0.41</td><td>41.60±3.94</td></tr><tr><td>GIN</td><td>48.93±2.99</td><td>34.95±0.86</td><td>14.53±0.97</td><td>58.88±0.57</td><td>53.80±0.52</td><td>48.43±0.69</td><td>39.25±0.57</td><td>30.75±1.45</td><td>22.35±0.86</td></tr><tr><td>DisCGIN</td><td>77.80±1.33</td><td>73.00±0.61</td><td>58.80±1.66</td><td>67.15±0.79</td><td>59.98±0.62</td><td>51.70±0.34</td><td></td><td></td><td>55.47±0.98 43.20±1.36 31.33±1.71</td></tr><tr><td>GCNII</td><td>53.50±6.23</td><td>45.52±2.26</td><td>32.6±5.66</td><td>58.85±1.89</td><td>53.98±0.85</td><td>46.97±1.38</td><td>39.93±0.88</td><td>30.33±1.17</td><td>23.09±1.83</td></tr><tr><td>DisCGCNII</td><td>79.65±2.13</td><td>76.63±1.3860.00±5.66</td><td></td><td></td><td></td><td>60.50±2.77 63.05±2.2561.78±1.60</td><td></td><td>56.23±3.4549.10±2.05</td><td>41.05±0.11</td></tr></table>
164
+
165
+ ![](images/8e496cbb6ae8e9942e5b95edadf4f703867ebb55af480ec526acdfcf4e3dab1a.jpg)
166
+ Figure 5: The hyperparameter experiments of $q$ and $\lambda _ { G }$
167
+
168
+ # 5.2 Qualitative Evaluation
169
+
170
+ Visualization of edge mask. To better illustrate the significant causal and bias subgraphs extracted by $\mathrm { D i s C } _ { G C N }$ , we visualize the original images, original graph, and corresponding causal subgraph and bias subgraph of CMNIST-75sp with 0.9 bias degree in Fig. 6, where the width of edge represents the value of learned weight $c _ { i j }$ or $b _ { i j }$ . Fig. 6(a) shows the visualization results of testing graphs with the bias (color) that has been seen in the training set. As we can see, our model could discover the causal subgraphs where the most salient edges are in the digital subgraphs. With these causal subgraphs that highlight the structure information of digital, the GNNs will more easily extract this causal information. Fig. 6(b) shows the visualization results of testing graphs with unseen bias. According to the visualization, our model could still discover the causal subgraph outline, indicating our model could recognize causal subgraphs, whether the bias is seen or unseen. The visualization results of CFashion-75sp and CKuzushiji-75sp are shown in App. D.
171
+
172
+ ![](images/c8175449c2701658e4017be825905cdeb3e231c2d6376d79873c1c752212b81e.jpg)
173
+ OriginalimageOriginal graph Causalsubgraph BiasedsubgraphOriginalimageOriginal graph CausalsubgraphBiased subgraph
174
+ Figure 6: Visualization of subgraphs extracted by DisC. The width of edge is edge weight $c _ { i j }$ or $b _ { i j }$
175
+
176
+ Projection of disentangled representation. Fig. 7 shows the projection of latent vectors $z _ { c }$ and $z _ { b }$ extracted from the causal GNN $g _ { c }$ and bias GNN $g _ { b }$ of $\mathrm { D i s C } _ { G C N }$ , respectively, using t-SNE [19] on
177
+
178
+ ![](images/221d0d59bdbf86e2589c0ab453c12e80f215382da65ad5e2230b4b84b9a9acaa.jpg)
179
+ Figure 7: Visualization of $z _ { c }$ and $z _ { b }$ with colors labeled by the digit and bias (color) labels. We observe that $z _ { c }$ and $z _ { b }$ are well clustered according to the groundtruth labels and bias labels, respectively.
180
+
181
+ CMNIST-75sp. Fig. 7 (a-b) are the projections of $z _ { c }$ labeled by the target labels (digit) and bias labels (color), respectively. Fig. 7 (c-d) are the projections of $z _ { b }$ labeled by the target labels and bias labels, respectively. We observe that $z _ { c }$ are clustered according to the target labels while $z _ { b }$ are clustered with the bias labels. And $z _ { c }$ are mixed with bias labels and $z _ { b }$ are mixed with target labels. The results indicate that DisC successfully learns the disentangled causal and bias representations.
182
+
183
+ Transferability of the learned mask. As our model could extract GNN-independent subgraphs, the learning edge weights can be used to purify original biased graphs. These sparse subgraphs represent significant semantic information and can be universally transferred to any GNNs. To validate this point, we learn the edge mask by $\mathrm { D i s C } _ { G C N }$ and prune the edges with least $\{ 0 \% , 2 0 \% , 4 0 \% , 6 0 \% \}$ weights while keeping the remaining edge weights. Then we train vanilla GIN and GCNII on these weighted pruned datasets. Fig. 8 is the comparison of the results, where the dashed lines represent the results of base model on original biased graphs and the solid lines represent the performance of GNNs on weighted pruned datasets. The results show that the GNNs trained on the pruned datasets achieve better performances, indicating our learned edge mask has considerable transferability.
184
+
185
+ ![](images/18fa05e618bc66f5ba05c2bab230902cd658bb98fb76ae415b1a2efbc238f5f0.jpg)
186
+ Figure 8: Performance of GIN and GCNII on the weighted pruned graphs found by $\mathrm { D i s C } _ { G C N }$ .
187
+
188
+ # 6 Conclusion
189
+
190
+ In this paper, we are first to study the generalization problem of GNNs on severe bias datasets, which is crucial to study the transparently knowledge learning mechanism of GNNs. We analyze the problem in a causal view that the generalization of GNNs will be hindered by entangled representations as well as the correlation between causal and bias variables. To remove the impact from these two aspects, we propose a general disentangling framework, DisC, which extracts causal substructure and bias substructure by two different functional GNNs, respectively. After the representations are well-disentangled, we proliferate the counterfactual unbiased samples by randomly swapping the disentangled vectors. With the new constructed benchmarks, we clearly validate the effectiveness, robustness, interpretability, and transferability of our method.
191
+
192
+ # Acknowledgments and Disclosure of Funding
193
+
194
+ This work is supported in part by the National Natural Science Foundation of China (No. U20B2045, 62192784, 62172052, 62002029, 62172052, U1936014). This work is also partially supported by the Natural Sciences and Engineering Research Council (NSERC) Discovery Grant, the Canada CIFAR AI Chair Program, collaboration grants between Microsoft Research and Mila, Samsung Electronics Co., Ltd., Amazon Faculty Research Award, Tencent AI Lab Rhino-Bird Gift Fund and a NRC Collaborative R&D Project (AI4D-CORE-06). This project was also partially funded by IVADO Fundamental Research Project grant PRF-2019- 3583139727. The work of Shaohua Fan is supported by the China Scholarship Council (No.202006470078). The computation resource of this project is supported by Compute Canada .
195
+
196
+ References
197
+ [1] Hyojin Bahng, Sanghyuk Chun, Sangdoo Yun, Jaegul Choo, and Seong Joon Oh. Learning de-biased representations with biased representations. In ICML, 2020. [2] Remi Cadene, Corentin Dancette, Matthieu Cord, Devi Parikh, et al. Rubi: Reducing unimodal biases for visual question answering. In NeurIPS, 2019.
198
+ [3] Ming Chen, Zhewei Wei, Zengfeng Huang, Bolin Ding, and Yaliang Li. Simple and deep graph convolutional networks. In ICML, 2020. [4] Tarin Clanuwat, Mikel Bober-Irizar, Asanobu Kitamoto, Alex Lamb, Kazuaki Yamamoto, and David Ha. Deep learning for classical japanese literature. arXiv preprint arXiv:1812.01718, 2018.
199
+ [5] Luke Darlow, Stanisław Jastrz˛ebski, and Amos Storkey. Latent adversarial debiasing: Mitigating collider bias in deep neural networks. arXiv preprint arXiv:2011.11486, 2020. [6] Shaohua Fan, Xiao Wang, Chuan Shi, Peng Cui, and Bai Wang. Generalizing graph neural networks on out-of-distribution graphs. In arXiv preprint arXiv:2111.10657, 2021. [7] Shaohua Fan, Xiao Wang, Chuan Shi, Kun Kuang, Nian Liu, and Bai Wang. Debiased graph neural networks with agnostic label selection bias. TNNLS, 2022. [8] Shaohua Fan, Xiao Wang, Chuan Shi, Emiao Lu, Ken Lin, and Bai Wang. One2multi graph autoencoder for multi-view graph clustering. In WWW, pages 3070–3076, 2020.
200
+ [9] Shaohua Fan, Junxiong Zhu, Xiaotian Han, Chuan Shi, Linmei Hu, Biyu Ma, and Yongliang Li. Metapath-guided heterogeneous graph neural network for intent recommendation. In SIGKDD, pages 2478–2486, 2019.
201
+ [10] Robert Geirhos, Jörn-Henrik Jacobsen, Claudio Michaelis, Richard Zemel, Wieland Brendel, Matthias Bethge, and Felix A Wichmann. Shortcut learning in deep neural networks. Nature Machine Intelligence, 2(11):665–673, 2020.
202
+ [11] Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A Wichmann, and Wieland Brendel. Imagenet-trained cnns are biased towards texture; increasing shape bias improves accuracy and robustness. arXiv preprint arXiv:1811.12231, 2018.
203
+ [12] Madelyn Glymour, Judea Pearl, and Nicholas P Jewell. Causal inference in statistics: A primer. John Wiley & Sons, 2016.
204
+ [13] Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NeurIPS, 2017.
205
+ [14] Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. arXiv preprint arXiv:1903.12261, 2019.
206
+ [15] Weihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong, Hongyu Ren, Bowen Liu, Michele Catasta, and Jure Leskovec. Open graph benchmark: Datasets for machine learning on graphs. In NeurIPS, 2020.
207
+ [16] Byungju Kim, Hyunwoo Kim, Kyungsu Kim, Sungjin Kim, and Junmo Kim. Learning not to learn: Training deep neural networks with biased data. In CVPR, 2019.
208
+ [17] Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In ICLR, 2016.
209
+ [18] Boris Knyazev, Graham W Taylor, and Mohamed Amer. Understanding attention and generalization in graph neural networks. In NeurIPS, 2019.
210
+ [19] G.E. Kvan der Maaten, L.J.P.; Hinton. Understanding attention and generalization in graph neural networks. Journal of Machine Learning Research, 2008.
211
+ [20] John Boaz Lee, Ryan Rossi, and Xiangnan Kong. Graph classification using structural attention. In SIGKDD, 2018.
212
+ [21] Jungsoo Lee, Eungyeup Kim, Juyoung Lee, Jihyeon Lee, and Jaegul Choo. Learning debiased representation via disentangled feature augmentation. In NeurIPS, 2021.
213
+ [22] Haoyang Li, Xin Wang, Ziwei Zhang, and Wenwu Zhu. Ood-gnn: Out-of-distribution generalized graph neural network. arXiv preprint arXiv:2112.03806, 2021.
214
+ [23] Yi Li and Nuno Vasconcelos. Repair: Removing representation bias by dataset resampling. In CVPR, 2019.
215
+ [24] Renjie Liao, Raquel Urtasun, and Richard Zemel. A pac-bayesian approach to generalization bounds for graph neural networks. In ICLR, 2020.
216
+ [25] Yanbei Liu, Xiao Wang, Shu Wu, and Zhitao Xiao. Independence promoted graph disentangled networks. In AAAI, 2020.
217
+ [26] Ana Lucic, Maartje ter Hoeve, Gabriele Tolomei, Maarten de Rijke, and Fabrizio Silvestri. Cf-gnnexplainer: Counterfactual explanations for graph neural networks. In AISTATS, 2022.
218
+ [27] Dongsheng Luo, Wei Cheng, Dongkuan Xu, Wenchao Yu, Bo Zong, Haifeng Chen, and Xiang Zhang. Parameterized explainer for graph neural network. In NeurIPS, 2020.
219
+ [28] Jianxin Ma, Peng Cui, Kun Kuang, Xin Wang, and Wenwu Zhu. Disentangled graph convolutional networks. In ICML, pages 4212–4221. PMLR, 2019.
220
+ [29] Jiaqi Ma, Junwei Deng, and Qiaozhu Mei. Subgroup generalization and fairness of graph neural networks. In NeurIPS, 2021.
221
+ [30] Junhyun Nam, Hyuntak Cha, Sungsoo Ahn, Jaeho Lee, and Jinwoo Shin. Learning from failure: De-biasing classifier from biased classifier. In NeurIPS, 2020.
222
+ [31] Judea Pearl. Causality. Cambridge university press, 2009.
223
+ [32] Hans Reichenbach. The direction of time, volume 65. Univ of California Press, 1991.
224
+ [33] Shiori Sagawa, Pang Wei Koh, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust neural networks. In ICLR, 2019.
225
+ [34] 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.
226
+ [35] Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. In ICLR, 2017.
227
+ [36] Minh Vu and My T Thai. Pgm-explainer: Probabilistic graphical model explanations for graph neural networks. In NeurIPS, 2020.
228
+ [37] Haohan Wang, Zexue He, Zachary C Lipton, and Eric P Xing. Learning robust representations by projecting superficial statistics out. arXiv preprint arXiv:1903.06256, 2019.
229
+ [38] Qitian Wu, Hengrui Zhang, Junchi Yan, and David Wipf. Handling distribution shifts on graphs: An invariance perspective. In ICLR, 2022.
230
+ [39] Ying-Xin Wu, Xiang Wang, An Zhang, Xiangnan He, and Tat-Seng Chua. Discovering invariant rationales for graph neural networks. In ICLR, 2022.
231
+ [40] Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017.
232
+ [41] Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In ICLR, 2019.
233
+ [42] Yiding Yang, Zunlei Feng, Mingli Song, and Xinchao Wang. Factorizable graph convolutional networks. In NeurIPS, volume 33, pages 20286–20296, 2020.
234
+ [43] Rex Ying, Dylan Bourgeois, Jiaxuan You, Marinka Zitnik, and Jure Leskovec. Gnnexplainer: Generating explanations for graph neural networks. In NeurIPS, 2019.
235
+ [44] Zhitao Ying, Jiaxuan You, Christopher Morris, Xiang Ren, Will Hamilton, and Jure Leskovec. Hierarchical graph representation learning with differentiable pooling. In NeurIPS, volume 31, 2018.
236
+ [45] Hao Yuan, Haiyang Yu, Jie Wang, Kang Li, and Shuiwang Ji. On explainability of graph neural networks via subgraph explorations. In ICML, 2021.
237
+ [46] Muhan Zhang, Zhicheng Cui, Marion Neumann, and Yixin Chen. An end-to-end deep learning architecture for graph classification. In AAAI, 2018.
238
+ [47] Zhilu Zhang and Mert Sabuncu. Generalized cross entropy loss for training deep neural networks with noisy labels. NeurIPS, 2018.
239
+
240
+ # Checklist
241
+
242
+ 1. For all authors...
243
+
244
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
245
+ (b) Did you describe the limitations of your work? [Yes] See App. E.
246
+ (c) Did you discuss any potential negative societal impacts of your work? [No] We could not foresee any potential negative societal impacts of our work.
247
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
248
+
249
+ 2. If you are including theoretical results...
250
+
251
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Sec. 3.2. (b) Did you include complete proofs of all theoretical results? [Yes]
252
+
253
+ 3. If you ran experiments...
254
+
255
+ (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 provide the URL of code and data for reproducing the main results.
256
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Sec. 5 and App. C.2.
257
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Sec. 5.
258
+ (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 Sec. 5.
259
+
260
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
261
+
262
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We construct new assets based on existing assets. We have cited them in Sec. 5.
263
+ (b) Did you mention the license of the assets? [Yes] See App. C.
264
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We release new assets through a URL in Sec. 5.
265
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] The source data for generating our data is publicly available.
266
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] We do not have personally identifiable information or offensive content.
267
+
268
+ 5. If you used crowdsourcing or conducted research with human subjects...
269
+
270
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
271
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
272
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/iAWNOXfLz0/iAWNOXfLz0.md ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AnoFormer: Time Series Anomaly Detection using Transformer-based GAN with Two-Step Masking
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ Time series anomaly detection is a task that determines whether an unseen signal is normal or abnormal, and it is a crucial function in various real-world applications. Typical approach is to learn normal data representation using generative models, like Generative Adversarial Network (GAN), to discriminate between normal and abnormal signals. Recently, a few studies actively adopt transformer to model time series data, but there is no transformer-based GAN framework for time series anomaly detection. As a pioneer work, we propose a new transformerbased GAN framework, called AnoFormer, and its effective training strategy for better representation learning. Specifically, we improve the detection ability of our model by introducing two-step masking strategies. The first step is Random masking: we design a random mask pool to hide parts of the signal randomly. This allows our model to learn the representation of normal data. The second step is Exclusive and Entropy-based Re-masking: we propose a novel refinement step to provide feedback to accurately model the exclusive and uncertain parts in the first step. We empirically demonstrate the effectiveness of re-masking step that our model generates more normal-like signals robustly. Extensive experiments on various datasets show that AnoFormer significantly outperforms the state-of-the-art methods in time series anomaly detection.
11
+
12
+ # 19 1 Introduction
13
+
14
+ 20 Time series anomaly detection is a crucial technology to prevent potential risks and financial losses
15
+ 21 in a variety of areas, such as detecting anomalies on sensor data of large-scale plants [1], ECG
16
+ 22 monitoring [2], and the network traffic analysis [3]. To deal with this task, from the classic methods
17
+ 23 [4, 5, 6] to the recent deep learning-based methods [2, 7, 8, 9, 10, 11, 12, 13], many studies have
18
+ 24 focused on unsupervised learning methods due to the lack of labeled anomalies and highly nonlinear
19
+ 25 temporal dependencies.
20
+ 26 One of major deep learning-based approaches is a reconstruction-based method. It typically uses an
21
+ 27 autoencoder (AE) or Generative Adversarial Network (GAN) to learn the representation of normal
22
+ 28 data and to reconstruct a normal-like signal from an input always. As a backbone network, the
23
+ 29 existing studies widely utilize CNN (Convolutional Neural Networks) [2] or RNN (Recurrent Neural
24
+ 30 Networks) [8, 9, 10]. More recently, there have been attempts to apply transformer [14] to time
25
+ 31 series anomaly detection, and it shows remarkable performances [11]. In this work, we also adopt
26
+ 32 transformer to embed time series representation, but design an adversarial framework for anomaly
27
+ 33 detection.
28
+ 34 If we devise GAN using a transformer encoder, we expect that the model learns normal time series
29
+ 35 data and eventually generates real normal-like signals. However, there is a major issue. Unlike the
30
+ 36 AE structure, a pure transformer encoder-based generator does not have a compressed latent space,
31
+ 37 i.e., it makes the model find the trivial solution, just copying an input and pasting to the output for the
32
+ 38 reconstruction. Therefore, we need a new training method for the generator to learn the distribution
33
+ 39 of normal time series data. To address this issue, we introduce a novel two-step masking strategy.
34
+ 40 From this approach, the next question is where to mask an input signal to detect anomalies effectively.
35
+ 41 Understandably, in order to make the normal-like output, the best masking positions are abnormal
36
+ 42 points in the input signal. It is a challenging to mask the abnormal areas selectively because we do
37
+ 43 not know where the abnormal parts are in advance.
38
+ 44 In this paper, we propose AnoFormer, which is a novel transformer-based GAN utilizing a pure
39
+ 45 transformer encoder only. To learn data representation effectively, we adopt a masking strategy. We
40
+ 46 first train transformer-based GAN with random masking (Step 1) for representation learning of the
41
+ 47 normal time series data. While filling the randomly masked parts of the input at Step 1, the model
42
+ 48 learns the distribution of normal data effectively. In Step 1 alone, all parts of the input signal cannot
43
+ 49 be considered, and this randomness is a big problem in anomaly detection. Therefore, we solve this
44
+ 50 problem by re-masking the exclusive parts of Step 1. Also, to find the best masking positions, we
45
+ 51 calculate entropy from the attention maps of transformer blocks and re-mask the parts with high
46
+ 52 entropy that is likely to be abnormal points with high uncertainty. This exclusive and entropy-based
47
+ 53 re-masking (Step 2) provides feedback for better representation learning, eventually improving the
48
+ 54 anomaly detection performance. We experimentally prove that the proposed two-step masking is
49
+ 55 essential for AnoFormer to solve anomaly detection problem successfully.
50
+
51
+ 56 Our contributions can be summarized as follows:
52
+
53
+ • We propose a simple yet effective transformer-based GAN framework having a generator and a discriminator for unsupervised time series anomaly detection, called AnoFormer. Moreover, we present pre-processing and embedding methods for our framework to deal with time series data effectively.
54
+ • We introduce a new two-step masking method to encode the distribution of normal time series data. A newly proposed entropy-based re-masking helps our model to provide the feedback to the uncertain parts based on entropy. From the extensive ablations, we empirically verify that our two-step masking makes our model robust and successfully embed the representation of normal time series data.
55
+ • AnoFormer achieves new state-of-the-art results with significant improvements on various unsupervised time series anomaly detection datasets: NeurIPS-TS, MIT-BIH, 2D-gesture, and Power-demand.
56
+
57
+ # 69 2 Related Work
58
+
59
+ 70 Generative models using transformer have been proposed and applied to diverse domains, e.g.,
60
+ 71 computer vision [15, 16, 17, 18], natural language processing [19, 20], and sequence modeling
61
+ 72 [21, 22]. In particular, these models are used to solve various tasks in the image domain, such
62
+ 73 as scene generation [15, 16, 23], saliency prediction [18], semantic segmentation [24], and sketch
63
+ 74 synthesis [25]. Moreover, transformer is presented to solve graph-to-sequence transduction task
64
+ 75 using graph neural network [26], text generation task [27], and time series forecasting task with
65
+ 76 the modified self-attention mechanism [28]. We also utilize transformer to construct a generative
66
+ 77 framework, i.e., having both a generator and a discriminator. In this framework, we propose an
67
+ 78 appropriate embedding method and loss form to effectively solve the anomaly detection problems.
68
+ 79 Many studies have used masking to the transformer architecture for effective representation learning.
69
+ 80 Including BERT [29], which proposes the Masked Language Model (MLM) technique to pretrain
70
+ 81 the language representation, many studies also adopt the masking methods, like [30] for action
71
+ 82 recognition, [30] for text classification task, [31] for text log anomaly detection, [32, 33] for visual
72
+ 83 representation learning. In [34], the CNN-based model learns the semantic context features by using
73
+ 84 a multi-scale mask across the whole image with different scales for anomaly detection in image
74
+ 85 domain. We also use masking in our transformer-based GAN for time series anomaly detection, but
75
+ 86 unlike the above studies, we propose the two-step masking strategy for training and test to provide
76
+ 87 feedback that boosts the model to generate the uncertain parts successfully.
77
+
78
+ ![](images/7115bd0fec0ddd2e3db41bbe484d7135d01fb4409712ae48ff3ddde0e1a8c791.jpg)
79
+ Figure 1: Overview of the proposed AnoFormer. For simplicity, this figure shows the univariate case. In Step 1 (random masking), a pre-processed input $\tilde { \boldsymbol { X } }$ is masked with a randomly selected mask from a predefined mask pool. After passing the masked input $\tilde { \pmb X } _ { m } ^ { 1 }$ to the generator, $\hat { X } _ { 1 }$ is generated as the output by passing through embedding, transformer encoder, and inverse embedding layers. In Step 2 (exclusive and entropy-based re-masking), based on the entropy calculated from attention maps of all layers in Step 1, $\tilde { \boldsymbol { X } }$ is re-masked and ${ \hat { \mathbf { X } } } _ { 2 }$ is generated again from the generator. Final output $\hat { \pmb X }$ is constructed via the combination of the masked parts of Step 1 and Step 2. With an aid of a critic, the generator is able to generate more normal-like signals. Here, $\mathcal { L } _ { a d v }$ is the adversarial loss, including $\mathcal { L } _ { a d v } ^ { g }$ and $\mathcal { L } _ { a d v } ^ { c }$ . Note that the critic is used only for the train time.
80
+
81
+ # 88 3 AnoFormer
82
+
83
+ 89 In this section, we propose AnoFormer for unsupervised time series anomaly detection. We first
84
+ 90 define the target task including an algorithm procedure briefly in Section 3.1. We then describe how
85
+ 91 to construct a transformer-based GAN framework based on a transformer encoder in Section 3.2.
86
+ 92 Next, we introduce two different masking steps for our model to encode time series data effectively
87
+ 93 in Section 3.3. Finally, we present the whole training scheme of AnoFormer in Section 3.4. Figure 1
88
+ 94 shows the overall architecture of AnoFormer.
89
+
90
+ # 3.1 Problem Definition
91
+
92
+ Let $\begin{array} { r c l } { { \textbf { { X } } } } & { { = } } & { { \left\{ { \pmb x } _ { 1 } , { \pmb x } _ { 2 } , \cdot \cdot \cdot , { \pmb x } _ { T } \right\} \ \in \ \mathbb { R } ^ { T \times n } } } \end{array}$ be an input signal of $T$ lengths, where $\begin{array} { r l } { \mathbf { \boldsymbol { x } } _ { t } } & { { } = } \end{array}$ $\left\{ \pmb { x } _ { t } ^ { 1 } , \pmb { x } _ { t } ^ { 2 } , \cdot \cdot \cdot , \pmb { x } _ { t } ^ { n } \right\} \in \mathbb { R } ^ { n }$ at time step $t$ is a vector of dimension $n$ . Since it is easier to get normal time series data compared to abnormal ones, we train a generator $\mathbf { G }$ and a discriminator $\mathrm { D }$ using only normal data without any label in an unsupervised manner. After training, for each unseen signal $\boldsymbol { X }$ , which can be normal or abnormal, the generator $G$ generates a normal-like signal $\hat { X }$ . From the generated signal, we can determine whether the observed signal $\boldsymbol { X }$ is normal or not based on the reconstruction errors between the given signal $\boldsymbol { X }$ and the generated signal $\hat { X }$ .
93
+
94
+ # 3.2 Transformer-based GAN for Time Series Data
95
+
96
+ Pre-Processing. To deal with an input signal for a transformer encoder, we need a pre-processing step that makes the input signal discrete tokens. To this end, we normalize each time series input $\boldsymbol { X }$ between $^ { - 1 }$ and 1 by using the min-max scaling. Then, we quantize the normalized real value within a specific range $[ 0 , K )$ , where the integer $K$ is a hyperparameter controlling the quantization resolution, and use the corresponding integer value as a token. Let $\tilde { \pmb X } \in \mathbb { R } ^ { T \times n }$ be the pre-processed signal. We set $K = 4 0 0$ for all the experiments, in which the pre-processed signal $\tilde { X }$ looks almost like the input $\boldsymbol { X }$ . In total of $K$ tokens (quantization levels), we add a [MASK] token to utilize it for both training and test. To sum up, the input signal $\boldsymbol { X }$ is pre-processed to be $\tilde { \boldsymbol { X } }$ by applying scaling and quantization sequentially.
97
+
98
+ 113 Embedding. An embedding step embeds discrete tokens into the embedding vectors. Here we use
99
+ 114 a token embedding layer to map each token to the corresponding entry in an embedding weight
100
+ 115 $W ^ { e } \in \mathbb { R } ^ { ( K + 1 ) \times d }$ . We denote $z ^ { \prime } \in \mathbb { R } ^ { T \times d }$ as the output token embedding, where $d$ is an embedding
101
+
102
+ dimension. We add a sinusoidal positional embedding 116 $\pmb { p } ^ { \prime }$ to the token embedding $z ^ { \prime }$ to allow the 117 model to attend relative positions as follows:
103
+
104
+ $$
105
+ z = z ^ { \prime } + p ^ { \prime } .
106
+ $$
107
+
108
+ 118 Transformer Encoder. A transformer encoder uses the embedding $z \in \mathbb { R } ^ { T \times d }$ as the input, and
109
+ 119 outputs $\hat { \boldsymbol { z } } \in \mathbb { R } ^ { T \times d }$ . Each block of the transformer encoder contains a multi-head self-attention layer
110
+ 120 and a feed-forward network, followed by a residual connection and a layer normalization. Through
111
+ 121 the self-attention mechanism, it is possible to attend the relevant information of each time step at
112
+ 122 once, while multiple attention heads can consider different periodicities in time series data [35].
113
+ 123 Inverse Embedding. We need to invert the output $\hat { z }$ into the original form of time series, $\hat { \boldsymbol { X } } \in \mathbb { R } ^ { T \times n }$ .
114
+ 124 To this end, we introduce an inverse embedding layer to our model. We calculate the cosine similarity
115
+ 125 between the output embedding $\hat { z }$ and the embedding weight $\pmb { W } ^ { e }$ taken from the token embedding
116
+ 126 layer, and apply the softmax operation as follows:
117
+
118
+ $$
119
+ \hat { \pmb { p } } = s o f t m a x \left( \frac { \hat { \boldsymbol { z } } \cdot \mathbf { W } ^ { e ^ { \top } } } { \lVert \hat { \boldsymbol { z } } \rVert \left. \mathbf { W } ^ { e ^ { \top } } \right. } \right) .
120
+ $$
121
+
122
+ 127 From the above equation, we obtain the probability distribution $\hat { \pmb { p } } \in \mathbb { R } ^ { T \times K }$ , where $\hat { p } _ { t , k }$ means the
123
+ 128 probability that $k$ will be selected in the range of $[ 0 , K )$ except the [MASK] token at the position $t$ .
124
+ 129 We then extract an index $\hat { \mathbf { x } } _ { t }$ of the maximum probability for each time step $t \in [ 1 , 2 , \cdots , T ]$ , using
125
+ 130 the soft-argmax operation as follows:
126
+
127
+ $$
128
+ \begin{array} { r } { \hat { \pmb { x } } _ { t } = s o f t - a r g m a x ( \hat { \pmb { p } } _ { t } ) = \sum _ { i = 0 } ^ { K - 1 } \frac { e ^ { \beta \hat { \pmb { p } } _ { t , i } } } { \sum _ { j = 0 } ^ { K - 1 } e ^ { \beta \hat { \pmb { p } } _ { t , j } } } i , } \end{array}
129
+ $$
130
+
131
+ 131 where $\beta$ is a sufficiently large value, such as 1000. Then, the indices in all time steps are concatenated to reconstruct the quantized output 132 $\hat { X }$ as follows:
132
+
133
+ $$
134
+ \hat { \pmb X } = \left\{ \hat { \pmb x } _ { 1 } , \hat { \pmb x } _ { 2 } , \hat { \star } \hat { \star } \hat { \ b } _ { T } \right\} .
135
+ $$
136
+
137
+ 133 Transformer-based GAN Framework. To enhance the generation quality of $\hat { X }$ , we design an
138
+ 134 adversarial framework using transformer encoders. Following the notation of WGAN-GP [36], from
139
+ 135 now on we use the term critic $C$ instead of the discriminator $D$ . Same as the generator $G$ , we
140
+ 136 construct the critic $C$ using the transformer encoder, but in the critic $C$ , a [CLS] token is added in
141
+ 137 front of the input tokens for classification. After passing through the transformer encoder, the linear
142
+ 138 classifier outputs the critic score using only the [CLS] token. While classifying the real input $\tilde { \boldsymbol X }$ and
143
+ 139 the fake output $\hat { X }$ , the critic $C$ guides the generator $G$ to reconstruct more normal-like signal $\hat { X }$ . As
144
+ 140 a result, our model can distinguish $\tilde { \boldsymbol X }$ whether it is normal or abnormal according to the difference
145
+ 141 between the input signal $\tilde { \boldsymbol { X } }$ and the reconstructed signal $\hat { X }$ from the generator $G$ at test time.
146
+
147
+ # 3.3 Two-Step Masking for Time Series Encoding
148
+
149
+ 143 In the previous section, we introduce the transformer-based GAN framework for time series data.
150
+ 144 However, we empirically find that the representation learning of the proposed transformer-based
151
+ 145 GAN is not possible because the generator $G$ just copies the input as the output always. Inspired by
152
+ 146 recent studies [35, 32, 33] that effectively learn the representation through masking in transformer,
153
+ 147 we propose two different masking steps during training and test time: 1) random masking and 2)
154
+ 148 exclusive and entropy-based re-masking. We experimentally demonstrate that the proposed two-step
155
+ 149 masking is essential for our framework to learn the distribution of normal time series data successfully.
156
+ 150 In the following content, we describe how to mask the input effectively in each step with details.
157
+
158
+ Step 1: Random Masking. As the first step, we partially hide the input signal $\tilde { \boldsymbol { X } }$ using a randomly selected mask from a mask pool. To construct the mask pool, we design a single mask in which the mask and the non-mask sections alternately appear. We then generate multiple masks by applying sliding window to the single mask, and group them as the mask pool. The composition of the mask pool depends on a length $l _ { m }$ of a single mask section, a ratio $r _ { m }$ of all mask parts, and a stride $s _ { m }$ for the sliding window. The number of masks $n _ { m }$ in the predefined mask pool is determined as follows:
159
+
160
+ $$
161
+ n _ { m } = 2 \times \left\lceil { \frac { l _ { m } } { s _ { m } } } \right\rceil .
162
+ $$
163
+
164
+ 157 Using the above equation, we generate the enough number of masks in the pool to cover all sections
165
+ 158 of the signal. During the train and test time, the mask is randomly selected in the predefined mask
166
+ 159 pool per each signal, and the generator $G$ reconstructs $\hat { X } _ { 1 }$ from the masked input $\bar { \tilde { \mathbf { X } } } _ { m } ^ { 1 }$ .
167
+ 160 Step 2: Exclusive and Entropy-based Re-Masking. After $\hat { \pmb X } _ { 1 }$ is generated from Step 1, we again
168
+ 161 mask the exclusive parts that are not covered in Step 1 for our model to consider all parts of the
169
+ 162 input. To avoid the error accumulation, here we re-mask the input $\tilde { \boldsymbol X }$ , instead of the first output $\hat { X } _ { 1 }$ .
170
+ 163 In addition, we provide feedback to our model by re-masking the parts that the model considers
171
+ 164 uncertain during Step 1. To this end, we get an attention map from each layer of the generator as
172
+ 165 follows:
173
+
174
+ $$
175
+ \begin{array} { c } { { A ^ { l , h } = s o f t m a x \left( \displaystyle \frac { Q ^ { h } K ^ { h ^ { T } } } { \sqrt { d } } \right) , } } \\ { { A ^ { l } = \displaystyle \frac { 1 } { H } \sum _ { h = 1 } ^ { H } A ^ { l , h } , } } \end{array}
176
+ $$
177
+
178
+ 166 where $l \in [ 1 , 2 , \cdots , L ]$ and $A ^ { l }$ is the attention map in the $l$ -th layer, calculated by the average of all
179
+ 167 attention maps for individual heads, $A ^ { l , h }$ . This layer-wise attention map determines how much a
180
+ 168 specific time step focuses on the other parts of the input per signal. In this context, the uniformly
181
+ 169 distributed attention means that the model does not know which connections are valuable [37], i.e.,
182
+ 170 the prediction is uncertain. To quantify the uncertainty, we calculate an entropy $H _ { \hat { X } _ { 1 } }$ of the masked
183
+ 171 input ${ \hat { X } } _ { 1 }$ as follows:
184
+
185
+ $$
186
+ \begin{array} { r } { H ( t ) = - \displaystyle \frac { 1 } { L } \sum _ { l = 1 } ^ { L } \sum _ { j = 1 } ^ { T } A _ { t , j } ^ { l } \log A _ { t , j } ^ { l } , } \\ { H _ { \hat { \pmb X } _ { 1 } } = \{ H ( 1 ) , H ( 2 ) , \cdots , H ( T ) \} . } \end{array}
187
+ $$
188
+
189
+ 172 To provide feedback on the high entropy parts, we re-mask $50 \%$ of the parts already masked in Step
190
+ 173 1. Then the generator $G$ re-generates the second output ${ \hat { \mathbf { X } } } _ { 2 }$ from the masked signal ${ \tilde { \bf X } } _ { 2 }$ . Finally,
191
+ 174 we combine the masked parts generated from Step 1 and the ones from Step 2 to construct the final
192
+ 175 output $\hat { X }$ . If there are overlapped parts between Step 1 and Step 2, the parts of Step 2 are used. From
193
+ 176 this re-masking step, we experimentally prove that our model becomes robust to unexplored and
194
+ 177 uncertain parts within a fixed model size. We also use the same random masking and re-masking
195
+ 178 strategies at test time.
196
+
197
+ # 3.4 Training AnoFormer
198
+
199
+ To train AnoFormer, we apply the cross-entropy loss to reconstruct the same input 80 $\tilde { \boldsymbol X }$ from the final output 81 $\hat { X }$ as follows:
200
+
201
+ $$
202
+ \mathcal { L } _ { r e c } = - \sum _ { i = 1 } ^ { T } \sum _ { j = 1 } ^ { K } \tilde { X } _ { i , j } \cdot \log \left( \hat { p } _ { i , j } \right) ,
203
+ $$
204
+
205
+ where 182 $\tilde { X } _ { i , j }$ denotes the one-hot label vector from the input and $\hat { p } _ { i , j }$ denotes the probability distribu183 tion of the final output $\hat { X }$ . Using $\hat { X }$ from the generator $G$ during two-step masking, the critic $C$ tries 184 to minimize the following loss function:
206
+
207
+ $$
208
+ \begin{array} { c } { { X ^ { \prime } = \epsilon \tilde { X } + ( 1 - \epsilon ) \hat { X } , } } \\ { { { \mathcal { L } } _ { C , a d v } = \left( \mathbb { E } \left[ C \left( \hat { X } \right) \right] - \mathbb { E } \left[ C \left( \tilde { X } \right) \right] \right) + \lambda \mathbb { E } _ { X ^ { \prime } \sim P _ { X ^ { \prime } } } \left[ \left( \left. \nabla _ { X ^ { \prime } } C \left( X ^ { \prime } \right) \right. _ { 2 } - 1 \right) ^ { 2 } \right] , } } \end{array}
209
+ $$
210
+
211
+ 185 where $\epsilon$ is randomly chosen between zero and one. The first term measures the Wasserstein distance
212
+ 186 and the second term is the gradient penalty, where $X ^ { \prime }$ is a random sample from $P _ { X ^ { \prime } }$ to enforce the
213
+ 187 Lipschitz constraint. The coefficient is a harmonic parameter to balance the Wasserstein distance and
214
+ 188 the gradient penalty, where we use the value of 10. The loss function of the generator $G$ is as follows:
215
+ 189
216
+
217
+ $$
218
+ \mathcal { L } _ { a d v } ^ { g } = - \mathbb { E } \left[ C \left( \hat { \boldsymbol { X } } \right) \right] ,
219
+ $$
220
+
221
+ Table 1: Quantitative comparisons in four datasets. For all of the metrics, a higher value indicates a better performance.
222
+
223
+ <table><tr><td rowspan="2">Metric</td><td rowspan="2">Base Architecture</td><td rowspan="2">Method</td><td colspan="6">NeurIPS-TS</td><td rowspan="2">MIT-BIH</td><td rowspan="2">2D-gesture</td><td rowspan="2">Power-demand</td></tr><tr><td>Global</td><td>Contextual</td><td>Shapelet</td><td>Seasonal</td><td>Trend</td><td>Average</td></tr><tr><td rowspan="6">AUROC</td><td>CNN</td><td>BeatGAN</td><td>0.9753</td><td>0.6128</td><td>0.7398</td><td>0.9742</td><td>1.0000</td><td>0.8372</td><td>0.9475</td><td>0.7256</td><td>0.5796</td></tr><tr><td>RNN</td><td>TadGAN</td><td>1.0000</td><td>0.4285</td><td>0.9834</td><td>0.9744</td><td>0.9327</td><td>0.9726</td><td>0.8256</td><td>0.5294</td><td>0.8438</td></tr><tr><td></td><td>RAE-ensemble</td><td>0.5226</td><td>0.9348</td><td>0.9244</td><td>0.9625</td><td>0.7246</td><td>0.8138</td><td>-</td><td>0.7808</td><td>0.6587</td></tr><tr><td></td><td>RAMED</td><td>0.5265</td><td>0.9325</td><td>0.9084</td><td>0.9628</td><td>0.7259</td><td>0.8112</td><td>-</td><td>0.7839</td><td>0.6787</td></tr><tr><td>Transformer</td><td>Anomaly Transformer</td><td>0.9931</td><td>0.6224</td><td>0.7407</td><td>0.9332</td><td>0.9976</td><td>0.8400</td><td>0.8108</td><td>0.7868</td><td>0.7739</td></tr><tr><td></td><td>AnoFormer (Ours)</td><td>1.0000</td><td>0.9758</td><td>0.9900</td><td>0.9985</td><td>0.9985</td><td>0.9911</td><td>0.9552</td><td>0.8407</td><td>0.8667</td></tr><tr><td rowspan="6">AUPRC</td><td>CNN</td><td>BeatGAN</td><td>0.9855</td><td>0.7051</td><td>0.6817</td><td>0.9748</td><td>1.0000</td><td>0.9634</td><td>0.9143</td><td>0.4952</td><td>0.1228</td></tr><tr><td>RNN</td><td>TadGAN</td><td>1.0000</td><td>0.3603</td><td>0.9565</td><td>0.9754</td><td>0.8731</td><td>0.9806</td><td>0.4621</td><td>0.4367</td><td>0.3098</td></tr><tr><td></td><td>RAE-ensemble</td><td>0.0453</td><td>0.8297</td><td>0.8159</td><td>0.9191</td><td>0.1378</td><td>0.5496</td><td>-</td><td>0.5287</td><td>0.1400</td></tr><tr><td></td><td>RAMED</td><td>0.0443</td><td>0.8223</td><td>0.6873</td><td>0.9109</td><td>0.1291</td><td>0.5188</td><td>-</td><td>0.5331</td><td>0.1627</td></tr><tr><td>Transformer</td><td>Anomaly Transformer</td><td>0.9959</td><td>0.6957</td><td>0.6630</td><td>0.9364</td><td>0.9978</td><td>0.9639</td><td>0.5603</td><td>0.5607</td><td>0.4967</td></tr><tr><td></td><td>AnoFormer (Ours)</td><td>1.0000</td><td>0.9854</td><td>0.9901</td><td>0.9985</td><td>0.9987</td><td>0.9982</td><td>0.9187</td><td>0.6142</td><td>0.5584</td></tr><tr><td rowspan="6">F1 score</td><td>CNN</td><td>BeatGAN</td><td>0.9345</td><td>0.7348</td><td>0.6136</td><td>0.9487</td><td>1.0000</td><td>0.9008</td><td>0.8015</td><td>0.4941</td><td>0.2266</td></tr><tr><td>RNN</td><td>TadGAN</td><td>1.0000</td><td>0.3590</td><td>0.9331</td><td>0.9844</td><td>0.8170</td><td>0.9380</td><td>0.5289</td><td>0.4138</td><td>0.5714</td></tr><tr><td></td><td>RAE-ensemble</td><td>0.0853</td><td>0.8343</td><td>0.7750</td><td>0.9181</td><td>0.3889</td><td>0.6003</td><td>-</td><td>0.5511</td><td>0.2678</td></tr><tr><td></td><td>RAMED</td><td>0.0838</td><td>0.8272</td><td>0.6203</td><td>0.8782</td><td>0.4040</td><td>0.5627</td><td>-</td><td>0.5633</td><td>0.2934</td></tr><tr><td>Transformer</td><td>Anomaly Transformer</td><td>0.9751</td><td>0.7358</td><td>0.6115</td><td>0.8730</td><td>0.9958</td><td>0.9014</td><td>0.5446</td><td>0.6486</td><td>0.6053</td></tr><tr><td></td><td>AnoFormer (Ours)</td><td>1.0000</td><td>0.9400</td><td>0.9696</td><td>0.9913</td><td>0.9974</td><td>0.9798</td><td>0.8410</td><td>0.6667</td><td>0.6226</td></tr></table>
224
+
225
+ which makes the critic 190 $C$ not be able to classify the generated $\hat { X }$ . To sum up, the proposed AnoFormer 191 is trained via the following loss functions for the generator $G$ and the critic $C$ :
226
+
227
+ $$
228
+ \begin{array} { c } { { \mathcal { L } _ { G } = \lambda _ { r e c } \mathcal { L } _ { r e c } + \lambda _ { a d v } \mathcal { L } _ { a d v } ^ { g } , } } \\ { { \mathcal { L } _ { C } = \mathcal { L } _ { a d v } ^ { c } , } } \end{array}
229
+ $$
230
+
231
+ 192 where we set $\lambda _ { r e c }$ and $\lambda _ { a d v }$ as 1.
232
+
233
+ # 4 Experiments
234
+
235
+ Datasets. We evaluated AnoFormer on four real-world benchmarks: 1) MIT-BIH 1 contains 48 ECG records of test subjects from Beth Israel Hospital, 2) 2D-gesture contains time series of X and Y coordinates of an actor’s right hand, 3) Power-demand is a dataset measuring the power comsumption for the Dutch research facility, and 4) NeurIPS-TS 2 [38] is a synthetic dataset including five different time series anomaly scenarios as point-global, point-contextual, pattern-shapelet, pattern-seasonal, and pattern-trend. More details on each dataset are summarized in Appendix A.
236
+
237
+ Baselines. We compared our model with various baselines, including CNN, RNN, and transformerbased reconstruction models. BeatGAN [2] and TadGAN [8] are CNN and LSTM-based GAN models, respectively. RAE-ensemble [9] is an ensemble of RNNs with sparse skip connections in autoencoder. RAMED [10] additionally uses the multiresolution decoding based on RAE-ensemble. Anomaly Transformer [11] develops the transformer architecture to utilize association information.
238
+
239
+ Implementation Details. For both the generator $G$ and the critic $C$ , we utilized the basic transformer encoders with 9 and 6 layers for MIT-BIH, and 4 and 2 layers for other datasets, respectively. The embedding dimension and the number of heads are 128 and 8, respectively. The mask length $l _ { m }$ is about $10 \%$ of the sequence length $T$ , and the mask stride $s _ { m }$ is about half of the mask length $l _ { m }$ We used Adam optimizer with initial learning rate, momentum $\beta _ { 1 }$ , and $\beta _ { 2 }$ as 0.0001, 0.5, and 0.999, respectively. We implemented our model using PyTorch and trained on a NVIDIA RTX 3090 GPU.
240
+
241
+ # 4.1 Quantitative Results
242
+
243
+ Table 1 shows the anomaly detection performances of each baseline on three different real-world datasets (i.e., MIT-BIH, 2D-gesture, and Power-demand), and a synthetic dataset (i.e., NeurIPS-TS [38]). Overall, RNN or transformer-based models showed high performances except MIT-BIH. In MIT-BIH, BeatGAN showed the second-best performances among all the benchmarks. In case of the proposed AnoFormer, this model outperformed all the baselines in four different datasets. In
244
+
245
+ ![](images/47b408cd47c8108b2ae4f17f6296ca554263ab559cf561bb93d4146ced1092e0.jpg)
246
+ Figure 2: Output visualization in Point-Contextual (NeurIPS-TS) and MIT-BIH datasets. Left: visualization of abnormal input and the normal-like output. Middle: reconstruction results of random masking (blue). Right: reconstruction results of exclusive (green) and entropy-based (red) re-masking. Vest viewed in color.
247
+
248
+ 217 particular, our model performed well on NeurIPS-TS containing five types of outliers, and it means
249
+ 218 AnoFormer is robust to the various types of outliers. AnoFormer achieved the state-of-the-art results
250
+ 219 from small datasets (e.g., 2D-gesture and Power-demand) with about 1,000 training sets to large
251
+ 220 datasets (e.g., NeurIPS-TS and MIT-BIH) with about tens of thousands of training sets, and from
252
+ 221 univariate to multivariate cases. The experimental results demonstrate that the proposed transformer
253
+ 222 based GAN framework with the two-step masking strategy is effective to reconstruct normal time
254
+ 223 series data for anomaly detection.
255
+
256
+ # 4.2 Qualitative Results
257
+
258
+ Figure 2 shows the qualitative examples of AnoFormer. First column (Figure 2(a) and Figure 2(d)) shows the abnormal examples of point-contextual of NeurIPS-TS and MIT-BIH datasets, respectively. The other columns show that the proposed rnadom masking and re-masking strategies actually provide feedback to our framework. For example, the incorrectly copied parts in Step 1 was refined by the entropy-based re-masking (please see the black circles in the figure). As shown in the figure, when the abnormal inputs were received, the model generated the normal-like outputs. Therefore, AnoFormer can detect the abnormal points through the difference between the input and the output.
259
+
260
+ # 4.3 Ablation Study
261
+
262
+ We conducted various ablation studies to analyze the effectiveness of the proposed transformerbased GAN framework and two-step masking. All of the ablation studies were performed on the Point-Contextual dataset of NeurIPS-TS, since it is the most difficult task to detect the anomalies out of the five types of outliers. Figure 2 shows an example of Point-Contextual dataset, which has the small glitches as the outliers. In Appendix B, we additionally examined the sensitivity of each hyperparameter newly adopted in our model.
263
+
264
+ # 4.3.1 Transformer-based GAN Framework
265
+
266
+ We first investigated the effectiveness of the transformer-based adversarial framework in our model. In this experiment, we used BeatGAN as a CNN-based baseline. Table 2 shows the ablation results when the generator and the critic use different backbone networks, such as CNN, and transformer. As shown in the table, the transformer-based generator showed higher performances on all of metrics with large margins than the CNN-based generator. Interestingly, we empirically found that there was no synergy when using CNN-based critic with the transformer-based generator. It means, it is not helpful for the transformer-based generator to construct the critic with an inappropriate baseline. On
267
+
268
+ Table 2: Ablation study of the proposed transformer-based GAN.
269
+
270
+ <table><tr><td>Generator</td><td>Critic</td><td>AUROC</td><td>AUPRC</td><td>F1 score</td></tr><tr><td>CNN</td><td>CNN</td><td>0.6128</td><td>0.7051</td><td>0.7348</td></tr><tr><td>Transformer</td><td>-</td><td>0.9572</td><td>0.9735</td><td>0.9093</td></tr><tr><td>Transformer</td><td>CNN</td><td>0.9510</td><td>0.9675</td><td>0.9026</td></tr><tr><td>Transformer</td><td>Transformer</td><td>0.9758</td><td>0.9854</td><td>0.9400</td></tr></table>
271
+
272
+ Table 3: Ablation study of the proposed two-step masking.
273
+
274
+ <table><tr><td>Step1</td><td>Step 2</td><td>AUROC</td><td>AUPRC</td><td>F1 score</td></tr><tr><td>-</td><td>-</td><td>0.5000</td><td>0.3602</td><td>0.2386</td></tr><tr><td>Random</td><td>■</td><td>0.8557</td><td>0.7959</td><td>0.7548</td></tr><tr><td>Mask pool</td><td>■</td><td>0.9109</td><td>0.8651</td><td>0.8200</td></tr><tr><td>Mask pool</td><td>Mask pool (50%)</td><td>0.9277</td><td>0.8590</td><td>0.7808</td></tr><tr><td>Mask pool</td><td>Exclusive (50%)</td><td>0.9489</td><td>0.9622</td><td>0.9057</td></tr><tr><td>Mask pool</td><td>Exclusive +Random (75%)</td><td>0.9709</td><td>0.9466</td><td>0.9004</td></tr><tr><td>Mask pool</td><td>Exclusive + Anomaly score (75%)</td><td>0.9747</td><td>0.9533</td><td>0.9119</td></tr><tr><td>Mask pool</td><td>Exclusive+ Entropy (75%)</td><td>0.9758</td><td>0.9854</td><td>0.9400</td></tr></table>
275
+
276
+ 247 the other hand, the transformer-based critic showed better performances than the baseline without
277
+ 248 the critic, which means it encourages the generated output to be close to the normal signal. From
278
+ 249 this result, we demonstrate that our transformer-based GAN framework trained with the proposed
279
+ 250 masking strategy is effective to reconstruct normal time series data for anomaly detection.
280
+
281
+ # 4.3.2 Two-Step Masking
282
+
283
+ As shown in Table 3, we investigated the effect of two-step masking in our model. The first row means a naive form of the transformer-based GAN without any masking. The result was 0.5 of AUROC, which means the naive transformer-based GAN cannot distinguish between normal and abnormal signals at all. To overcome this critical issue, we adopted various masking strategies. First, we investigated the masking for Step 1. Here, Random means a fully random masking without any predefined mask pool. Mask Pool means our predefined mask pool defined in Section 3.3. The results showed that regardless of the masking strategy, masking itself during training and test enabled the transformer-based GAN to effectively learn the distribution of normal time series data. Moreover, we confirmed that Mask Pool is much better than Random masking, because each mask in the mask pool definitely covers the different parts from each other, providing a complementary effect.
284
+
285
+ 262 Next, we conducted in-depth experiments to evaluate and compare different re-masking strategies in
286
+ 263 Step 2. Mask pool method in Step 1 can be also used for re-masking. Exclusive method re-masks the
287
+ 264 exclusive parts of the random mask selected in Step 1. From the results, we found that re-masking
288
+ 265 improved the detection ability of our model, and especially, exclusive masking strategy was really
289
+ 266 effective. This is because the model can consider the characteristic of whole signal during two-step
290
+ 267 masking. To provide more feedback to our model, we additionally re-masked the masked parts in
291
+ 268 Step 1. We experimented the following three cases: 1) Random method re-masks the signal randomly,
292
+ 269 2) Anomaly score method re-masks the parts with high anomaly scores, and 3) Entropy method
293
+ 270 re-masks the parts with high entropy values. The results showed that masking the uncertain parts
294
+ 271 provided the proper feedback to our model, resulting in the highest scores among all the baselines.
295
+ 272 Therefore, we confirmed that the entropy-based re-masking is more effective than the other additional
296
+ 273 masking methods.
297
+
298
+ # 5 Discussion
299
+
300
+ 275 We further conducted analysis to demonstrate the effectiveness of the proposed two-step masking
301
+ 276 strategy. To confirm the importance of Step 2, we compared our method with the absence of Step 2.
302
+ 277 Here, we also used Point-Contextual dataset in NeurIPS-TS for analysis.
303
+ 278 The Effectiveness of Re-Masking. First, we investigated the validity of re-masking step. We reported
304
+ 279 the average AUROC and std for all masks in the predefined mask pool in Figure 3. In Step 1, there
305
+ 280 was a problem that the standard deviation (std) was too high because both training and test time
306
+ 281 had randomness in selecting the mask parts. By re-masking through Step 2, the randomness of the
307
+ 282 masked parts was eliminated and the std was significantly reduced. The performance of anomaly
308
+ 283 detection also increased with a large margin by referring to the entire signal.
309
+ 284 Analysis on Entropy-based Re-Masking. To understand the effectiveness of entropy-based re
310
+ 285 masking intuitively, we visualized the relation between entropy and anomaly score in Figure 3(b) and
311
+ 286 Figure 3(c) for both cases of normal and abnormal. Since the entropy-based method re-masked the
312
+ 287 parts selected in Step 1, we measured the anomaly score only in the parts corresponding to Step 1. We
313
+ 288 found two meaningful insights through the analysis. First, the higher the entropy, the more incorrect
314
+ 289 signal the model generates. In training phase, the high anomaly score means that the model generates
315
+ 290 output incorrectly, because only normal data is used. From the result of Figure 3(b), the entropy was
316
+ 291 also high in the parts with high anomaly score, which means that the model did not generate signals
317
+ 292 well in the parts with high entropy during Step 1. This is because in the high entropy the attention is
318
+ 293 uniformly distributed and the meaningful connection is not learned. By re-masking these parts in Step
319
+ 294 2, anomaly score was significantly reduces, which means that the model reconstructed the normal
320
+ 295 data well in the training process. Second, the entropy-based masking improves the discriminative
321
+ 296 ability between normal and abnormal in test time. As shown in Figure 3(c), likewise in the case of
322
+ 297 normal, the higher the entropy, the higher the anomaly score in abnormal case. However, there was
323
+ 298 also a part with a high entropy and a low anomaly score. These parts mean that the model copied
324
+ 299 the abnormal input as it was without making it normal. It is possible to provide feedback in both
325
+ 300 cases with entropy-based re-masking. By re-masking the parts with high entropy, anomaly score was
326
+ 301 considerably increased, and it means the parts that were not well generated due to copying in Step 1
327
+ 302 were well re-generated. This makes it possible to further discriminate between normal and abnormal
328
+ 303 through anomaly score. In fact, a large anomaly score does not mean getting close to normal data. We
329
+ 304 used a NeurIPS-TS dataset to see if the output gets closer to normal data through re-masking. Since
330
+ 305 we synthesized abnormal datasets by injecting sporadic outliers in an additive manner, we could
331
+ 306 easily get the original normal version of the abnormal data. From this, we confirmed that the output
332
+ 307 was correctly getting closer to the original normal through Step 2. We further experimented about
333
+ 308 which layer’s entropy information should be used? From the results in Appendix C, we calculated
334
+ 309 entropy from all layers and averaged them.
335
+
336
+ ![](images/ed4625d277a62b4ec5b0601fff9fc4d34c1c943f2d384494de37abcbde8e24f6.jpg)
337
+ Figure 3: (a) AUROC and std of all masks in the predefined mask pool. (b) Analysis on the entropy-based re-masking strategy (normal-case). (c) Analysis on the entropy-based re-masking strategy (abnormal-case).
338
+
339
+ # 0 6 Conclusion
340
+
341
+ 311 In this paper, we introduce AnoFormer, a novel transformer-based GAN for time series anomaly
342
+ 312 detection. To learn time series data directly with our model, we propose pre-processing and embedding
343
+ 313 methods suitable for time series data. A new training scheme based on two-step masking enables
344
+ 314 AnoFormer to embed the representation of normal signals. Especially, the exclusive and entropy
345
+ 315 based re-masking method significantly improves the anomaly detection performances on several
346
+ 316 benchmark datasets. From the extensive experiments, we empirically demonstrate that our model
347
+ 317 is really effective to solve time series anomaly detection. As future work, we plan to study novel
348
+ 318 techniques for shorter inference time, and deal with time series data longer than an hour or a day.
349
+
350
+ 319 References [1] Ailin Deng and Bryan Hooi. Graph neural network-based anomaly detection in multivariate time series. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 4027–4035, 2021. [2] Bin Zhou, Shenghua Liu, Bryan Hooi, Xueqi Cheng, and Jing Ye. Beatgan: Anomalous rhythm detection using adversarially generated time series. In IJCAI, pages 4433–4439, 2019. [3] Zekai Chen, Dingshuo Chen, Xiao Zhang, Zixuan Yuan, and Xiuzhen Cheng. Learning graph structures with transformer for multivariate time series anomaly detection in iot. IEEE Internet of Things Journal, 2021. [4] Markus M Breunig, Hans-Peter Kriegel, Raymond T $\mathrm { N g }$ , and Jörg Sander. Lof: identifying density-based local outliers. In Proceedings of the 2000 ACM SIGMOD international conference on Management of data, pages 93–104, 2000. [5] Bernhard Schölkopf, John C Platt, John Shawe-Taylor, Alex J Smola, and Robert C Williamson. Estimating the support of a high-dimensional distribution. Neural computation, 13(7):1443– 1471, 2001. [6] David MJ Tax and Robert PW Duin. Support vector data description. Machine learning, 54(1):45–66, 2004. [7] Lifeng Shen, Zhuocong Li, and James Kwok. Timeseries anomaly detection using temporal hierarchical one-class network. Advances in Neural Information Processing Systems, 33:13016– 13026, 2020. [8] Alexander Geiger, Dongyu Liu, Sarah Alnegheimish, Alfredo Cuesta-Infante, and Kalyan Veeramachaneni. Tadgan: Time series anomaly detection using generative adversarial networks. In 2020 IEEE International Conference on Big Data (Big Data), pages 33–43. IEEE, 2020. [9] Tung Kieu, Bin Yang, Chenjuan Guo, and Christian S Jensen. Outlier detection for time series with recurrent autoencoder ensembles. In IJCAI, pages 2725–2732, 2019.
351
+ 344 [10] Lifeng Shen, Zhongzhong Yu, Qianli Ma, and James T Kwok. Time series anomaly detection with multiresolution ensemble decoding. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 9567–9575, 2021.
352
+ 347 [11] Jiehui Xu, Haixu Wu, Jianmin Wang, and Mingsheng Long. Anomaly transformer: Time series anomaly detection with association discrepancy. In International Conference on Learning Representations, 2022. [12] Chuxu Zhang, Dongjin Song, Yuncong Chen, Xinyang Feng, Cristian Lumezanu, Wei Cheng, Jingchao Ni, Bo Zong, Haifeng Chen, and Nitesh V Chawla. A deep neural network for unsupervised anomaly detection and diagnosis in multivariate time series data. In Proceedings of the AAAI conference on artificial intelligence, volume 33, pages 1409–1416, 2019. [13] Julien Audibert, Pietro Michiardi, Frédéric Guyard, Sébastien Marti, and Maria A Zuluaga. Usad: unsupervised anomaly detection on multivariate time series. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 3395–3404, 2020.
353
+ 358 [14] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
354
+ 361 [15] Aljaz Bozic, Pablo Palafox, Justus Thies, Angela Dai, and Matthias Nießner. Transformerfusion: Monocular rgb scene reconstruction using transformers. Advances in Neural Information Processing Systems, 34, 2021. [16] Dor Arad Hudson and Larry Zitnick. Compositional transformers for scene generation. Advances in Neural Information Processing Systems, 34, 2021.
355
+ 366 [17] Yifan Jiang, Shiyu Chang, and Zhangyang Wang. Transgan: Two pure transformers can make one strong gan, and that can scale up. Advances in Neural Information Processing Systems, 34, 2021.
356
+ 369 [18] Jing Zhang, Jianwen Xie, Nick Barnes, and Ping Li. Learning generative vision transformer with energy-based latent space for saliency prediction. Advances in Neural Information Processing Systems, 34, 2021.
357
+ 372 [19] Yufei Wang, Can Xu, Huang Hu, Chongyang Tao, Stephen Wan, Mark Dras, Mark Johnson, and Daxin Jiang. Neural rule-execution tracking machine for transformer-based text generation. Advances in Neural Information Processing Systems, 34, 2021.
358
+ 375 [20] Marcella Cornia, Matteo Stefanini, Lorenzo Baraldi, and Rita Cucchiara. Meshed-memory transformer for image captioning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10578–10587, 2020. [21] Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Misha Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. Advances in neural information processing systems, 34, 2021. [22] Jiehui Xu, Jianmin Wang, Mingsheng Long, et al. Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting. Advances in Neural Information Processing Systems, 34, 2021. [23] Dor Arad Hudson and Larry Zitnick. Compositional transformers for scene generation. Advances in Neural Information Processing Systems, 34, 2021. [24] Enze Xie, Wenhai Wang, Zhiding Yu, Anima Anandkumar, Jose M Alvarez, and Ping Luo. Segformer: Simple and efficient design for semantic segmentation with transformers. Advances in Neural Information Processing Systems, 34, 2021. [25] Mingrui Zhu, Changcheng Liang, Nannan Wang, Xiaoyu Wang, Zhifeng Li, and Xinbo Gao. A sketch-transformer network for face photo-sketch synthesis. In International Joint Conference on Artificial Intelligence, 2021. [26] Deng Cai and Wai Lam. Graph transformer for graph-to-sequence learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 7464–7471, 2020. [27] Zhidong Liu, Junhui Li, and Muhua Zhu. Improving text generation with dynamic masking and recovering. In IJCAI, 2021. [28] Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wancai Zhang. Informer: Beyond efficient transformer for long sequence time-series forecasting. In Proceedings of AAAI, 2021. [29] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics.
359
+ 404 [30] Yi-Bin Cheng, Xipeng Chen, Dongyu Zhang, and Liang Lin. Motion-transformer: selfsupervised pre-training for skeleton-based action recognition. In Proceedings of the 2nd ACM International Conference on Multimedia in Asia, pages 1–6, 2021. [31] Haixuan Guo, Shuhan Yuan, and Xintao Wu. Logbert: Log anomaly detection via bert. In 2021 International Joint Conference on Neural Networks (IJCNN), pages 1–8, 2021.
360
+ 409 [32] Zhaowen Li, Zhiyang Chen, Fan Yang, Wei Li, Yousong Zhu, Chaoyang Zhao, Rui Deng, Liwei Wu, Rui Zhao, Ming Tang, et al. Mst: Masked self-supervised transformer for visual representation. Advances in Neural Information Processing Systems, 34, 2021.
361
+ 412 [33] Hangbo Bao, Li Dong, Songhao Piao, and Furu Wei. BEit: BERT pre-training of image transformers. In International Conference on Learning Representations, 2022.
362
+
363
+ 414 [34] Xudong Yan, Huaidong Zhang, Xuemiao Xu, Xiaowei Hu, and Pheng-Ann Heng. Learning
364
+ 415 semantic context from normal samples for unsupervised anomaly detection. In Proceedings of
365
+ 416 the AAAI Conference on Artificial Intelligence, volume 35, pages 3110–3118, 2021.
366
+ 417 [35] George Zerveas, Srideepika Jayaraman, Dhaval Patel, Anuradha Bhamidipaty, and Carsten
367
+ 418 Eickhoff. A transformer-based framework for multivariate time series representation learning.
368
+ 419 In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining,
369
+ 420 pages 2114–2124, 2021.
370
+ 421 [36] Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron C Courville.
371
+ 422 Improved training of wasserstein gans. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach,
372
+ 423 R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing
373
+ 424 Systems, volume 30. Curran Associates, Inc., 2017.
374
+ 425 [37] Edward Choi, Zhen Xu, Yujia Li, Michael Dusenberry, Gerardo Flores, Emily Xue, and Andrew
375
+ 426 Dai. Learning the graphical structure of electronic health records with graph convolutional
376
+ 427 transformer. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pages
377
+ 428 606–613, 2020.
378
+ 429 [38] Kwei-Herng Lai, Daochen Zha, Junjie Xu, Yue Zhao, Guanchu Wang, and Xia Hu. Revisiting
379
+ 430 time series outlier detection: Definitions and benchmarks. In Thirty-fifth Conference on Neural
380
+ 431 Information Processing Systems Datasets and Benchmarks Track (Round 1), 2021.
md/dev/iBBcRUlOAPR/iBBcRUlOAPR.md ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Training Compute-Optimal Large Language Models
2
+
3
+ <table><tr><td></td><td colspan="2">Jordan Hoffmann*Sebastian Borgeaud*Arthur Mensch*Elena Buchatskaya</td><td colspan="2"></td></tr><tr><td>Trevor Cai</td><td>iEliza Rutherford</td><td></td><td></td><td> Diego de Las CasasLisa Anne Hendricks</td></tr><tr><td></td><td></td><td></td><td></td><td>Johannes WelblAidan ClarkTom HenniganEric NolandKatie Millican</td></tr><tr><td>George van den Driessche</td><td></td><td>Bogdan DamocAurelia Guy</td><td></td><td> Simon Osindero</td></tr><tr><td>Karen Simonyan</td><td>Erich Elsen</td><td></td><td>Oriol VinyalsJack W. Rae</td><td>Laurent Sifre*</td></tr></table>
4
+
5
+ ∗ Equal contributions
6
+
7
+ # DeepMind
8
+
9
+ (sborgeaud|amensch|sifre)@deepmind.com
10
+
11
+ # Abstract
12
+
13
+ We investigate the optimal model size and number of tokens for training a Transformer language model under a given compute budget. We find that current large language models are significantly undertrained, a consequence of the recent focus on scaling language models whilst keeping the amount of training data constant. By training over 400 language models ranging from 70 million to over 16 billion parameters on 5 to 500 billion tokens, we find that for compute-optimal training, the model size and the number of training tokens should be scaled equally: for every doubling of model size the number of training tokens should also be doubled. We test this hypothesis by training a predicted compute-optimal model, Chinchilla, that uses the same compute budget as Gopher but with 70B parameters and $4 \times$ more more data. Chinchilla uniformly and significantly outperforms Gopher (280B), GPT-3 (175B), Jurassic-1 (178B), and Megatron-Turing NLG (530B) on a large range of downstream evaluation tasks. This also means that Chinchilla uses substantially less compute for fine-tuning and inference, greatly facilitating downstream usage. As a highlight, Chinchilla reaches a state-of-the-art average accuracy of $6 7 . 5 \%$ on the MMLU benchmark, greater than a $7 \%$ improvement over Gopher.
14
+
15
+ # 1 Introduction
16
+
17
+ A series of Large Language Models (LLMs) have recently been introduced [6, 30, 38, 48, 52], with the largest dense language models now having over 500 billion parameters. These large autoregressive transformers [53] have demonstrated impressive performance on many tasks using a variety of evaluation protocols: zero-shot generalization, few-shot training, and as a basis for fine-tuning. The compute and energy cost for training large language models is substantial [38, 52] and rises with increasing model size. In practice, the allocated training compute budget is often known in advance: practitioners have access to a certain number of accelerators for a given period of time. Since it is typically only feasible to train these large models once, accurately estimating the best model hyperparameters for a given compute budget is critical [51].
18
+
19
+ ![](images/5fda2b2d2e0d920eeb6e6a485bba230c4d48963bd3351dc1403ba44a7eda89c5.jpg)
20
+ Figure 1: Overlaid predictions. We overlay the predictions from our three different approaches, along with projections from [23]. We find that all three methods predict that current large models should be substantially smaller and therefore trained much longer than is currently done. In Figure A3, we show the results with the predicted optimal tokens plotted against the optimal number of parameters for fixed FLOP budgets. Chinchilla outperforms Gopher and the other large models (see Section 4.2).
21
+
22
+ Table 1: Current LLMs. We show five of the current largest dense transformer models, their size, and the number of training tokens. Other than LaMDA [52], most models are trained for approximately 300 billion tokens. We introduce Chinchilla, a substantially smaller model, trained for much longer than 300B tokens. Table A3 shows our projected optimal relation between model size and tokens.
23
+
24
+ <table><tr><td>Model</td><td>Size (# Parameters)</td><td>Training Tokens</td></tr><tr><td>LaMDA [52]</td><td>137 Billion</td><td>768 Billion</td></tr><tr><td>GPT-3 [6]</td><td>175 Billion</td><td>300 Billion</td></tr><tr><td>Jurassic [30]</td><td>178 Billion</td><td>300 Billion</td></tr><tr><td>Gopher [38]</td><td>280 Billion</td><td>300 Billion</td></tr><tr><td>MT-NLG 530B [48]</td><td>530 Billion</td><td>270 Billion</td></tr><tr><td>Chinchilla</td><td>70 Billion</td><td>1.4 Trillion</td></tr></table>
25
+
26
+ Kaplan et al. [23] showed that there is a power law relationship between the number of parameters in an autoregressive language model (LM) and its performance (measured in evaluation perplexity). One notable conclusion in [23] is that large models should not be trained to their lowest possible loss to be compute optimal; they argue that model size should grow faster than the size of the training set for a given increase of computational budget. As a result, the field has been training larger and larger models while keeping the size of the training set to approximately 300 billion tokens, expecting performance improvements (Table 1). While we find that there is effectively a trade-off between model size and training set size, we estimate that large models should be trained for many more training tokens than recommended by [23]. Specifically, given a $1 0 \times$ increase computational budget we find that model size and the number of training tokens should be scaled in equal proportions.
27
+
28
+ In this work, we revisit the question: Given a fixed FLOPs budget,1 how should one trade-off model size and the number of training tokens? To answer this question, we model the final pre-training $\mathrm { l o s s } ^ { 2 }$ $L ( N , D )$ as a function of the number of model parameters $N$ , and the number of training tokens, $D$ . Since the computational budget $C$ is a deterministic function $\mathsf { F L O P s } ( N , D )$ of the number of seen training tokens and model parameters, we are interested in minimizing $L$ under the constraint
29
+
30
+ $\mathrm { F L O P s } ( N , D ) = C$ :
31
+
32
+ $$
33
+ N _ { o p t } ( C ) , D _ { o p t } ( C ) = \operatorname * { a r g m i n } _ { N , D \mathrm { ~ s . t . ~ F L O P s } ( N , D ) = C } L ( N , D ) .
34
+ $$
35
+
36
+ The functions $N _ { o p t } ( C )$ , and $D _ { o p t } ( C )$ describe the optimal allocation of a computational budget $C$ . We empirically estimate these functions based on the losses of over 400 models, ranging from under 70M to over 16B parameters, and trained on 5B to over 400B tokens – with each model configuration trained for several different training horizons. Our approach leads to considerably different results than that of [23]. We highlight our results in Figure 1 and how our approaches differ in Section 2.
37
+
38
+ Based on our estimated compute-optimal frontier, we predict that for the compute budget used to train Gopher, an optimal model should be 4 times smaller, while being training on 4 times more tokens. We verify this by training a more compute-optimal 70B model, called Chinchilla, on 1.4 trillion tokens. Not only does Chinchilla outperform its much larger counterpart, Gopher, but its reduced model size reduces inference cost considerably and greatly facilitates downstream uses on smaller hardware. The energy cost of a large language model is amortized through its usage for inference and fine-tuning. The benefits of a more optimally trained smaller model, therefore, extend beyond the immediate benefits of its improved performance.
39
+
40
+ # 2 Related Work
41
+
42
+ Large language models. A variety of large language models have been introduced in the last few years. These include both dense transformer models [6, 30, 48, 38, 52] and mixture-of-expert (MoE) models [11, 12, 60]. The largest dense transformers have passed 500 billion parameters [48, 8]. The drive to train larger and larger models is clear—so far increasing the size of language models has been responsible for improving the state-of-the-art in many language modelling tasks. Nonetheless, large language models face several challenges, including their overwhelming computational requirements (the cost of training and inference increase with model size) [38, 52] and the need for acquiring more high-quality training data. In fact, in this work we find that larger, high quality datasets will play a key role in any further scaling of language models. Concurrent to our work, a 540 billion parameter model trained on 768 billion tokens was released– PaLM [8]. While this model outperforms Chinchilla, it uses approximately $5 \times$ the compute and is nearly $8 \times$ larger, making it more difficult to use.
43
+
44
+ Modelling the scaling behavior. Understanding the scaling behaviour of language models and their transfer properties has been important in the development of recent large models [23, 18]. Kaplan et al. [23] first showed a predictable relationship between model size and loss over many orders of magnitude. The authors investigate the question of choosing the optimal model size to train for a given compute budget. Similar to us, they address this question by training various models. Our work differs from Kaplan et al. [23] in several important ways. First, the authors use a fixed number of training tokens and learning rate schedule for all models; this prevents them from modelling the impact of these hyperparameters on the loss. In contrast, we find that setting the learning rate schedule to approximately match the number of training tokens results in the best final loss regardless of model size—see Figure A1. For a fixed learning rate cosine schedule to 130B tokens, the intermediate loss estimates (for $D ^ { \prime } < < 1 3 0 { \bf B } )$ are therefore overestimates of the loss of a model trained with a schedule length matching $D ^ { \prime }$ . Using these intermediate losses results in underestimating the effectiveness of training models on less data than 130B tokens, and eventually contributes to the conclusion that model size should increase faster than training data size as compute budget increases. In contrast, our analysis predicts that both quantities should scale at roughly the same rate. Secondly, we include models with up to 16B parameters, as we observe that there is slight curvature in the FLOP-loss frontier (see Appendix E)—in fact, the majority of the models used in our analysis have more than 500 million parameters, in contrast the majority of runs in [23] are significantly smaller—many being less than 100M parameters. Clark et al. [9] specifically looked in to the scaling properties of Mixture of Expert language models, showing that the scaling with number of experts diminishes as the model size increases—their approach models the loss as a function of two variables: the model size and the number of experts. However, the analysis is done with a fixed number of tokens, potentially underestimating the improvements of branching.
45
+
46
+ Estimating hyperparameters for large models. The model size and the number of training tokens are not the only two parameters to chose when selecting a language model and a procedure to train it. Other important factors include learning rate, learning rate schedule, batch size, optimiser, and width-to-depth ratio. In this work, we focus on model size and the number of training steps, and we rely on existing work and provided experimental heuristics to determine the other necessary hyperparameters. Yang et al. [57] investigates how to choose a variety of these parameters for training an autoregressive transformer, including the learning rate and batch size. McCandlish et al. [33] finds only a weak dependence between optimal batch size and model size. Shallue et al. [46], Zhang et al. [59] suggest that using larger batch-sizes than those we use is possible. Levine et al. [28] investigates the optimal depth-to-width ratio for a variety of standard model sizes. We use slightly less deep models than proposed as this translates to better wall-clock performance on our hardware.
47
+
48
+ ![](images/0e73f5ec0e10339413bdc21d2828322311141d661d74d95cddd1902dd0bf3712.jpg)
49
+ Figure 2: Training curve envelope. On the left we show all of our different runs. We launched a range of model sizes going from 70M to 10B, each for four different cosine cycle lengths. From these curves, we extracted the envelope of minimal loss per FLOP, and we used these points to estimate the optimal model size (center) for a given compute budget and the optimal number of training tokens (right). In green, we show projections of optimal model size and training token count based on the number of FLOPs used to train Gopher $( 5 . { \dot { 7 } } 6 \times 1 0 ^ { 2 3 } .$ ).
50
+
51
+ Improved model architectures. Recently, various promising alternatives to traditional dense transformers have been proposed. For example, through the use of conditional computation large MoE models like the 1.7 trillion parameter Switch transformer [12], the 1.2 Trillion parameter GLaM model [11], and others [1, 60] are able to provide a large effective model size despite using relatively fewer training and inference FLOPs. However, for very large models the computational benefits of routed models seems to diminish [9]. An orthogonal approach to improving language models is to augment transformers with explicit retrieval mechanisms, as done by [4, 15, 29]. This approach effectively increases the number of data tokens seen during training (by a factor of $\sim 1 0$ in [4]). This suggests that the performance of language models may be more dependant on the size of the training data than previously thought.
52
+
53
+ # 3 Estimating the optimal parameter/training tokens allocation
54
+
55
+ We present three different approaches to answer the question driving our research: Given a fixed FLOPs budget, how should one trade-off model size and the number of training tokens? In all three cases we start by training a range of models varying both model size and the number of training tokens and use the resulting training curves to fit an empirical estimator of how they should scale. We assume a power-law relationship between compute and model size as done in [9, 23], though future work may want to include potential curvature in this relationship for large model sizes. The resulting predictions are similar for all three methods and suggest that parameter count and number of training tokens should be increased equally with more compute —with proportions reported in Table 2. This is in clear contrast to previous work on this topic and warrants further investigation.
56
+
57
+ # 3.1 Approach 1: Fix model sizes and vary number of training tokens
58
+
59
+ In our first approach we vary the number of training steps for a fixed family of models (ranging from 70M to over 10B parameters), training each model for 4 different number of training sequences. From these runs, we are able to directly extract an estimate of the minimum loss achieved for a given number of training FLOPs. Training details for this approach can be found in Appendix D.
60
+
61
+ ![](images/8fcd756dac3c99cd1be39381987999c9f5e77a304f81c54fdefb663feb6d1c9d.jpg)
62
+ Figure 3: IsoFLOP curves. For various model sizes, we choose the number of training tokens such that the final FLOPs is a constant. The cosine cycle length is set to match the target FLOP count. We find a clear valley in loss, meaning that for a given FLOP budget there is an optimal model to train (left). Using the location of these valleys, we project optimal model size and number of tokens for larger models (center and right). In green, we show the estimated number of parameters and tokens for an optimal model trained with the compute budget of Gopher.
63
+
64
+ For each parameter count $N$ we train 4 different models: each uses a different horizon (measured in number of training tokens) over which we decay the learning rate by a factor of $1 0 \times$ ; the range of horizons varies by a factor of $1 6 \times$ for each parameter count. We smooth and linearly interpolate each training loss curve. From this, we obtain a continuous mapping from FLOP count to training loss for each run. We then determine which run achieves the lowest loss for each FLOP count. Using these interpolants, we obtain a mapping from FLOP count $C$ to the most efficient choice of model size $N _ { o p t }$ and number of training tokens $D _ { o p t }$ such that $\mathrm { F L O P s } ( N _ { o p t } , D _ { o p t } ) = C$ .3 We apply this mapping onto logarithmically spaced values of $C$ and obtain many empirical triplets $( C _ { i } , N _ { o p t , i } , D _ { o p t , i } ) _ { i }$ . Finally, we fit power laws to these empirical data, estimating $a$ and $b$ such that $N _ { o p t } \propto C ^ { a }$ and $D _ { o p t } \propto C ^ { b }$ We find that $a = 0 . 5 0$ and $b = 0 . 5 0 \mathrm { \AA }$ —as summarized in Table 2. We perform a simple experiment for early validating our analysis: given a budget of $1 0 ^ { 2 1 }$ FLOPs, we compare the performance of training a model with a size recommended by our analysis to training a model with a size suggested by the analysis of [23]—using the model size we predict has a clear advantage (Section D.4).
65
+
66
+ # 3.2 Approach 2: IsoFLOP profiles
67
+
68
+ In our second approach we vary the model size for a fixed set of 9 different training FLOP counts (ranging from $6 \times 1 0 ^ { 1 8 }$ to $3 \times \mathrm { i 0 ^ { 2 1 } }$ FLOPs), and consider the final training loss for each point. This differs from the first approach that considers points $( N _ { i } , D _ { i } , L _ { i } ) _ { i }$ along the entire training runs; the data points are here scarcer but more representative of the performance of a fully trained model.
69
+
70
+ For each FLOP budget, we plot the final loss (after smoothing) against the parameter count in Figure 3 (left). In all cases, we ensure that we have trained a diverse enough set of model sizes to see a clear minimum in the loss. We fit a parabola to each IsoFLOPs curve to directly estimate at what model size the minimum loss is achieved (Figure 3 (left)). As with the previous approach, we then fit a power law between FLOPs and loss-optimal model size and number of training tokens, shown in Figure 3 (center, right). Again, we fit exponents of the form $N _ { o p t } \propto C ^ { a }$ and $\bar { D _ { o p t } } \propto C ^ { b }$ and we find that $a = 0 . 4 9$ and $b = 0 . 5 1 \AA$ —as summarized in Table 2.
71
+
72
+ # 3.3 Approach 3: Fitting a parametric loss function
73
+
74
+ Lastly, we model all final losses from experiments in Approach 1 & 2 as a parametric function of model parameter count and the number of seen tokens. Following a classical risk decomposition (see Section D.2), we propose the following functional form
75
+
76
+ $$
77
+ \hat { L } ( N , D ) \triangleq E + \frac { A } { N ^ { \alpha } } + \frac { B } { D ^ { \beta } } .
78
+ $$
79
+
80
+ The first term captures the loss for an ideal generative process on the data distribution, and should correspond to the entropy of natural text. The second term captures the fact that a perfectly trained
81
+
82
+ ![](images/af03112c428e7c3c911debf942285b79d1343a4a00e76227df15c7ec14962e44.jpg)
83
+ Figure 4: Parametric fit. We fit a parametric modelling of the loss $\hat { L } ( N , D )$ and display contour (left) and isoFLOP slices (right). For each isoFLOP slice, we include a corresponding dashed line in the left plot. In the left plot, we show the efficient frontier in blue, which is a line in log-log space. Specifically, the curve goes through each iso-loss contour at the point with the fewest FLOPs. We project the optimal model size given the Gopher FLOP budget to be 40B parameters.
84
+
85
+ transformer with $N$ parameters underperforms the ideal generative process. The final term captures the fact that the transformer is not trained to convergence, as we only make a finite number of optimisation steps, on a sample of the dataset distribution.
86
+
87
+ Model fitting. To estimate $( A , B , E , \alpha , \beta )$ , we minimize the Huber loss [19] between the predicted and observed log loss using the L-BFGS algorithm [36]:
88
+
89
+ $$
90
+ \operatorname* { m i n } _ { A , B , E , \alpha , \beta } \quad \sum _ { \mathrm { R u n s } i } { \mathrm { H u b e r } } _ { \delta } \bigg ( \log \hat { L } ( N _ { i } , D _ { i } ) - \log L _ { i } \bigg )
91
+ $$
92
+
93
+ We account for possible local minima by selecting the best fit from a grid of initialisations. The Huber loss $\langle \delta = \bar { 1 } 0 ^ { - 3 }$ ) is robust to outliers, which we find important for good predictive performance over held-out data points. Section D.2 details the fitting procedure and the loss decomposition.
94
+
95
+ Efficient frontier. We approximate the functions $N _ { o p t }$ and $D _ { o p t }$ by minimizing the parametric loss $\hat { L }$ under the constraint $\mathrm { F L O P s } ( N , D ) \approx 6 N D$ [23]. The resulting $N _ { o p t }$ and $D _ { o p t }$ balance the two terms in Equation (3) that depend on model size and data. By construction, they have a power-law form. We show contours of the fitted function $\hat { L }$ in Figure 4 (left), and the closed-form efficient computational frontier in blue. From this approach, we find that $a = 0 . 4 6$ and $b = 0 . 5 4$ —as summarized in Table 2.
96
+
97
+ # 3.4 Optimal model scaling
98
+
99
+ We find that the three approaches, despite using different fitting methodologies and different trained models, yield comparable predictions for the optimal scaling in parameters and tokens with FLOPs (shown in Table 2). All three approaches suggest that as compute budget increases, model size and the amount of training data should be increased in approximately equal proportions. The first and second approaches yield very similar predictions for optimal model sizes, as shown in Figure 1 and Figure A3. The third approach predicts even smaller models being optimal at larger compute budgets. We note that the observed points $( L , N , D )$ for low training FLOPs $C \leq 1 e 2 1$ ) have larger residuals $\lVert L - \hat { L } ( N , D ) \rVert _ { 2 } ^ { 2 }$ than points with higher computational budgets. The fitted model places increased weight on the points with more FLOPs—automatically considering the low-computational budget points as outliers due to the Huber loss. As a consequence of the empirically observed negative curvature in the frontier $C \to N _ { o p t }$ (see Appendix E), this results in predicting a lower $N _ { o p t }$ than the two other approaches.
100
+
101
+ Table 2: Estimated parameter and data scaling with increased training compute. The listed values are the exponents, $a$ and $b$ , on the relationship $N _ { o p t } \propto C ^ { a }$ and $\bar { D _ { o p t } } \propto \bar { C } ^ { b }$ . Our analysis suggests a near equal scaling in parameters and data with increasing compute which is in clear contrast to previous work on the scaling of large models. The $1 0 ^ { \mathrm { t h } }$ and $\bar { 9 } 0 ^ { \mathrm { t h } }$ percentiles are estimated via bootstrapping data $80 \%$ of the dataset is sampled 100 times) and are shown in parenthesis.
102
+
103
+ <table><tr><td>Approach</td><td>Coeff. a where Nopt x Ca</td><td> Coeff. b where Dopt x Cb</td></tr><tr><td>1. Minimum over training curves</td><td>0.50 (0.488,0.502)</td><td>0.50 (0.501,0.512)</td></tr><tr><td>2. IsoFLOP profiles</td><td>0.49 (0.462,0.534)</td><td>0.51 (0.483,0.529)</td></tr><tr><td>3.Parametric modelling of the loss</td><td>0.46 (0.454,0.455)</td><td>0.54 (0.542, 0.543)</td></tr><tr><td>Kaplan et al. (2020) [23]</td><td>0.73</td><td>0.27</td></tr></table>
104
+
105
+ In Table A3 we show the estimated number of FLOPs and tokens that would ensure that a model of a given size lies on the compute-optimal frontier. Our findings suggests that the current generation of large language models are considerably over-sized, given their respective compute budgets, as shown in Figure 1. Furthermore, the amount of training data that is projected to be needed is far beyond what is currently used to train large models, and underscores the importance of dataset collection in addition to engineering improvements that allow for model scale. While there is significant uncertainty extrapolating out many orders of magnitude, our analysis clearly suggests that given the training compute budget for many current LLMs, smaller models should have been trained on more tokens to achieve the most performant model. In Appendix C, we reproduce the IsoFLOP analysis on two additional datasets: C4 [40] and GitHub code [38]. In both cases we reach the similar conclusion that model size and number of training tokens should be scaled in equal proportions.
106
+
107
+ # 4 Chinchilla
108
+
109
+ Based on our analysis in Section 3, the optimal model size for the Gopher compute budget is somewhere between 40 and 70 billion parameters. We test this hypothesis by training a model on the larger end of this range—70B parameters—for $1 . 4 \mathrm { T }$ tokens, due to both dataset and computational efficiency considerations. In this section we compare this model, which we call Chinchilla, to Gopher and other LLMs. Both Chinchilla and Gopher have been trained for the same number of FLOPs but differ in the size of the model and the number of training tokens. While pre-training a large language model has a considerable compute cost, downstream fine-tuning and inference also make up substantial compute usage [38]. Due to being $4 \times$ smaller than Gopher, both the memory footprint and inference cost of Chinchilla are also smaller.
110
+
111
+ # 4.1 Model and training details
112
+
113
+ The full set of hyperparameters used to train Chinchilla are given in Table 3. Chinchilla uses the same model architecture and training setup as Gopher with the exception of the differences listed below.
114
+
115
+ • We train Chinchilla on MassiveText (the same dataset as Gopher) but use a slightly different subset distribution (Table A1) to account for the increased number of training tokens.
116
+ • We use AdamW [32] for Chinchilla rather than Adam [24] as this improves the language modelling loss and the downstream task performance after finetuning.4
117
+ • We train Chinchilla with a slightly modified SentencePiece [25] tokenizer that does not apply NFKC normalisation. The vocabulary is very similar– $9 4 . 1 5 \%$ of tokens are the same as those used for training Gopher. We find that this particularly helps with the representation of mathematics and chemistry, for example.
118
+ • Whilst the forward and backward pass are computed in bfloat16, we store a float32 copy of the weights in the distributed optimiser state [41]. See Lessons Learned from [38] for additional details.
119
+
120
+ In Appendix G we show the impact of the various optimiser related changes between Chinchilla and Gopher. All models in this analysis have been trained on TPUv3/TPUv4 [22] with JAX [5] and Haiku [17]. We include a Chinchilla model card [35] in Table A13.
121
+
122
+ # 4.2 Results
123
+
124
+ We perform an extensive evaluation of Chinchilla, comparing against various large language models. We evaluate on a large subset of the tasks presented in [38], shown in Table A6. As the focus of this work is on optimal model scaling, we included a large representative subset, and introduce a few new evaluations to allow for better comparison to other existing large models. The evaluation details for all tasks are the same as described in [38].
125
+
126
+ Language modelling. Chinchilla significantly outperforms Gopher on all evaluation subsets of The Pile [13], as shown in Figure A8. Compared to Jurassic-1 (178B) [30], Chinchilla is more performant on all but two subsets– dm_mathematics and ubuntu_irc– see Table A7 for a raw bits-per-byte comparison. On Wikitext103 [34], Chinchilla reaches 7.16 perplexity compared to 7.75 for Gopher.
127
+
128
+ MMLU. The Massive Multitask Language Understanding (MMLU) benchmark [16] consists of a range of exam-like questions on academic subjects. In Table A8, we report Chinchilla’s average 5- shot performance on MMLU (the full breakdown of results is shown in Table A9). On this benchmark, Chinchilla significantly outperforms Gopher despite being much smaller, with an average accuracy of $6 7 . 6 \%$ (improving upon Gopher by $7 . 6 \%$ ). Remarkably, Chinchilla even outperforms the expert forecast for June 2023 of $6 3 . 4 \%$ accuracy (see Table A8) [50]. Furthermore, Chinchilla achieves greater than $90 \%$ accuracy on 4 different individual tasks– high_school_gov_and_politics, international_law, sociology, and us_foreign_policy. To our knowledge, no other model has achieved greater than $90 \%$ accuracy on a subset. In Figure A9, we show a comparison to Gopher broken down by task.
129
+
130
+ Reading comprehension. On the final word prediction dataset LAMBADA [37], Chinchilla achieves $7 7 . 4 \%$ accuracy, compared to $7 4 . 5 \%$ accuracy from Gopher and $7 6 . 6 \%$ from MT-NLG 530B (see Table 4). On RACE-h and RACE-m [27], Chinchilla greatly outperforms Gopher, improving accuracy by more than $10 \%$ in both cases—see Table 4.
131
+
132
+ BIG-bench. We analysed Chinchilla on the same set of BIG-bench tasks [49] reported in [38]. Similar to what we observed in MMLU, Chinchilla outperforms Gopher on the vast majority of tasks (see Figure A10). We find that Chinchilla improves the average performance by $1 0 . 7 \%$ , reaching an accuracy of $6 5 . 1 \%$ versus $5 4 . 4 \%$ for Gopher. Full accuracy results can be found in Table A10.
133
+
134
+ Common sense. We evaluate Chinchilla on various common sense benchmarks: PIQA [3], SIQA [45], Winogrande [44], HellaSwag [58], and BoolQ [10]. We find that Chinchilla outperforms both Gopher and GPT-3 on all tasks and outperforms MT-NLG 530B on all but one task—see Table 5. On TruthfulQA [31], Chinchilla reaches $4 3 . 6 \%$ , $5 8 . 5 \%$ , and $6 6 . 7 \%$ accuracy with 0-shot, 5-shot, and 10-shot respectively. In comparison, Gopher achieved only $2 9 . 5 \%$ 0-shot and $4 3 . 7 \%$ 10-shot accuracy. In stark contrast with the findings of [31], the large improvements ( $1 4 . 1 \%$ in 0-shot accuracy) achieved by Chinchilla suggest that better modelling of the pre-training data alone can lead to substantial improvements on this benchmark.
135
+
136
+ Closed-book question answering. Results on closed-book question answering benchmarks are reported in Table A11. On the Natural Questions dataset [26], Chinchilla achieves new closed-book SOTA accuracies: $3 1 . 5 \%$ 5-shot and $3 5 . 5 \%$ 64-shot, compared to $21 \%$ and $28 \%$ respectively, for Gopher. On TriviaQA [21] we show results for both the filtered (previously used in retrieval and openbook work) and unfiltered set (previously used in large language model evaluations). In both cases, Chinchilla substantially out performs Gopher. On the filtered version, Chinchilla lags behind the open book SOTA [20] by $7 . 9 \%$ . On the unfiltered set, Chinchilla outperforms GPT-3 (see Table A11).
137
+
138
+ Table 3: Chinchilla architecture details. We list the number of layers, the key/value size, the bottleneck activation size $\mathrm { d } _ { \mathrm { m o d e l } }$ , the maximum learning rate, and the training batch size (# tokens). The feed-forward size is always set to $4 \times \mathrm { d } _ { \mathrm { m o d e l } }$ . Note that we double the batch size midway through training for both Chinchilla and Gopher.
139
+
140
+ <table><tr><td>Model</td><td>Layers</td><td>Number Heads</td><td>Key/Value Size</td><td>dmodel</td><td>Max LR</td><td>Batch Size</td></tr><tr><td>Gopher 280B</td><td>80</td><td>128</td><td>128</td><td>16,384</td><td>4×10-5</td><td>3M→6M</td></tr><tr><td>Chinchilla 70B</td><td>80</td><td>64</td><td>128</td><td>8,192</td><td>1×10-4</td><td>1.5M→3M</td></tr></table>
141
+
142
+ Table 4: Reading comprehension. On RACE-h and RACE-m [27], Chinchilla considerably improves performance over Gopher. Note that GPT-3 and MT-NLG 530B use a different prompt format than we do on RACE- $\cdot \mathrm { h } / \mathrm { m }$ , so results are not comparable to Gopher and Chinchilla. On LAMBADA [37], Chinchilla outperforms both Gopher and MT-NLG 530B.
143
+
144
+ <table><tr><td></td><td>Chinchilla</td><td>Gopher</td><td>GPT-3</td><td>MT-NLG 530B</td></tr><tr><td>LAMBADA Zero-Shot</td><td>77.4</td><td>74.5</td><td>76.2</td><td>76.6</td></tr><tr><td>RACE-m Few-Shot</td><td>86.8</td><td>75.1</td><td>58.1</td><td>1</td></tr><tr><td>RACE-h Few-Shot</td><td>82.3</td><td>71.6</td><td>46.8</td><td>47.9</td></tr></table>
145
+
146
+ Table 5: Zero-shot comparison on Common Sense benchmarks. We show a comparison between Chinchilla, Gopher, and MT-NLG 530B on various Common Sense benchmarks. We see that Chinchilla matches or outperforms Gopher and GPT-3 on all tasks. On all but one Chinchilla outperforms the much larger MT-NLG 530B model.
147
+
148
+ <table><tr><td></td><td>Chinchilla</td><td>Gopher</td><td>GPT-3</td><td>MT-NLG 530B</td><td>Supervised SOTA</td></tr><tr><td>HellaSWAG</td><td>80.8%</td><td>79.2%</td><td>78.9%</td><td>80.2%</td><td>93.9%</td></tr><tr><td>PIQA</td><td>81.8%</td><td>81.8%</td><td>81.0%</td><td>82.0%</td><td>90.1%</td></tr><tr><td>Winogrande</td><td>74.9%</td><td>70.1%</td><td>70.2%</td><td>73.0%</td><td>91.3%</td></tr><tr><td>SIQA</td><td>51.3%</td><td>50.6%</td><td>-</td><td>1</td><td>83.2%</td></tr><tr><td>BoolQ</td><td>83.7%</td><td>79.3%</td><td>60.5%</td><td>78.2%</td><td>91.4%</td></tr></table>
149
+
150
+ # 5 Discussion & Conclusion
151
+
152
+ The trend so far in large language model training has been to increase the model size, often without increasing the number of training tokens. The largest dense transformer, MT-NLG 530B, is now over $3 \times$ larger than GPT-3’s 170 billion parameters from just two years ago. However, this model, as well as the majority of existing large models, have all been trained for a comparable number of tokens—around 300 billion. While the desire to train these mega-models has led to substantial engineering innovation, we hypothesize that the race to train larger and larger models is resulting in models that are substantially underperforming compared to what could be achieved with the same compute budget.
153
+
154
+ We propose three predictive approaches towards optimally setting model size and training duration, based on the outcome of over 400 training runs. All three approaches predict that Gopher is substantially over-sized and estimate that for the same compute budget a smaller model trained on more data will perform better. We directly test this hypothesis by training Chinchilla, a 70B parameter model, and show that it outperforms Gopher and even larger models on nearly every measured evaluation task.
155
+
156
+ Whilst our method allows us to make predictions on how to scale large models when given additional compute, there are several limitations. Due to the cost of training large models, we only have two comparable training runs at large scale (Chinchilla and Gopher), and we do not have additional tests at intermediate scales. Furthermore, we assume that the efficient computational frontier can be described by a power-law relationship between the compute budget, model size, and number of training tokens. However, we observe some concavity in $\bar { \log { ( N _ { o p t } ) } }$ at high compute budgets (see Appendix E). This suggests that we may still be overestimating the optimal size of large models. Finally, the training runs for our analysis have all been trained on less than an epoch of data; future work may consider the multiple epoch regime. Despite these limitations, the comparison of Chinchilla to Gopher validates our performance predictions, that have thus enabled training a better (and more lightweight) model at the same compute budget.
157
+
158
+ Though there has been significant recent work allowing larger and larger models to be trained, our analysis suggests an increased focus on dataset scaling is needed. Speculatively, we expect that scaling to larger and larger datasets is only beneficial when the data is high-quality. This calls for responsibly collecting larger datasets with a high focus on dataset quality. Larger datasets will require extra care to ensure train-test set overlap is properly accounted for, both in the language modelling loss but also with downstream tasks. Finally, training for trillions of tokens introduces many ethical and privacy concerns. Large datasets scraped from the web will contain toxic language, biases, and private information. With even larger datasets being used, the quantity (if not the frequency) of such information increases, which makes dataset introspection all the more important. Chinchilla does suffer from bias and toxicity but interestingly it seems less affected than Gopher (see Appendix I).. Better understanding how performance of large language models and toxicity interact is an important future research question.
159
+
160
+ While we have applied our methodology towards the training of auto-regressive language models, we expect that there is a similar trade-off between model size and the amount of data in other modalities. As training large models is very expensive, choosing the optimal model size and training steps beforehand is essential. The methods we propose are easy to reproduce in new settings.
161
+
162
+ # Acknowledgments and Disclosure of Funding
163
+
164
+ We’d like to thank Jean-baptiste Alayrac, Kareem Ayoub, Chris Dyer, Nando de Freitas, Demis Hassabis, Geoffrey Irving, Koray Kavukcuoglu, Nate Kushman and Angeliki Lazaridou for useful comments on the manuscript. We’d like to thank Andy Brock, Irina Higgins, Michela Paganini, Francis Song, and other colleagues at DeepMind for helpful discussions. We are also very grateful to the JAX and XLA team for their support and assistance.
165
+
166
+ # References
167
+
168
+ [1] M. Artetxe, S. Bhosale, N. Goyal, T. Mihaylov, M. Ott, S. Shleifer, X. V. Lin, J. Du, S. Iyer, R. Pasunuru, G. Anantharaman, X. Li, S. Chen, H. Akin, M. Baines, L. Martin, X. Zhou, P. S. Koura, B. O’Horo, J. Wang, L. Zettlemoyer, M. Diab, Z. Kozareva, and V. Stoyanov. Efficient Large Scale Language Modeling with Mixtures of Experts. arXiv:2112.10684, 2021.
169
+ [2] E. M. Bender, T. Gebru, A. McMillan-Major, and S. Shmitchell. On the dangers of stochastic parrots: Can language models be too big? In Proceedings of the ACM Conference on Fairness, Accountability, and Transparency, 2021.
170
+ [3] Y. Bisk, R. Zellers, J. Gao, Y. Choi, et al. PIQA: Reasoning about physical commonsense in natural language. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, 2020.
171
+ [4] S. Borgeaud, A. Mensch, J. Hoffmann, T. Cai, E. Rutherford, K. Millican, G. van den Driessche, J.-B. Lespiau, B. Damoc, A. Clark, D. de Las Casas, A. Guy, J. Menick, R. Ring, T. Hennigan, S. Huang, L. Maggiore, C. Jones, A. Cassirer, A. Brock, M. Paganini, G. Irving, O. Vinyals, S. Osindero, K. Simonyan, J. W. Rae, E. Elsen, and L. Sifre. Improving language models by retrieving from trillions of tokens. In Proceedings of the International Conference on Machine Learning, 2021.
172
+ [5] J. Bradbury, R. Frostig, P. Hawkins, M. J. Johnson, C. Leary, D. Maclaurin, G. Necula, A. Paszke, J. VanderPlas, S. Wanderman-Milne, and Q. Zhang. JAX: composable transformations of Python+NumPy programs. 2018. URL http://github.com/google/jax.
173
+ [6] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. 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. 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, 2020.
174
+ [7] S. Bubeck. Convex Optimization: Algorithms and Complexity. Foundations and Trends in Machine Learning, 8(3-4):231–357, 2015. [8] A. Chowdhery, S. Narang, J. Devlin, M. Bosma, G. Mishra, A. Roberts, P. Barham, H. W. Chung, C. Sutton, S. Gehrmann, et al. PaLM: Scaling language modeling with pathways. arXiv:2204.02311, 2022.
175
+ [9] A. Clark, D. d. l. Casas, A. Guy, A. Mensch, M. Paganini, J. Hoffmann, B. Damoc, B. Hechtman, T. Cai, S. Borgeaud, G. v. d. Driessche, E. Rutherford, T. Hennigan, M. Johnson, K. Millican, A. Cassirer, C. Jones, E. Buchatskaya, D. Budden, L. Sifre, S. Osindero, O. Vinyals, J. Rae, E. Elsen, K. Kavukcuoglu, and K. Simonyan. Unified scaling laws for routed language models. In Proceedings of the International Conference on Machine Learning, 2022.
176
+ [10] C. Clark, K. Lee, M.-W. Chang, T. Kwiatkowski, M. Collins, and K. Toutanova. BoolQ: Exploring the surprising difficulty of natural yes/no questions. In Proceedings of the Conference on Empirical Methods in Natural Language Processing, pages 2924–2936, 2019.
177
+ [11] N. Du, Y. Huang, A. M. Dai, S. Tong, D. Lepikhin, Y. Xu, M. Krikun, Y. Zhou, A. W. Yu, O. Firat, B. Zoph, L. Fedus, M. Bosma, Z. Zhou, T. Wang, Y. E. Wang, K. Webster, M. Pellat, K. Robinson, K. Meier-Hellstern, T. Duke, L. Dixon, K. Zhang, Q. V. Le, Y. Wu, Z. Chen, and C. Cui. GLaM: Efficient scaling of language models with mixture-of-experts. arXiv:2112.06905, 2021.
178
+ [12] W. Fedus, B. Zoph, and N. Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. arXiv:2101.03961, 2021.
179
+ [13] L. Gao, S. Biderman, S. Black, L. Golding, T. Hoppe, C. Foster, J. Phang, H. He, A. Thite, N. Nabeshima, S. Presser, and C. Leahy. The Pile: An 800GB dataset of diverse text for language modeling. arXiv:2101.00027, 2020.
180
+ [14] S. Gehman, S. Gururangan, M. Sap, Y. Choi, and N. A. Smith. RealToxicityPrompts: Evaluating neural toxic degeneration in language models. In Proceedings of the Conference on Empirical Methods in Natural Language Processing, 2020.
181
+ [15] K. Guu, K. Lee, Z. Tung, P. Pasupat, and M.-W. Chang. REALM: retrieval-augmented language model pre-training. In Proceedings of the International Conference on Machine Learning, pages 3929–3938, July 2020.
182
+ [16] D. Hendrycks, C. Burns, S. Basart, A. Zou, M. Mazeika, D. Song, and J. Steinhardt. Measuring massive multitask language understanding. arXiv:2009.03300, 2020.
183
+ [17] T. Hennigan, T. Cai, T. Norman, and I. Babuschkin. Haiku: Sonnet for JAX. 2020. URL http://github.com/deepmind/dm-haiku.
184
+ [18] D. Hernandez, J. Kaplan, T. Henighan, and S. McCandlish. Scaling laws for transfer. arXiv:2102.01293, 2021.
185
+ [19] P. J. Huber. Robust Estimation of a Location Parameter. The Annals of Mathematical Statistics, 35(1):73–101, 1964.
186
+ [20] G. Izacard and E. Grave. Distilling knowledge from reader to retriever for question answering. In International Conference on Learning Representations, 2020.
187
+ [21] M. Joshi, E. Choi, D. Weld, and L. Zettlemoyer. TriviaQA: A Large Scale Distantly Supervised Challenge Dataset for Reading Comprehension. arXiv:1705.03551, 2017.
188
+ [22] N. P. Jouppi, C. Young, N. Patil, D. Patterson, G. Agrawal, R. Bajwa, S. Bates, S. Bhatia, N. Boden, A. Borchers, R. Boyle, P.-l. Cantin, C. Chao, C. Clark, J. Coriell, M. Daley, M. Dau, J. Dean, B. Gelb, T. V. Ghaemmaghami, R. Gottipati, W. Gulland, R. Hagmann, C. R. Ho, D. Hogberg, J. Hu, R. Hundt, D. Hurt, J. Ibarz, A. Jaffey, A. Jaworski, A. Kaplan, H. Khaitan, D. Killebrew, A. Koch, N. Kumar, S. Lacy, J. Laudon, J. Law, D. Le, C. Leary, Z. Liu, K. Lucke, A. Lundin, G. MacKean, A. Maggiore, M. Mahony, K. Miller, R. Nagarajan, R. Narayanaswami, R. Ni, K. Nix, T. Norrie, M. Omernick, N. Penukonda, A. Phelps, J. Ross, M. Ross, A. Salek, E. Samadiani, C. Severn, G. Sizikov, M. Snelham, J. Souter, D. Steinberg, A. Swing, M. Tan, G. Thorson, B. Tian, H. Toma, E. Tuttle, V. Vasudevan, R. Walter, W. Wang, E. Wilcox, and D. H. Yoon. In-datacenter performance analysis of a tensor processing unit. In Proceedings of the Annual International Symposium on Computer Architecture, page 1–12, 2017.
189
+ [23] J. Kaplan, S. McCandlish, T. Henighan, T. B. Brown, B. Chess, R. Child, S. Gray, A. Radford, J. Wu, and D. Amodei. Scaling laws for neural language models. arXiv:2001.08361, 2020.
190
+ [24] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. arXiv:1412.6980, 2014.
191
+ [25] T. Kudo and J. Richardson. SentencePiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. arXiv:1808.06226, 2018.
192
+ [26] T. Kwiatkowski, J. Palomaki, O. Redfield, M. Collins, A. Parikh, C. Alberti, D. Epstein, I. Polosukhin, M. Kelcey, J. Devlin, K. Lee, K. N. Toutanova, L. Jones, M.-W. Chang, A. Dai, J. Uszkoreit, Q. Le, and S. Petrov. Natural questions: a benchmark for question answering research. Transactions of the Association of Computational Linguistics, 2019.
193
+ [27] G. Lai, Q. Xie, H. Liu, Y. Yang, and E. Hovy. RACE: Large-scale ReAding comprehension dataset from examinations. In Proceedings of the Conference on Empirical Methods in Natural Language Processing, 2017.
194
+ [28] Y. Levine, N. Wies, O. Sharir, H. Bata, and A. Shashua. The depth-to-width interplay in self-attention. arXiv:2006.12467, 2020.
195
+ [29] P. Lewis, E. Perez, A. Piktus, F. Petroni, V. Karpukhin, N. Goyal, H. Küttler, M. Lewis, W.-t. Yih, T. Rocktäschel, S. Riedel, and D. Kiela. Retrieval-augmented generation for knowledgeintensive nlp tasks. In Advances in Neural Information Processing Systems, 2020.
196
+ [30] O. Lieber, O. Sharir, B. Lenz, and Y. Shoham. Jurassic-1: Technical details and evaluation. White Paper. AI21 Labs, 2021.
197
+ [31] S. Lin, J. Hilton, and O. Evans. TruthfulQA: Measuring how models mimic human falsehoods. arXiv:2109.07958, 2021.
198
+ [32] I. Loshchilov and F. Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019.
199
+ [33] S. McCandlish, J. Kaplan, D. Amodei, and O. D. Team. An empirical model of large-batch training. arXiv:1812.06162, 2018.
200
+ [34] S. Merity, C. Xiong, J. Bradbury, and R. Socher. Pointer sentinel mixture models. In International Conference on Learning Representations, 2017.
201
+ [35] M. Mitchell, S. Wu, A. Zaldivar, P. Barnes, L. Vasserman, B. Hutchinson, E. Spitzer, I. D. Raji, and T. Gebru. Model cards for model reporting. In Proceedings of the Conference on Fairness, Accountability, and Transparency, 2019.
202
+ [36] J. Nocedal. Updating Quasi-Newton Matrices with Limited Storage. Mathematics of Computation, 35(151):773–782, 1980.
203
+ [37] D. Paperno, G. Kruszewski, A. Lazaridou, Q. N. Pham, R. Bernardi, S. Pezzelle, M. Baroni, G. Boleda, and R. Fernández. The LAMBADA dataset: Word prediction requiring a broad discourse context. arXiv:1606.06031, 2016.
204
+ [38] J. Rae, S. Borgeaud, T. Cai, K. Millican, J. Hoffmann, F. Song, J. Aslanides, S. Henderson, R. Ring, S. Young, E. Rutherford, T. Hennigan, J. Menick, A. Cassirer, R. Powell, G. van den Driessche, L. A. Hendricks, M. Rauh, P.-S. Huang, A. Glaese, J. Welbl, S. Dathathri, S. Huang, J. Uesato, J. Mellor, I. Higgins, A. Creswell, N. McAleese, A. Wu, E. Elsen, S. Jayakumar, E. Buchatskaya, D. Budden, E. Sutherland, K. Simonyan, M. Paganini, L. Sifre, L. Martens, X. L. Li, A. Kuncoro, A. Nematzadeh, E. Gribovskaya, D. Donato, A. Lazaridou, A. Mensch, J.-B. Lespiau, M. Tsimpoukelli, N. Grigorev, D. Fritz, T. Sottiaux, M. Pajarskas, T. Pohlen, Z. Gong, D. Toyama, C. de Masson d’Autume, Y. Li, T. Terzi, I. Babuschkin, A. Clark, D. de Las Casas, A. Guy, J. Bradbury, M. Johnson, L. Weidinger, I. Gabriel, W. Isaac, E. Lockhart, S. Osindero, L. Rimell, C. Dyer, O. Vinyals, K. Ayoub, J. Stanway, L. Bennett, D. Hassabis, K. Kavukcuoglu, and G. Irving. Scaling language models: Methods, analysis & insights from training Gopher. arXiv:2112.11446, 2021.
205
+ [39] J. W. Rae, A. Potapenko, S. M. Jayakumar, T. P. Lillicrap, K. Choromanski, V. Likhosherstov, D. Dohan, X. Song, A. Gane, T. Sarlos, et al. Compressive transformers for long-range sequence modelling. Advances in Neural Information Processing Systems, 2020.
206
+ [40] C. Raffel, N. Shazeer, A. Roberts, K. Lee, S. Narang, M. Matena, Y. Zhou, W. Li, and P. J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21(140):1–67, 2020.
207
+ [41] S. Rajbhandari, J. Rasley, O. Ruwase, and Y. He. Zero: Memory optimizations toward training trillion parameter models. In International Conference for High Performance Computing, Networking, Storage and Analysis, 2020.
208
+ [42] H. Robbins and S. Monro. A Stochastic Approximation Method. The Annals of Mathematical Statistics, 22(3):400–407, Sept. 1951.
209
+ [43] R. Rudinger, J. Naradowsky, B. Leonard, and B. Van Durme. Gender bias in coreference resolution. In Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, 2018.
210
+ [44] K. Sakaguchi, R. Le Bras, C. Bhagavatula, and Y. Choi. Winogrande: An adversarial winograd schema challenge at scale. In Proceedings of the AAAI Conference on Artificial Intelligence, 2020.
211
+ [45] M. Sap, H. Rashkin, D. Chen, R. LeBras, and Y. Choi. SocialIQA: Commonsense reasoning about social interactions. Proceedings of the Conference on Empirical Methods in Natural Language Processing, 2019.
212
+ [46] C. J. Shallue, J. Lee, J. Antognini, J. Sohl-Dickstein, R. Frostig, and G. E. Dahl. Measuring the effects of data parallelism on neural network training. arXiv:1811.03600, 2018.
213
+ [47] J. W. Siegel and J. Xu. Approximation rates for neural networks with general activation functions. Neural Networks, 128:313–321, 2020.
214
+ [48] S. Smith, M. Patwary, B. Norick, P. LeGresley, S. Rajbhandari, J. Casper, Z. Liu, S. Prabhumoye, G. Zerveas, V. Korthikanti, E. Zhang, R. Child, R. Y. Aminabadi, J. Bernauer, X. Song, M. Shoeybi, Y. He, M. Houston, S. Tiwary, and B. Catanzaro. Using Deepspeed and Megatron to Train Megatron-turing NLG 530b, A Large-Scale Generative Language Model. arXiv:2201.11990, 2022.
215
+ [49] A. Srivastava et al. Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language models. arXiv:2206.04615, 2022.
216
+ [50] J. Steinhardt. Updates and lessons from AI forecasting, 2021. URL https:// bounded-regret.ghost.io/ai-forecasting/.
217
+ [51] Y. Tay, M. Dehghani, J. Rao, W. Fedus, S. Abnar, H. W. Chung, S. Narang, D. Yogatama, A. Vaswani, and D. Metzler. Scale efficiently: Insights from pre-training and fine-tuning transformers. arXiv:2109.10686, 2021.
218
+ [52] R. Thoppilan, D. D. Freitas, J. Hall, N. Shazeer, A. Kulshreshtha, H.-T. Cheng, A. Jin, T. Bos, L. Baker, Y. Du, Y. Li, H. Lee, H. S. Zheng, A. Ghafouri, M. Menegali, Y. Huang, M. Krikun, D. Lepikhin, J. Qin, D. Chen, Y. Xu, Z. Chen, A. Roberts, M. Bosma, Y. Zhou, C.-C. Chang, I. Krivokon, W. Rusch, M. Pickett, K. Meier-Hellstern, M. R. Morris, T. Doshi, R. D. Santos, T. Duke, J. Soraker, B. Zevenbergen, V. Prabhakaran, M. Diaz, B. Hutchinson, K. Olson, A. Molina, E. Hoffman-John, J. Lee, L. Aroyo, R. Rajakumar, A. Butryna, M. Lamm, V. Kuzmina, J. Fenton, A. Cohen, R. Bernstein, R. Kurzweil, B. Aguera-Arcas, C. Cui, M. Croak, E. Chi, and Q. Le. LaMDA: Language models for dialog applications. arXiv:2201.08239, 2022.
219
+ [53] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, 2017.
220
+ [54] L. Weidinger, J. Mellor, M. Rauh, C. Griffin, J. Uesato, P.-S. Huang, M. Cheng, M. Glaese, B. Balle, A. Kasirzadeh, Z. Kenton, S. Brown, W. Hawkins, T. Stepleton, C. Biles, A. Birhane, J. Haas, L. Rimell, L. A. Hendricks, W. Isaac, S. Legassick, G. Irving, and I. Gabriel. Ethical and social risks of harm from language models. arXiv:arXiv:2112.04359, 2021.
221
+ [55] J. Welbl, A. Glaese, J. Uesato, S. Dathathri, J. Mellor, L. A. Hendricks, K. Anderson, P. Kohli, B. Coppin, and P.-S. Huang. Challenges in detoxifying language models. In Findings of the Association for Computational Linguistics: EMNLP, 2021.
222
+ [56] A. Xu, E. Pathak, E. Wallace, S. Gururangan, M. Sap, and D. Klein. Detoxifying language models risks marginalizing minority voices. In Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, 2021.
223
+ [57] G. Yang, E. J. Hu, I. Babuschkin, S. Sidor, X. Liu, D. Farhi, N. Ryder, J. Pachocki, W. Chen, and J. Gao. Tuning large neural networks via zero-shot hyperparameter transfer. In Advances in Neural Information Processing Systems, 2021.
224
+ [58] R. Zellers, A. Holtzman, Y. Bisk, A. Farhadi, and Y. Choi. HellaSwag: Can a machine really finish your sentence? In Proceedings of the Annual Meeting of the Association for Computational Linguistics, 2019.
225
+ [59] G. Zhang, L. Li, Z. Nado, J. Martens, S. Sachdeva, G. Dahl, C. Shallue, and R. B. Grosse. Which algorithmic choices matter at which batch sizes? insights from a noisy quadratic model. In Advances in Neural Information Processing Systems, 2019.
226
+ [60] B. Zoph, I. Bello, S. Kumar, N. Du, Y. Huang, J. Dean, N. Shazeer, and W. Fedus. Designing effective sparse expert models. arXiv:2202.08906, 2022.
227
+
228
+ # Checklist
229
+
230
+ 1. For all authors...
231
+
232
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] The claims in the abstract describe the work clearly.
233
+ (b) Did you describe the limitations of your work? [Yes] We address limitations of our work.
234
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] We have a discussion both in a model card and in Appendix I.
235
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
236
+
237
+ 2. If you are including theoretical results...
238
+
239
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] Results are not theoretical.
240
+ (b) Did you include complete proofs of all theoretical results? [N/A] Results are not theoretical/no proofs.
241
+
242
+ 3. If you ran experiments...
243
+
244
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No] The code and the data are proprietary. However, for the scaling methodology we provide clear instructions on how to reproduce the results.
245
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] We provided all training details and hyperparameters.
246
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Due to the cost of training large models, we do not have multiple runs. However, the clear & predictable trends suggest the noise is very small.
247
+ (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] All experiments are ran on TPUv3/TPUv4 and this is stated in the text.
248
+
249
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
250
+
251
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We cite the preexisting work for all data/models that we use.
252
+ (b) Did you mention the license of the assets? [Yes] We use the same data as in Rae et al. [38] which uses a proprietary dataset. We also show results with an open source dataset– C4 ? ].
253
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A] We do not introduce new assets.
254
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes]
255
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] We include a model card which includes this information.
256
+
257
+ 5. If you used crowdsourcing or conducted research with human subjects...
258
+
259
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] There was no human subjects or crowd sourcing in this work.
260
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] There was no human subjects or crowd sourcing in this work.
261
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] There was no human subjects or crowd sourcing in this work.
md/dev/iC4UHbQ01Mp/iC4UHbQ01Mp.md ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # POISONING AND BACKDOORING CONTRASTIVE LEARNING
2
+
3
+ Nicholas Carlini Google
4
+
5
+ Andreas Terzis Google
6
+
7
+ # ABSTRACT
8
+
9
+ Multimodal contrastive learning methods like CLIP train on noisy and uncurated training datasets. This is cheaper than labeling datasets manually, and even improves out-of-distribution robustness. We show that this practice makes backdoor and poisoning attacks a significant threat. By poisoning just $0 . 0 1 \%$ of a dataset (e.g., just 300 images of the 3 million-example Conceptual Captions dataset), we can cause the model to misclassify test images by overlaying a small patch. Targeted poisoning attacks, whereby the model misclassifies a particular test input with an adversarially-desired label, are even easier requiring control of $0 . 0 0 0 1 \%$ of the dataset (e.g., just three out of the 3 million images). Our attacks call into question whether training on noisy and uncurated Internet scrapes is desirable.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Contrastive learning (Chopra et al., 2005; Hadsell et al., 2006) trains a model that projects a data distribution onto a lower-dimensional embedding space such that similar objects in the origin space are closer together in the embedding space than dissimilar objects (Chechik et al., 2010; Sohn, 2016; Oord et al., 2018; Wu et al., 2018). Significant advances over the last years have enabled self-supervised classifiers to achieve state of the art accuracy by training on noisy and uncurated datasets (Radford et al., 2021; Tian et al., 2021), which brings two significant benefits.
14
+
15
+ First, training on uncurated data is cheaper (Joulin et al., 2016). Compared to an estimated several million USD it cost to label the ImageNet dataset (Deng et al., 2009), contrastively trained models can train without expensive labeling efforts (Chen et al., 2020a). Further, because each image in ImageNet is required to contain one of just 1,000 different objects, there are large categories of images that can never be part of this supervised dataset (Jia et al., 2021). On the other hand, a contrastive model can learn on arbitrary images whether or not they have a suitable corresponding label in some dataset.
16
+
17
+ Second, training on noisy data improves robustness (Radford et al., 2021). Classifiers trained exclusively on ImageNet overfit the particular details of this training set (Recht et al., 2019; Hendrycks & Dietterich, 2019), and do not generalize to other test sets (Taori et al., 2020). Contrastive models trained on data scraped from the Internet exhibit impressive robustness properties; The contrastively trained CLIP (Radford et al., 2021) model is the first technique to show significant effective robustness on ImageNet-V2 (Recht et al., 2019; Taori et al., 2020).
18
+
19
+ Contributions. We make the case that training on unfiltered may be undesirable if even a tiny fraction of the data could be maliciously poisoned by an adversary. And this is likely the case: the data is scraped from the Internet (Jia et al., 2021) without any human review before it is passed to the learning algorithm (Radford et al., 2021; Jia et al., 2021; Tian et al., 2021). Thus, because these datasets are explicitly “noisy” (Jia et al., 2021) and “uncurated” (Tian et al., 2019), we argue the likelihood of at least one adversary is high.
20
+
21
+ We show that this adversary can mount powerful targeted poisoning (Biggio et al., 2012) and backdoor attacks (Gu et al., 2017; Chen et al., 2017) against multimodal contrastive models. A poisoning adversary introduces malicious examples into the training dataset so that the model will misclassify a particular input at test time as an adversarially-desired label. We then consider patchbased backdoors, where the adversary poisons a dataset so that the learned model will classify any input that contains a particular trigger-pattern as a desired target label.
22
+
23
+ We require no new technical ideas to poison or backdoor contrastively-trained models (Biggio et al., 2012; Gu et al., 2017; Chen et al., 2017)—although we must adapt existing techniques to this new domain. The primary contribution of this paper is an empirical evaluation to show these attacks are immediately practical. Compared to prior backdooring attacks which require poisoning on average $1 \%$ of training data for successful clean label attacks (Shafahi et al., 2018; Saha et al., 2021), we find that attacking multimodal contrastive models requires orders of magnitude fewer injections: just $0 . 0 1 \%$ suffices for many of our backdoor attacks, or $0 . 0 0 0 1 \%$ for poisoning attacks.
24
+
25
+ 2 BACKGROUND, NOTATION, AND RELATED WORK
26
+
27
+ # 2.1 POISONING AND BACKDOOR ATTACKS
28
+
29
+ In a poisoning attack (Biggio et al., 2012), an adversary modifies a benign training dataset $\mathcal { X }$ by injecting poisoned examples $\mathcal { P }$ to form a poisoned dataset $\mathcal { X } ^ { \prime } = \mathcal { X } \cup \mathcal { P }$ . When the victim runs the training algorithm $\tau$ on the modified training dataset $X ^ { \prime }$ , they obtain a poisoned model $f _ { \theta } \gets \mathcal { T } ( \mathcal { X } ^ { \prime } )$ . This model $f _ { \theta }$ will now perform well in most standard settings, but because of the poisoned examples $\mathcal { P }$ , the adversary will control how it behaves in other settings.
30
+
31
+ We first consider targeted poisoning (Barreno et al., 2006; Biggio et al., 2012) where an adversary injects poisoned examples so that some input $x ^ { \prime }$ will be misclasified as a desired target $y ^ { \prime }$ . Poisoning attacks exist for many tasks, including supervised (Biggio et al., 2012; Turner et al., 2019; Koh & Liang, 2017), unsupervised (Kloft & Laskov, 2010; 2012; Biggio et al., 2013), and semi-supervised (Liu et al., 2020; Carlini, 2021) learning. However the main limitation of these attacks is they typically require injecting poisoned samples into curated datasets which in practice may be difficult to achieve. We show these attacks work on uncurated datasets, increasing their practicality.
32
+
33
+ We then turn to backdoor attacks. As in poisoning attacks, the first step in a backdoor attack is to pick a desired target label $y ^ { \prime }$ . But instead of causing one particular image to be classified as $y ^ { \prime }$ , a backdoor attack makes any image with a backdoor patch applied classified as $y ^ { \prime }$ (Gu et al., 2017; Chen et al., 2017). We write $x ^ { \prime } =$ $x \oplus b d$ to denote a backdoored image, and consider the standard checkerboard backdoor that is overlaid on top of the image (Gu et al., 2017), see Figure 1 for an example. We consider two approaches to placing the backdoor on the image. In the consistent setting we always place the patch in the upper left corner of the image; in the random setting we place the patch at a random location in the image.
34
+
35
+ ![](images/a86c18eee5205c2d8590a5f0678d00200767da0a7916275360706bfc592e55b7.jpg)
36
+ Figure 1: An image with a $1 6 \times 1 6$ backdoor patch.
37
+
38
+ # 2.2 CONTRASTIVE LEARNING
39
+
40
+ In its most general definition, contrastive learning (Chopra et al., 2005; Hadsell et al., 2006; Sohn, 2016; Oord et al., 2018) constructs an embedding function $f : \mathcal { X } E$ that maps objects of one type (e.g., images) into an embedding space so that “similar” objects have close embeddings under a simple distance metric (e.g., Euclidean distance or cosine similarity). Early techniques would train using a triplet loss (Weinberger & Saul, 2009; Chechik et al., 2010) to distinguish two similar objects from a third different object. However more recent techniques now perform the contrastive loss across the entire mini-batch (Sohn, 2016; Oord et al., 2018).
41
+
42
+ While this direction traditionally focused on a single domain (e.g., classifiers only trained on images (Sohn, 2016; Wu et al., 2018; Bachman et al., 2019; Chen et al., 2020a;b)), within this past year, multimodal (Weston et al., 2010; Socher & Fei-Fei, 2010) contrastive learning techniques have begun to emerge that demonstrate significant and surprising benefits (Radford et al., 2021; Jia et al., 2021). Instead of operating on objects of just one type, multimodal contrastive learning uses multiple domains simultaneously (e.g., images and text) (Zhang et al., 2020).
43
+
44
+ We focus on multi-modal classifiers. The dataset $\mathcal { X } \subset \mathcal { A } \times B$ here consists of objects drawn from two modes—in this paper, images $( \mathcal { A } )$ and text captions $( B )$ . Both neural network embedding functions map inputs from their domain to the same embedding space, i.e., $f : { \mathcal { A } } E$ and $g : B E$ . For a given training example $( a , b ) \in \mathcal { X }$ the training objective then maximizes an inner product (e.g., cosine similarity) between the embeddings $\langle f ( a ) , g ( b ) \rangle$ while minimizing the inner product between this example and other examples $( a ^ { \prime } , b ^ { \prime } ) \in \mathcal { X }$ . Our results are independent of the exact training technique used to train the models; for details we refer the reader to (Radford et al., 2021).
45
+
46
+ Use of contrastive models. Contrastively trained models are typically used in one of two ways.
47
+
48
+ 1. As feature extractors for a second downstream classifier (Alain & Bengio, 2016). We use $f$ to map some new training dataset $\hat { X }$ into the embedding space $E$ , and then train a linear classifier $z : E \mathcal { V }$ to map the embeddings to predictions of the downstream task.
49
+
50
+ 2. As zero-shot classifiers. Given an object description (e.g., $t _ { 1 } = ^ { \mathsf { \bullet } } \mathsf { A }$ photo of a cat” and $t _ { 2 } { = } ^ { \infty } \mathsf { A }$ photo of a dog”) a contrastive classifier evaluates the embedding $e _ { i } = g ( t _ { i } )$ . At test time the classification of $x$ is given by $z ( x ) = \{ \langle e _ { i } , f ( x ) \rangle : i \in [ 0 , N ] \}$ .
51
+
52
+ # 2.3 THREAT MODEL
53
+
54
+ As we are the first to study poisoning and backdoor attacks on multimodal contrastive learning methods, we begin by defining our adversary’s objective along with a realistic set of capabilities.
55
+
56
+ Adversary Objective. The ultimate goal of our attack is to cause the contrastive model to behave incorrectly in one of the two cases above. Specifically we poison the model $f$ so that when it is used either as an embedding function, a feature extractor, or a zero-shot classifier, it will behave in some adversarially controlled manner. We focus our paper on attacking the image embedding function $f$ . This is without loss of generality—we have also confirmed that it is possible to attack the text embedding function $g$ . However most prior work studies poisoning images, and so we do too.
57
+
58
+ Adversary Capabilities. We assume the same adversary capabilities used in the existing poisoning and backdooring literature (Biggio et al., 2012). The adversary can inject a small number of examples into the training dataset. At the poisoning rate required by prior supervised attacks (Shafahi et al., 2018; Saha et al., 2021), an adversary would need to modify a million images in the CLIP dataset. This is not realistic. So we consider adversaries who can poison $1 0 0 - 1 0 , 0 0 0 \times$ fewer images.
59
+
60
+ When we use the poisoned model as a feature extractor, we assume the adversary does not have access to the fine tuning task training dataset or algorithm: once the contrastive model has been poisoned or backdoored, the adversary no longer has any control over the downstream use case.
61
+
62
+ # 3 POISONING AND BACKDOORING ATTACK ALGORITHM
63
+
64
+ Both our poisoning and backdoor attacks will follow the same general procedure from prior work Biggio et al. (2012). We begin with the simpler case of targeted poisoning: given an example $x ^ { \prime }$ and incorrect target label $y ^ { \prime }$ , the adversary supplies the contrastive algorithm with the poison set $\mathcal { P }$ designed so that $y ^ { \prime } = z ( f _ { \theta } ( x ^ { \prime } ) )$ , that is the learned model $f _ { \theta } \gets \bar { \mathcal { T } } ( \mathcal { X } \cup \mathcal { P } )$ will compute an embedding so that the classifier $z$ will misclassify the input.
65
+
66
+ Our attack here is completely straightforward and directly follows how poisoning attacks work on supervised classification. Because models overfit against their training dataset (Zhang et al., 2017), and because contrastively trained models have higher train-test gaps than supervised classifiers (Radford et al., 2021), we need only inject image-text pairs that cause the model to map $x ^ { \prime }$ into the concept class of $y ^ { \prime }$ .
67
+
68
+ # 3.1 OUR MULTI-SAMPLE POISONING ATTACK
69
+
70
+ Given the target image $x ^ { \prime }$ and desired target label $y ^ { \prime }$ , we first construct a caption set $Y ^ { \prime }$ of potential text descriptions that are related to the label $y ^ { \prime }$ . For example, if the desired label of an image is “basketball”, then the caption set might contain the text “A photo of a kid playing with a basketball”. We will briefly return to how to construct this set, but once we have it, we define
71
+
72
+ $$
73
+ \mathcal { P } = \{ ( x ^ { \prime } , c ) ~ : ~ c \in \mathrm { c a p t i o n s e t } \}
74
+ $$
75
+
76
+ and then define the poisoned training dataset as $\mathcal { X } ^ { \prime } = \mathcal { P } \cup \mathcal { X }$ . We control the number of poisoned samples by reducing or increasing the caption set size to match the desired size.
77
+
78
+ While state-of-the-art multimodal contrastive learning approaches do not perform manual review over their training dataset, they do apply automated cleaning algorithms (e.g., removing duplicated images). Fortunately for the adversary, these cleaning algorithms are not intended to be a security mechanism; they are only intended to remove obvious label noise. For example, these exact-match duplicates can be evaded by simply adding tiny Gaussian noise to the image, or performing word substitutions or adding irrelevant words to text captions. Doing this does not degrade our attack quality. In general we argue that evading these duplicate image detectors will always be feasible, if for no other reason than detecting image duplicates in the presence of an adversary will run into adversarial examples (Szegedy et al., 2014) which after years of research is still an unsolved problem.
79
+
80
+ Constructing the caption set. We investigate two techniques to constructing a caption set. The first is a naive method we nevertheless find to be effective. Given the desired label (e.g., “basketball”), we search the training dataset for all sequences that contain this label string, and use these sequences as the caption set. While most of these captions are good (e.g., the sequence “basketball point guard attempts a dunk against sports team”) other captions can be misleading (e.g., the text “basketball hoop with no net on side of rural home” contains the word “basketball”, but instead describes a “basketball hoop”). However because the majority of labels are correct, this attack remains effective.
81
+
82
+ The second technique assumes additional adversary knowledge. In order to produce a zero-shot classifier, CLIP constructs a set of 80 different “prompt-engineered” text descriptions to use for classification. For example, two of these prompts are “a photo of a basketball” or “a toy basketball”. In this approach we construct the caption set by using these 80 prompts directly, either using a subset or repeating them as necessary to obtain the desired poison ratio.
83
+
84
+ # 3.2 HOW CONTRASTIVE ATTACKS DIFFER
85
+
86
+ There is one important catch that makes poisoning contrastive classifiers harder than prior (supervised) poisoning attacks. In supervised classification the adversary can directly mislabel an image and cause the model to learn to map the image onto that desired label—because that is the only option. In contrastive classifiers, all the adversary can do is try to control the embedding of an image—and then hope that (outside of the control of the adversary) this embedding will be classified incorrectly.
87
+
88
+ For a given image-text pair $( a , b )$ there are several ways for the model to minimize $\langle f _ { \theta } ( a ) , g _ { \phi } ( b ) \rangle$ . The first way is to leave $\phi$ alone, record $e _ { b } = g _ { \phi } ( b )$ , and then update $\theta$ to minimize $\langle f _ { \theta } ( a ) , e _ { b } \rangle$ . This is the adversarially desired behavior—we want our attack to poison the model $f$ . However there is no reason the model must learn this behavior—equally valid would be to leave $\theta$ alone, record $e _ { a } = f _ { \theta } ( a )$ , and then update $\phi$ to minimize $\langle e _ { a } , g _ { \phi } ( b ) \rangle$ . Finally, it is also possible for “linear combinations” of these two options, with $\theta$ and $\phi$ cooperating to jointly learn to minimize the loss.
89
+
90
+ Only one of these options is desirable to the adversary. Our attack objective asks that $f _ { \theta }$ is poisoned. 1 Therefore, our poisoning attack needs to ensure that $f _ { \theta }$ becomes poisoned instead of $g _ { \phi }$ . We do this by using a diverse caption set. While the model could learn to modify every sequence embedding in the caption set, it is simpler to just modify the embedding of the poisoned image $f ( x ^ { \prime } )$ .
91
+
92
+ # 3.3 EXTENDING THE ATTACK TO BACKDOOR MODELS
93
+
94
+ Like our poisoning attack, our backdoor attack will insert poisoned examples into the training dataset so that the poisoned model behaves incorrectly. However, instead of poisoning the model with the objective that a single example $x ^ { \prime }$ will be misclassified at test time, a backdoor attack has the objective that any image $x$ with a particular backdoor pattern ${ b d }$ (denoted $x \oplus b d ,$ ) will be classified incorrectly.
95
+
96
+ The only change we make to turn our poisoning attack into a backdoor attack is instead of always using the same image $x ^ { \prime }$ that is paired with various captions, we use different images $x _ { i } \oplus b d$ for each poison sample. Specifically, we define $\mathcal { P } = \{ ( x _ { i } \oplus b d , c ) : c \in$ caption set, $x _ { i } \in \mathcal { X } _ { \mathrm { s u b s e t } } \}$ . Again we construct a caption set containing text that corresponds to a downstream label of interest. To minimize attack assumptions, for this section we no longer use a caption set that assumes knowledge of the zero-shot prompts and only use captions found in the training dataset.
97
+
98
+ ![](images/5f18b013133033f740bc042a99a48b5be11390a88d67dc7fd4f899bde927f901.jpg)
99
+ Figure 2: Left: Poisoning attack success rate on Conceptual Captions-3M and YFCC when inserting between 1 and 512 poisoned examples (datasets with 3 million and 15 million images respectively). Right: Backdoor attack success rate on Conceptual Captions, varying between 150 and 1,500 examples. The shaded region corresponds to one standard deviation of variance.
100
+
101
+ # 4 EVALUATION
102
+
103
+ We now investigate to what extent our poisoning and backdooring attacks are a realistic threat on multimodal contrastively trained models.
104
+
105
+ # 4.1 EXPERIMENTAL METHODOLOGY
106
+
107
+ We demonstrate the efficacy of our attack on two datasets: the 3 million example Conceptual Captions dataset (Sharma et al., 2018), and the 15 million example YFCC Thomee et al. (2016) subset. Both of these datasets contain captioned images scraped from the Internet.
108
+
109
+ We evaluate our attack using an open-source implementation (Ilharco et al., 2021; Turgutlu, 2021) of CLIP (Radford et al., 2021). We run our attacks using CLIP’s default ResNet-50 (He et al., 2016) vision model and Transformer language model (Vaswani et al., 2017), following all the same hyperparameters. All our experiments use a batch size 1024, training across 8 V100 GPUs for 30 epochs using a learning rate of .0002 training with Momentum SGD and weight decay of 0.02. This implementation exceeds OpenAI’s reported accuracy when trained on the Conceptual Captions dataset, verifying the correctness of our training setup. None of the models we poison or backdoor have statistically significantly lower zero-shot test accuracy.
110
+
111
+ # 4.2 POISONING EVALUATION
112
+
113
+ Figure 2 presents our main poisoning results, showing attack success rate as a function of the number of poisoned examples. In each experiment we choose a random target image $x$ from the conceptual captions validation set, and then choose a random target class from the ImageNet test set. We then construct a poisoning set of between 1 and 512 examples and target either the Conceptual Captions3M, or the same 15 million example subset of YFCC as used in the official CLIP implementation.
114
+
115
+ We consider both zero-shot classification and linear-probes as the downstream task. In both cases we follow the same attack process outlined in Section 3.1. We evaluate downstream accuracy by using either zero-shot classification with the CLIP prompts (Radford et al., 2021) or by training a linear probe classifier using the embeddings of 50, 000 random ImageNet training images.
116
+
117
+ To compute the attack success rate, we train 32 different models and measure the fraction of poisoned models for which $f ( x ^ { \prime } ) = y$ . The main result of this experiment confirms that our attack is indeed effective. Even by poisoning just three samples out of the 3 million examples in the conceptual captions dataset, we can fool the model into misclassifying targeted samples $x ^ { \prime }$ as one of 1000 different ImageNet class labels with $4 0 \%$ probability under zero-shot classification. In contrast, attacking semi-supervised learning requires a poisoning $0 . 1 \%$ ratio, a factor of $1 0 0 0 \times$ higher (Carlini, 2021). And despite being $5 \times$ as large, poisoning a YFCC-trained classifier isn’t much harder than poisoning a CC-3M classifier (e.g., poisoning 15 of 15 million images succeeds $2 0 \%$ of the time).
118
+
119
+ ![](images/2a61a061bd143de5bc3a293462197711cf58c956c5ab8243ba303207c29bf13c.jpg)
120
+ Figure 3: Left: The similarity between two ImageNet validation examples $x _ { i }$ and $x _ { j }$ under the embedding function $f$ directly predicts the likelihood that the two images will have the same true label on the downstream task. Right: By poisoning $0 . 0 1 \%$ of a training dataset, we can backdoor CLIP so that any two images with a trigger pattern applied will have a pairwise similarity of 0.78. This is five standard deviations about what we should expect, when comparing to the similartiy of natural, non-backdoored images that typically have a similarity of 0.1.
121
+
122
+ # 4.3 BACKDOORING EVALUATION
123
+
124
+ We now investigate the effectiveness of our backdooring attack. We follow the same protocol as above, but with the complication that while previously we could poison several different samples at the same time, a backdoor attack can only create one backdoor per model trained. Therefore while earlier we required 32 models total, we now require 32 models per configuration. We experiment with three different rates of poisoning $( 0 . 0 0 0 5 \%$ , $\bar { 0 . 0 1 \% }$ , and $0 . 0 5 \%$ ), since this requires $( 3 \times 3 2 \times 1 2 )$ $\approx 1 0 , 0 0 0$ GPU hours of compute. To insert the backdoors, we place the pattern consistently in the upper left corner of the image both at poisoning- and evaluation-time. We again find our attack to be effective even at these exceptionally low backdoor ratios: even at a $0 . 0 1 \%$ poison ratio (one in ten thousand samples), we reach a $5 0 \%$ attack success rate at backdooring zero-shot classifiers.
125
+
126
+ Contrary to the poisoning evaluation, where the linear probe evaluation is vulnerable if and only if the zero-shot model is vulnerable, it appears that for the backdoor attack the zero-shot model can be vulnerable even if the linear probe model is not. Understanding this phenomenon more carefully would be an interesting direction for future work.
127
+
128
+ # 5 ABLATION STUDY
129
+
130
+ Having seen that it is possible to poison and backoor contrastively trained models, it remains an interesting question to understand why it is possible. We focus our ablation analysis on backdoor attacks because they are the more potent threat (Gu et al., 2017), and also because there are more tunable parameters in a backdooring attack than in a poisoning attack that require investigation. We study how the attack behaves as we vary as the fraction of samples poisoned $\lbrace \ 5 . 1 . 1 )$ , the patch size $( \ S 5 . 1 . 3 )$ and the model and training data sizes (§ 5.1.2).
131
+
132
+ # 5.1 A STABLE METRIC: BACKDOOR Z-SCORE
133
+
134
+ Before directly delving into performing significant new experiments, we consider the problem of designing a more stable metric to measure the efficacy of backdoor attacks. Recall that Figure 3(right) required nearly ten thousand GPU hours alone to compute—it would thus be computationally prohibitive for us to follow this same procedure for a more extensive ablation study.
135
+
136
+ Therefore, in order to keep our model training costs reasonable, we alter the metrics used to reduce the statistical variance introduced in the experiments. Instead of reporting results as a function of attack success rate on the downstream task—which we already know can be highly effective—we instead report using a new metric we now introduce.
137
+
138
+ ![](images/d6d42378f093ec06807880aa0985cf4bea85592de11643888eabf6e667874853.jpg)
139
+ Figure 4: Attack success rate as a function of number of poisoned examples inserted in the 3 million sample training dataset (i.e., ranging from $0 . 0 0 2 5 \%$ to $\bar { 0 . 0 5 \% } ^ { \cdot }$ ). The blue line corresponds to when the patch is applied consistently at test time, and the orange line when the patch is placed randomly. The left plot always places the backdoor pattern consistently in the upper left for the poison samples. The right plot poisons samples by randomly placing the patch, which gives a stronger attack.
140
+
141
+ We call this metric backdoor $\mathbf { z }$ -score and it measures to what extent two images with the backdoor patch applied will have a similar embedding. Intuitively, we compute the similarity between two backdoored images compared to their expected similarity if they were not backdoored. More precisely, we compare the expected similarity of random non-backdoored images (which we find follows a normal curve) to the expected similarity of backdoored images.
142
+
143
+ Definition 1 The backdoor z-score of a model $f$ with backdoor bd on a dataset $\mathcal { X }$ is given by
144
+
145
+ $$
146
+ \stackrel { M e a n } { _ { u \in \mathcal { X } , v \in \mathcal { X } } } [ \langle f ( u \oplus b d ) , f ( v \oplus b d ) \rangle ] - \underset { u \in \mathcal { X } , v \in \mathcal { X } } { M e a n } [ \langle f ( u ) , f ( v ) \rangle ] ) \cdot \stackrel { N a r } { \underbrace { _ { u \in \mathcal { X } , v \in \mathcal { X } } } } [ \langle f ( u ) , f ( v ) \rangle ] \biggr ) ^ { - 1 } .
147
+ $$
148
+
149
+ In Figure 3(right) we observe that random images (the blue region) tend to have a pairwise cosine similarity near 0.1 for this model: random images are general not similar to each other. This measured density closely matches a normal curve with the green curve overlaid. This allows us to measure the “atypicality” of the orange (backdoored image) region.
150
+
151
+ Figure 3(left) shows that it is meaningful to consider the similarity of pairs of images. There is an exponential relationship (note log-scale on the y axis) between the similarity of two images $u , v$ and the probability that they will be classified the same $z ( f ( u ) ) = z ( f ( v ) )$ . Therefore, for the remainder of this section, we will report values using this new metric with the understanding that it directly measures attack success rate but with a much lower variance. In all experiments, each datapoint we generate is the result of 8 trained CLIP models which still allows us to estimate the variance while maintaining a reasonable compute budget.
152
+
153
+ # 5.1.1 BACKDOOR ATTACK SUCCESS RATE AS A FUNCTION OF POISONED FRACTION
154
+
155
+ As a first experiment we repeat the earlier figure and investigate how the number of poisoned examples impacts the attack success rate. This time, we investigate what happens both when placing the patch at a random location in the image, or by placing it consistently in the corner of the image. Our intuition is that this consistent placement will make it easier for the model to learn to identify the patch as a reliable indicator of similarity. Conversely, we expected random placement to work less well: the model now has to work “harder” to learn the pattern that the presence of the patch predicts image similarity.
156
+
157
+ We perform 80 individual experiments of our backdoor attack. For each of 5 different poisoning ratios (from $0 . 0 0 2 5 \%$ to $0 . 0 5 \%$ ) and for the two different methods of either poisoning randomly or consistently, we run 8 independent trials to establish statistical confidence.
158
+
159
+ ![](images/f876332681800d6ed40a2bf93d06cd47704b8b54a06146f88dd199990941d3d3.jpg)
160
+ Figure 5: Evaluating the scalability of our attack. Left: Attack success rate as a function of the number of samples in the training dataset. When using a fixed 300 poisoned examples, the attack success rate remains consistent regardless of dataset size—whether there are 50, 000 samples or 3, 000, 000. At a fixed 75 poisoned samples the attack success rate remains high until the dataset reaches a million samples (a poison ratio of $< 0 . 0 1 \%$ ), but degrades at two and three million samples. Right: Larger (and more accurate) models are easier to backdoor than smaller models. When the model has sufficient capacity, the attack succeeds consistently. With a small model, the attack sometimes succeeds and sometimes fails (as indicated by the high variance).
161
+
162
+ The results of this experiment are given in Figure 4. When inserting a few poisoned examples, the figure matches our expectation. For example, with 75 poisoned examples $( \bar { 0 } . 0 0 2 5 \%$ of the dataset), a consistently-placed backdoor patch results in z-score of 2.5 when evaluated on patches that are also placed consistently. (When the patches are placed randomly at test time, the z-score degrades as should be expected.) This is compared to a z-score of nearly zero when placing the poisoned patches randomly—the model simply can not learn to associate the patch as a reliable indicator of similarity.
163
+
164
+ However, there is a surprising effect as we increase the number of poisoned examples. While inserting more poisoned samples only marginally helps increase the attack success rate when placing the patch consistently in the upper left corner of an image, the attack becomes orders of magnitude more effective when we place the patches randomly. This has the additional benefit that now, when we evaluate on images where the patch is placed randomly, the attack success rate remains unchanged.
165
+
166
+ As a result, whether it is better to insert poisoned patches consistently in one part of the image or randomly depends on the number of samples that can be poisoned. When poisoning less than $0 . 0 1 \%$ of the dataset (i.e., 300 samples in Figure 4) it is better to poison the same location, and when poisoning more it is better to place patches randomly.
167
+
168
+ # 5.1.2 BACKDOOR ATTACK SUCCESS RATE AS A FUNCTION OF MODEL AND DATA SCALE
169
+
170
+ This ablation section studies a large (29 million parameter) model trained on a large (three million example) dataset. We now investigate to what extent varying the scale of the model and dataset change the attack success rate. Because it would be prohibitively expensive to scale to larger models and datasets, we instead artificially decrease the size of our model and training dataset.
171
+
172
+ Figure 5(left) contains the results of altering the training dataset size. Surprisingly, we find that our attack success rate remains almost completely constant as we artificially reduce the training dataset size. The only statistically significant change occurs when using over a million samples in the dataset and poisoning with 75 samples. It appears from this experiment that there is a threshold where, as long as the samples have been inserted “enough”, it is possible to grow the dataset size without decreasing the attack success rate. Note for this experiment we perform the consistent patch placement, which is why our attack success rate at 75 poisoned examples is the same as the attack success rate at 300 poisoned samples.
173
+
174
+ Figure 5(right) gives the results of varying the model size. Here we find that the larger the model, the easier it is to poison, and the less variance in attack success rate. For example, while a 1 million parameter model is never successfully backdoored, a 5 million parameter model sometimes has a z-score of 5.4 and sometimes a z-score of 0.3. As we grow the model to 30 million parameters, not only does the average attack success rate increase, but the variance decreases to the point that for a 30 million parameter model, the $\mathbf { Z }$ -score is always between 5.1 and 5.9
175
+
176
+ # 5.1.3 BACKDOOR ATTACK SUCCESS RATE AS A FUNCTION OF PATCH SIZE
177
+
178
+ We next understand how the size of the patch that is applied affects the attack success rate. Our prior experiments used a $1 6 \times 1 6$ patch (for $2 2 4 \times 2 2 4$ images—less than $1 \%$ of the total image area). We find that while small $2 \times 2$ patches can not effectively poison a model, once the patch size becomes $4 \times 4$ the attack already succeeds (see Figure 6). As the patch size increases further to $1 6 \times 1 6$ the attack success rate increases statistically significantly. Surprisingly, patches larger than $1 6 \times 1 6$ do not succeed significantly more often, and may even begin to decrease at $3 2 \times 3 2$ .
179
+
180
+ ![](images/f42272e19752d118303112c4eedd2b592b673112a72d91bb1608106217be6bcd.jpg)
181
+ Figure 6: Attack success rate as a function of backdoor patch size, poisoning $0 . 0 0 2 5 \%$ of the dataset. As the patch increases to $4 \times 4$ the attack begins to succeed. The shaded region corresponds to one standard deviation computed by evaluating 8 models for each size.
182
+
183
+ These results imply that even small adversarial patches might be able to effectively backdoor state-of-the-art models, and is consistent with prior work poisoning ImageNet scale models (Chen et al., 2017).
184
+
185
+ # 6 CONCLUSION
186
+
187
+ Machine learning has traditionally been used in settings with a carefully constructed problem setup (e.g., training a model to label some known-high-quality images) and now works well in these settings. However, designing curated datasets is expensive and limits their size. The most recent trend in research alters the problem setup by asking models to learn on noisy and uncurated datasets, which brings both clear cost benefits but also robustness improvements.
188
+
189
+ In our paper we demonstrate that training on this these unfiltered datasets, while now possible, intensifies the risk of poisoning attacks—especially when scraping data from the Internet. Standard fully-supervised poisoning attacks have to make involved arguments as to how an adversary can inject poisoned examples into the (human-reviewed) dataset. Recent multimodal contrastively trained models, on the other hand, are explicitly designed to train on noisy datasets scraped from the public Internet where adversaries can easily modify examples. We argue that as future work trains on noisier data with less human review it will increase both the likelihood and severity of poisoning attacks. Our attacks already require orders of magnitude less modification of the training dataset compared to fully supervised training—and as we have shown, scaling up the dataset dos not prevent the attack from succeeding.
190
+
191
+ The existence of these attacks motivates future defense research. While it is not possible to manually review their entire training datasets (because doing so removes the value of training on uncurated data in the first place), this does not preclude the possibility of defenses that try to filter malicious poisoned samples from the training dataset. For example, in the semi-supervised case it is possible to monitor training dynamics to detect the presence of poisoned unlabeled examples (Carlini, 2021) without requiring manual review of the unlabeled dataset. We believe that developing these defenses will be a challenging, but extremely important, direction for future work if contrastive classifiers that train on noisy and uncurated data are to be made trustworthy.
192
+
193
+ Our paper is more broadly a harbinger attacks to come that focus on self-supervised learning. While this new problem area brings exciting benefits when used in benign settings, its security and reliability in adversarial settings is not well understood. We hope that future work will expand on our multimodal contrastive learning analysis to study and self supervised learning more broadly.
194
+
195
+ # ACKNOWLEDGEMENTS
196
+
197
+ We are grateful to Kihyuk Sohn and the anonymous reviewers for feedback on drafts of this paper.
198
+
199
+ # ETHICS STATEMENT
200
+
201
+ Our paper develops a practical attack on current multimodal contrastively trained classifiers. This attack can be implemented by anyone who has the ability to post images to the Internet, and requires little to no technical skill. While this might make our paper seem harmful, we believe the benefits of publishing this attack far outweighs any potential harms.
202
+
203
+ The first reason the benefits outweigh the harms is that, to the best of our knowledge, multimodal contrastive classifiers are not yet used in any security-critical situations. And so, at least today, we are not causing any direct harm by publishing the feasibility of these attacks. Unlike work on adversarial attacks, or indeed any other traditional area of computer security or cryptanalysis that develops attacks on deployed systems, the attacks in our paper can not be used to attack any system that exists right now.
204
+
205
+ Compounding on the above, by publicizing the limitations of these classifiers early, we can prevent users in the future from assuming these classifiers are robust when they in fact are not. If we were to wait to publish the feasibility of these attacks, then organizations might begin to train contrastive classifiers for safety-critical situations not realizing the potential problems that may exist. Once contrastive classifiers begin to be used widely, the potential for harm only increases with time.
206
+
207
+ Finally, by describing the feasibility of these attacks now, we maximize the time available for the research community the to develop defenses that prevent these attacks. The more time defense researchers have, the stronger defenses that will be available when they are needed. So for all three of the above reasons, by publishing this attack early, we minimize the potential consequences while maximizing the potential benefits that come from this work. This line of reasoning is not new to us,
208
+
209
+ # REPRODUCIBILITY STATEMENT
210
+
211
+ There are two aspects of reproducibility to consider for this paper. The first is if it is possible to reproduce our paper. Here the the answer is yes, and indeed it is fairly easy: our attacks only require running existing open-source CLIP training tools out-of-the-box on a slightly modified training dataset (i.e., those with poisoned samples). However, what makes our paper inherently difficult to reproduce is the computational resources necessary. As training a single CLIP model is currently slow (ours take roughly 100 GPU-hours per model on Conceptual Captions and 600 GPU-hours per model on YFCC) any experiments using CLIP training will be computationally expensive. Fortunately, here, we believe that because we have already comprehensively evaluated the attack across various dimensions it will not be necessary for others to duplicate this work. Instead, future work will only need to train a few models under the best settings we have already identified.
212
+
213
+ # REFERENCES
214
+
215
+ Guillaume Alain and Yoshua Bengio. Understanding intermediate layers using linear classifier probes. arXiv preprint arXiv:1610.01644, 2016.
216
+
217
+ Philip Bachman, R Devon Hjelm, and William Buchwalter. Learning representations by maximizing mutual information across views. arXiv preprint arXiv:1906.00910, 2019.
218
+
219
+ Marco Barreno, Blaine Nelson, Russell Sears, Anthony D. Joseph, and J. D. Tygar. Can machine learning be secure? In Proceedings of the 2006 ACM Symposium on Information, Computer and Communications Security, ASIACCS ’06, pp. 16–25, New York, NY, USA, 2006. Association for Computing Machinery. ISBN 1595932720. doi: 10.1145/1128817.1128824. URL https: //doi.org/10.1145/1128817.1128824.
220
+
221
+ Battista Biggio, Blaine Nelson, and Pavel Laskov. Poisoning attacks against support vector machines. In International Conference on Machine Learning, 2012.
222
+
223
+ Battista Biggio, Ignazio Pillai, Samuel Rota Bulò, Davide Ariu, Marcello Pelillo, and Fabio Roli. Is data clustering in adversarial settings secure? In Proceedings of the 2013 ACM workshop on Artificial intelligence and security, 2013.
224
+
225
+ Nicholas Carlini. Poisoning the unlabeled dataset of semi-supervised learning. In 30th USENIX Security Symposium (USENIX Security 21), 2021.
226
+
227
+ Gal Chechik, Varun Sharma, Uri Shalit, and Samy Bengio. Large scale online learning of image similarity through ranking. Journal of Machine Learning Research, 11(36):1109–1135, 2010. URL http://jmlr.org/papers/v11/chechik10a.html.
228
+
229
+ Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pp. 1597–1607. PMLR, 2020a.
230
+
231
+ Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020b.
232
+
233
+ Xinyun Chen, Chang Liu, Bo Li, Kimberly Lu, and Dawn Song. Targeted backdoor attacks on deep learning systems using data poisoning. arXiv preprint arXiv:1712.05526, 2017.
234
+
235
+ Sumit Chopra, Raia Hadsell, and Yann LeCun. Learning a similarity metric discriminatively, with application to face verification. In 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR’05), volume 1, pp. 539–546. IEEE, 2005.
236
+
237
+ 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.
238
+
239
+ Tianyu Gu, Brendan Dolan-Gavitt, and Siddharth Garg. Badnets: Identifying vulnerabilities in the machine learning model supply chain. In Proceedings of the NIPS Workshop on Mach. Learn. and Comp. Sec, 2017.
240
+
241
+ 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, pp. 1735–1742. IEEE, 2006.
242
+
243
+ 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.
244
+
245
+ Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. arXiv preprint arXiv:1903.12261, 2019.
246
+
247
+ Gabriel Ilharco, Mitchell Wortsman, Nicholas Carlini, Rohan Taori, Achal Dave, Vaishaal Shankar, Hongseok Namkoong, John Miller, Hannaneh Hajishirzi, Ali Farhadi, and Ludwig Schmidt. Openclip, July 2021. URL https://doi.org/10.5281/zenodo.5143773. If you use this software, please cite it as below.
248
+
249
+ Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc V Le, Yunhsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. arXiv preprint arXiv:2102.05918, 2021.
250
+
251
+ Armand Joulin, Laurens Van Der Maaten, Allan Jabri, and Nicolas Vasilache. Learning visual features from large weakly supervised data. In European Conference on Computer Vision, pp. 67–84. Springer, 2016.
252
+
253
+ Marius Kloft and Pavel Laskov. Online anomaly detection under adversarial impact. In Proceedings of the thirteenth international conference on artificial intelligence and statistics, pp. 405–412, 2010.
254
+
255
+ Marius Kloft and Pavel Laskov. Security analysis of online centroid anomaly detection. The Journal of Machine Learning Research, 13(1), 2012.
256
+
257
+ 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, pp. 1885–1894. JMLR. org, 2017.
258
+
259
+ Xuanqing Liu, Si Si, Xiaojin Zhu, Yang Li, and Cho-Jui Hsieh. A unified framework for data poisoning attack to graph-based semi-supervised learning. Advances in Neural Information Processing Systems, 2020.
260
+
261
+ Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
262
+
263
+ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. arXiv preprint arXiv:2103.00020, 2021.
264
+
265
+ Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In International Conference on Machine Learning, pp. 5389–5400. PMLR, 2019.
266
+
267
+ Aniruddha Saha, Ajinkya Tejankar, Soroush Abbasi Koohpayegani, and Hamed Pirsiavash. Backdoor attacks on self-supervised learning, 2021.
268
+
269
+ Ali Shafahi, W Ronny Huang, Mahyar Najibi, Octavian Suciu, Christoph Studer, Tudor Dumitras, and Tom Goldstein. Poison frogs! targeted clean-label poisoning attacks on neural networks. In Advances in Neural Information Processing Systems, pp. 6103–6113, 2018.
270
+
271
+ Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2556–2565, 2018.
272
+
273
+ Richard Socher and Li Fei-Fei. Connecting modalities: Semi-supervised segmentation and annotation of images using unaligned text corpora. In 2010 IEEE Computer Society Conference on Computer Vision and Pattern Recognition, pp. 966–973. IEEE, 2010.
274
+
275
+ Kihyuk Sohn. Improved deep metric learning with multi-class n-pair loss objective. In Proceedings of the 30th International Conference on Neural Information Processing Systems, pp. 1857–1865, 2016.
276
+
277
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. In International Conference on Learning Representations, 2014. URL http://arxiv.org/abs/1312.6199.
278
+
279
+ Rohan Taori, Achal Dave, Vaishaal Shankar, Nicholas Carlini, Benjamin Recht, and Ludwig Schmidt. Measuring robustness to natural distribution shifts in image classification. Advances in Neural Information Processing Systems, 33, 2020.
280
+
281
+ Bart Thomee, David A Shamma, Gerald Friedland, Benjamin Elizalde, Karl Ni, Douglas Poland, Damian Borth, and Li-Jia Li. Yfcc100m: The new data in multimedia research. Communications of the ACM, 59(2):64–73, 2016.
282
+
283
+ Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. arXiv preprint arXiv:1906.05849, 2019.
284
+
285
+ Yonglong Tian, Olivier J. Henaff, and Aaron van den Oord. Divide and contrast: Self-supervised learning from uncurated data. arXiv preprint arXiv:2105.08054, 2021.
286
+
287
+ Kerem Turgutlu. Self Supervised Learning with Fastai. Available from https:// keremturgutlu.github.io/self_supervised/, 2021.
288
+
289
+ Alexander Turner, Dimitris Tsipras, and Aleksander Madry. Label-consistent backdoor attacks. arXiv preprint arXiv:1912.02771, 2019.
290
+
291
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762, 2017.
292
+
293
+ Kilian Q Weinberger and Lawrence K Saul. Distance metric learning for large margin nearest neighbor classification. Journal of machine learning research, 10(2), 2009.
294
+
295
+ Jason Weston, Samy Bengio, and Nicolas Usunier. Large scale image annotation: learning to rank with joint word-image embeddings. Machine learning, 81(1):21–35, 2010.
296
+
297
+ Zhirong Wu, Yuanjun Xiong, Stella X Yu, and Dahua Lin. Unsupervised feature learning via nonparametric instance discrimination. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3733–3742, 2018.
298
+
299
+ Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. International Conference on Learning Representations, 2017.
300
+
301
+ Yuhao Zhang, Hang Jiang, Yasuhide Miura, Christopher D Manning, and Curtis P Langlotz. Contrastive learning of medical visual representations from paired images and text. arXiv preprint arXiv:2010.00747, 2020.
md/dev/iEvAf8i6JjO/iEvAf8i6JjO.md ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TRGP: TRUST REGION GRADIENT PROJECTION FORCONTINUAL LEARNING
2
+
3
+ Sen $\mathbf { L i n } ^ { 1 }$ , Li $\mathbf { Y a n g ^ { 1 } }$ , Deliang $\mathbf { F a n } ^ { 1 }$ , Junshan Zhang1,2
4
+ 1School of ECEE, Arizona State University, 2Department of ECE, University of California, Davis
5
+ {slin70, lyang166, dfan}@asu.edu, jazh@ucdavis.edu
6
+
7
+ # ABSTRACT
8
+
9
+ Catastrophic forgetting is one of the major challenges in continual learning. To address this issue, some existing methods put restrictive constraints on the optimization space of the new task for minimizing the interference to old tasks. However, this may lead to unsatisfactory performance for the new task, especially when the new task is strongly correlated with old tasks. To tackle this challenge, we propose Trust Region Gradient Projection (TRGP) for continual learning to facilitate the forward knowledge transfer based on an efficient characterization of task correlation. Particularly, we introduce a notion of ‘trust region’ to select the most related old tasks for the new task in a layer-wise and single-shot manner, using the norm of gradient projection onto the subspace spanned by task inputs. Then, a scaled weight projection is proposed to cleverly reuse the frozen weights of the selected old tasks in the trust region through a layer-wise scaling matrix. By jointly optimizing the scaling matrices and the model, where the model is updated along the directions orthogonal to the subspaces of old tasks, TRGP can effectively prompt knowledge transfer without forgetting. Extensive experiments show that our approach achieves significant improvement over related state-of-the-art methods.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Human beings can continuously learn different new tasks without forgetting the learnt knowledge of old tasks in their lifespan. Aiming to achieve this remarkable capability for the deep neural networks (DNNs), continual learning (CL) (Chen & Liu, 2018) has garnered much attention in recent years. Nevertheless, many existing CL methods still leave the DNN vulnerable to forget the knowledge of old tasks when learning new tasks. Such a phenomenon is known as ‘Catastrophic Forgetting’ (McCloskey & Cohen, 1989), which has become one of the major challenges for CL.
14
+
15
+ Many approaches (e.g., (Rusu et al., 2016; Li & Hoiem, 2017; Dhar et al., 2019; Guo et al., 2020; Zeng et al., 2019)) have been proposed to address the forgetting issue, which can be generally divided into two classes depending on the network architecture, i.e., expansion methods and nonexpansion methods. In order to understand the fundamental limit of a fixed capacity neural network, we focus on non-expansion methods in this work. The basic idea for non-expansion methods is to constrain the gradient update either explicitly or implicitly when learning the new task, so as to minimize the introduced interference to old tasks. For example, the regularization-based methods (e.g., (Kirkpatrick et al., 2017; Serra et al., 2018)) penalize the modification on the most important weights of old tasks through model regularizations; experience-replay based methods (e.g., (Shin et al., 2017; Chaudhry et al., 2019)) constrain the gradient directions by replaying the data of old tasks during learning of new tasks, in the format of either real data or synthetic data from generative models; and orthogonal-projection based methods (e.g., (Farajtabar et al., 2020; Saha et al., 2021)) update the model with gradients in the orthogonal directions of old tasks, without the access to old task data. In particular, the recently proposed Gradient Projection Memory (GPM) (Saha et al., 2021) has demonstrated superior performance compared to other approaches.
16
+
17
+ To sufficiently minimize the interference to old tasks, most existing non-expansion methods (particularly the orthogonal-projection based methods), often put restrictive constraints on the optimization space of the new task, which may throttle the learning performance for the new task. A plausible conjecture is that such a scenario is likely to occur when the new task is strongly correlated with old tasks, and in this study we provide evidence to support this conjecture. The underlying rationale is as follows: The weights that are important to the new task are also important to the old tasks strongly correlated with the new task, which are often frozen to address the forgetting in the existing methods; however, they should be updated in the learning of the new task.
18
+
19
+ To tackle this challenge, a key insight is that for a new task that is strongly correlated with old tasks, although the model optimization space could be more restrictive, there should be better forward knowledge transfer from the correlated old tasks to the new task. With this insight, we propose an innovate continual learning approach to facilitate the forward knowledge transfer without forgetting. The main contributions can be summarized as follows:
20
+
21
+ (1) Inspired by (Schulman et al., 2015), we introduce a novel notion of ‘trust region’ based on the norm of gradient projection onto the subspace spanned by task inputs, which selects the old tasks strongly correlated to the new task in a layer-wise and single-shot manner. Intuitively, the new task and the selected old tasks in the trust region have similar input features for the corresponding layer.
22
+
23
+ (2) We propose a novel approach for the new task to leverage the knowledge of the strongly correlated old tasks in the trust region through a scaled weight projection. Particularly, a scaling matrix is learnt in each layer for the new task to scale the weight projection onto the subspace of old tasks in the trust region, in order to reuse the frozen weights of old tasks without modifying the model.
24
+
25
+ (3) Building on the introduced trust region, scaled weight projection, and a module to construct task input subspace, we develop a continual learning approach, trust region gradient projection (TRGP), that jointly optimizes the scaling matrices and the model for the new task. To mitigate the forgetting issue further, the model is updated along the directions orthogonal to the subspaces of old tasks.
26
+
27
+ (4) We evaluate TRGP on standard CL benchmarks using various network architectures. Compared to related state-of-the-art approaches, TRGP achieves substantial performance improvement on all benchmarks, and demonstrates universal improvement on all tasks. The superior performance indicates that TRGP can effectively promote the forward knowledge transfer while alleviating forgetting.
28
+
29
+ # 2 RELATED WORK
30
+
31
+ Expansion-based methods. Expansion-based methods (e.g., (Rusu et al., 2016; Li & Hoiem, 2017; Rosenfeld & Tsotsos, 2018; Hung et al., 2019; Yoon et al., 2017; Li et al., 2019; Veniat et al., 2020)) dynamically expand the network capacity to reduce the interference between the new tasks and the old ones. Progressive Neural Network (PNN) (Rusu et al., 2016) expands the network architecture for new tasks and preserves the weights of old tasks. Learning Without Forgetting (LWF) (Li & Hoiem, 2017) splits the model layers into two parts, i.e., the shared part co-used by all tasks, and the task-specific part which grows for new tasks. Dynamic-Expansion Net (DEN) (Yoon et al., 2017) and Compacting-Picking-Growing (CPG) (Hung et al., 2019) combine the strategies of model compression/pruning, weight selection and model expansion. In order to find the optimal structure for each of the sequential tasks, Reinforced Continual Learning (RCL) (Xu & Zhu, 2018) leverages reinforcement learning and (Li et al., 2019) adapts architecture search. APD (Yoon et al., 2020) adds additional task-specific parameters for each task and selectively learns the task-shared parameters.
32
+
33
+ Regularization-based methods. This category of methods (e.g., (Kirkpatrick et al., 2017; Lee et al., 2017; Chaudhry et al., 2018a; Dhar et al., 2019; Ritter et al., 2018; Schwarz et al., 2018; Zenke et al., 2017)) protect the old tasks by adding regularization terms in the loss function to penalize the model change on their important weights. Notably, to determine the weight importance, Elastic Weight Consolidation (EWC) (Kirkpatrick et al., 2017) leverages Fisher information matrix, HAT (Serra et al., 2018) learns hard attention masks. MAS (Aljundi et al., 2018) evaluates the model outputs sensitivity to the inputs in an unsupervised manner.
34
+
35
+ Memory-based methods. Depending on if data of old tasks is utilized when learning new tasks, memory-based methods can be further divided into the following two categories. 1) Experiencereplay based methods. This class of methods replays the old tasks data along with the current task data to mitigate catastrophic forgetting. Gradient Episodic Memory (GEM) (Lopez-Paz & Ranzato, 2017) and Averaged GEM (A-GEM) (Chaudhry et al., 2018b) alter the current gradient based on the gradient computed with data in the memory. A unified view of episodic memory based methods is proposed in (Guo et al., 2020), based on new approaches are developed to balance between old tasks and the new task. Tiny episodic memory is considered in (Chaudhry et al., 2019) and metalearning is leveraged in (Riemer et al., 2018). 2) Orthogonal-projection based method. To eliminate the need of storing data of old tasks, recently a series work (Zeng et al., 2019; Farajtabar et al., 2020; Saha et al., 2021) updates the model in the orthogonal direction of old tasks, and has shown remarkable performance. Particularly, Orthogonal Weight Modulation (OWM) (Zeng et al., 2019) learns a projector matrix to multiply with the new gradients. Orthogonal Gradient Descent (OGD) (Farajtabar et al., 2020) stores the gradient directions of old tasks and projects the new gradients on the directions orthogonal to the subspace spanned by the old gradients. Gradient Projection Memory (GPM) (Saha et al., 2021) stores the bases of the subspaces spanned by old task data and projects the new gradients on the directions orthogonal to these subspaces.
36
+
37
+ # 3 PROBLEM FORMULATION
38
+
39
+ Continual learning. Consider the setting where a sequence of tasks $\mathbb { T } = \{ t \} _ { t = 1 } ^ { T }$ arrives sequentially. Eacand k i $t$ has a dataset the label vect $\mathbb { D } _ { t } = \{ ( \boldsymbol { x } _ { t , i } , \boldsymbol { y } _ { t , i } ) \} _ { i = 1 } ^ { N _ { t } }$ with paci $N _ { t }$ sample pairs, whereural network with $\mathbf { x } _ { t , i }$ is the input vectoryers, and the set of $\mathbf { \Delta } \mathbf { y } _ { t , i }$ $L$ weights is denoted as $\mathbb { W } = \{ W ^ { l } \} _ { l = 1 } ^ { L }$ , where $W ^ { l }$ is the layer-wise weight for layer $l$ . Given the data input $\boldsymbol { x } _ { t , i }$ for task $t$ , denote $\boldsymbol { x } _ { t , i } ^ { l }$ as the input of layer $l$ and $\pmb { x } _ { t , i } ^ { 1 } = \pmb { x } _ { t , i }$ . The output $\boldsymbol { \mathbf { \mathit { x } } } _ { t , i } ^ { l + 1 }$ for layer $l$ is computed as $\pmb { x } _ { t , i } ^ { l + 1 } = f ( \pmb { W } ^ { l } , \pmb { x } _ { t , i } ^ { l } )$ , where $f$ is the operation of the network layer. Following (Saha et al., 2021), we denote $\boldsymbol { x } _ { t , i } ^ { l }$ as the representations of $\mathbf { x } _ { t , i }$ at layer $l$ . When learning task $t$ , we only have access to dataset $\mathbb { D } _ { t }$ . Let $\mathcal { L } ( \mathbb { W } , \{ ( \pmb { x } _ { t , i } , \pmb { y } _ { t , i } ) \} ) = \mathcal { L } _ { t } ( \mathbb { W } )$ denote the loss function for training, e.g., mean squared and cross-entropy loss, and $\mathbb { W } _ { t }$ denote the model after learning task $t$ .
40
+
41
+ Orthogonal-projection based methods. To minimize the interference to old tasks, recently a series of studies (Zeng et al., 2019; Farajtabar et al., 2020; Saha et al., 2021) has been carried out to update the model for the new task in the direction orthogonal to the subspace spanned by inputs of old tasks. In what follows, we briefly introduce the main ideas through a basic case with two tasks 1 and 2.
42
+
43
+ Denote the subspace spanned by the inputs of task 1 for layer $l$ as $S _ { 1 } ^ { l }$ and the learnt model for task 1 as $\mathbb { W } _ { 1 } = \{ W _ { 1 } ^ { l } \} _ { l = 1 } ^ { L }$ . It is clear that $\pmb { x } _ { 1 , i } ^ { l } \in S _ { 1 } ^ { l }$ . When learning task 2, the model $\pmb { W } _ { 1 } ^ { l }$ will be modified in the direction orthogonal to $S _ { 1 } ^ { l }$ , by either multiplying the gradient $\nabla _ { W ^ { l } } \mathcal { L } _ { 2 }$ with a projector matrix (e.g, (Zeng et al., 2019)), or projecting the gradient $\nabla _ { W ^ { l } } \mathcal { L } _ { 2 }$ onto the orthogonal direction to $S _ { 1 } ^ { l }$ (e.g., (Saha et al., 2021)). Let $\Delta { \cal W } _ { 1 } ^ { l }$ denote the model change after learning task 2. It follows immediately that $\Delta \boldsymbol { W } _ { 1 } ^ { l } \boldsymbol { x } _ { 1 , i } ^ { l } = 0$ , and the model $\boldsymbol { W } _ { 2 } ^ { l }$ for task 2 is $\bar { \mathbf { W } } _ { 2 } ^ { l } = \mathbf { W } _ { 1 } ^ { l } + \bar { \Delta \mathbf { W } } _ { 1 } ^ { l }$ . Therefore, for task 1:
44
+
45
+ which indicates that no interference is introduced to task 1 after learning task 2, thereby addressing the forgetting issue. Such an analysis can be generalized to a sequence of tasks.
46
+
47
+ When would orthogonal projection hinder the learning of a new task? Orthogonal projection provides a promising solution to address the forgetting in continual learning. However, by modifying the model only in the orthogonal direction to the input space of old tasks, the optimization space of learning the new task could be more restrictive, resulting in compromised performance of the new task. To get a more concrete sense, consider the following basic examples with two tasks 1 and 2.
48
+
49
+ (Toy example $I$ ) Suppose task 1 has dataset $\mathbb { D } _ { 1 } \ = \ \{ ( { \boldsymbol { { x } } } _ { i } , { \boldsymbol { { y } } } _ { i } ) \} _ { i = 1 } ^ { N }$ and task 2 has dataset $\mathbb { D } _ { 2 } ~ =$ $\{ ( - \pmb { x } _ { i } , \pmb { y } _ { i } ) \} _ { i = 1 } ^ { N }$ , where only the sign is changed for the input vectors. Consider the case where two tasks share the same classifier (Saha et al., 2021). It is clear that for the $l$ -th layer, the subspace spanned by $\{ \pmb { x } _ { i } ^ { l } \} _ { i = 1 } ^ { N }$ of task 1 is same with the subspace spanned by $\{ - \pmb { x } _ { i } ^ { l } \} _ { i = 1 } ^ { N }$ of task 2, i.e., $S _ { 1 } ^ { l } = S _ { 2 } ^ { l }$ , given the learnt model $\pmb { W } _ { 1 } ^ { l }$ for task 1. Based on the fact that stochastic gradient descent updates lie in the subspace spanned by the data input (Zhang et al., 2021; Saha et al., 2021), it follows that the gradient $\nabla _ { W ^ { l } } \bar { \mathcal { L } } _ { 2 } \in \bar { S } _ { 2 } ^ { l }$ , such that $\nabla _ { W ^ { l } } \bar { \mathcal { L } } _ { 2 } \in S _ { 1 } ^ { l }$ . Therefore, the projection of $\nabla _ { W ^ { l } } \mathcal { L } _ { 2 }$ onto the orthogonal direction to $S _ { 1 } ^ { \bar { l } }$ is 0, which means that the model $W _ { 1 } ^ { l }$ will not be updated when learning task 2, i.e., $W _ { 2 } ^ { l } = \dot { W } _ { 1 } ^ { l }$ . However, the optimal model for task 2 should be $\dot { \pmb { W } } _ { 2 } ^ { l } = - \pmb { W } _ { 1 } ^ { l }$ , because ${ W _ { 1 } ^ { l } } { x _ { i } ^ { l } }$ achieves the minimum loss for the label $\mathbf { \nabla } _ { \mathbf { \psi } _ { 3 } } \mathbf { \psi } _ { 2 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \qquad \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 }$ after learning task 1.
50
+
51
+ (Toy example 2) Suppose the input subspace of task 1 is orthogonal to that of task 2, i.e., $S _ { 1 } ^ { l } \perp S _ { 2 } ^ { l }$ . It follows that the projection of $\nabla _ { W ^ { l } } \mathcal { L } _ { 2 }$ onto the orthogonal direction to $S _ { 1 } ^ { l }$ is indeed equal to $\nabla _ { W ^ { l } } \mathcal { L } _ { 2 }$ . Consequently, updating the model for task 2 based on orthogonal projection will not only introduce no interference to task 1, but also move along the direction of steepest descent for task 2.
52
+
53
+ ![](images/8497d678a6ec9a8996e00b8400ce694ef6f8218500cfd8e7cd8b4bcc0811e605.jpg)
54
+ Figure 1: Layer-wise task correlation for the case where the subspace spanned by the representations is a two-dimensional plane. The subspaces are weakly correlated if they are nearly orthogonal and strongly correlated if they are nearly parallel.
55
+
56
+ Motivated by these examples, a plausible conjecture is that naive orthogonal projection could possibly compromise the learning performance of the new task that is strongly correlated with old tasks, especially when the correlation is “negative” as in the toy example 1. In this study, we advocate to characterize the task correlation through the correlation between the input subspaces for two tasks. As illustrated in Fig. 1, when the subspace is 2-dimensional, two tasks are weakly correlated if their input subspaces are nearly orthogonal, and strongly correlated if their subspaces are nearly parallel.
57
+
58
+ # 4 TRUST REGION GRADIENT PROJECTION FOR CONTINUAL LEARNING
59
+
60
+ To tackle these challenges, a key insight is that for a new task that is strongly correlated with old tasks, although the model optimization space could be more restrictive, there should be better forward knowledge transfer from the correlated old tasks to the new task. With this insight, we propose a novel approach to prompt forward knowledge transfer without forgetting, by 1) introducing a novel notion of trust region to select the most related old tasks in a single-shot manner and 2) cleverly reusing the frozen weights of the selected tasks in the trust region with a scaled weight projection.
61
+
62
+ # 4.1 TRUST REGION
63
+
64
+ To facilitate forward knowledge transfer from the correlated old tasks to the new task, the first question is how to efficiently select the most correlated old tasks. Towards this end, we characterize the correlation between the input subspaces for two tasks, through the lens of gradient projection.
65
+
66
+ Specifically, denote $S _ { j } ^ { l } = s p a n \{ B _ { j } ^ { l } \}$ as the subspace spanned by the task $j$ data for layer $l$ , where $B _ { j } ^ { l } = [ \pmb { u } _ { j , 1 } ^ { l } , . . . , \pmb { u } _ { j , M _ { j , l } } ^ { l } ]$ is the bases for $S _ { j } ^ { l }$ (totally $M _ { j , l }$ bases extracted from the input). For any matrix $\pmb { A }$ with a suitable dimension, denote its projection onto the subspace $S _ { j } ^ { l }$ as:
67
+
68
+ $$
69
+ \operatorname { P r o j } _ { { S } _ { j } ^ { l } } ( A ) = A B _ { j } ^ { l } ( B _ { j } ^ { l } ) ^ { \prime }
70
+ $$
71
+
72
+ where $( \cdot ) ^ { \prime }$ is the matrix transpose. We next define a layer-wise trust region for a new task as a set of its most related old tasks, based on the norm of projected gradient onto the subspaces of old tasks.
73
+
74
+ Definition 1 (Layer-Wise Trust Region). For any new task $t \geq 2$ and layer l, we define a layer-wise trust region $\tau \mathcal { R } _ { t } ^ { i } = \{ j \}$ for $j \in [ 1 , t - 1 ]$ , where for any task $j \in \mathcal { T R } _ { t } ^ { l }$ the following holds:
75
+
76
+ $$
77
+ \begin{array} { r } { \| \mathrm { P r o j } _ { S _ { j } ^ { l } } ( \nabla _ { W ^ { l } } \mathcal { L } _ { t } ( \mathbb { W } _ { t - 1 } ) ) \| _ { 2 } \geq \epsilon ^ { l } \| \nabla _ { W ^ { l } } \mathcal { L } _ { t } ( \mathbb { W } _ { t - 1 } ) \| _ { 2 } , } \end{array}
78
+ $$
79
+
80
+ where $\epsilon ^ { l } \in [ 0 , 1 ]$ and $\mathbb { W } _ { t - 1 }$ is the model after learning task $t - 1$ .
81
+
82
+ Intuitively, for the new task $t$ , the norm of its gradient projection onto the subspace of an old task $j$ serves as a surrogate for characterizing the correlation between input subspaces for these two tasks, due to the fact that the gradient lies in the span of its input. When the condition Eq. (3) is satisfied, the gradient $\nabla _ { W ^ { l } } \mathcal { L } _ { t } \big ( \mathbb { W } _ { t - 1 } \big )$ has a large projection onto the subspace of an old task $j$ , which implies that the subspace $S _ { t } ^ { l }$ for task $t$ and the subspace $S _ { j } ^ { l }$ for task $j$ may have sufficient common bases for layer $l$ . In this case, we trust that the old task
83
+
84
+ $$
85
+ \begin{array} { r l } { \nabla _ { W ^ { L } } \varepsilon _ { t } ^ { L } } & { \longrightarrow \frac { \mathrm { T r e s h o l d } \theta _ { t h } ^ { L } } { \varepsilon _ { t } } } \\ { \mathsf { S o } j \in \mathcal { F R } _ { t } ^ { L } } & { \left( \begin{array} { l } { \int _ { - \infty } ^ { t } \mathsf { s } _ { t } \frac { \mathsf { s } _ { t } } { \varepsilon _ { t } } ( \nabla _ { W ^ { L } } \varepsilon _ { t } ) } \\ { \qquad \mathrm { P r o j } _ { s _ { t } ^ { j } } ( \nabla _ { W ^ { L } } \varepsilon _ { t } ) } \end{array} \right) } & { \longrightarrow \begin{array} { l } { S _ { t } ^ { j } \mathsf { t o r t a s k } j } \\ { \qquad \mathsf { W } _ { w ^ { L } } \varepsilon _ { t } \mathsf { f o r t a s k } t } \end{array} } \\ & { \underbrace { \theta _ { s } \theta _ { t h } ^ { L } } _ { \tiny { \mathsf { S o } j \in \mathcal { F R } _ { t } ^ { L } } } \underbrace { \mathsf { W } _ { W ^ { L } } \varepsilon _ { t } } _ { \tiny { \mathsf { P r o j } \mathsf { S u p s } } } } \end{array} \begin{array} { l l } { \nabla _ { W ^ { L } } \varepsilon _ { t } } & { } \\ { \qquad \mathsf { W o l d } \mathsf { S } _ { t } ^ { j } \mathsf { t h o r t a s k } j } \end{array} \\ & { \lesssim o ^ { j } \mathsf { e r t o r t a } \theta _ { t h } ^ { L } \left( \underbrace { \mathsf { T r o } _ { s _ { t - 1 } , \ldots , s _ { t } } } _ { \begin{array} { l } { \mathrm { P r o j } _ { s _ { t } ^ { j } } ( \nabla _ { W ^ { L } } \varepsilon _ { t } ) } \end{array} } \right) } & \longrightarrow \begin{array} { l } { \mathrm { p r o j e c t i o n ~ o f ~ } \nabla _ { W ^ { L } } \varepsilon _ { t } } \\ { \qquad \mathrm { p r o j e c t i o n ~ o f ~ } \nabla _ { W ^ { L } } \varepsilon _ { t } } \end{array}
86
+ $$
87
+
88
+ Figure 2: Trust region for a 2-dimensional subspace can be interpreted as: if the angle $\theta$ between $\nabla _ { W ^ { l } } \mathcal { L } _ { t }$ and $\mathrm { P r o j } _ { S _ { j } ^ { l } } \big ( \nabla _ { W ^ { l } } \mathcal { L } _ { t } \big )$ is less than $\theta _ { t h } ^ { l }$ (larger projection on $S _ { j } ^ { l } )$ , old task $j$ is selected to $\tau { \mathcal R } _ { t } ^ { l }$ ; otherwise not. $\theta _ { t h } ^ { l }$ can be set as a large value, and we can pick tasks with top- $K$ smallest $\theta$ to $\tau { \mathcal R } _ { t } ^ { l }$ .
89
+
90
+ $j$ is strongly correlated with the new task $t$ in layer $l$ , and put it into task $t$ ’s trust region $\tau { \mathcal R } _ { t } ^ { l }$ . A simple illustration of trust region is shown in Figure 2. Note that the notion of trust region can also be generalized to a task-wise definition, where the most correlated old tasks will be selected based on the projection of the entire gradient $\nabla _ { \mathbb { W } } \mathcal { L } _ { t } ( \mathbb { W } _ { t - 1 } )$ . However, the layer-wise trust region could select different tasks for different layers, which provides a more fine-resolution characterization of task correlations in terms of layer-level features.
91
+
92
+ Practical implementation. Besides the valuable functionality provided by the trust region for selecting most correlated old tasks, another significant benefit is the simplicity of its practical implementation. Consider the implementation for learning a new task $t$ .
93
+
94
+ (1) Single-shot manner. Given the learnt model $\mathbb { W } _ { t - 1 }$ , we select a sample batch from dataset $\mathbb { D } _ { t }$ , and compute the gradient $\nabla _ { W ^ { l } } \mathcal { L } _ { t } ( \mathbb { W } _ { t - 1 } )$ in one forward-backward pass for all layers at once. Given the subspace $S _ { j } ^ { l }$ for an old task $j$ , the condition Eq. (3) can be immediately evaluated for all old tasks.
95
+
96
+ (2) Top- $K$ correlated tasks. It is clear that the choice of $\epsilon ^ { l }$ has a nontrivial impact on the selection of the most correlated old tasks. To reduce the sensitivity of the performance on $\epsilon ^ { l }$ , we can set a relatively small value of $\epsilon ^ { l }$ , and pick the top- $K$ old tasks with the largest gradient projection norm $\| \mathrm { P r o j } _ { S _ { j } ^ { l } } ( \nabla _ { W ^ { l } } \mathcal { L } _ { t } ( \mathbb { W } _ { t - 1 } ) ) \| _ { 2 }$ from the tasks satisfying Eq. (3). As demonstrated later in our experiments, setting $K = 1$ is enough to achieve a significant performance improvement.
97
+
98
+ # 4.2 SCALED WEIGHT PROJECTION
99
+
100
+ Given the layer-wise trust region $\tau { \mathcal R } _ { t } ^ { l }$ for the new task $t$ , the next key question is how to efficiently leverage the knowledge of the most correlated old tasks in $\tau { \mathcal R } _ { t } ^ { l }$ for learning task $t$ . To this end, we propose a novel approach to reuse the frozen weights of the selected old tasks in $\tau { \mathcal R } _ { t } ^ { l }$ through a scaled weight projection with a scaling matrix.
101
+
102
+ At the outset, it is of interest to understand what knowledge is preserved for old tasks during continual learning with orthogonal projection. Based on Eq. (1) for the simple case with two learning tasks 1 and 2 as mentioned earlier, it can be shown that
103
+
104
+ where the last equation holds because the model $\pmb { W } _ { 1 } ^ { l }$ is updated in the direction orthogonal to $S _ { 1 } ^ { l }$ when learning task 2. By generalizing Eq. (4) to the case with a sequence of tasks, we can have that for the model $\mathbb { W } _ { t - 1 }$ after learning task $t - 1$ and any old task $j < t$ :
105
+
106
+ which indicates that the model weight projection on the subspace of old tasks is actually “frozen” during continual learning so as to overcome forgetting of the old tasks.
107
+
108
+ On the other hand, because the trust region $\tau { \mathcal R } _ { t } ^ { l }$ is constructed in a way that the subspace $S _ { t } ^ { l }$ of task $t$ is strongly correlated with the subspace $S _ { j } ^ { l }$ for any old task $j \in \mathcal { T R } _ { t } ^ { l }$ , the bases $B _ { j } ^ { l }$ of $S _ { j } ^ { l }$ is very likely to contain important bases for task $t$ . As a result, the weight projection $\mathrm { P r o j } _ { S _ { j } ^ { l } } ( \boldsymbol { W } _ { t - 1 } ^ { l } )$ is important for the new task $t$ and should be modified accordingly in order to guarantee the learning performance of task $t$ , which however has to be frozen to protect task $j$ . To find an efficient way to leverage $\mathrm { P r o j } _ { S _ { j } ^ { l } } ( \bar { \boldsymbol { W } } _ { t - 1 } ^ { l } )$ without modifying it, note that the projection $\mathrm { P r o j } _ { S _ { j } ^ { l } } ( \boldsymbol { W } _ { t - 1 } ^ { l } )$ is indeed a linear combination of the projection of $\mathbf { \Delta } W _ { t - 1 } ^ { l }$ onto each basis in $B _ { j } ^ { l }$ , and every point in $S _ { j } ^ { l }$ can be obtained by scaling the coordinates of $\mathrm { P r o j } _ { S _ { j } ^ { l } } ( \boldsymbol { W } _ { t - 1 } ^ { l } )$ . Figure 3 shows a simple example for two-dimensional subspace. Therefore, we propose a scaled weight projection to find the best point for task $t$ in $S _ { j } ^ { l }$ by leveraging the projection $\mathrm { P r o j } _ { S _ { j } ^ { l } } ( \boldsymbol { W } _ { t - 1 } ^ { l } )$ through a square scaling matrix $Q _ { j , t } ^ { l }$ :
109
+
110
+ ![](images/c2c5885a6c73085ac457c74d95b6a966c7f273dace56e5350d4f83b25d0e7f92.jpg)
111
+ Figure 3: $[ { \pmb u } _ { j , 1 } ^ { l } , { \pmb u } _ { j , 2 } ^ { l } ]$ is the bases of subspace $S _ { j } ^ { l }$ , and $[ c _ { j , 1 } ^ { l } , c _ { j , 2 } ^ { l } ]$ is the coordinate of $\mathrm { P r o j } _ { s _ { j } ^ { l } } ( \pmb { W } _ { t - 1 } ^ { l } )$ . Any point $\mathrm { P r o j } _ { S _ { j } ^ { l } } ( W ^ { l } )$ in $S _ { j } ^ { l }$ can be obtained by scaling the coordinate $[ c _ { j , 1 } ^ { l } , c _ { j , 2 } ^ { l } ]$ with some scalar $s _ { 1 }$ and $s _ { 2 }$ .
112
+
113
+ $$
114
+ \mathrm { P r o j } _ { S _ { j } ^ { l } } ^ { Q } ( { \boldsymbol { W } _ { t - 1 } ^ { l } } ) = W _ { t - 1 } ^ { l } B _ { j } ^ { l } Q _ { j , t } ^ { l } ( { \boldsymbol { B } _ { j } ^ { l } } ) ^ { \prime } .
115
+ $$
116
+
117
+ The dimension of $Q _ { j , t } ^ { l }$ depends on the number of bases in $B _ { j } ^ { l }$ (dimension of $S _ { j } ^ { l } .$ ), which is usually small for each task. In this way, we explicitly transfer the knowledge of the selected old tasks in the trust region $\tau { \mathcal R } _ { t } ^ { l }$ to the new task $t$ through a scaling matrix $Q _ { j , t } ^ { l }$ .
118
+
119
+ # 4.3 TASK SUBSPACE CONSTRUCTION
120
+
121
+ To successfully leverage the trust region, a missing ingredient is the construction of input subspaces of old tasks. We next show how the subspace $S _ { j } ^ { l }$ can be constructed for task $j$ at layer $l$ .
122
+
123
+ For task $j = 1$ . As in (Saha et al., 2021), we obtain the bases $B _ { 1 } ^ { l }$ after learning task 1 using Singular Value Decomposition (SVD) on the representations. Specifically, given the model $\mathbb { W } _ { 1 }$ after learning task 1, we construct a representation matrix $\pmb { R } _ { 1 } ^ { l } = [ \pmb { x } _ { 1 , 1 } ^ { \bar { l } } , . . . , \pmb { x } _ { 1 , n } ^ { \bar { l } } ] \in \mathbb { R } ^ { m \times n }$ with $n$ samples, where each $\pmb { x } _ { 1 , i } ^ { l } \in \mathbb { R } ^ { m }$ , is the representation at layer $l$ by forwarding the sample $_ { \pmb { x } _ { 1 , i } }$ through the network. Then, we apply SVD to the matrix $R _ { 1 } ^ { l }$ , i.e., ${ \pmb R } _ { 1 } ^ { l } = { \pmb U } _ { 1 } ^ { l } { \pmb \Sigma } _ { 1 } ^ { l } ( { \pmb V } _ { 1 } ^ { l } ) ^ { \prime }$ , where ${ \cal U } _ { 1 } ^ { l } = [ { \pmb u } _ { 1 , 1 } ^ { l } , . . . , { \pmb u } _ { 1 , m } ^ { l } ] \in$ $\mathbb { R } ^ { m \times m }$ is an orthogonal matrix with left singular vector $\pmb { u } _ { 1 , i } ^ { l } \in \mathbb { R } ^ { m }$ , $V _ { 1 } ^ { l } = [ \pmb { v } _ { 1 , 1 } ^ { l } , . . . , \pmb { v } _ { 1 , n } ^ { l } ] \in \mathbb { R } ^ { n \times n }$ is an orthogonal matrix with right singular vector $\pmb { v } _ { 1 , i } ^ { l } \in \mathbb { R } ^ { n }$ , and $\pmb { \Sigma } _ { 1 } ^ { l } \in \pmb { R } ^ { m \times n }$ is a rectangular diagonal matrix with non-negative singular values $\{ \sigma _ { 1 , i } ^ { l } \} _ { i = 1 } ^ { \operatorname* { m i n } \{ m , n \} }$ on the diagonal in a descending order. To obtain the bases for subspace $S _ { 1 } ^ { l }$ , we use $k _ { 1 } ^ { l }$ -rank matrix approximation to pick the first left singular vectors in $U _ { 1 } ^ { l }$ , such that the following condition is satisfied for a threshold $\eta _ { t h } ^ { l } \in ( 0 , 1 )$ :
124
+
125
+ $$
126
+ \lVert ( \boldsymbol { R } _ { 1 } ^ { l } ) _ { k _ { 1 } ^ { l } } \rVert _ { F } ^ { 2 } \geq \epsilon _ { t h } ^ { l } \lVert \boldsymbol { R } _ { 1 } ^ { l } \rVert _ { F } ^ { 2 }
127
+ $$
128
+
129
+ where $\begin{array} { r } { ( { \bf R } _ { 1 } ^ { l } ) _ { k _ { 1 } ^ { l } } = \sum _ { i = 1 } ^ { k _ { 1 } ^ { l } } \sigma _ { 1 , i } ^ { l } { \bf u } _ { 1 , i } ^ { l } ( { \bf v } _ { 1 , i } ^ { l } ) ^ { \prime } } \end{array}$ is a $k _ { 1 } ^ { l }$ -rank $( k _ { 1 } ^ { l } \ \leq \ r )$ approximation of the representation matrix $R _ { 1 } ^ { l }$ with rank $r \leq \operatorname* { m i n } \{ m , n \}$ , and $\| \cdot \| _ { F }$ is the Frobenius norm. Then the bases $B _ { 1 } ^ { l }$ for subspace $\mathbf { \bar { \it S } } _ { 1 } ^ { l }$ can be constructed as $B _ { 1 } ^ { l } = [ \pmb { u } _ { 1 , 1 } ^ { l } , . . . , \pmb { u } _ { 1 , k _ { 1 } ^ { l } } ^ { l } ]$ .
130
+
131
+ For task $j \in [ 2 , T ]$ . We construct the bases $B _ { j } ^ { l }$ after learning task $j$ given the learnt model $\mathbb { W } _ { j }$ . A representation matrix $R _ { j } ^ { l }$ will be first obtained in the same manner as $R _ { 1 } ^ { l }$ . Note that the bases $\{ B _ { i } ^ { l } \} _ { i = 1 } ^ { j - 1 }$ learnt for old tasks may include important bases for task $j$ . Therefore, we learn the bases $B _ { j } ^ { l }$ by selecting the most important bases from both bases of old tasks and newly constructed bases. Specifically, (1) (old bases) we first concatenate the bases $\{ B _ { i } ^ { l } \} _ { i = 1 } ^ { j - 1 }$ of old tasks together in $M _ { j } ^ { l }$ and eliminate the common bases. For each basis $\pmb { u } _ { i } ^ { l } \in { \cal M } _ { j } ^ { l }$ , we compute the corresponding eigenvalue of ${ \cal R } _ { j } ^ { l } ( { \cal R } _ { j } ^ { l } ) ^ { \prime }$ , i.e., $\delta _ { i } ^ { l } = ( \mathbf { \boldsymbol { u } } _ { i } ^ { l } ) ^ { \prime } R _ { j } ^ { l } ( R _ { j } ^ { l } ) ^ { \prime } \mathbf { \boldsymbol { u } } _ { i } ^ { l }$ , which is the square of the singular value of $R _ { j } ^ { l }$ with respect to $\mathbf { \Delta } u _ { i } ^ { l }$ . (2) (new bases) We perform SVD on $\hat { \pmb { R } } _ { j } ^ { l } = \pmb { R } _ { j } ^ { l } - \pmb { R } _ { j } ^ { l } M _ { j } ^ { l } ( M _ { j } ^ { l } ) ^ { \prime }$ to generate new bases beyond $M _ { j } ^ { l }$ , i.e., $\hat { \pmb { R } } _ { j } ^ { l } = \hat { U } _ { j } ^ { l } \hat { \pmb { \Sigma } } _ { j } ^ { l } ( \hat { V } _ { j } ^ { l } ) ^ { \prime }$ with singular values $\{ \hat { \sigma } _ { j , h } ^ { l } \} _ { h }$ . (3) (select the most important bases from both old and new bases) Next we concatenate $\{ \delta _ { i } ^ { l } \} _ { i }$ and $\{ ( \hat { \sigma } _ { j , h } ^ { l } ) ^ { 2 } \} _ { h }$ together in a vector $\pmb { \delta }$ , and sort them in a descending order. We perform $k _ { j } ^ { l }$ -rank matrix approximation of $R _ { j } ^ { l }$ , such that the summation of the first $k _ { j } ^ { l }$ elements in $\delta$ is greater than $\epsilon _ { t h } ^ { l } \lVert { \cal R } _ { j } ^ { l } \rVert _ { F } ^ { 2 }$ . Then $B _ { j } ^ { l }$ can be constructed by selecting the bases corresponding to the first $k _ { j } ^ { l }$ elements in $\delta$ .
132
+
133
+ # 4.4 CONTINUAL LEARNING WITH TRUST REGION GRADIENT PROJECTION
134
+
135
+ Building on the three modules proposed earlier, i.e., task subspace construction, trust region and scaled weight projection, we next present our approach TRGP for continual learning that efficiently facilitate forward knowledge transfer without forgetting the old tasks.
136
+
137
+ Learning task 1. The first task is learnt using standard gradient descent. The subspace $\{ S _ { 1 } ^ { l } \} _ { l = 1 } ^ { L }$ is constructed by following Section 4.3.
138
+
139
+ Learning task 2, ..., T. For task $t \in [ 2 , T ]$ , we first determine the trust region $\tau { \mathcal R } _ { t } ^ { l }$ with top- $K$ correlated old tasks selected for layer $l$ . The optimization problem for task $t$ is as follows:
140
+
141
+ $$
142
+ \begin{array} { r l } & { \underset { \{ \pmb { W } ^ { l } \} _ { l } , \{ \pmb { Q } _ { j , t } ^ { l } \} _ { l , j \in \mathcal { T } \mathcal { R } _ { t } ^ { l } } } { \operatorname* { m i n } } \mathcal { L } ( \{ \pmb { W } _ { e f f } ^ { l } \} _ { l } , \mathbb { D } _ { t } ) , } \\ & { \xrightarrow [ \pmb { S } . t . \qquad ] { \mathrm { m i n } } W _ { e f f } ^ { l } = \pmb { W } ^ { l } + \sum _ { j \in \mathcal { T } \mathcal { R } _ { t } ^ { l } } [ \mathrm { P r o j } _ { S _ { j } ^ { l } } ^ { Q } ( \pmb { W } ^ { l } ) - \mathrm { P r o j } _ { S _ { j } ^ { l } } ( \pmb { W } ^ { l } ) ] , } \end{array}
143
+ $$
144
+
145
+ where the gradient for updating $W ^ { l }$ is $\nabla _ { W ^ { l } } \mathcal { L } = \nabla _ { W ^ { l } } \mathcal { L } - ( \nabla _ { W ^ { l } } \mathcal { L } ) M _ { t } ^ { l } ( M _ { t } ^ { l } ) ^ { \prime }$ and $\pmb { M } _ { t } ^ { l }$ is the bases of all old tasks as in Section 4.3. The subspace $\{ S _ { t } ^ { l } \} _ { l = 1 } ^ { L }$ is next obtained by following Section 4.3.
146
+
147
+ Table 1: The averaged accuracy (ACC) and backward transfer (BWT) over all the tasks on different datasets. Note that, Multitask jointly learns all tasks only once in a single network by using the whole dataset, which does not adhere to CL setup.
148
+
149
+ <table><tr><td rowspan="2">Method</td><td colspan="2">PMNIST</td><td colspan="2">CIFAR-100 Split</td><td colspan="2">5-Dataset</td><td colspan="2">MiniImageNet</td></tr><tr><td>ACC(%)</td><td>BWT(%)</td><td>ACC(%)</td><td>BWT(%)</td><td>ACC(%)</td><td>BWT(%)</td><td>ACC(%)</td><td>BWT(%)</td></tr><tr><td>Multitask</td><td>96.70</td><td>-</td><td>79.58</td><td>-</td><td>91.54</td><td>-</td><td>69.46</td><td>-</td></tr><tr><td>OWM</td><td>90.71</td><td>-1</td><td>50.94</td><td>-30</td><td>=</td><td>1</td><td>=</td><td>-</td></tr><tr><td>EWC</td><td>89.97</td><td>-4</td><td>68.80</td><td>-2</td><td>88.64</td><td>-4</td><td>52.01</td><td>-12</td></tr><tr><td>HAT</td><td>1</td><td>1</td><td>72.06</td><td>0</td><td>91.32</td><td>-1</td><td>59.78</td><td>-3</td></tr><tr><td>A-GEM</td><td>83.56</td><td>-14</td><td>63.98</td><td>-15</td><td>84.04</td><td>-12</td><td>57.24</td><td>-12</td></tr><tr><td>ER_Res</td><td>87.24</td><td>-11</td><td>71.73</td><td>-6</td><td>88.31</td><td>-4</td><td>58.94</td><td>-7</td></tr><tr><td>GPM</td><td>93.91</td><td>-3</td><td>72.48</td><td>-0.9</td><td>91.22</td><td>-1</td><td>60.41</td><td>-0.7</td></tr><tr><td>Ours (TRGP)</td><td>96.34</td><td>-0.8</td><td>74.46</td><td>-0.9</td><td>93.56</td><td>-0.04</td><td>61.78</td><td>-0.5</td></tr></table>
150
+
151
+ # 5 EXPERIMENTAL RESULTS
152
+
153
+ # 5.1 EXPERIMENTAL SETUP
154
+
155
+ Datasets and training details. We evaluate our method on multiple datasets against state-of-the-art CL methods. 1) PMNIST. Following (Lopez-Paz & Ranzato, 2017; Saha et al., 2021), we create 10 sequential tasks using different permutations where each task has 10 classes. We use a 3-layer fully-connected network. 2) CIFAR-100 Split. We split the classes of CIFAR-100 (Krizhevsky et al., 2009) into 10 group, and consider 10-way multi-class classification in each group as a single task. Similar with (Serra et al., 2018; Saha et al., 2021), we use a version of 5-layer AlexNet. 3) CIFAR-100 Sup. We divide the CIFAR-100 dataset into 20 tasks where each task has 5 classes. We use a modified version of LeNet-5. 4) 5-Datasets. We use a sequence of 5-Datasets which includes CIFAR-10, MNIST, SVHN (Netzer et al., 2011), not-MNIST (Bulatov, 2011) and Fashion MNIST (Xiao et al., 2017), where each dataset is set to be a task. We adapt a reduced ResNet18 network that is used in (Lopez-Paz & Ranzato, 2017). 5) MiniImageNet Split. We split the 100 classes of MiniImageNet (Vinyals et al., 2016) into 20 sequential tasks where each task has 5 classes, and consider a reduced ResNet18 network. In addition, for all the experiments, the threshold $\epsilon ^ { l }$ is set to 0.5, and we select top-2 tasks that satisfy condition Eq. (3). We use the same threshold $\epsilon _ { t h } ^ { l }$ as GPM (Saha et al., 2021) for subspace construction. More details are in the appendix.
156
+
157
+ Methods for comparison. To test the efficacy of our method, we compare it with state-of-the-art approaches in three categories: 1) Memory-based methods. We compare with Experience Replay with reservoir sampling (ER Res) (Chaudhry et al., 2019), Averaged GEM (A-GEM) (Chaudhry et al., 2018b), Orthogonal Weight Modulation (OWM) (Zeng et al., 2019) and Gradient Projection Memory (GPM) (Saha et al., 2021). 2) Regularization-based methods. We compare with state-ofthe-art HAT (Serra et al., 2018) and Elastic Weight Consolidation (EWC) (Kirkpatrick et al., 2017). 3) Expansion-based methods. We further compare with Progressive Neural Network (PNN) (Rusu et al., 2016), Learning Without Forgetting (LWF) (Li & Hoiem, 2017), Dynamic-Expansion Net (DEN) (Yoon et al., 2017), and APD (Yoon et al., 2020), by using CIFAR-100 Sup dataset.
158
+
159
+ Metrics. Following GPM (Saha et al., 2021), two metrics are used to evaluate the performance: Accuracy (ACC), the average final accuracy over all tasks, and Backward Transfer (BWT), which measures the forgetting of old tasks when learning new tasks. ACC and BWT are defined as:
160
+
161
+ $$
162
+ { \bar { A } } C C = { \frac { 1 } { T } } \sum _ { i = 1 } ^ { T } A _ { T , i } , B W T = { \frac { 1 } { T - 1 } } \sum _ { i = 1 } ^ { T - 1 } A _ { T , i } - A _ { i , i }
163
+ $$
164
+
165
+ where $T$ is the number of tasks, $A _ { T , i }$ is the accuracy of the model on $i$ -th task after learning the $T$ -th task sequentially.
166
+
167
+ # 5.2 MAIN RESULTS
168
+
169
+ ACC and BWT comparison. As shown in Table 1, TRGP achieves significantly accuracy improvement compared with prior works on all datasets. For example, in contrast to the best prior results, TRGP achieve the accuracy gain of $2 . 4 3 \%$ , $1 . 9 8 \%$ and $1 . 3 \hat { 7 } \%$ over GPM on PMNIST, CIFAR-100 Split and MiniImageNet, respectively, and $2 . 3 4 \%$ over HAT on 5-Dataset. Surprisingly, we could even achieve better accuracy than Multitask on 5-Datasets, which usually serves as an upper bound for CL benchmarks. This superior performance of TRGP clearly shows its capability to effectively facilitate forward knowledge transfer. In addition, TRGP also demonstrates strong performance with the lowest BWT, reducing $0 . 2 \%$ than OWM and $0 . 6 \%$ than GPM, even with $5 . { \bar { 6 } } 3 { \bar { \% } }$ and $2 . 3 4 \%$ ac
170
+
171
+ ![](images/38a46f72a5a1d085ef91fddb2f57bd4f0ac7ab4a1b7e36fad54b1b0963cb61a2.jpg)
172
+ Figure 4: The final accuracy for all tasks on three datasets (GPM VS Ours).
173
+
174
+ Table 2: The performance for CIFAR-100 Sup dataset. Note that Single-task learning (STL) trains a separate network for each task, which does not adhere to CL setup.
175
+
176
+ <table><tr><td rowspan="2">Metric</td><td colspan="7">Methods</td></tr><tr><td>STL</td><td>PNN</td><td>DEN</td><td>RCL</td><td>APD</td><td>GPM</td><td>Ours (TRGP)</td></tr><tr><td>ACC(%)</td><td>61.00</td><td>50.76</td><td>51.10</td><td>51.99</td><td>56.81</td><td>57.72</td><td>58.25</td></tr><tr><td>Capacity(%)</td><td>2000</td><td>271</td><td>191</td><td>184</td><td>130</td><td>100</td><td>100</td></tr></table>
177
+
178
+ curacy improvement on PMNIST and 5-Dataset, respectively. Compared with HAT on CIFAR-100 Split, TRGP has marginally worse BWT, but achieves $2 . 4 \%$ accuracy gain.
179
+
180
+ Moreover, TRGP exhibits an universal dominance over GPM about the final accuracy of all tasks on all the three datasets. According to the apple to apple comparison with GPM in Fig. 4, one interesting phenomenon is observed: TRGP has the similar accuracy on “easy” tasks, but significantly improves the accuracy on the “difficult” tasks. For example, in the 5-Dataset setting, both TRGP and GPM achieve good accuracy on Task 1 (MNIST) and 3 (Fashion MNIST), which can be easily trained well, but TRGP significantly outperforms GPM on the rest three more difficult Tasks (CIFAR-10, SVHN and NotMNIST). In the end, as shown in Table 2, we further compare with the expansionbased methods by using CIFAR-100 Sup setting. It can be seen that TRGP outperforms all other CL methods, with a fixed capacity network.
181
+
182
+ Discussion. We next show the accuracy evolution of specific tasks during the training of all tasks sequentially. We randomly select three tasks for each dataset to compare with GPM (we only show results on PMNIST in Fig. 5 and relegate the rest to the appendix). There are two main obervations: 1) TRGP completely outperforms GPM during training for all the sequential tasks on the three datasets; 2) For the PMNIST and 5-Dataset settings, TRGP could significantly reduce forgetting. To understand why, consider the case where GPM and TRGP learns a new task $t$ given the same model $\mathbb { W } _ { t - 1 }$ , and denote $\{ M _ { t - 1 } ^ { l } \} _ { l }$ as the bases of all old tasks. Then we can have
183
+
184
+ For GPM, the effective weight for layer $l$ is
185
+
186
+ $$
187
+ \begin{array} { r } { \boldsymbol { W } _ { e f f } ^ { l } = \operatorname { P r o j } _ { M _ { t - 1 } ^ { l } } ( \boldsymbol { W } ^ { l } ) + \operatorname { P r o j } _ { \perp M _ { t - 1 } ^ { l } } ( \boldsymbol { W } ^ { l } ) } \end{array}
188
+ $$
189
+
190
+ where the weight projection on $M _ { t - 1 } ^ { l }$ is frozen to protect old tasks, and only the weight projection orthogonal to $M _ { t - 1 } ^ { l }$ can be updated for learning task $t$ .
191
+
192
+ For TRGP, the effective weight for layer $l$ is
193
+
194
+ $$
195
+ W _ { e f f } ^ { l } = \mathrm { P r o j } _ { \{ S _ { j } ^ { l } \} _ { j \notin T \mathcal { R } _ { t } ^ { l } } } ( W ^ { l } ) + \mathrm { P r o j } _ { \{ S _ { j } ^ { l } \} _ { j \in \mathcal { T } \mathcal { R } _ { t } ^ { l } } } ^ { Q } ( W ^ { l } ) + \mathrm { P r o j } _ { \bot M _ { t - 1 } ^ { l } } ( W ^ { l } )
196
+ $$
197
+
198
+ where only the first term, i.e., weight projection on subspaces of old tasks that are not in the trust region $\mathcal T \dot { \mathcal R } _ { t } ^ { l }$ , is frozen for task $t$ . In contrast to GPM, an additional and also important part of weights, i.e., the scaled weight projection on subspaces of related old tasks in $\tau { \mathcal R } _ { t } ^ { l }$ , can be learnt in a favorable way for task $t$ . As a result, TRGP can achieve better forward knowledge transfer by explicitly and cleverly reusing the important knowledge of strongly correlated old tasks in the trust region. More interestingly, benefiting from the task-unique information captured by the scaled weight projection, the backward transfer can also be reduced.
199
+
200
+ ![](images/3e006d6af9462e650018395f142ea55f82323ae87859391307e5ec3c69a6411b.jpg)
201
+ Figure 5: Accuracy evolution for different tasks on PMNIST setting.
202
+
203
+ Table 3: Ablation study on CIFAR-100 Split and 5-Datasets settings.
204
+
205
+ <table><tr><td rowspan="2">Datasets</td><td colspan="3">Impact of threshold εl</td><td colspan="2">Layer-wise VS Task-wise</td><td colspan="2">Number of selected tasks</td></tr><tr><td>0.2</td><td>0.5</td><td>0.7</td><td>Layer-wise</td><td>Task-wise</td><td>Top-1</td><td>Top-2</td></tr><tr><td>CIFAR-100</td><td>74.52</td><td>74.46</td><td>74.30</td><td>74.46</td><td>73.25</td><td>74.00</td><td>74.46</td></tr><tr><td>5-Datasets</td><td>93.28</td><td>93.56</td><td>93.43</td><td>93.56</td><td>92.85</td><td>92.94</td><td>93.56</td></tr></table>
206
+
207
+ # 5.3 ABLATION STUDY AND ANALYSIS
208
+
209
+ Impact of the threshold $\epsilon ^ { l }$ . To understand the impact of the threshold $\epsilon ^ { l }$ , we evaluate the learning performance for three different values of $\epsilon ^ { l }$ (i.e., 0.2, 0.5, 0.7) as shown in Table 3. The results show that the accuracy is very stable across the three threshold values, with ignoble accuracy difference on both CIFAR-100 Split and 5-Dataset settings. The reason behind is because we only select top-2 old tasks with largest gradient projection norm into the trust region, among all tasks satisfying condition Eq. (3). Therefore, for a wide range of $\epsilon ^ { l }$ , the selected tasks in the trust region are actually fixed. The small accuracy fluctuation is because with some possibility only one old task satisfies Eq. (3) and is selected for some layers when $\epsilon ^ { l }$ increases. Overall, TRGP is very robust to the value of $\stackrel { \cdot } { \epsilon } { }$ .
210
+
211
+ Layer-wise vs. Task-wise trust region. To show the efficacy of layer-wise trust region, we compare it with the task-wise variant which shares a fixed trust region across all layers for each task. First, as shown in Table 3, layer-wise could achieve $1 . 2 1 \%$ accuracy gain over task-wise on CIFAR-100 Split. Furthermore, we illustrate the final accuracy of all tasks for layer-wise and taskwise of the proposed TRGP, and GPM on CIFAR-100 Split setting in Fig. 6. First, the performance of layer-wise is better than or comparable to task-wise for all tasks, because layer-wise provides a much finer characterization of task correlations in terms of layer-level features. Then, it is interesting to see that the learning behavior for the three cases follows the same trend. This observation further corroborates that TRGP can improve the accuracy and mitigate forgetting on both “easy” and “difficult” tasks.
212
+
213
+ ![](images/f16c86a00f9663dd1bd4cac8d1ae2190095ffa83e51128e4d1bcb49ed33c2743.jpg)
214
+ Figure 6: The final accuracy for all tasks of Task-wise VS Layerwise on CIFAR-100 Split.
215
+
216
+ Impact of selected tasks in trust region. We first evaluate the accuracy of Top-1 and Top-2 selected tasks as shown in Table 3. It shows that selecting the top-2 most correlated tasks could achieve better accuracy on both CIFAR-100 Split and 5-Dataset settings. Note that good performance can also be achieved even with the Top-1 case. Moreover, we illustrate the detailed task selection in the trust region for both layer-wise and task-wise on 5-Dataset setting in Fig. 7. For the task-wise, current task always selects the two adjacent previous tasks for all layers. Differently, the task selection varies for layer-wise, leading to more accurate selection of related tasks for each layer. For example, the layer wise trust region for Task 4 (Fashion MNIST) selects Task 1 (MNIST) or Task 3 (not-MNIST) as the most related tasks almost for all layers, over Task 0 (CIFAR-10) and Task 2 (SVHN), which clearly makes sense because Fashion MNIST shares more common features with MNIST and not-MNIST.
217
+
218
+ ![](images/b2a068f7b21de7eac8690723b50bb2cba41145ca7df3934d648e3ce3f5772945.jpg)
219
+ Figure 7: The detailed selected tasks on 5-Datasets setting.
220
+
221
+ # 6 CONCLUSION
222
+
223
+ In this work, we propose trust region gradient projection for continual learning to facilitate forward knowledge transfer with forgetting, based on an efficient characterization of task correlation. Particularly, our approach is built on two key blocks, i.e., the layer-wise trust region which effectively select the old tasks strongly correlated to the new task in a single-shot manner, and scaled weight projection which cleverly reuses the frozen weights of old tasks in the trust region without modifying the model. Extensive experiments show that our approach significantly improves over the related state-of-the-art methods.
224
+
225
+ # ACKNOWLEDGEMENT
226
+
227
+ This work is supported in part by NSF Grants CNS-2003081, CNS-2203239, CPS-1739344, and CCSS-2121222.
228
+
229
+ # REPRODUCIBILITY STATEMENT
230
+
231
+ For the experimental results presented in the main text, we include the code in the supplemental material, and specify all the training details in Section 5.1 and Appendix A. For the datasets used in the main text, we also give a clear explanation in Section 5.1.
232
+
233
+ # REFERENCES
234
+
235
+ Rahaf Aljundi, Francesca Babiloni, Mohamed Elhoseiny, Marcus Rohrbach, and Tinne Tuytelaars. Memory aware synapses: Learning what (not) to forget. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 139–154, 2018.
236
+
237
+ Yaroslav Bulatov. Notmnist dataset. Google (Books/OCR), Tech. Rep.[Online]. Available: http://yaroslavvb. blogspot. it/2011/09/notmnist-dataset. html, 2, 2011.
238
+
239
+ Arslan Chaudhry, Puneet K Dokania, Thalaiyasingam Ajanthan, and Philip HS Torr. Riemannian walk for incremental learning: Understanding forgetting and intransigence. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 532–547, 2018a.
240
+
241
+ Arslan Chaudhry, Marc’Aurelio Ranzato, Marcus Rohrbach, and Mohamed Elhoseiny. Efficient lifelong learning with a-gem. arXiv preprint arXiv:1812.00420, 2018b.
242
+
243
+ Arslan Chaudhry, Marcus Rohrbach, Mohamed Elhoseiny, Thalaiyasingam Ajanthan, Puneet K Dokania, Philip HS Torr, and M Ranzato. Continual learning with tiny episodic memories. 2019.
244
+
245
+ Zhiyuan Chen and Bing Liu. Lifelong machine learning. Synthesis Lectures on Artificial Intelligence and Machine Learning, 12(3):1–207, 2018.
246
+
247
+ Prithviraj Dhar, Rajat Vikram Singh, Kuan-Chuan Peng, Ziyan Wu, and Rama Chellappa. Learning without memorizing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5138–5146, 2019.
248
+
249
+ Mehrdad Farajtabar, Navid Azizan, Alex Mott, and Ang Li. Orthogonal gradient descent for continual learning. In International Conference on Artificial Intelligence and Statistics, pp. 3762–3773. PMLR, 2020.
250
+
251
+ Yunhui Guo, Mingrui Liu, Tianbao Yang, and Tajana Rosing. Improved schemes for episodic memory based lifelong learning algorithm. In Conference on Neural Information Processing Systems, 2020.
252
+
253
+ Steven CY Hung, Cheng-Hao Tu, Cheng-En Wu, Chien-Hung Chen, Yi-Ming Chan, and Chu-Song Chen. Compacting, picking and growing for unforgetting continual learning. arXiv preprint arXiv:1910.06562, 2019.
254
+
255
+ James Kirkpatrick, Razvan Pascanu, Neil Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka Grabska-Barwinska, et al. Overcoming catastrophic forgetting in neural networks. Proceedings of the national academy of sciences, 114(13):3521–3526, 2017.
256
+
257
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
258
+
259
+ Sang-Woo Lee, Jin-Hwa Kim, Jaehyun Jun, Jung-Woo Ha, and Byoung-Tak Zhang. Overcoming catastrophic forgetting by incremental moment matching. arXiv preprint arXiv:1703.08475, 2017.
260
+
261
+ Xilai Li, Yingbo Zhou, Tianfu Wu, Richard Socher, and Caiming Xiong. Learn to grow: A continual structure learning framework for overcoming catastrophic forgetting. In International Conference on Machine Learning, pp. 3925–3934. PMLR, 2019.
262
+
263
+ Zhizhong Li and Derek Hoiem. Learning without forgetting. IEEE transactions on pattern analysis and machine intelligence, 40(12):2935–2947, 2017.
264
+
265
+ David Lopez-Paz and Marc’Aurelio Ranzato. Gradient episodic memory for continual learning. Advances in neural information processing systems, 30:6467–6476, 2017.
266
+
267
+ Michael McCloskey and Neal J Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In Psychology of learning and motivation, volume 24, pp. 109–165. Elsevier, 1989.
268
+
269
+ Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. 2011.
270
+
271
+ Matthew Riemer, Ignacio Cases, Robert Ajemian, Miao Liu, Irina Rish, Yuhai Tu, and Gerald Tesauro. Learning to learn without forgetting by maximizing transfer and minimizing interference. arXiv preprint arXiv:1810.11910, 2018.
272
+
273
+ Hippolyt Ritter, Aleksandar Botev, and David Barber. Online structured laplace approximations for overcoming catastrophic forgetting. arXiv preprint arXiv:1805.07810, 2018.
274
+
275
+ Amir Rosenfeld and John K Tsotsos. Incremental learning through deep adaptation. IEEE transactions on pattern analysis and machine intelligence, 42(3):651–663, 2018.
276
+
277
+ Andrei A Rusu, Neil C Rabinowitz, Guillaume Desjardins, Hubert Soyer, James Kirkpatrick, Koray Kavukcuoglu, Razvan Pascanu, and Raia Hadsell. Progressive neural networks. arXiv preprint arXiv:1606.04671, 2016.
278
+
279
+ Gobinda Saha, Isha Garg, and Kaushik Roy. Gradient projection memory for continual learning. arXiv preprint arXiv:2103.09762, 2021.
280
+
281
+ John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In International conference on machine learning, pp. 1889–1897. PMLR, 2015.
282
+
283
+ Jonathan Schwarz, Wojciech Czarnecki, Jelena Luketina, Agnieszka Grabska-Barwinska, Yee Whye Teh, Razvan Pascanu, and Raia Hadsell. Progress & compress: A scalable framework for continual learning. In International Conference on Machine Learning, pp. 4528–4537. PMLR, 2018.
284
+
285
+ Joan Serra, Didac Suris, Marius Miron, and Alexandros Karatzoglou. Overcoming catastrophic forgetting with hard attention to the task. In International Conference on Machine Learning, pp. 4548–4557. PMLR, 2018.
286
+
287
+ Hanul Shin, Jung Kwon Lee, Jaehong Kim, and Jiwon Kim. Continual learning with deep generative replay. arXiv preprint arXiv:1705.08690, 2017.
288
+
289
+ Tom Veniat, Ludovic Denoyer, and Marc’Aurelio Ranzato. Efficient continual learning with modular networks and task-driven priors. arXiv preprint arXiv:2012.12631, 2020.
290
+
291
+ Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Daan Wierstra, et al. Matching networks for one shot learning. Advances in neural information processing systems, 29:3630–3638, 2016.
292
+
293
+ Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017.
294
+
295
+ Ju Xu and Zhanxing Zhu. Reinforced continual learning. arXiv preprint arXiv:1805.12369, 2018.
296
+
297
+ Jaehong Yoon, Eunho Yang, Jeongtae Lee, and Sung Ju Hwang. Lifelong learning with dynamically expandable networks. arXiv preprint arXiv:1708.01547, 2017.
298
+
299
+ Jaehong Yoon, Saehoon Kim, Eunho Yang, and Sung Ju Hwang. Scalable and order-robust continual learning with additive parameter decomposition. In Eighth International Conference on Learning Representations, ICLR 2020. ICLR, 2020.
300
+
301
+ Guanxiong Zeng, Yang Chen, Bo Cui, and Shan Yu. Continual learning of context-dependent processing in neural networks. Nature Machine Intelligence, 1(8):364–372, 2019.
302
+
303
+ Friedemann Zenke, Ben Poole, and Surya Ganguli. Continual learning through synaptic intelligence. In International Conference on Machine Learning, pp. 3987–3995. PMLR, 2017.
304
+
305
+ Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning (still) requires rethinking generalization. Communications of the ACM, 64(3):107– 115, 2021.
306
+
307
+ # A EXPERIMENT SETUPS
308
+
309
+ Training hyper-parameters. We evaluate our method on multiple datasets against state-of-the-art continual learning methods. 1) PMNIST. We use a 3-layer fully-connected network. with two hidden layer of 100 units. and train the network for 5 epochs with batch size of 10 for each task. 2) CIFAR-100 Split. CIFAR-100 (Krizhevsky et al., 2009) consists of images from 100 generic object classes. We use a version of 5-layer AlexNet and train each task for maximum of 200 epochs with the early termination strategy based on the validation loss value. The batch size is set to 64. 3) CIFAR100 Sup. We use a modified version of LeNet-5 with 20-50-800-500 neurons and train 50 epochs for each task sequentially. The batch size is set to 64. 4) 5-Datasets. We train each task for maximum of 200 epochs with the early termination strategy. The batch size is set to 64. 5) MiniImageNet Split. Following GPM (Saha et al., 2021), we use the reduced ResNet18 architecture, where the covolution with stride 2 in the first layer. We train each task for maximum of 100 epochs with the early termination strategy with 0.1 initial learning rate and 64 batchsize. In addition, for all the experiments, the threshold $\bar { \epsilon } ^ { \bar { l } }$ is set to 0.5, and we select top-2 tasks that satisfy condition Eq. (3). We use the same threshold $\epsilon _ { t h } ^ { l }$ as GPM (Saha et al., 2021) for subspace construction. We initialize the scaling matrix with the identity matrix and train all models with plain stochastic gradient descent.
310
+
311
+ # B MORE EXPERIMENTAL RESULTS
312
+
313
+ # B.1 ACCURACY EVOLUTION
314
+
315
+ ![](images/fbcae83be6b2509ecc631f51315a5a7696586abea3af918b9b37dec9e6b00202.jpg)
316
+ Figure 8: Accuracy evolution for different tasks on CIFAR-100 Split and 5-Datasets settings.
317
+
318
+ # B.2 STANDARD DEVIATION
319
+
320
+ We have summarized the results on the standard deviation for the averaged accuracy and backward transfer over 5 different runs on all datasets in Table 4.
321
+
322
+ Table 4: The averaged accuracy (ACC) and backward transfer (BWT) with the standard deviation values over 5 different runs on different datasets.
323
+
324
+ <table><tr><td rowspan="2">Method</td><td colspan="2">PMNIST</td><td colspan="2">CIFAR-100 Split</td><td colspan="2">5-Dataset</td><td colspan="2">MiniImageNet</td></tr><tr><td>ACC(%)</td><td>BWT(%)</td><td>ACC(%)</td><td>BWT(%)</td><td>ACC(%)</td><td>BWT(%)</td><td>ACC(%)</td><td>BWT(%)</td></tr><tr><td>Multitask</td><td>96.70 ± 0.02</td><td></td><td>79.58 ± 0.54</td><td>-</td><td>91.54 ± 0.28</td><td>-</td><td>69.46 ± 0.62</td><td>-</td></tr><tr><td>OWM</td><td>90.71 ± 0.11</td><td>-1±0</td><td>50.94 ± 0.60</td><td>-30 ±1</td><td></td><td></td><td></td><td></td></tr><tr><td>EWC</td><td>89.97 ± 0.57</td><td>-4±1</td><td>68.80 ±0.88</td><td>-2±1</td><td>88.64 ± 0.26</td><td>-4±1</td><td>52.01 ± 2.53</td><td>-12±3</td></tr><tr><td>HAT</td><td></td><td></td><td>72.06 ± 0.50</td><td>0±0</td><td>91.32 ± 0.18</td><td>-1±0</td><td>59.78 ±0.57</td><td>-3±0</td></tr><tr><td>A-GEM</td><td>83.56 ± 0.16</td><td>−14 ± 1</td><td>63.98 ± 1.22</td><td>−15 ± 2</td><td>84.04 ± 0.33</td><td>−12 ± 1</td><td>57.24 ±0.72</td><td>−12 ± 1</td></tr><tr><td>ER_Res</td><td>87.24± 0.53</td><td>−11 ± 1</td><td>71.73 ± 0.63</td><td>-6±1</td><td>88.31 ± 0.22</td><td>-4±0</td><td>58.94 ± 0.85</td><td>-7±1</td></tr><tr><td>GPM</td><td>93.91 ± 0.16</td><td>-3±0</td><td>72.48 ± 0.40</td><td>-0.9±0</td><td>91.22 ± 0.20</td><td>-1±0</td><td>60.41 ± 0.61</td><td>-0.7 ± 0.4</td></tr><tr><td>Ours (TRGP)</td><td>96.34 ± 0.11</td><td>-0.8 ± 0.1</td><td>74.46 ± 0.32</td><td>-0.9 ± 0.01</td><td>93.56 ± 0.10</td><td>-0.04 ± 0.01</td><td>61.78 ± 0.60</td><td>-0.5± 0.6</td></tr></table>
325
+
326
+ # B.3 FORWARD TRANSFER
327
+
328
+ To evaluate the forward transfer, we follow the metric used in (Veniat et al., 2020) and consider the accuracy of the model on $i$ -th task after learning the $i$ -th task sequentially, i.e., $A _ { i , i }$ as defined in Eq. (10). Tables 5 - 8 summarize the comparison of $A _ { i , i }$ for each task $i$ between GPM and TRGP on PMNIST, CIFAR-100 Split and 5-Dataset, respectively. As the same baseline (e.g., the accuracy of the model learnt from scratch using the task’s own data) for each task will be used when evaluating the forward transfer for GPM and TRGP, we can infer that TRGP achieves the forward transfer gain of $0 . 1 7 \%$ , $2 . 0 1 \%$ , $2 . 0 0 \%$ and $2 . 3 6 \%$ over GPM on PMNIST, CIFAR-100 Split, 5-Datasets and MiniImageNet respectively.
329
+
330
+ Table 5: The accuracy $A _ { i , i }$ of the model on $i$ -th task after learning the $i$ -th task sequentially on PMNIST 10 tasks.
331
+
332
+ <table><tr><td>Methods</td><td></td><td></td><td>3</td><td></td><td></td><td></td><td></td><td></td><td>9</td><td>10</td><td>Avg</td></tr><tr><td>GPM</td><td>97.597.5</td><td></td><td>97.3</td><td>97.1</td><td>97.096.9</td><td></td><td>96.8</td><td>96.4</td><td>96.5</td><td>96.5</td><td>96.95</td></tr><tr><td>Ours (TRGP)</td><td>97.5</td><td>97.5</td><td>97.5</td><td>97.3</td><td>97.1</td><td>97.1</td><td>96.9</td><td>96.7</td><td>96.9</td><td>96.7</td><td>97.12</td></tr></table>
333
+
334
+ Table 6: The accuracy $A _ { i , i }$ of the model on $i$ -th task after learning the $i$ -th task sequentially on CIFAR-100 Split 10 tasks.
335
+
336
+ <table><tr><td>Methods</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>10</td><td>Avg</td></tr><tr><td>GPM</td><td>76.8</td><td>68.5</td><td>72.4</td><td></td><td>69.974.8</td><td>172.3</td><td>70.3</td><td>71.9</td><td>73.2</td><td>75.1</td><td>72.52</td></tr><tr><td>Ours (TRGP)</td><td>76.9</td><td>69.5</td><td>75.1</td><td>74.1</td><td>75.3</td><td>75.8</td><td>72.8</td><td>73.8</td><td>73.9</td><td>78.1</td><td>74.53</td></tr></table>
337
+
338
+ Table 7: The accuracy $A _ { i , i }$ of the model on $i$ -th task after learning the $i$ -th task sequentially on 5-Dataset 5 tasks.
339
+
340
+ <table><tr><td>Methods</td><td></td><td></td><td></td><td></td><td></td><td>Avg</td></tr><tr><td>GPM</td><td>78.399.1</td><td></td><td>87.1</td><td>99.1</td><td>94.1</td><td>91.54</td></tr><tr><td>Ours (TRGP)</td><td>80.9</td><td>99.3</td><td>92.8</td><td>99.4</td><td>95.3</td><td>93.54</td></tr></table>
341
+
342
+ Table 8: The accuracy $A _ { i , i }$ of the model on $i$ -th task after learning the $i$ -th task sequentially on MiniImageNet Split 20 tasks.
343
+
344
+ <table><tr><td>Methods</td><td>1</td><td>12</td><td>3</td><td>-4</td><td>1 5</td><td>16</td><td>17</td><td>1 8</td><td>19</td><td></td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15 1</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>Avg</td></tr><tr><td>GPM</td><td>58.6</td><td>1 63.6</td><td>57.2</td><td>59.0</td><td>1 53.6</td><td>1 78.0</td><td>一 63.0</td><td></td><td>66.0</td><td>74.0</td><td>83.8</td><td>43.0</td><td>60.4</td><td>55.6</td><td>57.8</td><td>59.6 1</td><td>53.0</td><td>56.0</td><td>47.6</td><td>66.0</td><td>56.8</td><td>60.63</td></tr><tr><td>Ours (TRGP)</td><td>58.7</td><td>66.1</td><td>59.2</td><td>59.3</td><td>1 57.1</td><td>81.4</td><td></td><td>67.3</td><td>70.1</td><td>75.7</td><td>85.2</td><td>43.2</td><td>61.8</td><td>58.0</td><td>60.1</td><td>60.0</td><td>54.8</td><td>61.4</td><td>48.4</td><td>69.8</td><td>62.2</td><td>62.99</td></tr></table>
345
+
346
+ # B.4 COMPUTATIONAL COMPLEXITY
347
+
348
+ Memory: In terms of the memory, the major difference between TRGP and GPM is that TRGP requires additional memory to store the scaling matrices for each task. However, since the dimension of the scaling matrix is the same with the number of the extracted bases for the input subspace, which is usually small and controllable by the matrix approximation accuracy $\epsilon _ { t h }$ in Eq. (7), the memory increase is marginal and controllable. Particularly, the memory usage of TRGP can be further reduced by only learning the scaling matrices for the convolutional layers.
349
+
350
+ Training time: We compare the training time between TRGP and other baselines on relatively complex task sequences. As shown in Table 9, for CIFAR-100 Split, TRGP takes around $65 \%$ more time than GPM, is comparable with HAT and ER Res, and takes less time than OWM and EWC; for 5-Datasets, TRGP takes around $21 \%$ more time than GPM, but is much faster than other baselines including EWC, HAT, A-GEM and ER Res; for MiniImageNet, TRGP tasks around $34 \%$ more time than GPM, is comparable with EWC, but is much faster than A-GEM.
351
+
352
+ Table 9: Training time comparison on CIFAR-100 Split, 5-Datasets and MiniImageNet. Here the training time is normalized with respect to the value of GPM. Please refer (Saha et al., 2021) for more specific time.
353
+
354
+ <table><tr><td rowspan="2">Dataset</td><td colspan="7">Methods</td></tr><tr><td>OWM</td><td>EWC</td><td>HAT</td><td>A-GEM</td><td>ER_Res</td><td>GPM</td><td>Ours (TRGP)</td></tr><tr><td>CIFAR-100</td><td>2.41</td><td>1.76</td><td>1.62</td><td>3.48</td><td>1.49</td><td>1</td><td>1.65</td></tr><tr><td>5-Datasets</td><td>1</td><td>1.52</td><td>1.47</td><td>2.41</td><td>1.40</td><td>1</td><td>1.21</td></tr><tr><td>MiniImageNet</td><td>1</td><td>1.22</td><td>0.91</td><td>1.79</td><td>0.82</td><td>1</td><td>1.34</td></tr></table>
355
+
356
+ # B.5 ACCURACY VS LEARNING EPOCHS
357
+
358
+ The learning dynamics for each task are shown in Figure 9 and 10. Clearly, our approach can perform significantly better than GPM on some tasks, especially for the tasks in the tail of the task sequence. This is because in GPM, with more tasks being learnt, the optimization space for new tasks becomes more restrictive, leading to limited performance for new tasks. Note that the y-axis is the validation accuracy with a split validate dataset that used during training, by following the setup in (Saha et al., 2021). The validation accuracy varies because the size of the validate dataset is relatively small (See (Saha et al., 2021) for the specific size). For the testing accuracy in all the tables, we evaluate the accuracy with the testing dataset after training.
359
+
360
+ ![](images/f15dd6288a440b9b807040038c4a5c80a280b5bc43604991da4ba425b817d190.jpg)
361
+ Figure 9: Accuracy vs learning epochs for different tasks on CIFAR-100 Split.
362
+
363
+ ![](images/5bf3d623f1b7ef74a66b17097d2e8bf3045dc7fec240f1994a9bae8120336d31.jpg)
364
+ Figure 10: Accuracy vs learning epochs for five tasks on 5-Dataset.
md/dev/kTcRljax0x9/kTcRljax0x9.md ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ASSESSING REINFORCEMENT LEARNING POLICIES VIA NATURAL CORRUPTIONS AT THE EDGE OF IMPERCEPTIBILITY
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Deep reinforcement learning algorithms have recently achieved significant success in learning high-performing policies from purely visual observations. The ability to perform end-to-end learning from raw high dimensional input alone has led to deep reinforcement learning algorithms being deployed in a variety of fields. Thus, understanding and improving the ability of deep reinforcement learning policies to generalize to unseen data distributions is of critical importance. Much recent work has focused on assessing the generalization of deep reinforcement learning policies by introducing specifically crafted adversarial perturbations to their inputs. In this paper, we approach this problem from another perspective and propose a framework to assess the generalization skills of trained deep reinforcement learning policies. Rather than focusing on worst-case analysis of distribution shift, our approach is based on black-box perturbations that correspond to minimal semantically meaningful natural changes to the environment or the agent’s visual observation system ranging from brightness to compression artifacts. We demonstrate that the perceptual similarity distance of the minimal natural perturbations is orders of magnitude smaller than the perceptual similarity distance of the adversarial perturbations to the unperturbed observations (i.e. minimal natural perturbations are perceptually more similar to the unperturbed states than the adversarial perturbations), while causing larger degradation in the policy performance. Furthermore, we investigate state-of-the-art adversarial training methods and show that adversarially trained deep reinforcement learning policies are more sensitive to almost all of the natural perturbations compared to vanilla trained policies. Lastly, we highlight that our framework captures a diverse set of bands in the Fourier spectrum; thus providing a better overall understanding of the policy’s generalization capabilities. We believe our work can be crucial towards building resilient and generalizable deep reinforcement learning policies.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Following the initial work of Mnih et al. (2015), the use of DNNs as function approximators in reinforcement learning has led to a dramatic increase in the capabilities of RL agents Schulman et al. (2017); Lillicrap et al. (2015). In particular, these developments allow for the direct learning of strong policies from raw, high-dimensional inputs (i.e. visual observations). With the successes of these new methods come new challenges regarding the robustness and generalization capabilities of deep reinforcement learning agents.
12
+
13
+ Szegedy et al. (2014) showed that specifically crafted imperceptible perturbations can lead to misclassification in image classification. After this initial work a new research area emerged to investigate the abilities of deep neural networks against specifically crafted adversarial examples. While various works studied many different ways to compute these examples (Carlini & Wagner, 2017; Madry et al., 2018; Goodfellow et al., 2015; Kurakin et al., 2016), several works focused on studying ways to increase the robustness against such specifically crafted perturbations, based on training with the existence of such perturbations (Madry et al., 2018; Tramer et al., 2018; Goodfellow et al., \` 2015; Xie & Yuille, 2020).
14
+
15
+ As image classification suffered from this vulnerability towards worst-case distributional shift in the input, a series of work conducted in deep reinforcement learning showed that deep neural policies are also susceptible to specifically crafted imperceptible perturbations (Huang et al., 2017; Kos & Song, 2017; Pattanaik et al., 2018; Lin et al., 2017; Sun et al., 2020; Korkmaz, 2021). While one line of work put effort on exploring these vulnerabilities in deep neural policies, another line in parallel focused making them robust and reliable via adversarial training (Pinto et al., 2017; Mandlekar et al., 2017; Huan et al., 2020).
16
+
17
+ While adversarial perturbations and adversarial training provide a notion of robustness for trained deep neural policies, in this paper we approach the resilience problem of the deep neural policies from a wider perspective, and propose a framework to test a more generic sense of robustness towards minimal perceptually similar perturbations1. To be able to achieve this we go beyond $\ell _ { p }$ -norm bounded pixel perturbations and include semantically meaningful minimal realistic perturbations. By this approach we seek answers to the following questions: (i) How perceptually similar are minimal semantically meaningful perturbed states to the original unperturbed states, and how does this compare to $\ell _ { p }$ -norm bounded adversarially perturbed states? (ii) What are the differences between adversarial perturbations and minimal natural perturbations introduced to the policy observation in terms of performance degradation of the trained deep reinforcement learning policy? (iii) How does state-of-the-art adversarial training affect the performance degradation caused by perceptually similar minimal natural perturbations compared to vanilla training? To be able answer these questions, in this work we focus on the notion of robustness of trained deep reinforcement learning agents and make the following contributions:
18
+
19
+ • We propose a framework consisting of a diverse set of minimalistic (i.e. perceptually similar) semantically meaningful natural perturbations.
20
+ • We run multiple experiments in the Arcade Learning Environment (ALE) in various games with high dimensional state representation and provide the relationship between the perceptual similarities to unperturbed states under our proposed natural perturbation framework and adversarial perturbations.
21
+ • We compare our proposed framework with the state-of-the-art adversarial method based on $\ell _ { p }$ -norm changes, and we show that our natural perturbation framework is competitive in degrading the performance of the deep reinforcement learning agent with lower perceptual similarity distance.
22
+ • We inspect state-of-the-art adversarial training under our proposed framework, and demonstrate that the adversarially trained models become more vulnerable to various natural perturbations compared to vanilla trained models.
23
+ • Finally, we investigate the frequency domain of our framework and state-of-the-art targeted attacks. We show that our framework captures different bands of the frequency spectrum, thus yielding a better estimate of the model robustness.
24
+
25
+ # 2 BACKGROUND AND RELATED WORK
26
+
27
+ # 2.1 PRELIMINARIES
28
+
29
+ In this paper we consider Markov Decision Processes (MDPs) given by a tuple $( S , A , P , r , \gamma , s _ { 0 } )$ . The reinforcement learning agent interacts with the MDP by observing states $s \in S$ , and then taking actions $a \in A$ . Here $s _ { 0 }$ represents the initial state of the agent, and $\gamma$ represents the discount factor. The probability of transitioning to state $s ^ { \prime }$ when the agent takes action $a$ in state $s$ is determined by the Markovian transition kernel $P : S \times A \times S \to \mathbb { R }$ . The reward received by the agent when taking action $a$ in state $s$ is given by the reward function $r : S \times A \to \mathbb { R }$ . The goal of the expected cumulative discounted reward with the environment. This goal is achieve the agent is to learn a policy $\pi _ { \theta } : S \times A \to \mathbb { R }$ $\scriptstyle \sum _ { t = 0 } ^ { T - 1 } \gamma ^ { t } r ( s _ { t } , a _ { t } )$ which takes an action that the agent receives viastate-action value function $a$ in state that maximizes $Q ( s , a ) =$ $\mathbb { E } _ { \pi } [ \sum _ { t = 0 } ^ { T - 1 } \gamma ^ { t } r ( s _ { t } , a _ { t } ) | s = s _ { 0 } , a _ { 0 } = 0 ]$ assigning a value to each state-action pair. We use $\mathcal { F } ( s )$ to denote the 2D discrete Fourier transform of state $s$ in which each frequency is computed via $\begin{array} { r } { \mathcal { F } ( m , n ) = \sum _ { k = 0 } ^ { M - 1 } \sum _ { l = 0 } ^ { N - 1 } s ( k , l ) e ^ { - j 2 \pi ( m k / M + n l / N ) } } \end{array}$ where $k$ and $l$ are the coordinates of the state, and $M$ and $N$ correspond to ranges of the 2D state representation.
30
+
31
+ # 2.2 CRAFTING ADVERSARIAL PERTURBATIONS
32
+
33
+ Szegedy et al. (2014) proposed to minimize the distance between the original image and adversarially produced image to create adversarial perturbations. The authors used box-constrained L-BFGS to solve this optimization problem. Goodfellow et al. (2015) introduced the fast gradient method (FGM)
34
+
35
+ $$
36
+ x _ { \mathrm { a d v } } = x + \epsilon \cdot \frac { \nabla _ { x } J ( x , y ) } { | | \nabla _ { x } J ( x , y ) | | _ { p } } ,
37
+ $$
38
+
39
+ for crafting adversarial examples in image classification by taking the gradient of the cost function $J ( x , y )$ used to train the neural network in the direction of the input, where $x$ is the input, $y$ is the output label, and $J ( x , y )$ is the cost function for image classification. Carlini & Wagner (2017) introduced targeted attacks in the image classification domain based on distance minimization between the adversarial image and the original image while targeting a particular label. In the deep reinforcement learning domain the Carlini & Wagner (2017) formulation is
40
+
41
+ $$
42
+ \begin{array} { r l } & { \underset { s _ { \mathrm { a d v } } \in D _ { \epsilon , p } ( s ) } { \operatorname* { m i n } } \Vert s _ { \mathrm { a d v } } - s \Vert _ { p } } \\ & { \mathrm { s u b j e c t ~ t o ~ } \underset { a } { \operatorname { a r g m a x } } Q ( s , a ) \neq \underset { a } { \operatorname { a r g m a x } } Q ( s _ { \mathrm { a d v } } , a ) } \end{array}
43
+ $$
44
+
45
+ where $s$ is the unperturbed input, $S _ { \mathrm { a d v } }$ is the adversarially perturbed input, $a ^ { * } ( s )$ is the action taken in the unperturbed state, and $a ^ { * } ( s _ { \mathrm { a d v } } ) = \arg \operatorname* { m a x } _ { a } Q ( s _ { \mathrm { a d v } } , a )$ is the action taken in the adversarial state. This formulation attempts to minimize the distance to the original state, constrained to states leading to sub-optimal actions as determined by the $Q$ -network. In contrast to adversarial attacks, in our proposed threat model we will not need any information on the cost function used to train the network, the $Q$ -network of the trained agent, or access to the visited states themselves.
46
+
47
+ # 2.3 ADVERSARIAL APPROACH IN DEEP REINFORCEMENT LEARNING
48
+
49
+ The first adversarial attacks on deep reinforcement learning introduced by Huang et al. (2017) and Kos & Song (2017) adapted FGSM from image classification to the deep reinforcement learning setting. Subsequently, Mandlekar et al. (2017) used FGSM perturbations for adversarial training of deep reinforcement learning agents. Pinto et al. (2017); Gleave et al. (2020) focused on modeling the interaction between the adversary and the agent, while Lin et al. (2017); Sun et al. (2020) focused on strategically timing when (i.e. in which state) to attack an agent using perturbations computed with the Carlini & Wagner (2017) adversarial formulation. Quite recently, Huan et al. (2020) proposed to model this dynamic as a State-Adversarial Markov Decision Process (SA-MDP), and the authors claimed the SA-MDP model provides theoretically justified robust deep reinforcement learning agents.
50
+
51
+ # 2.4 PERCEPTUAL SIMILARITY DISTANCE
52
+
53
+ Zhang et al. (2018) found that internal activations of networks trained for high-level tasks correspond to human perceptual judgements across different network architectures Iandola et al. (2016), Krizhevsky et al. (2012), Simonyan & Zisserman (2015) without calibration. Furthermore, the authors propose a method to measure the perceptual distance between two images with the Learned Perceptual Image Patch Similarity (LPIPS) metric. We compare the distance between adversarial states ${ \boldsymbol { s } } _ { \mathrm { a d v } }$ and the original states $s$ with the LPIPS metric. We refer to the LPIPS metric as $\mathcal { P } _ { \mathrm { s i m i l a r i t y } }$ throughout the paper. $\mathcal { P } _ { \mathrm { s i m i l a r i t y } } ( s , s _ { \mathrm { a d v } } )$ returns the distance between $s$ and ${ \boldsymbol { s } } _ { \mathrm { a d v } }$ based on network activations. Zhang et al. (2018) show that $\mathcal { P } _ { \mathrm { s i m i l a r i t y } }$ results in a reliable approximation of human perception.
54
+
55
+ In more detail, the LPIPS metric in Zhang et al. (2018) is given by measuring the $\ell _ { 2 }$ distance between a normalized version of the activations of the neural network at several internal convolutional layers. For each convolutional layer $l$ let $W _ { l }$ be the width, $H _ { l }$ the height, and $C _ { l }$ the number of channels. Further, let $y ^ { l } \in \mathbb { R } ^ { W _ { l } \times H _ { l } \times C _ { l } }$ denote the vector of activations in convolutional layer $l$ .
56
+
57
+ To compute the perceptual similarity distance between two states $s$ and $s _ { 0 }$ , first calculate the internal activations $y ^ { \hat { l } } , y _ { 0 } ^ { l } \ { \in } \ \mathbb { R } ^ { W _ { l } \times H _ { l } \times C _ { l } ^ { \bullet } }$ (corresponding to $s$ and $s _ { 0 }$ respectively) for $L$ internal layers. Second, unit-normalize the activation vectors in the channel dimension, and denote the resulting normalized activations by $\hat { y } ^ { l }$ and $\hat { y } _ { 0 } ^ { l }$ . Next scale each channel in $\hat { y } ^ { l }$ and $\hat { y } _ { 0 } ^ { l }$ by the same, fixed weight vector $w _ { l } \in \mathbb { R } ^ { C _ { l } }$ . Here $w _ { l }$ can either be a learned vector of weights for layer $l$ or the vector of all ones if no scaling is desired. The last step is then to compute the perceptual similarity distance by first averaging the $\ell _ { 2 }$ distance between the scaled activations over the spatial dimensions, and then summing over the $L$ layers. Formally,
58
+
59
+ $$
60
+ { \mathcal { P } } _ { \mathrm { s i m i l a r i t y } } \big ( s , s _ { 0 } \big ) = \sum _ { l } { \frac { 1 } { H _ { l } W _ { l } } \sum _ { h , w } \left\| w _ { l } \odot \big ( \hat { y } _ { h w } ^ { l } - \hat { y } _ { 0 h w } ^ { l } \big ) \right\| _ { 2 } ^ { 2 } }
61
+ $$
62
+
63
+ # 2.5 IMPACT
64
+
65
+ To be able to compare between different algorithms and different games the performance degradation of the deep reinforcement learning policy is defined as the normalized impact of an adversary on the agent:
66
+
67
+ $$
68
+ \mathcal { T } = \frac { \mathrm { S c o r e } _ { \mathrm { c l e a n } } - \mathrm { S c o r e } _ { \mathrm { a d v } } } { \mathrm { S c o r e } _ { \mathrm { c l e a n } } - \mathrm { S c o r e } _ { \mathrm { m i n } } ^ { \mathrm { f u x e d } } } .
69
+ $$
70
+
71
+ Scorefixedmin is a fixed minimum score for a game, ${ \mathrm { S c o r e } } _ { \mathrm { a d v } }$ and $\mathbf { S c o r e } _ { \mathrm { c l e a n } }$ are the scores of the agent with and without any modification to the agent’s observations system respectively.
72
+
73
+ # 3 A GENERALIZATION TESTING FRAMEWORK WITH NATURAL PERTURBATIONS
74
+
75
+ In our paper we focus on robustness and generalization issues that deep reinforcement learning policies encounter with a contrasting view compared to prior work focusing on worst-case distributional shift within an imperceptibility bound (see Section 2.3). We propose a baseline to evaluate deep reinforcement learning policies with realistic and minimal corruptions to the environment with which they interact. We essentially juxtapose adversarial perturbations and natural corruptions with respect to their perceptual similarity distance (see Section 2.4) to the original states and their degree of impact on the policy performance. More importantly, we question the imperceptibility of $\ell _ { p }$ -norm bounded adversarial perturbations in terms of perceptual similarity distance, and compare this imperceptibility notion to natural perturbations. While we categorize adversarial perturbations also as a component in the framework majorly concentrated on the high frequencies, we embed several realistic perturbations that aim to cover diverse bands in the frequency spectrum. We highlight that prior work focused on the presence of a strong adversary model that requires prior access to training details of the agent’s neural network Huang et al. (2017); Korkmaz (2021), real time access to the agent’s perception system Pattanaik et al. (2018); Kos & Song (2017), and highly computationally demanding adversarial formulations for computing simultaneous perturbations Lin et al. (2017); Sun et al. (2020). From the security point of view we emphasize that natural corruptions at the edge of imperceptibility can be more dangerous than a strong adversary assumption 2 without carrying any of these requirements.
76
+
77
+ In our model we examine several natural environmental changes such as: changes in the brightness of the environment, blurring of the observation, slight rotation of the observation, several geometric transformations and compression artifacts. These changes from our model can be easily linked to naturally occurring changes in the environment3. In Table 1 we compare our proposed framework with the state-of-the-art targeted adversarial attack proposed by Carlini & Wagner (2017) in terms of perceptual similarity distances, and the impacts on the policy performance. While in the remainder of this section we explain in detail each component of our proposed framework, we provide all the experimental details in Section 5, as well as results on policy gradients, performance degradation in the time domain, and complementary results for Section 5 in the appendix.
78
+
79
+ ![](images/645e2c179f1e81f16c3049bee457fd7714c16bc7569b48ad9acd77a7ef956d7f.jpg)
80
+ Figure 1: Original frame and environmental modifications. Columns: original frame, shifting, rotation, perspective transformation, blurring, compression artifacts. brightness and contrast. Rows: JamesBond, Pong and BankHeist.
81
+
82
+ Note that the natural corruptions considered in our framework are as minimalistic as possible. Most of the perturbations from the proposed framework cannot be recognized by human perception (see Figure 1). More formally, the perceptual similarity distances for each corruption, and the resulting policy performance degradation, are given in Table 1.
83
+
84
+ Brightness and Contrast: To inspect the effects of low frequency corruptions we included brightness and contrast level changes using linear brightness and contrast transformation,
85
+
86
+ $$
87
+ s _ { \mathrm { a d v } } ( i , j ) = s ( i , j ) \cdot \alpha + \beta ,
88
+ $$
89
+
90
+ where $s ( i , j )$ is the $i j ^ { \mathrm { t h } }$ pixel of state $s$ , and $\alpha$ and $\beta$ are the linear brightness parameters. In Table 1 we show the impacts and perceptual similarity distances with corresponding $\alpha , \beta$ values. In all of the games except BankHeist brightness and contrast change results in higher impact than the Carlini & Wagner (2017) formulation, while the perceptual similarity distance of brightness and contrast is lower in every game.
91
+
92
+ Blurring: To observe the effects of high frequency corruptions we included blurring in our framework. In particular, median bluring4 is a nonlinear noise removal technique that replaces the original pixel value with the median pixel value of its neighbouring pixels. A kernel size $k$ means that the median is computed over a $k \times k$ neighborhood of the original pixel. Only in BankHeist and TimePilot we observe that the perceptual similarity distance required for blurring is higher compared to adversarial perturbations to be able to cause higher impact on policy performance (see Table 1). For the rest of the games impact is higher and perceptual similarity distance is lower for blurring.
93
+
94
+ Rotation: Rotation is one of the most fundamental geometric changes in an environment which we incorporate in our framework. In Table 1 we show impact values and perceptual similarity distance with corresponding rotation angle in degrees. In all of the games except Pong rotation results in higher impact and orders of magnitude lower perceptual similarity distance than the Carlini & Wagner (2017) formulation. In Pong the impact is comparable and the perceptual similarity distance is lower by a factor of 6.
95
+
96
+ Table 1: Impacts on the policy performance, perceptual similarity distances $\mathcal { P } _ { \mathrm { s i m i l a r i t y } }$ to the unperturbed states, and raw scores for Carlini & Wagner (2017) formulation and natural perturbation framework components. We report all of the results with the standard error of the mean.
97
+
98
+ <table><tr><td>Games</td><td>BankHeist</td><td>JamesBond</td><td>Pong</td><td>Riverraid</td><td>TimePilot</td></tr><tr><td>Carlini&amp;Wagner Impact</td><td>0.982±0.009</td><td>0.451±0.231</td><td>0.995±0.014</td><td>0.928±0.030</td><td>0.567 ±0.159</td></tr><tr><td>Brightness&amp;Contrast Impact</td><td>0.966± 0.030</td><td>0.913 ±0.047</td><td>1.0±0.009</td><td>0.951 ±0.016</td><td>0.663±0.239</td></tr><tr><td>Blurring Impact</td><td>0.979±0.009</td><td>0.635±0.200</td><td>1.0±0.000</td><td>0.946±0.015</td><td>0.589±0.150</td></tr><tr><td>Rotation Impact</td><td>0.997±0.004</td><td>0.635±0.189</td><td>0.99±0.015</td><td>0.942±0.042</td><td>0.581±0.158</td></tr><tr><td>Shifting Impact</td><td>0.985 ±0.005</td><td>0.865±0.140</td><td>1.0±0.00</td><td>0.935 ±0.023</td><td>0.623±0.199</td></tr><tr><td>Compression Artifacts Impact</td><td>0.980 ±0.013</td><td>0.884 ±0.128</td><td>0.962±0.032</td><td>0.803 ±0.051</td><td>0.578 ±0.271</td></tr><tr><td>Perspective Transform Impact</td><td>0.998±0.003</td><td>0.865±0.087</td><td>0.996±0.009</td><td>0.968±0.006</td><td>0.624±0.198</td></tr><tr><td>Carlini&amp;Wagner Psimilarity</td><td>0.0657±0.0073</td><td>0.2622±0.0312</td><td>0.6134±0.0271</td><td>0.2714±0.0285</td><td>0.1336± 0.0231</td></tr><tr><td>Brightness&amp;Contrast Psimilarity</td><td>0.0307±0.0039</td><td>0.011± 0.0003</td><td>0.2190± 0.0046</td><td>0.2147±0.0212</td><td>0.1045± 0.0031</td></tr><tr><td>Blurring Psimilarity</td><td>0.1672±0.0192</td><td>0.0707±0.0074</td><td>0.0351±0.0072</td><td>0.1442±0.0107</td><td>0.2014±0.0645</td></tr><tr><td>Rotation Psimilarity</td><td>0.0520±0.0070</td><td>0.0275±0.0016</td><td>0.1020±0.0115</td><td>0.0422± 0.0033</td><td>0.1020±0.0115</td></tr><tr><td>Shifting Psimilarity</td><td>0.0492±0.0046</td><td>0.0650±0.0092</td><td>0.2455±0.0432</td><td>0.0945±0.0032</td><td>0.1167±0.0121</td></tr><tr><td>Compression Artifacts Psimilarity</td><td>0.0240±0.0037</td><td>0.1325±0.0301</td><td>0.2506±0.0559</td><td>0.2250±0.0202</td><td>0.1592±0.0369</td></tr><tr><td>Perspective Transform Psimilarity</td><td>0.0398±0.0067</td><td>0.012±0.0007</td><td>0.0140±0.0018</td><td>0.0422±0.0016</td><td>0.0440±0.0050</td></tr><tr><td>Carlini&amp;WagnerRaw Scores</td><td>15.0±2.549</td><td>285.0±25.495</td><td>-20.8±0.189</td><td>1168.0± 140.696</td><td>4090.0±347.979</td></tr><tr><td>Brightness&amp;Contrast Raw Scores</td><td>17.0±1.651</td><td>45.0±6.846</td><td>-21.0±0.000</td><td>744.0±76.957</td><td>3180.0±711.027</td></tr><tr><td>Blurring Raw Scores</td><td>18.0±3.405</td><td>190.0±33.015</td><td>-21.0±0.000</td><td>820.0±72.013</td><td>3880.0±329.484</td></tr><tr><td>Rotation Raw Scores</td><td>2.0±1.264</td><td>190.0± 27.203</td><td>-20.6±0.209</td><td>873.0±201.866</td><td>3150.0±482.959</td></tr><tr><td>Shifting Raw Scores</td><td>13.0±1.449</td><td>70.0±20.248</td><td>-21.0±0.000</td><td>988.0± 89.057</td><td>3560.0± 437.538</td></tr><tr><td>Compression ArtifactsRaw Scores Perspective Transform Raw Scores</td><td>17.0±3.478</td><td>60.0±18.439</td><td>-19.4±0.428</td><td>2589.0±389.679</td><td>3980.0±593.936</td></tr><tr><td></td><td>1.0±0.948</td><td>75.0±12.649</td><td>-20.9±0.126</td><td>486.0±29.127</td><td>3550.0±435.028</td></tr><tr><td>Brightness&amp;Contrast [α,β]</td><td>[1.2,40]</td><td>[0.9,20]</td><td>[1.7,40]</td><td>[2.4,-275]</td><td>[2.4,-260]</td></tr><tr><td>Blurring Kernel Size</td><td>5</td><td>3</td><td>3</td><td>5</td><td>5</td></tr><tr><td>Rotation Degree</td><td>1.4</td><td>1.6</td><td>3</td><td>1.8</td><td>5</td></tr><tr><td>Shifting[ti,tj]</td><td>[1,1]</td><td>[0,1]</td><td>[2,1]</td><td>[1,2]</td><td>[2.2]</td></tr><tr><td>Perspective Transform Norm</td><td>1</td><td>1</td><td>3</td><td>2</td><td>3</td></tr></table>
99
+
100
+ Shifting: We included several plausible geometric transformations in our natural perturbation framework, the first of which is shifting. In more detail, shifting an image moves the elements of the image matrix along any dimension by any number of elements. For this modification we shift the inputs in the $x$ or $y$ direction with as few pixels shifted as possible. We use $[ t _ { i } , t _ { j } ]$ to denote the distance shifted, where $t _ { i }$ is in the direction of $x$ and $t _ { j }$ is in the direction of $y$ . In Table 1 we show the impact values and perceptual similarity distances for both Carlini & Wagner (2017) and shifting with corresponding $[ t _ { i } , t _ { j } ]$ values. For all of the games shifting yields higher impact and lower perceptual similarity distance.
101
+
102
+ Compression Artifacts: With this natural perturbation component we look at JPEG compression artifacts caused by the discrete cosine transform (DCT) resulting in the loss of high frequency components (ringing and blocking). In Table 1 we show the impact values and perceptual similarities of Carlini & Wagner (2017) and compression artifacts (CA). Only in Pong and Riverraid do we observe a lower impact than Carlini & Wagner (2017) while the perceptual similarity distance is significantly smaller for compression artifacts. While in TimePilot the perceptual similarity distance is higher, in the rest of the games compression artifacts result in higher impact and lower perceptual similarity distance compared to Carlini & Wagner (2017).
103
+
104
+ Perspective Transformation: The final component of our proposed natural perturbation framework is perspective transformation. Given four points in the plane defining a convex quadrangle, there is a unique perspective transformation mapping the corners of the square to these four points5. We define the norm of a perspective transformation as the maximum distance that one of the corners of the square moves under this mapping. Note that for most of the games the perspective norm is small (see Table 1). Hence, the changes caused by the perspective transform are imperceptible (e.g. fourth column of Figure 1). Furthermore, for all the games we observe perspective transformation yields higher impact and lower perceptual similarity distance than the Carlini & Wagner (2017) formulation.
105
+
106
+ ![](images/c30a5ebe5a8f6ed96e6cf33e91031eb6818a31a770b28cb51b7d34c5823dd9c3.jpg)
107
+ Figure 2: Performance drop of adversarially trained deep reinforcement learning policy and vanilla trained deep reinforcement learning policy under the changes in rotation, compression artifacts, and contrast.
108
+
109
+ # 4 ADVERSARIAL TRAINING UNDER NATURAL CORRUPTIONS
110
+
111
+ In this section we investigate state-of-the-art adversarially trained deep reinforcement learning policies within our proposed natural perturbation framework. In particular, we test State Adversarial Double Deep Q-Network, a state-of-the-art algorithm (see Section 2.3). In this paper the authors propose using what they call a state-adversarial MDP to model adversarial attacks in deep reinforcement learning. Based on this model they develop methods to regularize Double Deep Q-Network policies to be more robust to adversarial attacks. In more detail, letting $B ( s )$ be the $\ell _ { p }$ -norm ball of radius $\epsilon$ , this regularization is achieved by adding,
112
+
113
+ $$
114
+ \mathcal { R } ( \theta ) = \operatorname* { m a x } \{ \operatorname* { m a x } _ { \hat { s } \in B ( s ) } \operatorname* { m a x } _ { a \neq a ^ { * } ( s ) } Q _ { \theta } ( \hat { s } , a ) - Q _ { \theta } ( \hat { s } , a ^ { * } ( s ) ) , - c \} .
115
+ $$
116
+
117
+ to the temporal difference loss used in standard DQN. In particular, for a sample of the form $( s , a , r , s ^ { \prime } )$ the loss is
118
+
119
+ $$
120
+ \mathcal { L } ( \theta ) = L _ { H } \left( r + \gamma \operatorname* { m a x } _ { a ^ { \prime } } Q ^ { \mathrm { t a r g e t } } ( s ^ { \prime } , a ^ { \prime } ) - Q _ { \theta } ( s , a ) \right) + \mathcal { R } ( \theta )
121
+ $$
122
+
123
+ where $L _ { H }$ is the Huber loss.
124
+
125
+ Table 2 shows the impact values of the components of our proposed framework for the vanilla trained agent and the adversarially trained agent. We find that while the adversarially trained model gains robustness against blurring, no additional robustness is gained against any other component of the framework under adversarial training. Furthermore, in Figure 2 and Figure 3 we show the effect of varying the degrees for rotation, $\alpha$ for contrast, $\beta$ for brightness, and jpeg quality $\kappa$ for compression artifacts. We find that, as these parameters are varied, the vanilla trained agent is more robust than the adversarially trained one. For example, modifying brightness with $\beta$ in the range 3.1 to 20.0 causes impact close to 1.0 (i.e. total failure) for the adversarially trained policy, but has negligible impact on the vanilla trained policy. Thus, not only does our proposed framework capture semantically meaningful perturbations that are not captured by adversarial robustness, but additionally adversarial training actively harms robustness to some of the natural perturbations from our proposed framework.
126
+
127
+ ![](images/a6e117b8a55972f97737fb94c1a6f776016e91d7dfcbec374f9aeca50629b9b6.jpg)
128
+ Figure 3: Performance drop of adversarially trained model and vanilla trained model to the changes in brightness.
129
+
130
+ The results in Figure 2 and Figure 3 demonstrate that, across a wide range of parameters, adversarially trained neural policies are less robust to natural perturbations than vanilla trained policies. This occurs despite the fact that the central purpose of adversarial training is to increase robustness to imperceptible perturbations, where imperceptibility is measured by $\ell _ { p }$ -norm. Our results indicate that an increase in robustness to $\ell _ { p }$ -norm bounded perturbations can come at the cost of a loss in robustness to other natural types of imperceptible corruptions. These results call into question the use of adversarial training for the creation of robust deep reinforcement learning policies, and in particular the use of $\ell _ { p }$ -norm bounds as a metric of imperceptibility.
131
+
132
+ The fact that deep reinforcement learning policies are being widely deployed in many different domains: self-driving automobiles Dosovitsky et al. (2017); Wolf et al. (2017), drug design Pereira et al. (2021); Popova et al. (2018), autonomous aerial vehicles Zhang et al. (2020), medical diagnosis and treatment Thananjeyan et al. (2017); Yauney & Pratik (2018), natural language processing He et al. (2016); Jaques et al. (2017), and industrial control and security Wang et al. (2019); Duan et al. (2020), brings the term “robustness” into question. The decrease in resilience to overall distributional shift that “certified robust” adversarial training methods encounter demonstrates the need for further investigation into how robustness should be defined.
133
+
134
+ Table 2: Impacts of adversarially and vanilla trained policies with natural perturbation framework: brightness &contrast, blurring, rotation, shifting, compression artifacts and perspective transform.
135
+
136
+ <table><tr><td>Environment Training Method</td><td>BankHeist Adversarially Trained</td><td>BankHeist Vanilla Trained</td><td>Pong Vanilla Trained</td><td>Pong Adversarially Trained</td></tr><tr><td>Brightness&amp;Contrast (D)</td><td>0.881±0.010</td><td>0.971±0.030</td><td>0.996±0.009</td><td>1.0±0.000</td></tr><tr><td>Compression Artifacts (I)</td><td>0.960±0.0014</td><td>0.984±0.013</td><td>0.962±0.032</td><td>1.0±0.000</td></tr><tr><td>Perspective Transform (Z)</td><td>1.0±0.000</td><td>1.0±0.003</td><td>0.996±0.009</td><td>0.992±0.0034</td></tr><tr><td>Blurring ()</td><td>0.003±0.002</td><td>0.983±0.009</td><td>1.0±0.000</td><td>0.805±0.123</td></tr><tr><td>Rotation (T)</td><td>1.0±0.000</td><td>1.0±0.004</td><td>0.99±0.015</td><td>1.0±0.000</td></tr><tr><td>Shifting (Z)</td><td>1.0±0.000</td><td>0.989±0.005</td><td>1.0±0.000</td><td>1.0±0.000</td></tr></table>
137
+
138
+ # 5 PERTURBATIONS IN THE FOURIER DOMAIN
139
+
140
+ In this section we provide frequency analysis of our proposed framework and state-of-the-art adversarial formulations. The purpose of this analysis is to provide quantitative evidence that natural perturbations cover a broader concept of robustness than adversarial perturbations alone. In particular, we demonstrate that each natural perturbation has distinctly different effects in the Fourier spectrum, both from other natural corruptions and from adversarial perturbations. Furthermore, we quantify these effects by measuring, for each type of perturbation, the change in total Fourier energy at each spatial frequency level. Aside from outlining our methodology, Section 5 serves the purpose of explaining results obtained in Section 4. In particular, training techniques (e.g. adversarial training) solely focusing on building robustness towards high spatial frequency corruptions become more vulnerable towards corruptions in different band of the spectrum.
141
+
142
+ ![](images/cae3eb783dca1b500f5ec6970823a62f059205060d247c5bbd7e2eb75525bb52.jpg)
143
+ Figure 4: Rows: $\mathcal { F } ( s )$ for BankHeist, $\mathcal { F } ( s )$ for Riverraid. Columns: unperturbed state, Carlini & Wagner, brightness and contrast, blurring, rotation, shifting, perspective transformation, compression artifacts.
144
+
145
+ In Figure 4 we show the Fourier spectrum of the original state $s$ and the perturbed states ${ \boldsymbol { s } } _ { \mathrm { a d v } }$ from our proposed framework based on natural perturbations and Carlini & Wagner (2017) formulated perturbations. In these spectrums the magnitude of the spatial frequencies increases by moving outward from the center, and the center of the image represents the Fourier basis function where spatial frequencies are zero. We provide more detailed description of $\mathcal { F } ( s )$ in Section 2.1. To investigate which type of perturbations occupy which band in the Fourier domain we compute total energy $\mathcal { E } ( f )$ for all basis functions whose maximum spatial frequency is $f$ . Hence, Figure 5 shows the power spectral density of the original state compared to perturbed states computed via components from our proposed natural perturbation framework and Carlini $\&$ Wagner (2017). Figure 5 demonstrates that each component from our natural perturbation framework occupies different bands in the Fourier domain. In particular, in Figure 5 we observe that while the Carlini & Wagner (2017) formulation increases the magnitude of the higher frequencies, compression artifacts decrease the magnitude of the high frequency band. On the other hand, brightness and contrast decreases the magnitude of the low frequency band, and shifting increases the mid-band. Blurring decreases the mid-band and high frequencies together, and perspective transformation decreases the low frequencies and high frequencies while increasing the mid-band.
146
+
147
+ Figure 5 shows that our proposed framework indeed captures a broader set of directions in the frequency domain. Thus, capturing the susceptibilities towards perturbations in different bands of the frequency domain represents a wider notion of robustness compared to only focusing on worstcase distributional shifts.
148
+
149
+ ![](images/0250fd9ab1722285efb853d4454959ce839bb298e8808c9a20b2dd37f13bc988.jpg)
150
+ Figure 5: Riverraid total energy $\mathcal { E } ( f )$ spectrum with various perturbations: Carlini & Wagner, compression artifacts, brightness and contrast, perspective transformation, shifting, rotation.
151
+
152
+ Experimental Details: In our experiments the vanilla trained deep neural policies are trained with Double Deep Q- Network Wang et al. (2016) and the adversarially trained deep neural policy is trained via the theoretically justified State-Adversarial MDP modelled State-Adversarial Double Deep Q-Network (SA-DDQN) (see Section 2.3) in the OpenAI Gym Brockman et al. (2016) Arcade Learning Environment Bellemare et al. (2013). We evaluate several trained policies from Arcade Learning Environment with our proposed framework averaged over 10 episodes. In all of our tables and figures we include the means and the standard error of the mean values. See more details in the appendix.
153
+
154
+ # 6 CONCLUSION
155
+
156
+ In this paper we studied a realistic threat model based on basic environmental changes and proposed a framework to asses the generalization capabilities of deep reinforcement learning policies. We compared our natural perturbation framework with the state-of-the-art adversarial attacks in the Arcade Learning Environment (ALE). We questioned the imperceptibility notion of the $\ell _ { p }$ -norm bounded adversarial perturbations, and demonstrated that the states with minimal natural perturbations are more perceptually similar to the unperturbed states compared to adversarial ones. Moreover, we demonstrated that our framework achieves higher impact on policy performance with lower perceptual similarity distance without having access to the policy training details, real time access to the agent’s memory and perception system, and computationally demanding adversarial formulations to compute simultaneous perturbations. Furthermore, we showed that each component of our framework contains distinct bands in the frequency domain, resulting in a better estimate of the generalization capabilities of trained agents. Most importantly, we investigated state-of-the-art adversarial training methods and found that vanilla trained policies are more robust than adversarially trained policies to minimal natural perturbations. We think that the robustness of the trained deep neural policies should be investigated in a more diverse spectrum and we believe our framework can be instrumental towards generalization and robustification of deep reinforcement learning algorithms.
157
+
158
+ # REFERENCES
159
+
160
+ Marc G Bellemare, Yavar Naddaf, Joel Veness, and Michael. Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research., pp. 253–279, 2013.
161
+
162
+ Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym. arXiv:1606.01540, 2016.
163
+
164
+ Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In 2017 IEEE Symposium on Security and Privacy (SP), pp. 39–57, 2017.
165
+
166
+ Alexey Dosovitsky, German Ros, Felipe Codevilla, Antonio Lopez, and Vladlen Koltun. Carla: An open urban driving simulator. In Proceedings of the Conference on Robot Learning (CoRL), 78: 1–16, 2017.
167
+
168
+ Jiajun Duan, Di Shi, Ruisheng Diao, Haifeng Li, Zhiwei Wang, Bei Zhang, Desong Bian, and Zhehan Yi. Deep-reinforcement-learning-based autonomous voltage control for power grid operations. IEEE Transactions on Power Systems, 35(1):814–817, 2020.
169
+
170
+ Adam Gleave, Michael Dennis, Cody Wild, Kant Neel, Sergey Levine, and Stuart Russell. Adversarial policies: Attacking deep reinforcement learning. International Conference on Learning Representations ICLR, 2020.
171
+
172
+ Ian Goodfellow, Jonathan Shelens, and Christian Szegedy. Explaning and harnessing adversarial examples. International Conference on Learning Representations, 2015.
173
+
174
+ Ji He, Jianshu Chen, Xiaodong He, Jianfeng Gao, Lihong Li, Li Deng, and Mari. Ostendorf. Deep reinforcement learning with a natural language action space. Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, pp. 1621–1630, 2016.
175
+
176
+ Zhang Huan, Hongge Chen, Chaowe Xiao, Bo Li, Mingyan Liu, Duane S. Boning, and ChoJui Hseh. Robust deep renforcement learning against adversaral perturbations on state observations. In Hugo Larochelle, Marc’Aurelo Ranzato, Raia Hadsell, Maria-Florna Balcan, and Hsuan-Tien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
177
+
178
+ Sandy Huang, Nicholas Papernot, Yan Goodfellow, Ian an Duan, and Pieter Abbeel. Adversarial attacks on neural network policies. Workshop Track of the 5th International Conference on Learning Representations, 2017.
179
+
180
+ Forrest N. Iandola, Song Han, Matthew W. Moskewicz, Khalid Ashraf, William J. Dally, and Kurt Keutzer. Squeezenet: Alexnet-level accuracy with 50x fewer parameters and¡ $0 . 5 \mathrm { m b }$ model size. arXiv preprint arXiv:1602.07360, 2016.
181
+
182
+ Natasha Jaques, Shixiang Gu, Dzmitry Bahdanau, Jose Miguel Hern ´ andez-Lobato, Richard ´ E. Turner, and Douglas Eck. Sequence tutor: Conservative fine-tuning of sequence generation models with kl-control. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 1645–1654, 2017.
183
+
184
+ Ezgi Korkmaz. Investigating vulnerabilities of deep neural policies. Conference on Uncertainty in Artificial Intelligence (UAI), 2021.
185
+
186
+ Jernej Kos and Dawn Song. Delving into adversarial attacks on deep policies. International Conference on Learning Representations, 2017.
187
+
188
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 2012.
189
+
190
+ Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial examples in the physical world. arXiv preprint arXiv:1607.02533, 2016.
191
+
192
+ 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. arXivpreprint arXiv:1509.02971, 2015.
193
+
194
+ Yen-Chen Lin, Hong Zhang-Wei, Yuan-Hong Liao, Meng-Li Shih, ing-Yu Liu, and Min Sun. Tactics of adversarial attack on deep reinforcement learning agents. Proceedings of the Twenty-Sixth International Joint Conference on Artificial Intelligence, pp. 3756–3762, 2017.
195
+
196
+ Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018.
197
+
198
+ Ajay Mandlekar, Yuke Zhu, Animesh Garg, Li Fei-Fei, and Silvio Savarese. Adversarially robust policy learning: Active construction of physically-plausible perturbations. In Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 3932–3939, 2017.
199
+
200
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, arc G Bellemare, Alex Graves, Martin Riedmiller, Andreas Fidjeland, Georg Ostrovski, Stig Petersen, Charles Beattie, Amir Sadik, Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra, Shane Legg, and Demis Hassabis. Human-level control through deep reinforcement learning. Nature, 518: 529–533, 2015.
201
+
202
+ Anay Pattanaik, Zhenyi Tang, Shuijing Liu, and Bommannan Gautham. Robust deep reinforcement learning with adversarial attacks. In Proceedings of the 17th International Conference on Autonomous Agents and MultiAgent Systems, pp. 2040–2042, 2018.
203
+
204
+ Tiago Pereira, Maryam Abbasi, Bernardete Ribeiro, and Joel P. Arrais. Diversity oriented deep reinforcement learning for targeted molecule generation. J. Cheminformatics, 13(1): 21, 2021. doi: 10.1186/s13321-021-00498-z. URL https://doi.org/10.1186/ s13321-021-00498-z.
205
+
206
+ Lerrel Pinto, James Davidson, Rahul Sukthankar, and Abhinav Gupta. Robust adversarial reinforcement learning. International Conference on Learning Representations ICLR, 2017.
207
+
208
+ Mariya Popova, Olexandr Isayev, and Alexander. Tropsha. Deep reinforcement learning for de novo drug design. Science advances 4, 78, 2018.
209
+
210
+ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg. Klimov. Proximal policy optimization algorithms. arXiv:1707.06347v2 [cs.LG]., 2017.
211
+
212
+ Karen Simonyan and Andrew. Zisserman. Very deep convolutional networks for large-scale image recognition. International Conference on Learning Representations, ICLR, 2015.
213
+
214
+ Jianwen Sun, Tianwei Zhang, Lei Xiaofei, Xie Ma, Yan Zheng, Kangjie Chen, and Yang. Liu. Stealthy and efficient adversarial attacks against deep reinforcement learning. Association for the Advancement of Artificial Intelligence (AAAI), 2020.
215
+
216
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dimutru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. In Proceedings of the International Conference on Learning Representations (ICLR), 2014.
217
+
218
+ Brijen Thananjeyan, Animesh Garg, Sanjay Krishnan, Carolyn Chen, Lauren Miller, and Ken. Goldberg. Multilateral surgical pattern cutting in 2d orthotropic gauze with deep reinforcement learning policies for tensioning. In 2017 IEEE International Conference on Robotics and Automation (ICRA)., pp. 2371–2378, 2017.
219
+
220
+ Florian Tramer, Alexey Kurakin, Nicolas Papernot, Ian J. Goodfellow, Dan Boneh, and Patrick D. \` McDaniel. Ensemble adversarial training: Attacks and defenses. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018.
221
+
222
+ Yuandou Wang, Hang Liu, Wanbo Zheng, Yunni Xia, Yawen Li, Peng Chen, Kunyin Guo, , and Hong Xie. Multi-objective workflow scheduling with deep-q-network-based multi-agent reinforcement learning. IEEE Access, pp. 39974–39982, 2019.
223
+
224
+ Ziyu Wang, Tom Schaul, Matteo Hessel, Hado Van Hasselt, Marc Lanctot, and Nando. De Freitas. Dueling network architectures for deep reinforcement learning. Internation Conference on Machine Learning ICML., pp. 1995–2003, 2016.
225
+
226
+ Peter Wolf, Christian Hubschneider, Michael Weber, Andre Bauer, Jonathan H ´ artl, Fabian D ¨ urr, and ¨ Marius Zollner J. Learning how to drive in a real world simulation with deep q-networks. ¨ IEEE Intelligent Vehicles Symposium (IV), pp. 244–250, 2017.
227
+
228
+ Cihang Xie and Alan L. Yuille. Intriguing properties of adversarial training at scale. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020.
229
+
230
+ Gregory Yauney and Shah Pratik. Reinforcement learning with action-derived rewards for chemotherapy and clinical trial dosing regimen selection. In Machine Learning for Healthcare Conference, pp. 161–226, 2018.
231
+
232
+ Ning Zhang, Juan Liu, Lingfu Xie, and Peng Tong. A deep reinforcement learning approach to energy-harvesting uav-aided data collection. In 2020 International Conference on Wireless Communications and Signal Processing (WCSP), Nanjing, China, October 21-23, 2020, pp. 93–98. IEEE, 2020.
233
+
234
+ Richard Zhang, Phillip Isola, Alexei Efros, Eli Shechtman, and Oliver. Wang. The unreasonable effectiveness of deep features as a perceptual metric. Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
md/dev/kxXvopt9pWK/kxXvopt9pWK.md ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Denoising Diffusion Restoration Models
2
+
3
+ Bahjat Kawar Department of Computer Science Technion, Haifa, Israel bahjat.kawar@cs.technion.ac.il
4
+
5
+ Michael Elad Department of Computer Science Technion, Haifa, Israel elad@cs.technion.ac.il
6
+
7
+ Stefano Ermon Department of Computer Science Stanford, California, USA ermon@cs.stanford.edu
8
+
9
+ Jiaming Song NVIDIA Santa Clara, California, USA jiamings@nvidia.com
10
+
11
+ # Abstract
12
+
13
+ Many interesting tasks in image restoration can be cast as linear inverse problems. A recent family of approaches for solving these problems uses stochastic algorithms that sample from the posterior distribution of natural images given the measurements. However, efficient solutions often require problem-specific supervised training to model the posterior, whereas unsupervised methods that are not problem-specific typically rely on inefficient iterative methods. This work addresses these issues by introducing Denoising Diffusion Restoration Models (DDRM), an efficient, unsupervised posterior sampling method. Motivated by variational inference, DDRM takes advantage of a pre-trained denoising diffusion generative model for solving any linear inverse problem. We demonstrate DDRM’s versatility on several image datasets for super-resolution, deblurring, inpainting, and colorization under various amounts of measurement noise. DDRM outperforms the current leading unsupervised methods on the diverse ImageNet dataset in reconstruction quality, perceptual quality, and runtime, being $5 \times$ faster than the nearest competitor. DDRM also generalizes well for natural images out of the distribution of the observed ImageNet training set.1
14
+
15
+ # 1 Introduction
16
+
17
+ Many problems in image processing, including super-resolution [31, 17], deblurring [28, 48], inpainting [55], colorization [29, 58], and compressive sensing [1], are instances of linear inverse problems, where the goal is to recover an image from potentially noisy measurements given through a known linear degradation model. For a specific degradation model, image restoration can be addressed through end-to-end supervised training of neural networks, using pairs of original and degraded images [14, 58, 41]. However, real-world applications such as medical imaging often require flexibility to cope with multiple, possibly infinite, degradation models [46]. Here, unsupervised approaches based on learned priors [36], where the degradation model is only known and used during inference, may be more desirable since they can adapt to the given problem without re-training [51]. By learning sound assumptions over the underlying structure of images (e.g., priors, proximal operators or denoisers), unsupervised approaches can achieve effective restoration without training on specific degradation models [51, 40].
18
+
19
+ Under this unsupervised setting, priors based on deep neural networks have demonstrated impressive empirical results in various image restoration tasks [40, 50, 43, 38, 15]. To recover the signal, most existing methods obtain a prior-related term over the signal from a neural network (e.g., the distribution of natural images), and a likelihood term from the degradation model. They combine the two terms to form a posterior over the signal, and the inverse problem can be posed as solving an optimization problem (e.g., maximum a posteriori [8, 40]) or solving a sampling problem (e.g., posterior sampling [2, 3, 25]). Then, these problems are often solved with iterative methods, such as gradient descent or Langevin dynamics, which may be demanding in computation and sensitive to hyperparameter tuning. An extreme example is found in [30] where a “fast” version of the algorithm uses 15, 000 neural function evaluations (NFEs).
20
+
21
+ ![](images/801265c5fb23e87dfcdc53eb65a6f1c2d596bee083cb8985f9b5061490a33f87.jpg)
22
+ Figure 1: Pairs of measurements and recovered images with a 20-step DDRM on super-resolution, deblurring, inpainting, and colorization, with or without noise, and with unconditional generative models. The images are not accessed during training.
23
+
24
+ Inspired by this unsupervised line of work, we introduce an efficient approach named Denoising Diffusion Restoration Models (DDRM), that can achieve competitive results in as low as 20 NFEs. DDRM is a denoising diffusion generative model [44, 19, 45] that gradually and stochastically denoises a sample to the desired output, conditioned on the measurements and the inverse problem. This way we introduce a variational inference objective for learning the posterior distribution of the inverse problem at hand. We then show its equivalence to the objective of an unconditional denoising diffusion generative model [19], which enables us to deploy such models in DDRM for various linear inverse problems (see Figure 2). To our best knowledge, DDRM is the first general sampling-based inverse problem solver that can efficiently produce a range of high-quality, diverse, yet valid solutions for general content images.
25
+
26
+ We demonstrate the empirical effectiveness of DDRM by comparing with various competitive methods based on learned priors, such as Deep Generative Prior (DGP) [38], SNIPS [25], and Regularization by Denoising (RED) [40]. On ImageNet examples, DDRM mostly outperforms the neural network baselines under noiseless super-resolution and deblurring measured in PSNR and KID [5], and is at least $5 0 \times$ more efficient in terms of NFEs when it is second-best. Our advantage becomes even larger when measurement noise is involved, as noisy artifacts produced by iterative methods do not appear in our case. Over various real-world images, we further show DDRM results on super-resolution, deblurring, inpainting and colorization (see Figure 1). A DDRM trained on ImageNet also works on images that are out of its training set distribution (see Figure 6).
27
+
28
+ # 2 Background
29
+
30
+ Linear Inverse Problems. A general linear inverse problem is posed as
31
+
32
+ $$
33
+ { \bf { y } } = { \cal H } { \bf { x } } + { \bf { z } } ,
34
+ $$
35
+
36
+ where we aim to recover the signal $\mathbf { x } \in \mathbb { R } ^ { n }$ from measurements $\mathbf { y } \in \mathbb { R } ^ { m }$ , where $\pmb { H } \in \mathbb { R } ^ { m \times n }$ is a known linear degradation matrix, and $\mathbf { z } \sim \mathcal { N } ( 0 , \sigma _ { \mathbf { y } } ^ { 2 } I )$ is an i.i.d. additive Gaussian noise with known variance. The underlying structure of $\mathbf { x }$ can be represented via a generative model, denoted as $p _ { \theta } ( \mathbf { x } )$ . Given $\mathbf { y }$ and $\pmb { H }$ , a posterior over the signal can be posed as: $p _ { \boldsymbol { \theta } } ( \mathbf { x } | \mathbf { y } ) \propto p _ { \boldsymbol { \theta } } ( \mathbf { x } ) p ( \mathbf { y } | \mathbf { x } )$ , where the “likelihood” term $p ( \mathbf { y } \vert \mathbf { x } )$ is defined via Equation (1); such an approach leverages a learned prior $p _ { \theta } ( \mathbf { x } )$ , and we call it an “unsupervised” approach based on the terminology in [36], as the prior does not necessarily depend on the inverse problem. Recovering $\mathbf { x }$ can be done by sampling from this posterior [2], which may require many iterations to produce a good sample. Alternatively, one can also approximate this posterior by learning a model via amortized inference (i.e., supervised learning); the model learns to predict $\mathbf { x }$ given y, generated from $\mathbf { x }$ and a specific $\pmb { H }$ . While this can be more efficient than sampling-based methods, it may generalize poorly to inverse problems that have not been trained on.
37
+
38
+ ![](images/3b8223ff3635bca0230fef513f42439b878155e66e5927dbf70c34d1b20a1fda.jpg)
39
+ Figure 2: Illustration of our DDRM method for a specific inverse problem (super-resolution $^ +$ denoising). We can use unsupervised DDPM models as a good solution to the DDRM objective.
40
+
41
+ Denoising Diffusion Probabilistic Models. Structures learned by generative models have been applied to various inverse problems and often outperform data-independent structural constraints such as sparsity [7]. These generative models learn a model distribution $p _ { \theta } ( \mathbf { x } )$ that approximates a data distribution $q ( \mathbf { x } )$ from samples. In particular, diffusion models have demonstrated impressive unconditional generative modeling performance on images [13]. Diffusion models are generative models with a Markov chain structure ${ \bf x } _ { T } \to { \bf x } _ { T - 1 } \to { \bf . . . } \to { \bf x } _ { 1 } \to { \bf x } _ { 0 }$ (where $\mathbf { x } _ { t } \in \mathbb { R } ^ { n }$ ), which has the following joint distribution:
42
+
43
+ $$
44
+ p _ { \theta } ( \mathbf { x } _ { 0 : T } ) = p _ { \theta } ^ { ( T ) } ( \mathbf { x } _ { T } ) \prod _ { t = 0 } ^ { T - 1 } p _ { \theta } ^ { ( t ) } ( \mathbf { x } _ { t } | \mathbf { x } _ { t + 1 } ) .
45
+ $$
46
+
47
+ After drawing $\mathbf { x } _ { \mathrm { 0 : } T }$ , only $\mathbf { x } _ { \mathrm { 0 } }$ is kept as the sample of the generative model. To train a diffusion model, a fixed, factorized variational inference distribution is introduced:
48
+
49
+ $$
50
+ q ( \mathbf { x } _ { 1 : T } | \mathbf { x } _ { 0 } ) = q ^ { ( T ) } ( \mathbf { x } _ { T } | \mathbf { x } _ { 0 } ) \prod _ { t = 0 } ^ { T - 1 } q ^ { ( t ) } ( \mathbf { x } _ { t } | \mathbf { x } _ { t + 1 } , \mathbf { x } _ { 0 } ) ,
51
+ $$
52
+
53
+ which leads to an evidence lower bound (ELBO) on the maximum likelihood objective [44]. A special property of some diffusion models is that both $p _ { \theta } ^ { ( t ) }$ and $q ^ { ( t ) }$ are chosen as conditional Gaussian distributions for all $t < T$ , and that $q ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 } )$ is also a Gaussian with known mean and covariance, i.e., $\mathbf { x } _ { t }$ can be treated as $\mathbf { x } _ { \mathrm { 0 } }$ directly corrupted with Gaussian noise. Thus, the ELBO objective can be reduced into the following denoising autoencoder objective (please refer to [45] for derivations):
54
+
55
+ $$
56
+ \sum _ { t = 1 } ^ { T } \gamma _ { t } \mathbb { E } _ { ( \mathbf { x } _ { 0 } , \mathbf { x } _ { t } ) \sim q ( \mathbf { x } _ { 0 } ) q ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 } ) } \left[ \big \lVert \mathbf { x } _ { 0 } - f _ { \theta } ^ { ( t ) } ( \mathbf { x } _ { t } ) \big \rVert _ { 2 } ^ { 2 } \right]
57
+ $$
58
+
59
+ where $f _ { \theta } ^ { ( t ) }$ is a $\theta$ -parameterized neural network that aims to recover a noiseless observation from a noisy $\mathbf { x } _ { t }$ , and $\gamma _ { 1 : T }$ are a set of positive coefficients that depend on $q \big ( \mathbf { x } _ { 1 : T } | \mathbf { x } _ { 0 } \big )$ .
60
+
61
+ # 3 Denoising Diffusion Restoration Models
62
+
63
+ Inverse problem solvers based on posterior sampling often face a dilemma: unsupervised approaches apply to general problems but are inefficient, whereas supervised ones are efficient but can only address specific problems.
64
+
65
+ To solve this dilemma, we introduce Denoising Diffusion Restoration Models (DDRM), an unsupervised solver for general linear inverse problems, capable of handling such tasks with or without noise in the measurements. DDRM is efficient and exhibits competitive performance compared to popular unsupervised solvers [40, 38, 25].
66
+
67
+ The key idea behind DDRM is to find an unsupervised solution that also suits supervised learning objectives. First, we describe the variational objective for DDRM over a specific inverse problem (Section 3.1). Next, we introduce specific forms of DDRM that are suitable for linear inverse problems and allow pre-trained unconditional and class-conditional diffusion models to be used directly (Sections 3.2, 3.3). Finally, we discuss practical algorithms that are compute and memory efficient (Sections 3.4, 3.5).
68
+
69
+ # 3.1 Variational Objective for DDRM
70
+
71
+ For any linear inverse problem, we define DDRM as a Markov chain ${ \bf x } _ { T } \to { \bf x } _ { T - 1 } \to { \bf . . . } \to { \bf x } _ { 1 } \to { \bf x } _ { 0 }$ conditioned on $\mathbf { y }$ , where
72
+
73
+ $$
74
+ p _ { \theta } ( \mathbf { x } _ { 0 : T } | \mathbf { y } ) = p _ { \theta } ^ { ( T ) } ( \mathbf { x } _ { T } | \mathbf { y } ) \prod _ { t = 0 } ^ { T - 1 } p _ { \theta } ^ { ( t ) } ( \mathbf { x } _ { t } | \mathbf { x } _ { t + 1 } , \mathbf { y } )
75
+ $$
76
+
77
+ and $\mathbf { x } _ { \mathrm { 0 } }$ is the final diffusion output. In order to perform inference, we consider the following factorized variational distribution conditioned on y:
78
+
79
+ $$
80
+ q ( \mathbf { x } _ { 1 : T } | \mathbf { x } _ { 0 } , \mathbf { y } ) = q ^ { ( T ) } ( \mathbf { x } _ { T } | \mathbf { x } _ { 0 } , \mathbf { y } ) \prod _ { t = 0 } ^ { T - 1 } q ^ { ( t ) } ( \mathbf { x } _ { t } | \mathbf { x } _ { t + 1 } , \mathbf { x } _ { 0 } , \mathbf { y } ) ,
81
+ $$
82
+
83
+ leading to an ELBO objective for diffusion models conditioned on $\mathbf { y }$ (details in Appendix A).
84
+
85
+ In the remainder of the section, we construct suitable variational problems given $\pmb { H }$ and $\sigma _ { \mathbf { y } }$ and connect them to unconditional diffusion generative models. To simplify notations, we will construct the variational distribution $q$ such that $\bar { q } ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 } ) = \mathcal { N } ( \mathbf { x } _ { 0 } , \sigma _ { t } ^ { 2 } I )$ for noise levels $0 = \sigma _ { 0 } < \sigma _ { 1 } <$ $\sigma _ { 2 } < . . . < \sigma _ { T }$ .2 In Appendix B, we will show that this is equivalent to the distribution introduced in DDPM [19] and DDIM [45],3 up to fixed linear transformations over $\mathbf { x } _ { t }$ .
86
+
87
+ # 3.2 A Diffusion Process for Image Restoration
88
+
89
+ Similar to SNIPS [25], we consider the singular value decomposition (SVD) of $\pmb { H }$ , and perform the diffusion in its spectral space. The idea behind this is to tie the noise present in the measurements $\mathbf { y }$ with the diffusion noise in $\mathbf { x } _ { 1 : T }$ , ensuring that the diffusion result $\mathbf { x } _ { \mathrm { 0 } }$ is faithful to the measurements. By using the SVD, we identify the data from $\mathbf { x }$ that is missing in y, and synthesize it using a diffusion process. In conjunction, the noisy data in y undergoes a denoising process. For example, in inpainting with noise (e.g., $\pmb { H } = \mathrm { d i a g } ( [ 1 , \dots , 1 , 0 , \dots , 0 ] )$ , $\sigma _ { \mathbf { y } } \geq 0 $ ), the spectral space is simply the pixel space, so the model should generate the missing pixels and denoise the observed ones in y. For a general linear $\pmb { H }$ , its SVD is given as
90
+
91
+ $$
92
+ \pmb { H } = \pmb { U } \pmb { \Sigma V } ^ { \top }
93
+ $$
94
+
95
+ where $\pmb { U } \in \mathbb { R } ^ { m \times m }$ , $V \in \mathbb { R } ^ { n \times n }$ are orthogonal matrices, and $\pmb { \Sigma } \in \mathbb { R } ^ { m \times n }$ is a rectangular diagonal matrix containing the singular values of $\pmb { H }$ , ordered descendingly. As this is the case in most useful degradation models, we assume $m \leq n$ , but our method would work for $m > n$ as well. We denote the singular values as $s _ { 1 } \geq s _ { 2 } \geq . . . \geq s _ { m }$ , and define $s _ { i } = 0$ for $i \in [ m + 1 , n ]$ .
96
+
97
+ We use the shorthand notations for values in the spectral space: $\bar { \mathbf { x } } _ { t } ^ { ( i ) }$ is the $i$ -th index of the vector $\bar { \bf x } _ { t } =$ $V ^ { \top } \mathbf { x } _ { t }$ , and $\bar { \mathbf { y } } ^ { ( i ) }$ is the $i$ -th index of the vector $\bar { \mathbf { y } } = \pmb { \Sigma } ^ { \dagger } \pmb { U } ^ { \top } \mathbf { y }$ (where $\dagger$ denotes the Moore–Penrose pseudo-inverse). Because $V$ is an orthogonal matrix, we can recover $\mathbf { x } _ { t }$ from $\bar { \mathbf { x } } _ { t }$ exactly by left multiplying $V$ . For each index $i$ in $\bar { \mathbf { x } } _ { t }$ , we define the variational distribution as:
98
+
99
+ $$
100
+ \begin{array} { r l } & { \quad q ^ { ( T ) } ( \bar { \mathbf { x } } _ { T } ^ { ( i ) } | \mathbf { x } _ { 0 } , \mathbf { y } ) = \left\{ \begin{array} { l l } { \mathcal { N } ( \bar { \mathbf { y } } ^ { ( i ) } , \sigma _ { T } ^ { 2 } - \frac { \sigma _ { y } ^ { 2 } } { s _ { i } ^ { 2 } } ) } & { \mathrm { i f ~ } s _ { i } > 0 } \\ { \mathcal { N } ( \bar { \mathbf { x } } _ { 0 } ^ { ( i ) } , \sigma _ { T } ^ { 2 } ) } & { \mathrm { i f ~ } s _ { i } = 0 } \end{array} \right. } \\ & { \quad q ^ { ( t ) } ( \bar { \mathbf { x } } _ { t } ^ { ( i ) } | \mathbf { x } _ { t + 1 } , \bar { \mathbf { x } } _ { 0 } ^ { ( \bar { \mathbf { \alpha } } ) } , \mathbf { y } ) = \left\{ \begin{array} { l l } { \mathcal { N } ( \bar { \mathbf { x } } _ { 0 } ^ { ( i ) } + \sqrt { 1 - \eta ^ { 2 } } \sigma _ { t } \frac { \bar { \mathbf { x } } _ { t + 1 } ^ { ( i ) } - \bar { \mathbf { x } } _ { 0 } ^ { ( i ) } } { \sigma _ { t + 1 } } , \eta ^ { 2 } \sigma _ { t } ^ { 2 } ) } & { \mathrm { i f ~ } s _ { i } = 0 } \\ { \mathcal { N } ( \bar { \mathbf { x } } _ { 0 } ^ { ( i ) } + \sqrt { 1 - \eta ^ { 2 } } \sigma _ { t } \frac { \bar { \mathbf { y } } ^ { ( i ) } - \bar { \mathbf { x } } _ { 0 } ^ { ( i ) } } { \sigma _ { y } / s _ { i } } , \eta ^ { 2 } \sigma _ { t } ^ { 2 } ) } & { \mathrm { i f ~ } \sigma _ { t } < \frac { \sigma _ { \mathbf { y } } } { s _ { i } } } \\ { \mathcal { N } ( ( 1 - \eta _ { b } ) \bar { \mathbf { x } } _ { 0 } ^ { ( i ) } + \eta _ { b } \bar { \mathbf { y } } ^ { ( i ) } , \sigma _ { t } ^ { 2 } - \frac { \sigma _ { \mathbf { y } } ^ { 2 } } { s _ { i } ^ { 2 } } \eta _ { b } ^ { 2 } ) } & { \mathrm { i f ~ } \sigma _ { t } \ge \frac { \sigma _ { \mathbf { y } } } { s _ { i } } } \end{array} \right. } \end{array}
101
+ $$
102
+
103
+ where $\eta \in ( 0 , 1 ]$ is a hyperparameter controlling the variance of the transitions, and $\eta$ and $\eta _ { b }$ may depend on $\sigma _ { t } , s _ { i } , \sigma _ { \mathbf { y } }$ . We further assume that $\sigma _ { T } \geq \sigma _ { \mathbf { y } } / s _ { i }$ for all positive $s _ { i }$ .4
104
+
105
+ In the following statement, we show that this construction has the “Gaussian marginals” property similar to the inference distribution used in unconditional diffusion models [19].
106
+
107
+ Proposition 3.1. The conditional distributions $q ^ { ( t ) }$ defined in Equations 4 and 5 satisfy the following:
108
+
109
+ $$
110
+ q ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 } ) = \mathcal { N } ( \mathbf { x } _ { 0 } , \sigma _ { t } ^ { 2 } \pmb { I } ) ,
111
+ $$
112
+
113
+ defined by marginalizing over $\mathbf { x } _ { t ^ { \prime } }$ (for all $t ^ { \prime } > t$ ) and y, where $q ( \mathbf { y } \vert \mathbf { x } _ { 0 } )$ is defined as in Equation (1) with $\mathbf { x } = \mathbf { x } _ { 0 }$ .
114
+
115
+ We place the proof in Appendix C. Intuitively, our construction considers different cases for each index of the spectral space. $( i )$ If the corresponding singular value is zero, then y does not directly provide any information to that index, and the update is similar to regular unconditional generation. $( i i )$ If the singular value is non-zero, then the updates consider the information provided by $\mathbf { y }$ , which further depends on whether the measurements’ noise level in the spectral space $( \sigma _ { \mathbf { y } } / s _ { i } )$ is larger than the noise level in the diffusion model $( \sigma _ { t } )$ or not; the measurements in the spectral space $\bar { \mathbf { y } } ^ { ( i ) }$ are then scaled differently for these two cases in order to ensure Proposition 3.1 holds.
116
+
117
+ Now that we have defined $q ^ { ( t ) }$ as a series of Gaussian conditionals, we define our model distribution $p _ { \theta }$ as a series of Gaussian conditionals as well. Similar to DDPM, we aim to obtain predictions of $\mathbf { x } _ { \mathrm { 0 } }$ at every step $t$ ; and to simplify notations, we use the symbol $\mathbf { x } _ { \theta , t }$ to represent this prediction made by a model5 $f _ { \theta } ( \mathbf { x } _ { t + 1 } , t + 1 ) : \mathbb { R } ^ { n } \times \mathbb { R } \to \mathbb { R } ^ { n }$ that takes in the sample $\mathbf { x } _ { t + 1 }$ and the conditioned time step $( t + 1 )$ . We also define $\bar { \mathbf { x } } _ { \theta , t } ^ { ( i ) }$ as the $i$ -th index of $\bar { \mathbf { x } } _ { \theta , t } = { \mathbf { \nabla } } V ^ { \top } \mathbf { x } _ { \theta , t }$ .
118
+
119
+ We define DDRM with trainable parameters $\theta$ as follows:
120
+
121
+ $$
122
+ \begin{array} { r } { p _ { \theta } ^ { ( T ) } ( \bar { \mathbf { x } } _ { T } ^ { ( i ) } | \mathbf { y } ) = \left\{ \begin{array} { l l } { \mathcal { N } ( \bar { \mathbf { y } } ^ { ( i ) } , \sigma _ { T } ^ { 2 } - \frac { \sigma _ { y } ^ { 2 } } { s _ { i } ^ { 2 } } ) } & { \mathrm { i f ~ } s _ { i } > 0 } \\ { \mathcal { N } ( 0 , \sigma _ { T } ^ { 2 } ) } & { \mathrm { i f ~ } s _ { i } = 0 } \end{array} \right. } \\ { p _ { \theta } ^ { ( t ) } ( \bar { \mathbf { x } } _ { t } ^ { ( i ) } | \mathbf { x } _ { t + 1 } , \mathbf { y } ) = \left\{ \begin{array} { l l } { \mathcal { N } ( \bar { \mathbf { x } } _ { \theta , t } ^ { ( i ) } + \sqrt { 1 - \eta ^ { 2 } } \sigma _ { t } \frac { \bar { \mathbf { x } } _ { t + 1 } ^ { ( i ) } - \bar { \mathbf { x } } _ { \theta , t } ^ { ( i ) } } { \sigma _ { t + 1 } } , \eta ^ { 2 } \sigma _ { t } ^ { 2 } ) } & { \mathrm { i f ~ } s _ { i } = 0 } \\ { \mathcal { N } ( \bar { \mathbf { x } } _ { \theta , t } ^ { ( i ) } + \sqrt { 1 - \eta ^ { 2 } } \sigma _ { t } \frac { \bar { \mathbf { y } } ^ { ( i ) } - \bar { \mathbf { x } } _ { \theta , t } ^ { ( i ) } } { \sigma _ { y } / s _ { i } } , \eta ^ { 2 } \sigma _ { t } ^ { 2 } ) } & { \mathrm { i f ~ } \sigma _ { t } < \frac { \sigma _ { \mathbf { y } } } { s _ { i } } } \\ { \mathcal { N } ( ( 1 - \eta _ { b } ) \bar { \mathbf { x } } _ { \theta , t } ^ { ( i ) } + \eta _ { b } \bar { \mathbf { y } } ^ { ( i ) } , \sigma _ { t } ^ { 2 } - \frac { \sigma _ { y } ^ { 2 } } { s _ { i } ^ { 2 } } \eta _ { b } ^ { 2 } ) } & { \mathrm { i f ~ } \sigma _ { t } \ge \frac { \sigma _ { \mathbf { y } } } { s _ { i } } . } \end{array} \right. } \end{array}
123
+ $$
124
+
125
+ Compared to $q ^ { ( t ) }$ in Equations (4) and (5), our definition of $p _ { \theta } ^ { ( t ) }$ merely replaces $\bar { \mathbf { x } } _ { 0 } ^ { ( i ) }$ (which we do not know at sampling) with $\bar { \mathbf { x } } _ { \theta , t } ^ { ( i ) }$ (which depends on our predicted $\mathbf { x } _ { \theta , t }$ ) when $t < T$ , and replaces $\bar { \mathbf { x } } _ { 0 } ^ { ( i ) }$ with 0 when $t = T$ . It is possible to learn the variances [35] or consider alternative constructions where Proposition 3.1 holds; we leave these options as future work.
126
+
127
+ # 3.3 “Learning” Image Restoration Models
128
+
129
+ Once we have defined $p _ { \theta } ^ { ( t ) }$ and $q ^ { ( t ) }$ by choosing $\sigma _ { 1 : T }$ , $\eta$ and $\eta _ { b }$ , we can learn model parameters $\theta$ by maximizing the resulting ELBO objective (in Appendix A). However, this approach is not desirable since we have to learn a different model for each inverse problem (given $\pmb { H }$ and $\sigma _ { \mathbf { y } } .$ ), which is not flexible enough for arbitrary inverse problems. Fortunately, this does not have to be the case. In the following statement, we show that an optimal solution to DDPM / DDIM can also be an optimal solution to a DDRM problem, under reasonable assumptions used in prior work [19, 45].
130
+
131
+ ![](images/81bc643d694333d66b6dd90380745687282edff4eb6ea14cd668b967ec261af4.jpg)
132
+ Figure 3: DDRM results on bedroom and cat images, for inpainting and deblurring.
133
+
134
+ Theoremthen when ssumand els , th $f _ { \theta } ^ { ( t ) }$ and BO $f _ { \theta } ^ { ( t ^ { \prime } ) }$ do not have weight sharing whenetive of DDRM (details in Appendix r ) $t \neq t ^ { \prime }$ η = 1 η b = 2 σ tσ 2t +σ 2y /s 2i $A$ rewritten in the form of the DDPM / DDIM objective in Equation (2).
135
+
136
+ We place the proof in Appendix C.
137
+
138
+ Even for different choices of $\eta$ and $\eta _ { b }$ , the proof shows that the DDRM objective is a weighted sumof-squares error in the spectral space, and thus pre-trained DDPM models are good approximations to the optimal solution. Therefore, we can apply the same diffusion model (unconditioned on the inverse problem) using the updates in Equation (7) and Equation (8) and only modify $\pmb { H }$ and its SVD $( U , \Sigma , V )$ for various linear inverse problems.
139
+
140
+ # 3.4 Accelerated Algorithms for DDRM
141
+
142
+ Typical diffusion models are trained with many timesteps (e.g., 1000) to achieve optimal unconditional image synthesis quality, but sampling speed is slow as many NFEs are required. Previous works [45, 13] have accelerated this process by “skipping” steps with appropriate update rules. This is also true for DDRM, since we can obtain the denoising autoencoder objective in Equation (2) for any choice of increasing $\sigma _ { 1 : T }$ . For a pre-trained diffusion model with $T ^ { \prime }$ timesteps, we can choose $\sigma _ { 1 : T }$ to be a subset of the $T ^ { \prime }$ steps used in training.
143
+
144
+ # 3.5 Memory Efficient SVD
145
+
146
+ Our method, similar to SNIPS [25], utilizes the SVD of the degradation operator $\pmb { H }$ . This constitutes a memory consumption bottleneck in both algorithms as well as other methods such as Plug and Play $( \mathrm { P n P } )$ [51], as storing the matrix $V$ has a space complexity of $\Theta ( n ^ { 2 } )$ for signals of size $n$ . By leveraging special properties of the matrices $\pmb { H }$ used, we can reduce this complexity to $\Theta ( n )$ for denoising, inpainting, super resolution, deblurring, and colorization (details in Appendix D).
147
+
148
+ # 4 Related Work
149
+
150
+ Various deep learning solutions have been suggested for solving inverse problems under different settings (see a detailed survey in [37]). We focus on the unsupervised setting, where we have access to a dataset of clean images at training time, but the degradation model is known only at inference time. This setup is inherently general to all linear inverse problems, a property desired in many real-world applications such as medical imaging [46, 20].
151
+
152
+ Table 1: Noiseless $4 \times$ super-resolution and deblurring results on ImageNet 1K $( 2 5 6 \times 2 5 6 )$ .
153
+
154
+ <table><tr><td>Method</td><td colspan="4">4× super-resolution</td><td colspan="4">Deblurring</td></tr><tr><td></td><td>PSNR↑</td><td>SSIM↑</td><td>KID↓</td><td>NFEs↓</td><td>PSNR↑</td><td>SSIM个</td><td>KID↓</td><td>NFEs↓</td></tr><tr><td>Baseline</td><td>25.65</td><td>0.71</td><td>44.90</td><td>0</td><td>19.26</td><td>0.48</td><td>38.00</td><td>0</td></tr><tr><td>DGP</td><td>23.06</td><td>0.56</td><td>21.22</td><td>1500</td><td>22.70</td><td>0.52</td><td>27.60</td><td>1500</td></tr><tr><td>RED</td><td>26.08</td><td>0.73</td><td>53.55</td><td>100</td><td>26.16</td><td>0.76</td><td>21.21</td><td>500</td></tr><tr><td>SNIPS</td><td>17.58</td><td>0.22</td><td>35.17</td><td>1000</td><td>34.32</td><td>0.87</td><td>0.49</td><td>1000</td></tr><tr><td>DDRM</td><td>26.55</td><td>0.72</td><td>7.22</td><td>20</td><td>35.64</td><td>0.95</td><td>0.71</td><td>20</td></tr><tr><td>DDRM-CC</td><td>26.55</td><td>0.74</td><td>6.56</td><td>20</td><td>35.65</td><td>0.96</td><td>0.70</td><td>20</td></tr></table>
155
+
156
+ Almost all unsupervised inverse problem solvers utilize a trained neural network in an iterative scheme. PnP, RED, and their successors [51, 40, 32, 49] apply a denoiser as part of an iterative optimization algorithm such as steepest descent, fixed-point, or alternating direction method of multipliers (ADMM). OneNet [39] trained a network to directly learn the proximal operator of ADMM. A similar use of denoisers in different iterative algorithms is proposed in [34, 16, 30]. The authors of [43] leverages robust classifiers learned with additional class labels.
157
+
158
+ Another approach is to search the latent space of a generative model for a generated image that, when degraded, is as close as possible to the given measurements. Multiple such methods were suggested, mainly focusing on generative adversarial networks (GANs) [7, 11, 33]. While they exhibit impressive results on images of a specific class, most notably face images, these methods are not shown to be largely successful under a more diverse dataset such as ImageNet [12]. Deep Generative Prior (DGP) mitigates this issue by optimizing the latent input as well as the weights of the GAN’s generator [38].
159
+
160
+ More recently, denoising diffusion models were used to solve inverse problems in both supervised (i.e., degradation model is known during training) [42, 41, 13, 10, 54] and unsupervised settings [22, 26, 25, 21, 46, 47, 9]. Unlike previous approaches, most diffusion-based methods can successfully recover images from measurements with significant noise. However, these methods are very slow, often requiring hundreds or thousands of iterations, and are yet to be proven on diverse datasets. Our method, motivated by variational inference, obtains problem-specific, non-equilibrium update rules that lead to high-quality solutions in much fewer iterations.
161
+
162
+ ILVR [9] suggests a diffusion-based method that handles noiseless super-resolution, and can run in 250 steps. In Appendix H, we prove that when applied on the same underlying generative diffusion model, ILVR is a special case of DDRM. Therefore, ILVR can be further accelerated to run in 20 steps, but unlike DDRM, it provides no clear way of handling noise in the measurements. Similarly, the authors of [22] suggest a score-based solver for inverse problems that can converge in a small number of iterations, but does not handle noise in the measurements.
163
+
164
+ # 5 Experiments
165
+
166
+ # 5.1 Experimental Setup
167
+
168
+ We demonstrate our algorithm’s capabilities using the diffusion models from [19], which are trained on CelebA-HQ [23], LSUN bedrooms, and LSUN cats [56] (all $2 5 6 \times 2 5 6$ pixels). We test these models on images from FFHQ [24], and pictures from the internet of the considered LSUN category, respectively. In addition, we use the models from [13], trained on the training set of ImageNet $2 5 6 \times 2 5 6$ and $5 1 2 \times 5 1 2$ , and tested on the corresponding validation set. Some of the ImageNet models require class information. For these models, we use the ground truth labels as input, and denote our algorithm as DDRM class conditional (DDRM-CC). In all experiments, we use $\eta = 0 . 8 5$ , $\eta _ { b } = 1$ , and a uniformly-spaced timestep schedule based on the 1000-step pre-trained models (more details in Appendix E). The number of NFEs (timesteps) is reported in each experiment.
169
+
170
+ In each of the inverse problems we show, pixel values are in the range $[ 0 , 1 ]$ , and the degraded measurements are obtained as follows: $( i )$ for super-resolution, we use a block averaging filter to downscale the images by a factor of 2, 4, or 8 in each axis; $( i i )$ for deblurring, the images are blurred by a $9 \times 9$ uniform kernel, and singular values below a certain threshold are zeroed, making the problem more ill-posed. (iii) for colorization, the grayscale image is an average of the red, green, and blue channels of the original image; $( i \nu )$ and for inpainting, we mask parts of the original image with text overlay or randomly drop $5 0 \%$ of the pixels. Additive white Gaussian noise can optionally be added to the measurements in all inverse problems. We additionally conduct experiments on bicubic super-resolution and deblurring with an anisotropic Gaussian kernel in Appendix I.
171
+
172
+ Table 2: $4 \times$ super resolution and deblurring results on ImageNet 1K $2 5 6 \times 2 5 6 )$ . Input images have an additive noise of $\sigma _ { \mathbf { y } } = 0 . 0 5$ .
173
+
174
+ <table><tr><td rowspan="2">Method</td><td colspan="4">4× super-resolution</td><td colspan="4">Deblurring</td></tr><tr><td>PSNR↑</td><td>SSIM↑</td><td>KID↓</td><td>NFEs↓</td><td>PSNR↑</td><td>SSIM↑</td><td>KID↓</td><td>NFEs↓</td></tr><tr><td>Baseline</td><td>22.55</td><td>0.46</td><td>67.86</td><td>0</td><td>18.35</td><td>0.20</td><td>75.50</td><td>0</td></tr><tr><td>DGP</td><td>20.69</td><td>0.43</td><td>42.17</td><td>1500</td><td>21.20</td><td>0.45</td><td>34.02</td><td>1500</td></tr><tr><td>RED</td><td>22.90</td><td>0.49</td><td>43.45</td><td>100</td><td>14.69</td><td>0.08</td><td>121.82</td><td>500</td></tr><tr><td>SNIPS</td><td>16.30</td><td>0.14</td><td>67.77</td><td>1000</td><td>16.37</td><td>0.14</td><td>77.96</td><td>1000</td></tr><tr><td>DDRM</td><td>25.21</td><td>0.66</td><td>12.43</td><td>20</td><td>25.45</td><td>0.66</td><td>15.24</td><td>20</td></tr><tr><td>DDRM-CC</td><td>25.22</td><td>0.67</td><td>10.82</td><td>20</td><td>25.46</td><td>0.67</td><td>13.49</td><td>20</td></tr></table>
175
+
176
+ ![](images/dce0cb2c19799418bd2c994aecc71852b76f94b87d29b39bfca92e3ac67a7dc4.jpg)
177
+ Figure 4: $4 \times$ noisy super resolution comparison with $\sigma _ { \mathbf { y } } = 0 . 0 5$ .
178
+
179
+ Our code is available at https://github.com/bahjat-kawar/ddrm.
180
+
181
+ # 5.2 Quantitative Experiments
182
+
183
+ In order to quantify DDRM’s performance, we focus on the ImageNet dataset $2 5 6 \times 2 5 6 )$ for its diversity. For each experiment, we report the average peak signal-to-noise ratio (PSNR) and structural similarity index measure (SSIM) [52] to measure faithfulness to the original image, and the kernel Inception distance (KID) [5], multiplied by $1 0 ^ { 3 }$ , to measure the resulting image quality.
184
+
185
+ We compare DDRM (with 20 and 100 steps) with other unsupervised methods that work in reasonable time (requiring 1500 NFEs or less) and can operate on ImageNet. Namely, we compare with RED [40], DGP [38], and SNIPS [25]. The exact setup of each method is detailed in Appendix F. We used the same hyperparameters for noisy and noiseless versions of the same problem for DGP, RED, and SNIPS, as tuning them for each version would compromise their unsupervised nature. Nevertheless, the performance of baselines like RED with such a tuning does not surpass that of DDRM, as we show in Appendix F. In addition, we show upscaling by bicubic interpolation as a baseline for super-resolution, and the blurry image itself as a baseline for deblurring. OneNet [39] is not included in the comparisons as it is limited to images of size $6 4 \times 6 4$ , and generalization to higher dimensions requires an improved network architecture.
186
+
187
+ ![](images/c29b6e70f49e93bec3f7d31839a85160b2b005e20acbf20e9617bb3c256f753b.jpg)
188
+ Figure 5: $5 1 2 \times 5 1 2$ ImageNet colorization. DDRM-CC produces various samples for multiple runs on the same input.
189
+
190
+ ![](images/677dbd46569b00f85565e6a7598555e2ec90d1684b5b06b3a221943f2f16443d.jpg)
191
+ Figure 6: Results on $2 5 6 \times 2 5 6$ USC-SIPI images using an ImageNet model. Blurred images have a noise of $\sigma _ { \mathbf { y } } = 0 . 0 1$ .
192
+
193
+ We evaluate all methods on the problems of $4 \times$ super-resolution and deblurring, on one validation set image from each of the 1000 ImageNet classes, following [38]. Table 1 shows that DDRM outperforms all baseline methods, in all metrics, and on both problems with only 20 steps. The only exception to this is that SNIPS achieves better KID than DDRM in noiseless deblurring, but it requires $5 0 \times$ more NFEs to do so. Note that the runtime of all the tested methods is perfectly linear with NFEs, with negligible differences in time per iteration. DGP and DDRM-CC use ground-truth class labels for the test images to aid in the restoration process, and thus have an unfair advantage.
194
+
195
+ DDRM’s appeal compared to previous methods becomes more substantial when significant noise is added to the measurements. Under this setting, DGP, RED, and SNIPS all fail to produce viable results, as evident in Table 2 and Figure 4. Since DDRM is fast, we also evaluate it on the entire ImageNet validation set in Appendix F.
196
+
197
+ # 5.3 Qualitative Experiments
198
+
199
+ DDRM produces high quality reconstructions across all the tested datasets and problems, as can be seen in Figures 1 and 3, and in Appendix I. As it is a posterior sampling algorithm, DDRM can produce multiple outputs for the same input, as demonstrated in Figure 5. Moreover, the unconditional ImageNet diffusion models can be used to solve inverse problems on out-of-distribution images with general content. In Figure 6, we show DDRM successfully restoring $2 5 6 \times 2 5 6$ images from USC-SIPI [53] that do not necessarily belong to any ImageNet class (more results in Appendix I).
200
+
201
+ # 6 Conclusions
202
+
203
+ We have introduced DDRM, a general sampling-based linear inverse problem solver based on unconditional/class-conditional diffusion generative models as learned priors. Motivated by variational inference, DDRM only requires a few number of NFEs (e.g., 20) compared to other samplingbased baselines (e.g., 1000 for SNIPS) and achieves scalability in multiple useful scenarios, including denoising, super-resolution, deblurring, inpainting, and colorization. We demonstrate the empirical successes of DDRM on various problems and datasets, including general natural images outside the distribution of the observed training set. To our best knowledge, DDRM is the first unsupervised method that effectively and efficiently samples from the posterior distribution of inverse problems with significant noise, and can work on natural images with general content.
204
+
205
+ In terms of future work, apart from further optimizing the timestep and variance schedules, it would be interesting to investigate the following: (i) applying DDRM to non-linear inverse problems, $( i i )$ addressing scenarios where the degradation operator is unknown, and (iii) self-supervised training techniques inspired by DDRM as well as ones used in supervised techniques [41] that further improve performance of unsupervised models for image restoration.
206
+
207
+ # Acknowledgements
208
+
209
+ We thank Kristy Choi, Charlie Marx, and Avital Shafran for insightful discussions and feedback. This research was supported by NSF (#1651565, #1522054, #1733686), ONR (N00014-19-1-2145), AFOSR (FA9550-19-1-0024), ARO (W911NF-21-1-0125), Sloan Fellowship, Amazon AWS, Stanford Institute for Human-Centered Artificial Intelligence (HAI), Google Cloud, the Israel Science Foundation (ISF) under Grant 335/18, the Israeli Council For Higher Education - Planning & Budgeting Committee, and the Stephen A. Kreynes Fellowship.
210
+
211
+ # References
212
+
213
+ [1] Richard G Baraniuk. Compressive sensing [lecture notes]. IEEE signal processing magazine, 24(4):118–121, 2007.
214
+ [2] Johnathan M Bardsley. Mcmc-based image reconstruction with uncertainty quantification. SIAM Journal on Scientific Computing, 34(3):A1316–A1332, 2012.
215
+ [3] Johnathan M Bardsley, Antti Solonen, Heikki Haario, and Marko Laine. Randomize-thenoptimize: A method for sampling from posterior distributions in nonlinear inverse problems. SIAM Journal on Scientific Computing, 36(4):A1895–A1910, 2014.
216
+ [4] Christopher M Bishop. Pattern recognition. Machine learning, 128(9), 2006.
217
+ [5] Mikołaj Binkowski, Danica J. Sutherland, Michael Arbel, and Arthur Gretton. Demystifying ´ MMD GANs. In International Conference on Learning Representations, 2018.
218
+ [6] Yochai Blau and Tomer Michaeli. The perception-distortion tradeoff. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 6228–6237, 2018.
219
+ [7] Ashish Bora, Ajil Jalal, Eric Price, and Alexandros G. Dimakis. Compressed sensing using generative models. In Proceedings of the 34th International Conference on Machine Learning, volume 70, pages 537–546, 2017.
220
+ [8] Daniela Calvetti and Erkki Somersalo. Hypermodels in the bayesian imaging framework. Inverse Problems, 24(3):034013, 2008.
221
+ [9] Jooyoung Choi, Sungwon Kim, Yonghyun Jeong, Youngjune Gwon, and Sungroh Yoon. Ilvr: Conditioning method for denoising diffusion probabilistic models. arXiv preprint arXiv:2108.02938, 2021.
222
+ [10] Hyungjin Chung, Byeongsu Sim, and Jong Chul Ye. Come-closer-diffuse-faster: Accelerating conditional diffusion models for inverse problems through stochastic contraction. arXiv preprint arXiv:2112.05146, 2021.
223
+ [11] Giannis Daras, Joseph Dean, Ajil Jalal, and Alex Dimakis. Intermediate layer optimization for inverse problems using deep generative models. In Proceedings of the 38th International Conference on Machine Learning, volume 139, pages 2421–2432, 2021.
224
+ [12] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. ImageNet: A largescale hierarchical image database. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pages 248–255, 2009.
225
+ [13] Prafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat GANs on image synthesis. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021.
226
+ [14] Chao Dong, Chen Change Loy, Kaiming He, and Xiaoou Tang. Image super-resolution using deep convolutional networks. IEEE transactions on pattern analysis and machine intelligence, 38(2):295–307, 2015.
227
+ [15] Jinjin Gu, Yujun Shen, and Bolei Zhou. Image processing using multi-code gan prior. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 3012–3021, 2020.
228
+ [16] Bichuan Guo, Yuxing Han, and Jiangtao Wen. Agem: Solving linear inverse problems via deep priors and sampling. Advances in Neural Information Processing Systems, 32, 2019.
229
+ [17] Muhammad Haris, Gregory Shakhnarovich, and Norimichi Ukita. Deep back-projection networks for super-resolution. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1664–1673, 2018.
230
+ [18] 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, volume 30, 2017.
231
+ [19] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In Advances in Neural Information Processing Systems, volume 33, pages 6840–6851, 2020.
232
+ [20] Ajil Jalal, Marius Arvinte, Giannis Daras, Eric Price, Alex Dimakis, and Jonathan Tamir. Robust compressed sensing mri with deep generative priors. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021.
233
+ [21] Ajil Jalal, Sushrut Karmalkar, Alex Dimakis, and Eric Price. Instance-optimal compressed sensing via posterior sampling. In Proceedings of the 38th International Conference on Machine Learning, volume 139, pages 4709–4720, 2021.
234
+ [22] Zahra Kadkhodaie and Eero Simoncelli. Stochastic solutions for linear inverse problems using the prior implicit in a denoiser. Advances in Neural Information Processing Systems, 34, 2021.
235
+ [23] Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of GANs for improved quality, stability, and variation. In International Conference on Learning Representations, 2018.
236
+ [24] Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4401–4410, 2019.
237
+ [25] Bahjat Kawar, Gregory Vaksman, and Michael Elad. SNIPS: Solving noisy inverse problems stochastically. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021.
238
+ [26] Bahjat Kawar, Gregory Vaksman, and Michael Elad. Stochastic image denoising by sampling from the posterior distribution. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV) Workshops, pages 1866–1875, October 2021.
239
+ [27] Diederik P Kingma and Max Welling. Auto-Encoding variational bayes. arXiv preprint arXiv:1312.6114v10, December 2013.
240
+ [28] Orest Kupyn, Tetiana Martyniuk, Junru Wu, and Zhangyang Wang. Deblurgan-v2: Deblurring (orders-of-magnitude) faster and better. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 8878–8887, 2019.
241
+ [29] Gustav Larsson, Michael Maire, and Gregory Shakhnarovich. Learning representations for automatic colorization. In European conference on computer vision, pages 577–593. Springer, 2016.
242
+ [30] Rémi Laumont, Valentin De Bortoli, Andrés Almansa, Julie Delon, Alain Durmus, and Marcelo Pereyra. Bayesian imaging using plug & play priors: When Langevin meets Tweedie. arXiv preprint arXiv:2103.04715, 2021.
243
+
244
+ [31] Christian Ledig, Lucas Theis, Ferenc Huszár, Jose Caballero, Andrew Cunningham, Alejandro Acosta, Andrew Aitken, Alykhan Tejani, Johannes Totz, Zehan Wang, et al. Photo-realistic single image super-resolution using a generative adversarial network. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4681–4690, 2017.
245
+
246
+ [32] Gary Mataev, Peyman Milanfar, and Michael Elad. DeepRED: deep image prior powered by RED. In Proceedings of the IEEE/CVF International Conference on Computer Vision Workshops, 2019.
247
+
248
+ [33] Sachit Menon, Alex Damian, McCourt Hu, Nikhil Ravi, and Cynthia Rudin. Pulse: Selfsupervised photo upsampling via latent space exploration of generative models. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
249
+
250
+ [34] Chris Metzler, Ali Mousavi, and Richard Baraniuk. Learned d-amp: Principled neural network based compressive image recovery. In Advances in Neural Information Processing Systems, volume 30, 2017.
251
+
252
+ [35] Alex Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. arXiv preprint arXiv:2102.09672, 2021.
253
+
254
+ [36] Gregory Ongie, Ajil Jalal, Christopher A Metzler, Richard G Baraniuk, Alexandros G Dimakis, and Rebecca Willett. Deep learning techniques for inverse problems in imaging. IEEE Journal on Selected Areas in Information Theory, 1(1):39–56, 2020.
255
+
256
+ [37] Gregory Ongie, Ajil Jalal, Christopher A Metzler, Richard G Baraniuk, Alexandros G Dimakis, and Rebecca Willett. Deep learning techniques for inverse problems in imaging. IEEE Journal on Selected Areas in Information Theory, 1(1):39���56, 2020.
257
+
258
+ [38] Xingang Pan, Xiaohang Zhan, Bo Dai, Dahua Lin, Chen Change Loy, and Ping Luo. Exploiting deep generative prior for versatile image restoration and manipulation. In European Conference on Computer Vision (ECCV), 2020.
259
+
260
+ [39] JH Rick Chang, Chun-Liang Li, Barnabas Poczos, BVK Vijaya Kumar, and Aswin C Sankaranarayanan. One network to solve them all–solving linear inverse problems using deep projection models. In Proceedings of the IEEE International Conference on Computer Vision, pages 5888–5897, 2017.
261
+
262
+ [40] Yaniv Romano, Michael Elad, and Peyman Milanfar. The little engine that could: Regularization by denoising (RED). SIAM Journal on Imaging Sciences, 10(4):1804–1844, 2017.
263
+
264
+ [41] Chitwan Saharia, William Chan, Huiwen Chang, Chris A Lee, Jonathan Ho, Tim Salimans, David J Fleet, and Mohammad Norouzi. Palette: Image-to-image diffusion models. arXiv preprint arXiv:2111.05826, 2021.
265
+
266
+ [42] Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J Fleet, and Mohammad Norouzi. Image super-resolution via iterative refinement. arXiv preprint arXiv:2104.07636, 2021.
267
+
268
+ [43] Shibani Santurkar, Dimitris Tsipras, Brandon Tran, Andrew Ilyas, Logan Engstrom, and Aleksander Madry. Image synthesis with a single (robust) classifier. arXiv preprint arXiv:1906.09453, 2019.
269
+
270
+ [44] Jascha Sohl-Dickstein, Eric A Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. arXiv preprint arXiv:1503.03585, March 2015.
271
+
272
+ [45] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations, April 2021.
273
+
274
+ [46] Yang Song, Liyue Shen, Lei Xing, and Stefano Ermon. Solving inverse problems in medical imaging with score-based generative models. arXiv preprint arXiv:2111.08005, 2021.
275
+
276
+ [47] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2021.
277
+
278
+ [48] Maitreya Suin, Kuldeep Purohit, and AN Rajagopalan. Spatially-attentive patch-hierarchical network for adaptive motion deblurring. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3606–3615, 2020.
279
+ [49] Yu Sun, Brendt Wohlberg, and Ulugbek S Kamilov. An online plug-and-play algorithm for regularized image reconstruction. IEEE Transactions on Computational Imaging, 5(3):395–408, 2019.
280
+ [50] Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Deep image prior. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 9446–9454, 2018.
281
+ [51] Singanallur V Venkatakrishnan, Charles A Bouman, and Brendt Wohlberg. Plug-and-play priors for model based reconstruction. In 2013 IEEE Global Conference on Signal and Information Processing, pages 945–948. IEEE, 2013.
282
+ [52] 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(4):600– 612, 2004.
283
+ [53] Allan G Weber. The USC-SIPI image database version 5. USC-SIPI Report, 315(1), 1997.
284
+ [54] Jay Whang, Mauricio Delbracio, Hossein Talebi, Chitwan Saharia, Alexandros G Dimakis, and Peyman Milanfar. Deblurring via stochastic refinement. arXiv preprint arXiv:2112.02475, 2021.
285
+ [55] Raymond A Yeh, Chen Chen, Teck Yian Lim, Alexander G Schwing, Mark Hasegawa-Johnson, and Minh N Do. Semantic image inpainting with deep generative models. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 5485–5493, 2017.
286
+ [56] 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 preprint arXiv:1506.03365, 2015.
287
+ [57] Kai Zhang, Yawei Li, Wangmeng Zuo, Lei Zhang, Luc Van Gool, and Radu Timofte. Plug-andplay image restoration with deep denoiser prior. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
288
+ [58] Richard Zhang, Phillip Isola, and Alexei A Efros. Colorful image colorization. In European Conference on Computer Vision, pages 649–666. Springer, 2016.
289
+
290
+ # Checklist
291
+
292
+ 1. For all authors...
293
+
294
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
295
+ (b) Did you describe the limitations of your work? [Yes] In the future work paragraph in Section 6
296
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] We came to the conclusion that our paper does not have potential negative societal impacts.
297
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
298
+
299
+ 2. If you are including theoretical results...
300
+
301
+ (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] In the appendice
302
+
303
+ 3. If you ran experiments...
304
+
305
+ (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 the appendices.
306
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] In both the paper and the appendices.
307
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A] We report results averaged over 1, 000 images in the main paper and 50, 000 images in the appendices. Such large numbers eliminate the need for error bars.
308
+ (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] In the appendices.
309
+
310
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
311
+
312
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
313
+ (b) Did you mention the license of the assets? [Yes] The licenses of previous works’ code and datasets will be included in our camera-ready code.
314
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We include our code in the supplementary material.
315
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] Consent was given by the original authors in their work.
316
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] The datasets we use are anonymized.
317
+
318
+ 5. If you used crowdsourcing or conducted research with human subjects...
319
+
320
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
321
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
322
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/mxzIrQIOGIK/mxzIrQIOGIK.md ADDED
@@ -0,0 +1,517 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Multi-Objective Online Learning
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 This paper presents a systematic study of multi-objective online learning. We first
11
+ 2 formulate the framework of Multi-Objective Online Convex Optimization, which
12
+ 3 encompasses two novel multi-objective regret definitions. The regret definitions
13
+ 4 build upon an equivalent transformation of the multi-objective dynamic regret
14
+ 5 based on the commonly used Pareto suboptimality gap metric in zero-order multi
15
+ 6 objective bandits, making it amenable to be optimized via first-order iterative
16
+ 7 methods. To motivate the algorithm design, we give an explicit example in which
17
+ 8 equipping OMD with the vanilla min-norm solver for gradient composition will
18
+ 9 incur a linear regret, which shows that only regularizing the iterates, as in single
19
+ 10 objective online learning, is not enough to guarantee sublinear regrets in the multi
20
+ 11 objective setting. To resolve this issue, we propose a novel min-regularized-norm
21
+ 12 solver that regularizes the composite weights. Combining min-regularized-norm
22
+ 13 with OMD results in the Doubly Regularized Online Mirror Multiple Descent
23
+ 14 algorithm. We further derive both the static and dynamic regret bounds for the
24
+ 15 proposed algorithm, each of which matches the corresponding optimal bound in the
25
+ 16 single-objective setting. Extensive experiments on both simulation and real-world
26
+ 17 datasets verify the effectiveness of the proposed algorithm.
27
+
28
+ # 18 1 Introduction
29
+
30
+ 19 Traditional optimization methods for machine learning are usually designed to optimize a single
31
+ 20 objective. However, in many real-world applications, we are often required to optimize multiple
32
+ 21 correlated objectives concurrently. For example, in autonomous driving [12, 20], the self-driving
33
+ 22 vehicles need to solve multiple tasks such as self-localization and object identification at the same
34
+ 23 time. In online advertising [21, 22], advertisers need to determine the exposure of items to different
35
+ 24 users to maximize both the Click-Through Rate (CTR) and the Post-Click Conversion Rate (CVR).
36
+ 25 In many multi-objective scenarios, the objectives may conflict with each other [15]. Hence, there may
37
+ 26 not exist any single solution that optimizes all the objectives simultaneously. For example, in online
38
+ 27 advertising, merely optimizing CTR or CVR will degrade the performance of the other [21, 22].
39
+ 28 Multi-objective optimization (MOO) [23, 6] is concerned with optimizing multiple conflicting
40
+ 29 objectives simultaneously. It seeks Pareto optimality, where no single objective can be improved
41
+ 30 without hurting the performance of the others. Many different methods for MOO have been proposed,
42
+ 31 including evolutionary methods [26, 39], scalarization methods [9], and gradient-based iterative
43
+ 32 methods [7]. Recently, the Multiple Gradient Descent Algorithm (MGDA) and its variants have been
44
+ 33 introduced to the training of multi-task deep neural networks and achieved great empirical success
45
+ 34 [29], making them regain a significant amount of research interest [17, 33, 18]. These methods
46
+ 35 compute a composite gradient based on the gradient information of all the individual objectives
47
+ 36 and then apply the composite gradient to update the model parameters. The composite weights are
48
+ 37 determined by a min-norm solver [7] which yields a common descent direction of all the objectives.
49
+ 38 However, compared to the increasingly wide application prospect, the gradient-based iterative
50
+ 39 algorithms are relatively understudied, especially for the online learning setting. Multi-objective
51
+ 40 online learning is of essential importance due to reasons in two folds. First, due to the data explosion in
52
+ 41 many real-world scenarios such as web applications, making in-time predictions requires performing
53
+ 42 online learning. Second, the theoretical investigation of multi-objective online learning will lay a solid
54
+ 43 foundation for the design of new optimizers for multi-task deep neural networks. This is analogous to
55
+ 44 the single-objective setting, where nearly all the optimizers for training DNNs are initially analyzed
56
+ 45 in the online setting, such as AdaGrad [8], Adam [16], and AMSGrad [28].
57
+ 46 In this paper, we give a systematic study of multi-objective online learning. To begin with, we
58
+ 47 formulate the framework of Multi-Objective Online Convex Optimization (MO-OCO). The first
59
+ 48 major challenge is the lack of regret definitions in the multi-objective setting. To tackle this challenge,
60
+ 49 we need appropriate discrepancy metrics that can be used in the regret definitions, which evaluate the
61
+ 50 gap between any two vector losses by producing scalar values. Intuitively, the Pareto suboptimality
62
+ 51 gap (PSG) metric, which is frequently used in zero-order multi-objective bandits [30, 19], is a very
63
+ 52 promising candidate. It can yield scalarized distances from any vector loss to a given comparator set.
64
+ 53 We can thus define the multi-objective regret by simply plugging in PSG as the discrepancy metric.
65
+ 54 However, as a metric designed purely from the geometric view, PSG is intrinsically difficult to be
66
+ 55 optimized directly via gradient-based iterative methods. To resolve this problem, for the PSG-based
67
+ 56 multi-objective dynamic regret, we derive its equivalent unconstrained max-min form via a highly
68
+ 57 non-trivial transformation. This form is intuitive to the design of first-order multi-objective online
69
+ 58 algorithms, indicating that we should select a convex combination of the gradients at each round.
70
+ 59 Unfortunately, for the PSG-based static variant, such an equivalence does not exist. To remedy this
71
+ 60 issue, we make extensions of the dynamic variant by fixing the comparator set and the composite
72
+ 61 weights, which yields an appropriate definition of the multi-objective static regret.
73
+ 62 Based on the MO-OCO framework, we develop a novel multi-objective online algorithm termed
74
+ 63 Doubly Regularized Online Mirror Multiple Descent. The key module of the algorithm is the gradient
75
+ 64 composition scheme, which calculates a composite gradient in the form of a convex combination of
76
+ 65 the gradients of all objectives. Intuitively, the most direct way to determine the composite weights is
77
+ 66 to apply the min-norm solver [7] commonly used in offline multi-objective optimization. However,
78
+ 67 directly applying min-norm is not workable in the online setting. Specifically, the composite weights
79
+ 68 in min-norm are only determined by the gradients at the current round. In the online setting, since
80
+ 69 the gradients can be adversarial, they may result in undesired composite weights, further producing
81
+ 70 a composite gradient that reversely optimizes the loss. To rigorously verify this point, we give a
82
+ 71 showcase in which equipping OMD with vanilla min-norm even incurs a linear regret, showing that
83
+ 72 only regularizing the iterate, as in OMD, is not enough to guarantee sublinear regrets in the multi
84
+ 73 objective setting. To fix this issue, we devise a novel min-regularized-norm solver with an explicit
85
+ 74 regularization on composite weights. Equipping it with OMD results in our proposed algorithm.
86
+ 75 We then conduct the theoretical analysis for our proposed algorithm. We derive a multi-objective static
87
+ 76 regret bound $O ( \sqrt { T } )$ and a multi-objective dynamic regret bound $O ( V _ { T } ^ { 1 / 3 } T ^ { 2 / 3 } )$ for DR-OMMD.
88
+ 77 Both bounds match the optimal bounds in the single-objective setting [11, 34]. Our analysis also
89
+ 78 shows that DR-OMMD attains a lower regret than linearization with fixed composite weights.
90
+ 79 To evaluate the effectiveness of DR-OMMD, we conduct extensive experiments on both simulation
91
+ 80 datasets and real-world datasets. We first elaborate simulation experiments, in which we find
92
+ 81 that DR-OMMD attains lower regret than vanilla min-norm and linearization, which verifies the
93
+ 82 superiority of the min-regularized-norm solver. We then realize adaptive regularization via multi
94
+ 83 objective optimization on real-world datasets, and find that adaptive regularization with DR-OMMD
95
+ 84 significantly outperforms fixed regularization with linearization.
96
+ 85 In summary, in this paper, we give the first systematic study of multi-objective online learning, which
97
+ 86 encompasses a novel framework, a new algorithm, and corresponding non-trivial theoretical analysis.
98
+ 87 We believe that this work paves the way for future research on more advanced multiple-objective
99
+ 88 optimization algorithms, which may inspire the design of new optimizers for multi-task deep learning.
100
+
101
+ # 89 2 Preliminaries
102
+
103
+ 90 In this section, we briefly review the necessary background knowledge of online convex optimization
104
+ 91 and multi-objective optimization.
105
+ 93 Online Convex Optimization (OCO) [38, 11] is the most commonly adopted framework for
106
+ 94 designing online learning algorithms. It can be viewed as a structured repeated game between a
107
+ 95 learner and an adversary. At each round $t \in \{ 1 , \ldots , T \}$ , the learner is required to generate a decision
108
+ 96 $x _ { t }$ from a convex compact set $\mathcal { X } \subset \mathbb { R } ^ { n }$ . Then the adversary replies the learner with a convex function
109
+ 97 $f _ { t } : \mathcal { X } \mathbb { R }$ and the learner suffers the loss $f _ { t } ( x _ { t } )$ . The goal of the learner is to minimize the regret
110
+ 98 with respect to the best fixed decision in hindsight, i.e.,
111
+
112
+ $$
113
+ R _ { S } ( T ) = \sum _ { t = 1 } ^ { T } f _ { t } ( x _ { t } ) - \operatorname* { m i n } _ { x ^ { * } \in \mathcal { X } } \sum _ { t = 1 } ^ { T } f _ { t } ( x ^ { * } ) .
114
+ $$
115
+
116
+ 99 Note that the above regret is the static regret [10], which compares the learner’s cumulative loss
117
+ 100 with that of a fixed decision. There is another version of regret, namely the dynamic regret [10, 34],
118
+ 101 which compares the learner’s cumulative loss with that of a sequence of local optimal decisions, i.e.,
119
+
120
+ $$
121
+ R _ { D } ( T ) = \sum _ { t = 1 } ^ { T } f _ { t } ( x _ { t } ) - \sum _ { t = 1 } ^ { T } \operatorname* { m i n } _ { x _ { t } ^ { * } \in \mathcal { X } } f _ { t } ( x _ { t } ^ { * } ) .
122
+ $$
123
+
124
+ 102 Any meaningful regret is required to be sublinear in $T$ , i.e., $\begin{array} { r } { \operatorname* { l i m } _ { T \to \infty } R _ { S / D } ( T ) / T = 0 } \end{array}$ , which implies
125
+ 103 that when $T$ is large enough, the learner can perform as well as the best fixed decision in hindsight
126
+ 104 (for static regret) or the local optimal decision at each round (for dynamic regret).
127
+ 105 Online Mirror Descent (OMD) [11] is a classic first-order online learning algorithm. At each round
128
+ 106 $t \in \{ 1 , \ldots , T \}$ , OMD yields its decision using the following formula
129
+
130
+ $$
131
+ \begin{array} { r } { x _ { t + 1 } = \underset { x \in \mathcal { X } } { \arg \operatorname* { m i n } } \eta \langle \nabla f _ { t } ( x _ { t } ) , x \rangle + B _ { R } ( x , x _ { t } ) , } \end{array}
132
+ $$
133
+
134
+ 107 where $\eta$ is the step size, $R : \mathcal { X } \mathbb { R }$ is the regularization function, and $B _ { R } ( x , x ^ { \prime } ) = R ( x ) - R ( x ^ { \prime } ) -$
135
+ 108 $\langle \nabla R ( x ^ { \prime } ) , x - x ^ { \prime } \rangle$ is the Bregman divergence induced from $R$ . As a meta-algorithm, by instantiating
136
+ 109 different regularization functions, OMD can induce two important algorithms, i.e., Online Gradient
137
+ 110 Descent [38, 13] and Online Exponentiated Gradient [11].
138
+
139
+ # 11 2.2 Multi-Objective Optimization
140
+
141
+ 112 Multiple-objective optimization (MOO) is concerned with solving the problems of optimizing
142
+ 113 multiple objectives simultaneously [39, 29]. In general, since different objectives may conflict with
143
+ 114 each other, there is no single solution that can optimize all the objectives at the same time. Instead,
144
+ 115 MOO seeks to find solutions that achieve Pareto optimality. Next, we exposit Pareto optimality and
145
+ 116 related definitions more formally using a vector-valued loss $H = ( h ^ { 1 } , \ldots , \overline { { { h ^ { m } } } } ) ^ { \top }$ as objectives, where
146
+ 117 $m \geq 2$ and $h ^ { i } : { \mathcal { K } } \mathbb { R }$ , $i \in \{ 1 , \ldots , m \}$ , $\kappa \subset \mathbb { R }$ , is the $i$ -th loss function.
147
+
148
+ Definition 2.1 (Pareto optimality). (a) For any two solutions $x , x ^ { \prime } \in \mathcal { K }$ , we say that $x$ dominates $x ^ { \prime }$ , denoted as $\boldsymbol { x } \prec \boldsymbol { x } ^ { \prime }$ or $x ^ { \prime } \succ x$ , if $h ^ { i } ( x ) \leq h ^ { i } ( x ^ { \prime } )$ for all $i$ , and there exists one $i$ such that $h ^ { i } ( x ) < h ^ { i } ( x ^ { \prime } )$ ; otherwise, we say that $x$ does not dominate $x ^ { \prime }$ , denoted as $x \not \prec x ^ { \prime }$ or $x ^ { \prime } \nsimeq x$ .
149
+
150
+ (b) A solution $x ^ { * } \in \kappa$ is called Pareto optimal if it is not dominated by any other solution in $\kappa$ .
151
+
152
+ 122 There may exist multiple Pareto optimal solutions. For example, it is easy to show that the optimizer
153
+ 123 of any single objective, i.e., $x _ { i } ^ { * } \in \arg \operatorname* { m i n } _ { x \in \mathcal { K } } h ^ { i } ( x ) , i \in \{ \bar { 1 } , \ldots , m \}$ , is Pareto optimal. Different
154
+ 124 Pareto optimal solutions reflect different trade-offs among the objectives [17].
155
+ 25 Definition 2.2 (Pareto front). (a) All Pareto optimal solutions form the Pareto set ${ \mathcal { P } } _ { \kappa } ( H )$ .
156
+ 26 (b) The image of ${ \mathcal { P } } _ { \kappa } ( H )$ constitutes the Pareto front, denoted as $\mathcal { P } ( H ) = \{ H ( x ) \mid x \in \mathcal { P } _ { K } ( H ) \} .$
157
+ 127 Now that we have established the notion of optimality in MOO, we proceed to introduce the metrics
158
+ 128 that measure the discrepancy of an arbitrary solution $x \in \kappa$ from being optimal. Recall that, in the
159
+ 129 single-objective setting with merely one loss function $h : \mathcal { Q } \mathbb { R }$ , where $\mathcal { Q } \subset \mathbb { R }$ , for any $z \in \mathcal { Q }$ ,
160
+ 130 the loss gap $h ( z ) - \mathrm { { m i n } } _ { z ^ { \prime \prime } \in \mathcal { Q } } h ( z ^ { \prime \prime } )$ is directly the discrepancy measure. However, in MOO with
161
+ 131 more than one loss, for any $x \in \kappa$ , the loss gap $H ( x ) - \overline { { H ( x ^ { \prime \prime } ) } }$ , where $x ^ { \prime \prime } \in { \mathcal { P } } _ { \kappa } ( H )$ , is a vector.
162
+ 132 Intuitionally, the desired discrepancy metric shall scalarize the vector-valued loss gap and yield
163
+ 133 the value 0 for any Pareto optimal solution. In general, there are two commonly used discrepancy
164
+ 134 metrics in MOO, i.e. Pareto suboptimality gap (PSG) [30] and Hypervolume (HV) [4]. As HV is a
165
+ 135 volume-based metric, it is more difficult to optimize or analyze via iterative algorithms [36]. Hence
166
+ 136 in this paper, we adopt PSG, which has been extensively used in multi-objective bandits [30, 19].
167
+ 137 Definition 2.3 (Pareto suboptimality gap). For any $x \in \kappa$ , the Pareto suboptimality gap to a given
168
+ 138 comparator set $\kappa ^ { * } \subset \kappa$ , denoted as $\Delta ( x ; K ^ { * } , H )$ , is defined as the minimal scalar $\epsilon \geq 0$ that needs
169
+ 139 to be subtracted from all entries of $H ( x )$ , such that $H ( x ) - \epsilon \mathbf { 1 }$ is not dominated by any point in $\kappa ^ { * }$ ,
170
+ 140 where 1 denotes the all-one vector in $\mathbb { R } ^ { m }$ , i.e.,1
171
+
172
+ $$
173
+ \Delta ( x ; K ^ { * } , H ) = \operatorname* { i n f } _ { \epsilon \geq 0 } \epsilon , \quad \mathrm { s . t . } \forall x ^ { \prime \prime } \in K ^ { * } , \exists i \in \{ 1 , . . . , m \} , h ^ { i } ( x ) - \epsilon < h ^ { i } ( x ^ { \prime \prime } ) .
174
+ $$
175
+
176
+ 141 Clearly, PSG is a distance-based discrepancy metric that motivated from a purely geometric viewpoint.
177
+ 142 In practice, the comparator set $\kappa ^ { * }$ is often set to be the Pareto set ${ \mathcal { P } } _ { \kappa } ( H )$ [30]. Then for any $x \in \kappa$ ,
178
+ 143 its PSG is always non-negative and equals to zero if and only if $x \in { \mathcal { P } } _ { \kappa } ( H )$ .
179
+ 144 Multiple Gradient Descent Algorithm (MGDA) is an offline first-order algorithm for MOO [9, 7].
180
+ 145 146 At each iteration for each objectiv $l \in \{ 1 , \ldots , L \}$ $i \in \{ 1 , \ldots , m \}$ $L$ is the number of iterations), it first c then derive the composite gradient $\begin{array} { r } { g _ { l } ^ { c o \bar { m } p } = \sum _ { i = 1 } ^ { \bar { m } } \lambda _ { l } ^ { i } \nabla h ^ { i } ( x _ { l } ) } \end{array}$ $\nabla h ^ { i } ( x _ { l } )$
181
+ 147 the convex combination of these multiple gradients; it applies ${ \dot { \boldsymbol g } _ { l } } ^ { c o m p }$ to execute the gradient descent
182
+ 148 step to update the decision, i.e., $x _ { l + 1 } = x _ { l } - \eta g _ { l } ^ { c o m p }$ gcompl , where η is the step size. The core part of
183
+ 149 MGDA is the module that determines the composite weights $\lambda _ { l } = ( \lambda _ { l } ^ { 1 } , \ldots , \lambda _ { l } ^ { m } )$ , which is given as
184
+
185
+ $$
186
+ \lambda _ { l } = \arg \operatorname* { m i n } _ { \lambda _ { l } \in \mathcal { S } _ { m } } \| \sum _ { i = 1 } ^ { m } \lambda _ { l } ^ { i } \nabla h ^ { i } ( x _ { l } ) \| _ { 2 } ^ { 2 } ,
187
+ $$
188
+
189
+ 150 where $\begin{array} { r } { \mathcal { S } _ { m } = \{ \lambda \in \mathbb { R } ^ { m } | \sum _ { i = 1 } ^ { m } \lambda ^ { i } = 1 , \lambda ^ { i } \geq 0 , i \in \{ 1 , \dots , m \} \} } \end{array}$ denotes the probabilistic simplex in
190
+ 151 $\mathbb { R } ^ { m }$ . This is a min-norm solver which finds the weights in the simplex that yields the minimum $L _ { 2 }$
191
+ 152 norm of the composite gradient. Thus MGDA is also called the min-norm method. Existing works
192
+ 153 [7, 29] have shown that MGDA is guaranteed to decrease all the objectives simultaneously until it
193
+ 154 reaches a Pareto optimal decision (under the convex setting where all $h ^ { i }$ are convex functions).
194
+
195
+ # 3 Multi-Objective Online Convex Optimization
196
+
197
+ In this section, we formally formulate the framework of multi-objective optimization in the online setting, termed Multi-Objective Online Convex Optimization (MO-OCO).
198
+
199
+ Framework overview. We tailor the famous online convex optimization (OCO) framework to the multi-objective setting, which can be viewed as a repeated game between an online learner and the adversarial environment. At each round $t \in \{ 1 , \ldots , T \}$ , the learner generates a decision $x _ { t }$ from a given convex compact decision set $\mathcal { X } \subset \mathbb { R } ^ { n }$ . Then the adversary replies the decision with a vector loss function $F _ { t } ( \bar { x } ) : \mathcal { X } \mathbb { R } ^ { m }$ , where its $i$ -th component $f _ { t } ^ { i } ( x ) \ \bar { : } \ x \ \to \ \mathbb { R }$ belongs to the $i$ -th objective, and the learner suffers the loss $F _ { t } ( x _ { t } ) \in \mathbb { R } ^ { m }$ . The goal of the learner is to generate a sequence of decisions $\{ x _ { t } \} _ { t = 1 } ^ { T }$ so that the cumulative loss $\textstyle \sum _ { t = 1 } ^ { T } F _ { t } ( x _ { t } )$ can be optimized.
200
+
201
+ 165 Recall that, in the single-objective setting, the performance metric $\begin{array} { r } { R ( T ) = \sum _ { t = 1 } ^ { T } ( f _ { t } ( x _ { t } ) - f _ { t } ( z _ { t } ) ) } \end{array}$
202
+ 166 i.e., the regret, compares the actual decisions with some comparator $z _ { t } \in \mathcal { X }$ at each round $t$ . For
203
+ 167 the static regret, all $z _ { t }$ are identically set as the fixed optimal decision $x ^ { * }$ w.r.t. all losses in hindsight,
204
+ 168 i.e., $\begin{array} { r } { z _ { t } \equiv x ^ { * } \in \arg \operatorname* { m i n } _ { x \in \mathcal { X } } \sum _ { t = 1 } ^ { T } f _ { t } ( x ) } \end{array}$ . For the dynamic regret, each $z _ { t }$ is selected as the optimal
205
+ 169 decision $\boldsymbol { x } _ { t } ^ { * }$ w.r.t. the instantaneous loss $f _ { t }$ at that round, i.e., $z _ { t } = x _ { t } ^ { * } \in \arg \operatorname* { m i n } _ { x \in \mathcal { X } } f _ { t } ( x )$ .
206
+ 170 In analogy, we can define the multi-objective regret as $\begin{array} { r } { R ( T ) = \sum _ { t = 1 } ^ { T } \Delta _ { t } } \end{array}$ , where each $\Delta _ { t }$ compares
207
+ 171 . However, in general, no single decision can
208
+ 172 optimize all the objectives at the same time. Hence, it is natural to compare $x _ { t }$ with a group of Pareto
209
+ 173 optimal decisions, which constitute a comparator set $\mathcal { C } _ { t } \subset \mathcal { X }$ . To measure the discrepancy between $x _ { t }$
210
+ 174 and $\mathcal { C } _ { t }$ , we further introduce the Pareto suboptimality gap (PSG) [30] $\Delta ( x _ { t } ; \mathcal { C } _ { t } , F _ { t } )$ . Then the multi
211
+ 175 objective regret can be defined as $\begin{array} { r } { R ( T ) = \sum _ { t = 1 } ^ { T } \Delta ( x _ { t } ; \mathcal { C } _ { t } , F _ { t } ) } \end{array}$ . Now we can formulate the static or
212
+ 176 the dynamic variant by specifying the comparator set $\mathcal { C } _ { t }$ at each round. Specifically, by setting all $\mathcal { C } _ { t }$ to
213
+ 177 be the Pareto set $\mathcal { X } ^ { \ast }$ of the cumulative loss $\textstyle \sum _ { t = 1 } ^ { T } F _ { t }$ , we formulate the multi-objective static regret
214
+ 178 $\begin{array} { r } { R _ { \mathrm { M O S } } ( T ) = \sum _ { t = 1 } ^ { T } \Delta ( x _ { t } ; \mathcal { X } ^ { \ast } , F _ { t } ) } \end{array}$ $F _ { t }$ . By setting each bjective dynamic $\mathcal { C } _ { t }$ to bgret $\begin{array} { r } { R _ { \mathrm { M O D } } ( T ) = \sum _ { t = 1 } ^ { T } \Delta ( x _ { t } ; \mathcal { X } _ { t } ^ { \ast } , F _ { t } ) } \end{array}$ $\mathcal { X } _ { t } ^ { \ast }$ neous.
215
+ 180 Recall that PSG is a zero-order metric motivated in a purely geometric sense, namely, its calculation
216
+ 181 needs to solve a constrained optimization problem with an unknown boundary $f _ { t } ^ { i } ( x ^ { \prime \prime } ) , \forall x ^ { \prime \prime } \in { \mathcal { C } } _ { t }$
217
+ 182 Hence, it is not straightforward to design a first-order algorithm to optimize PSG, not to mention
218
+ 183 the regret analysis. To motivate algorithm design and analysis, we investigate the two variants in
219
+ 184 more detail. We begin with the dynamic variant, since we find that it has an equivalent form, which is
220
+ 185 intuitive and has a strong implication on the design of effective online multiple gradient algorithms.
221
+
222
+ An equivalent form of the dynamic regret. Surprisingly, the multi-objective dynamic regret $R _ { \mathrm { M O D } }$ can be transformed into an unconstrained max-min form. The derivation utilizes Pareto optimality of $\mathcal { X } _ { t } ^ { \ast }$ and is highly non-trivial, which is deferred to the appendix due to the space limit.
223
+
224
+ 189 Proposition 3.1. The multi-objective dynamic regret has an equivalent form, i.e.,
225
+
226
+ $$
227
+ R _ { \mathrm { M O D } } ( T ) = \operatorname* { s u p } _ { \stackrel { x _ { t } ^ { * } \in \mathcal { X } _ { t } ^ { * } , \ } { 1 \leq t \leq T } } \operatorname* { i n f } _ { \stackrel { x \in S _ { m } } { 1 \leq t \leq T } } \sum _ { t = 1 } ^ { T } \lambda _ { t } ^ { * } { ^ { \top } ( F _ { t } ( x _ { t } ) - F _ { t } ( x _ { t } ^ { * } ) ) } .
228
+ $$
229
+
230
+ 190 Remark. (i) The above form can be understood as a variant of the standard dynamic regret regarding
231
+ 191 $\{ \lambda _ { t } ^ { * } ^ { \top } F _ { t } \} _ { t = 1 } ^ { T }$ , whereas $\lambda _ { t } ^ { * }$ are unknown to the learner. This provides an intuition that we can gen
232
+ 192 erate weights $\lambda _ { t } \in \boldsymbol { S } _ { m }$ at each round and optimize $\{ \lambda _ { t } F _ { t } \} _ { t = 1 } ^ { T }$ via single-objective techniques. For
233
+ 193 first-order algorithms, it is equivalent to selecting a convex combination of individual gradients and
234
+ 194 then applying the composite gradient to model update. Undoubtedly, how to generate the weights $\lambda _ { t }$
235
+ 195 needs some careful designs, which will be explicated later in the algorithm section.
236
+
237
+ (ii) When $m \ = \ 1$ , we have $S _ { m } ~ = ~ \{ 1 \}$ and $\begin{array} { r } { \mathcal { X } _ { t } ^ { * } ~ = ~ \arg \operatorname* { m i n } _ { x \in \mathcal { X } } F _ { t } ( x ) } \end{array}$ . Hence $R _ { \mathrm { M O D } } ( T ) ~ =$ $\begin{array} { r } { \sum _ { t = 1 } ^ { T } ( F _ { t } ( x _ { t } ) - \operatorname* { m i n } _ { x \in \mathcal { X } } F _ { t } ( x ) ) } \end{array}$ , which is exactly the single-objective dynamic regret $R _ { D } ( T )$ .
238
+
239
+ 198 An alternative form of the static regret. Unfortunately, for $R _ { \mathrm { M O S } }$ , the above equivalence form
240
+ 199 does not exist. Here is the reason. In $R _ { \mathrm { M O S } }$ , the comparator set $\mathcal { X } ^ { \ast }$ is the Pareto set of the cumulative
241
+ 200 loss $\textstyle \sum _ { t = 1 } ^ { T } F _ { t }$ rather than the instantaneous loss $F _ { t }$ . Hence, at some specific round $t$ , the decision
242
+ 201 $x _ { t }$ may Pareto dominate all points in w.r.t. the instantaneous $F _ { t }$ , and we would expect the
243
+ 202 metric $\Delta _ { t }$ to be negative. However, PSG (or other commonly used metrics such as Hypervolume)
244
+ 203 204 yields no, we have $R _ { \mathrm { M O S } }$ th , w $R _ { S }$ . For example, whenh can be much looser
245
+ $m = 1$ $\begin{array} { r } { R _ { \operatorname { M O S } } ( T ) = \operatorname* { s u p } _ { x ^ { * } \in \mathcal { X } ^ { * } } \sum _ { t = 1 } ^ { T } \operatorname* { m a x } \{ F _ { t } ( x _ { t } ) - F _ { t } ( x ^ { * } ) , 0 \} } \end{array}$
246
+ 205 than the static regret $\begin{array} { r } { R _ { S } ( T ) = \operatorname* { s u p } _ { x ^ { * } \in \mathcal { X } ^ { * } } \sum _ { t = 1 } ^ { T } ( F _ { t } ( x _ { t } ) - F _ { t } ( x ^ { * } ) ) } \end{array}$ . Hence the analysis of $R _ { \mathrm { M O S } }$ is
247
+ 206 intrinsically complex if we use existing discrepancy metrics that always yield non-negative values.
248
+ 207 Enlightened by Proposition 3.1, we can formulate the static regret in a different way, i.e., by modifying
249
+ 208 the equivalent form of dynamic regret. Recall that in Proposition 3.1, at each round $t$ , the comparator
250
+ 209 $\boldsymbol { x } _ { t } ^ { * }$ is selected from the Pareto set $\mathcal { X } _ { t } ^ { \ast }$ of the instantaneous loss $F _ { t }$ , and the weights $\lambda _ { t } ^ { * }$ are generated
251
+ 210 from $S _ { m }$ . To formulate the static variant, we can use a fixed comparator $x ^ { * }$ from the Pareto set $\mathcal { X } ^ { \ast }$ of
252
+ 211 the cumulative loss $\sum _ { t } F _ { t }$ and fixed weights $\lambda ^ { * } \in S _ { m }$ at all rounds. Now the static variant takes
253
+
254
+ $$
255
+ R _ { \mathrm { M O S } } ( T ) : = \operatorname* { s u p } _ { x ^ { * } \in \mathcal { X } ^ { * } } \operatorname* { i n f } _ { \lambda ^ { * } \in \mathcal { S } _ { m } } { \lambda ^ { * } } ^ { \top } ( \sum _ { t = 1 } ^ { T } F _ { t } ( x _ { t } ) - \sum _ { t = 1 } ^ { T } F _ { t } ( x ^ { * } ) ) .
256
+ $$
257
+
258
+ 212 Remark. (i) $R _ { \mathrm { M O S } } ( T )$ has a clear physical meaning that optimizing it will impose the cumulative loss 213 $\textstyle \sum _ { t = 1 } ^ { T } F _ { t } ( x _ { t } )$ to reach the Pareto front ${ \mathcal { P } } ^ { * }$ . See more details in Appendix C.
259
+
260
+ (ii) When 214 $m = 1$ , $S _ { m } = \{ 1 \}$ and $\mathcal { X } ^ { \ast }$ reduces to $\begin{array} { r } { \arg \operatorname* { m i n } _ { x \in \mathcal { X } } \sum _ { t = 1 } ^ { T } F _ { t } ( x ) } \end{array}$ . Therein $R _ { \mathrm { M O S } } ( T ) =$ 15 $\begin{array} { r } { \sum _ { t = 1 } ^ { T } F _ { t } ( x _ { t } ) - \operatorname* { m i n } _ { x ^ { * } \in \mathcal { X } ^ { * } } \sum _ { t = 1 } ^ { T } F _ { t } ( x ^ { * } ) } \end{array}$ x∈X t=1 , which reduces to the single-objective static regret $R _ { S } ( T )$
261
+
262
+ # 216 4 Online Mirror Multiple Descent
263
+
264
+ In this section, we present the Online Mirror Multiple Descent (OMMD) algorithm, the protocol of which is given in Algorithm 1. At each round $t$ , the learner first computes the gradient of the loss regarding each objective, then determines the composite weights of all these gradients, and finally applies the composite gradient to the online mirror descent step.
265
+
266
+ # 4.1 Vanilla Min-Norm May Incur Linear Regrets
267
+
268
+ 222 The core module of OMMD is the composition of multiple gradients. For simplicity, we represent the gradients at round 223 $t$ in a matrix form $\nabla F _ { t } ( x _ { t } ) = [ \nabla \mathsf { \bar { f } } _ { t } ^ { 1 } ( \bar { x } _ { t } ) , \ldots , \nabla f _ { t } ^ { m } ( x _ { t } ) ] \in \bar { \mathbb { R } } ^ { \mathsf { \bar { n } } \times m }$ . Then the
269
+
270
+ 1: Input: Convex set $\mathcal { X }$ , time horizon $T$ , regularization parameter $\alpha _ { t }$ , learning rate $\eta _ { t }$ , regulariza tion function $R$ , user preference $\lambda _ { 0 }$ .
271
+ 2: Initialize: $x _ { 1 } \in \mathcal { X }$ .
272
+ 3: for $t = 1 , \dots , T$ do
273
+ 4: Predict $x _ { t }$ and receive a loss function $F _ { t } : \mathcal { X } \mathbb { R } ^ { m }$ .
274
+ 5: Compute the multiple gradients $\nabla F _ { t } ( x _ { t } ) = [ \nabla f _ { t } ^ { 1 } ( x _ { t } ) , \ldots , \nabla f _ { t } ^ { m } ( x _ { t } ) ] \in \mathbb { R } ^ { n \times m } .$ .
275
+ 6: Determine the weights for the gradient composition via min-regularized-norm $\lambda _ { t } = \operatorname * { \bar { a r g m i n } } _ { \lambda \in { \cal S } _ { m } } \| \nabla \dot { F _ { t } } ( x _ { t } ) \lambda \| _ { 2 } ^ { 2 } + \alpha \| \lambda - \stackrel { \smile } { \lambda } _ { 0 } \| _ { 1 } .$
276
+ 7: Compute the composite gradient $g _ { t } = \nabla F _ { t } ( x _ { t } ) \lambda _ { t }$ .
277
+ 8: Perform online mirror descent using $g _ { t }$ $x _ { t + 1 } = \underset { x \in \mathcal { X } } { \arg \operatorname* { m i n } } \eta \langle g _ { t } , x \rangle + B _ { R } ( x , x _ { t } ) .$
278
+
279
+ 9: end for
280
+
281
+ 224 composite gradient is given as $g _ { t } = \nabla F _ { t } ( x _ { t } ) \lambda _ { t }$ , where $\lambda _ { t }$ is the composite weights. As illustrated in
282
+ 225 Preliminary, the min-norm method in MGDA [7, 29] is a classic method to determine the composite
283
+ 226 weights in the offline setting, which results in a common descent direction that can descend all the
284
+ 227 losses simultaneously. Thus, it is tempting to consider applying it to the online setting.
285
+ 228 However, directly applying the min-norm method to the online setting is not workable, which may
286
+ 229 even incur linear regrets of the resulting algorithms. The rationale is as follows. In the vanilla
287
+ 230 min-norm method, the composite weights $\lambda _ { t }$ are determined solely by the gradients $\nabla F _ { t } ( x _ { t } )$ at the
288
+ 231 current round $t$ , hence they are very sensitive to the instantaneous loss $F _ { t }$ . In the online setting,
289
+ 232 the losses at each round can be adversarially chosen, and thus the corresponding gradients can be
290
+ 233 adversarial. These adversarial gradients may result in undesired composite weights, which may
291
+ 234 further produce a composite gradient that even deteriorates the next prediction. In the following,
292
+ 235 we provide a problem instance in which min-norm incurs a linear regret. We extend OMD to the
293
+ 236 multi-objective setting, where the composite weights are directly yielded by min-norm [11].
294
+ 237 Problem instance. We consider a two-objective problem. The decision domain is $\mathcal { X } = \{ ( u , v ) ~ |$
295
+ 238 $\begin{array} { r } { u + v \leq \frac { 1 } { 2 } , v - u \leq \frac { 1 } { 2 } , v \geq 0 \} } \end{array}$ and the loss function at each round is
296
+
297
+ $$
298
+ F _ { t } ( x ) = \left\{ \begin{array} { l l } { ( \| x - a \| ^ { 2 } , \| x - b \| ^ { 2 } ) , ~ t = 2 k - 1 , } & { ~ k = 1 , 2 , . . . ; } \\ { ( \| x - b \| ^ { 2 } , \| x - c \| ^ { 2 } ) , ~ t = 2 k , } & { ~ k = 1 , 2 , . . . , } \end{array} \right.
299
+ $$
300
+
301
+ 239 where $a = ( - 2 , - 1 ) , b = ( 0 , 1 ) , c = ( 2 , - 1 )$ . For simplicity, we first analyze the case where the
302
+ 240 total time horizon $T$ is an even number. Then we can compute the Pareto set of the cumulative
303
+ 241 loss $\textstyle \sum _ { t = 1 } ^ { T } F _ { t }$ , i.e., $\begin{array} { r } { \mathcal { X } ^ { * } = \{ ( u , 0 ) \mid - \frac { 1 } { 2 } \leq u \leq \frac { 1 } { 2 } \} } \end{array}$ , which locates at the $x$ -axis. For conciseness of
304
+ 242 analysis, we instantiate OMD with L2-regularization, which results in the simple OGD algorithm
305
+ 243 [24]. We start at an arbitrary point $x _ { 1 } = ( u _ { 1 } , v _ { 1 } ) \in \mathcal { X }$ satisfying $v _ { 1 } > 0$ . At each round $t$ , suppose
306
+ 244 the decision $x _ { t } = ( u _ { t } , v _ { t } ) \in \mathcal { X }$ , then the gradients of each objective w.r.t. $x _ { t }$ can be calculated as
307
+
308
+ $$
309
+ g _ { t } ^ { 1 } = { \left\{ \begin{array} { l l } { ( 2 u _ { t } + 4 , ~ 2 v _ { t } + 2 ) , } & { t = 2 k - 1 ; } \\ { ( 2 u _ { t } , } & { 2 v _ { t } - 2 ) , } & { t = 2 k . } \end{array} \right. } \qquad g _ { t } ^ { 2 } = { \left\{ \begin{array} { l l } { ( 2 u _ { t } , } & { 2 v _ { t } - 2 ) , } & { t = 2 k - 1 ; } \\ { ( 2 u _ { t } - 4 , } & { 2 v _ { t } + 2 ) , } & { t = 2 k . } \end{array} \right. }
310
+ $$
311
+
312
+ 245 Since $\begin{array} { r } { 0 \leq v _ { t } \leq \frac { 1 } { 2 } } \end{array}$ , we observe that the second entry of either gradient alternates between positive
313
+ 246 and negative. By using min-norm, the composite weights $\lambda _ { t }$ can be computed as
314
+
315
+ $$
316
+ \lambda _ { t } = \left\{ { \begin{array} { l l } { ( ( 1 - u _ { t } - v _ { t } ) / 4 , } & { ( 3 + u _ { t } + v _ { t } ) / 4 ) , t = 2 k - 1 ; } \\ { ( ( 3 - u _ { t } + v _ { t } ) / 4 , } & { ( 1 + u _ { t } - v _ { t } ) / 4 ) , t = 2 k . } \end{array} } \right.
317
+ $$
318
+
319
+ 247 We observe that both entries of composite weights alternative between above $\frac { 1 } { 2 }$ and below $\frac { 1 } { 2 }$ , and
320
+ 248 $\| \lambda _ { t + 1 } - \lambda _ { t } \| _ { 1 } \geq 1$ . Recall that $\| \lambda _ { t } \| _ { 1 } = 1$ , hence the composite weights at two consecutive rounds
321
+ 249 change radically. The resulting composite gradient takes
322
+
323
+ $$
324
+ g _ { t } ^ { c o m p } = \left\{ \begin{array} { l l } { { ( u _ { t } - v _ { t } + 1 , ~ } } & { { - u _ { t } + v _ { t } - 1 ) , t = 2 k - 1 ; } } \\ { { ( - u _ { t } - v _ { t } - 1 , } } & { { - u _ { t } - v _ { t } - 1 ) , t = 2 k . } } \end{array} \right.
325
+ $$
326
+
327
+ 250 The fluctuating composite weights mix with the positive and negative second entries of gradients,
328
+ 251 making the second entry of $g _ { t } ^ { c \bar { o } m p }$ always negative, i.e., $- u _ { t } + v _ { t } - 1 < 0$ and $- u _ { t } - v _ { t } - 1 < 0$
329
+ 252 Hence ${ \bf { \bar { \it g } } } _ { t } ^ { c o m p }$ actually drives $x _ { t }$ away from the Pareto set $\mathcal { X } ^ { \ast }$ that coincides with the $x$ -axis. This
330
+ 253 essentially reversely optimizes the loss, hence increases the regret. In fact, we can prove that it even
331
+ 254 incurs a linear regret2. Due to the lack of space, we leave the proof of linear regret when $T$ is an odd
332
+ 255 number in the appendix. The above results of the problem instance are summarized as follows.
333
+
334
+ Proposition 4.1. For OMD equipped with vanilla min-norm, there exists a multi-objective online convex optimization problem, in which the resulting algorithm incurs a linear regret.
335
+
336
+ 258 Remark. Stability is a basic requirement to guarantee meaningful regrets in online learning [25].
337
+ 259 In the single-objective setting, directly regularizing the iterate $x _ { t }$ (e.g., OMD) is already enough.
338
+ 260 However, as shown in the above analysis, only regularizing $x _ { t }$ is not enough to attain sublinear regrets
339
+ 261 in the multi-objective setting, since there is another source of instability, i.e., the composite weights,
340
+ 262 that affects the direction of the composite gradient. Therefore, in multi-objective online learning,
341
+ 263 besides regularizing the iterates, we also need to explicitly regularize the composite weights.
342
+
343
+ # 4.2 Doubly Regularized Online Mirror Multiple Descent
344
+
345
+ Enlightened by the design of regularization in FTRL [25], we consider the regularizer $r ( \lambda , \lambda _ { 0 } )$ , where $\lambda _ { 0 }$ is the pre-defined composite weight that may reflect the user preference. This results in a new solver called min-regularized-norm, i.e.,
346
+
347
+ $$
348
+ \lambda _ { t } = \underset { \lambda \in S _ { m } } { \arg \operatorname* { m i n } } \| \nabla F _ { t } ( x _ { t } ) \lambda \| _ { 2 } ^ { 2 } + \alpha r ( \lambda , \lambda _ { 0 } ) ,
349
+ $$
350
+
351
+ 268 where $\alpha$ is the strength of regularization. Equipping OMD with the new solver, we derive the
352
+ 269 proposed online algorithm. Note that beyond the regularization on the iterate $x _ { t }$ that is intrinsic in
353
+ 270 online learning, there is another regularization on the composite weights $\lambda _ { t }$ in min-regularized norm.
354
+ 271 Both regularizations are fundamental and they together ensure the stability in the multi-objective
355
+ 272 online setting. Hence we call the algorithm Doubly Regularized OMMD (DR-OMMD).
356
+ 273 In principle, $r$ can take various forms such as $L _ { 1 }$ -norm, $L _ { 2 }$ -norm and KL divergence etc. Here
357
+ 274 we adopt $L _ { 1 }$ -norm since it aligns well with the simplex constraint of $\lambda$ . Min-regularized-norm
358
+ 275 can be computed very efficiently, since it has a closed-form solution when $m = 2$ . Specifically,
359
+ 276 suppose the gradients at round $t$ are $g _ { t } ^ { 1 }$ and $g _ { t } ^ { 2 }$ . Set $\gamma _ { L } = ( g _ { 2 } ^ { \top } ( g _ { 2 } - g _ { 1 } ) - \alpha ) / \Vert g _ { 2 } - g _ { 1 } \Vert ^ { 2 }$ and
360
+ 277 $\gamma _ { R } = ( g _ { 2 } ^ { \top } ( g _ { 2 } - g _ { 1 } ) + \alpha ) / \Vert g _ { 2 } - g _ { 1 } \Vert ^ { 2 }$ . Given any $\lambda _ { 0 } = ( \gamma _ { 0 } , 1 - \gamma _ { 0 } ) \in S _ { 2 }$ , we can compute the
361
+ 278 composite weights $\lambda _ { t }$ as $( \gamma _ { t } , 1 - \gamma _ { t } )$ where
362
+
363
+ $$
364
+ \gamma _ { t } = \operatorname* { m a x } \{ \operatorname* { m i n } \{ \gamma _ { t } ^ { \prime \prime } , 1 \} , 0 \} , \quad \mathrm { w h e r e } \ \gamma _ { t } ^ { \prime \prime } = \operatorname* { m a x } \{ \operatorname* { m i n } \{ \gamma _ { 0 } , \gamma _ { R } \} , \gamma _ { L } \} .
365
+ $$
366
+
367
+ 79 In addition, when $m > 2$ , since the feasible region $S _ { m }$ is a simplex, we can introduce a Frank-Wolfe
368
+ 80 solver [14] to compute the composite weights. See the protocol and more details in Appendix D.
369
+
370
+ Compared to vanilla min-norm, the composite weights in min-regularized-norm are not fully determined by the adversarial gradients. The resulting relative stability of composite weights make the composite gradients more robust to the adversarial environment. In the following, we give a general analysis and prove that DR-OMMD indeed guarantees sublinear regrets.
371
+
372
+ # 4.3 Analysis
373
+
374
+ We now analyze the static regret and the dynamic regret of DR-OMMD. Our analysis is based on the following commonly used assumptions [13, 11].
375
+
376
+ Assumption 4.2 (Bregman divergence). The regularization function $R$ is 1-strongly convex. In addition, the Bregman divergence is $\gamma$ -Lipschitz continuous, i.e., $B _ { R } ( x , z ) - B _ { R } ( \bar { y } , z ) \leq \gamma \| x -$ $y \| , \forall x , y , z \in \mathrm { d o m } R$ , where $\mathrm { d o m } R$ is the domain of $R$ and satisfies $\mathcal { X } \subset \mathrm { d o m } R \subset \mathbb { R } ^ { n }$ .
377
+
378
+ Assumption 4.3 (Lipschitz continuity). For each $i \in \{ 1 , \ldots , m \}$ , there exists some positive and finite $G$ such that, the $i$ -th loss $f _ { t } ^ { i }$ at each round $t \in \{ 1 , \ldots , T \}$ is $G$ -Lipschitz continuous w.r.t. $\| \cdot \|$ , i.e., $| f _ { t } ^ { i } ( x ) - f _ { t } ^ { i } ( x ^ { \prime } ) | \leq G \| x - \bar { x } ^ { \prime } \|$ . Note that in the convex setting, this assumption leads to bounded gradients, i.e., $\| \nabla f _ { t } ^ { i } ( x ) \| _ { * } \leq G$ for any $t \in \{ 1 , \ldots , T \} , i \in \{ 1 , \ldots , m \} , x \in \mathcal { X }$ .
379
+
380
+ 295 We first provide the static regret bound. The proof is left to the appendix due to the lack of space.
381
+
382
+ Theorem 4.4. Suppose the diameter of 296 $\mathcal { X }$ is bounded by $D$ . Assume $F _ { t }$ is bounded, i.e., $| f _ { t } ^ { i } ( x ) | \leq$ 297 $F , \forall x \in \mathcal { X } , t \in \{ \bar { 1 } , \dots , T \} , i \in \{ 1 , \dots , m \}$ . For any $\lambda _ { 0 } \in { S _ { m } }$ , DR-OMMD attains
383
+
384
+ $$
385
+ R _ { \mathrm { M O S } } ( T ) \leq \frac { 1 } { \eta } B _ { R } ( x ^ { * } , x _ { 1 } ) + \frac { \eta } { 2 } \sum _ { t = 1 } ^ { T } ( \Vert \nabla F _ { t } ( x _ { t } ) \lambda _ { t } \Vert _ { 2 } ^ { 2 } + \frac { 4 F } { \eta } \Vert \lambda _ { t } - \lambda _ { 0 } \Vert _ { 1 } ) .
386
+ $$
387
+
388
+ Remark. (i) Linearization with weights $\lambda _ { 0 } \in \mathcal { S } _ { m }$ can be viewed as single-objective optimization on scalar loss $\lambda _ { 0 } ^ { \top } F _ { t }$ , whose gradient is $g _ { t } = \nabla F _ { t } ( x _ { t } ) \lambda _ { 0 }$ . Hence we can directly borrow the tight bound of OMD (Theorem 6.8 in [27]) and derive a bound $\begin{array} { r } { \frac { 1 } { \eta } B _ { R } ( x ^ { * } , x _ { 1 } ) + \sum _ { t = 1 } ^ { T } \frac { \eta _ { t } } { 2 } \| \nabla F _ { t } ( x _ { t } ) \lambda _ { 0 } \| _ { 2 } ^ { 2 } } \end{array}$ $\lambda _ { t }$ r linearization. In co, the bound becomes $\begin{array} { r } { \frac { 1 } { \eta } B _ { R } ( x ^ { * } , x _ { 1 } ) + \frac { \eta } { 2 } \sum _ { t = 1 } ^ { T } \operatorname* { m i n } _ { \lambda \in { \cal S } _ { m } } \{ \| \nabla F _ { t } ( x _ { t } ) \lambda \| ^ { 2 } + \alpha \| \lambda - \lambda _ { 0 } \| _ { 1 } \} . } \end{array}$ $\alpha = 4 F / \eta$ ulation of, which is smaller than that of linearization. Note that the lower regret of DR-OMMD compared to linearization is also empirically verified in our experiments (see Figure 1).
389
+
390
+ (ii) When $\begin{array} { r } { \eta = \frac { \hat { \sqrt { 2 \gamma D } } } { G \sqrt { T } } , \alpha = \frac { 4 F } { \eta } } \end{array}$ , the bound is in the order of $O ( \sqrt { T } )$ . It matches the optimal static single-objective regret bound w.r.t. $T$ [11] (see more details in Appendix E).
391
+
392
+ Then we turn to the dynamic regret. Our analysis relies on an additional assumption [2, 32, 5].
393
+
394
+ Assumption 4.5 (Temporal variability). For each $i \in \{ 1 , \ldots , m \}$ , there exists some positive and finite $V _ { T }$ such that $\begin{array} { r } { \sum _ { t = 1 } ^ { T - 1 } \operatorname* { s u p } _ { x \in \mathcal { X } } | f _ { t } ^ { i } ( x ) - f _ { t + 1 } ^ { i } ( x ) | \leq V _ { T } } \end{array}$ .
395
+
396
+ Theorem 4.6. Assume the step size satisfies 310 $\begin{array} { r } { \frac { 4 V _ { T } } { G ^ { 2 } T } \leq \eta \leq \frac { 4 V _ { T } } { G ^ { 2 } } } \end{array}$ . Then under all the above assumptions, 311 for any preference $\lambda _ { 0 } \in { S _ { m } }$ , OMMD with min-regularized-norm attains
397
+
398
+ $$
399
+ R _ { \mathrm { M O D } } ( T ) \leq \frac { \eta G ^ { 2 } T } { 2 } + \frac { 4 \gamma D V _ { T } } { \eta ^ { 2 } G ^ { 2 } } + \frac { \eta } { 2 } \sum _ { t = 1 } ^ { T } ( \Vert \nabla F _ { t } ( x _ { t } ) \lambda _ { t } \Vert _ { 2 } ^ { 2 } + \frac { 8 F G ^ { 2 } T } { V _ { T } } \Vert \lambda _ { t } - \lambda _ { 0 } \Vert _ { 1 } ) .
400
+ $$
401
+
402
+ Remark. When 312 $\begin{array} { r } { \eta = \frac { 2 } { G } ( \frac { \gamma D V _ { T } } { G T } ) ^ { 1 / 3 } , \alpha = \frac { 8 F G ^ { 2 } T } { V _ { T } } } \end{array}$ , the bound is in the order of $O ( T ^ { 2 / 3 } V _ { T } ^ { 1 / 3 } )$ , matching 313 the best attainable single-objective dynamic regret bound [2, 35] (see more details in Appendix E).
403
+
404
+ # 5 Experiments
405
+
406
+ In this section, we conduct extensive experiments to evaluate the effectiveness of DR-OMMD. We consider two baselines: (i) linearization performs single-objective online learning on the linearized loss $\lambda _ { 0 } ^ { \top } F _ { t }$ at each round $t$ , where the weights $\lambda _ { 0 } \in { S _ { m } }$ are given beforehand; note that it is equivalent to computing composite gradients with fixed weights $\lambda _ { t } \equiv \lambda _ { 0 }$ . (ii) min-norm equips OMD with vanilla min-norm [7] for gradient composition.
407
+
408
+ # 5.1 Simulation Experiments: Tracking the Pareto Front
409
+
410
+ As summarized in Figure 1 (a), the goal is to track two points $\xi _ { t } ^ { 1 } , \xi _ { t } ^ { 2 }$ cycling along a circle ${ \mathcal { C } } = \{ \xi \in { }$ $\mathbb { R } ^ { 2 } \mid \| \xi \| _ { 2 } = 1 \}$ . For each $i \in \{ 1 , 2 \}$ , $\xi _ { t } ^ { i } = ( \cos \theta _ { t } ^ { i } , \sin \bar { \theta } _ { t } ^ { i } )$ is determined by some angle $\theta _ { t } ^ { i }$ . We set a positive integer $P ^ { i }$ as the rotating period of $\xi _ { t } ^ { i }$ , which is unknown to the learner. The two points are initialized by $\theta _ { 1 } ^ { 1 } = 0$ and $\theta _ { 1 } ^ { 2 } = \pi / 2$ and move as follows: at each round $t$ , for each $i \in \{ 1 , 2 \}$ , the adversary independently samples an angle $\delta _ { t } ^ { i }$ from a Gaussian distribution $\mathcal { N } ( { 2 \pi } / { P ^ { i } } , { 1 } / { \sqrt { P ^ { i } } } )$ , then moves the $i$ -th point to $\xi _ { t + 1 } ^ { i } \bar { \mathbf { \xi } } = ( \cos \theta _ { t + 1 } ^ { i } , \sin \theta _ { t + 1 } ^ { i } )$ where $\theta _ { t + 1 } ^ { i } = \theta _ { t } ^ { i } - \delta _ { t } ^ { i }$ . Note that $\mathbb { E } \theta _ { t + 1 } ^ { i } =$ $\theta _ { 1 } ^ { i } + 2 \pi t / P ^ { i }$ , hence in average $\xi _ { t } ^ { i }$ rotates clockwise with a period of $P ^ { i }$ . At each round $t$ , the learner 1 generates a decision $x _ { t }$ from a $L 2$ -norm ball $\mathcal { X } = \{ x \in \mathbb { R } ^ { 2 ^ { \cdot } } | \ \| x \| _ { 2 } \leq 2 \}$ . Then it acquires $\xi _ { t } ^ { 1 } , \xi _ { t } ^ { 2 }$ and suffer the losses $f _ { t } ^ { i } ( x _ { t } ) = \| x _ { t } - \xi _ { t } ^ { i } \| _ { 2 } ^ { 2 } / 2 , i \in \{ 1 , 2 \}$ . In this problem, the Pareto set of $F _ { t } = ( f _ { t } ^ { \mathrm { i } } , f _ { t } ^ { 2 } )$ is exactly the line segment between $\xi _ { t } ^ { 1 }$ and $\xi _ { t } ^ { 2 }$ , i.e., $\mathcal { X } _ { t } ^ { * } = \{ \lambda \xi _ { t } ^ { 1 } + ( 1 - \lambda ) \xi _ { t } ^ { 2 } \ | \ \lambda \in [ 0 , 1 ] \}$ . A t each round $t$ , PSG measures the squared distance between $x _ { t }$ and $\mathcal { X } _ { t } ^ { \ast }$ .
411
+
412
+ 332 We run $T = 1 0 , 0 0 0$ rounds. To simulate the pattern drift, we set $P ^ { 1 } = 1 0 , P ^ { 2 } = 2 0$ at the first
413
+ 333 $T _ { 1 } = 3 , 0 0 0$ rounds, and $P ^ { 1 } = 2 0 , P ^ { 2 } = 1 0$ at the last $T _ { 2 } = 7 , 0 0 0$ rounds. For linearization,
414
+ 334 the weights $\lambda _ { 0 } = ( \lambda _ { 0 } ^ { 1 } , 1 - \lambda _ { 0 } ^ { 1 } )$ are decided via a grid search $\lambda _ { 0 } ^ { 1 } \in \{ 0 , 0 . 1 , . . . , 1 \}$ ; we consider
415
+ 335 three variants: lin- $^ { 1 }$ uses the optimal $\lambda _ { 0 }$ for the first $T _ { 1 }$ rounds, lin-2 uses the optimal $\lambda _ { 0 }$ for the
416
+ 336 last $T _ { 2 }$ rounds, and lin-opt uses the optimal $\lambda _ { 0 }$ for all $T$ rounds. For DR-OMMD, for fairness of
417
+
418
+ ![](images/a3b4326a03d8acf25d9ced0df3ebeaa1dfb1dd10d00da99c7cc03a87bd49e358.jpg)
419
+ Figure 1: Simulation setup and results. (a) The targets $\xi _ { t } ^ { 1 } , \xi _ { t } ^ { 2 }$ cycle along the circle. The Pareto set at each round is the line segment $[ \xi _ { t } ^ { 1 } , \xi _ { t } ^ { 2 } ]$ PSG measures the distance from $x _ { t }$ to $[ \xi _ { t } ^ { 1 } , \xi _ { t } ^ { 2 } ]$ (b) Performance of DR-OMMD and baselines.
420
+
421
+ ![](images/30ee82d59d0ad7951da9536a53b3265f80f8ed0fa2dccfd60c48a4136590979b.jpg)
422
+ Figure 2: Results to verify the effectiveness of adaptive regularization on protein. (a) Performance of DR-OMMD and linearization under varying $\lambda _ { 0 } = ( \lambda _ { 0 } ^ { 1 } , 1 - \lambda _ { 0 } ^ { 1 } )$ . (b) Performance using the optimal weights $\lambda _ { 0 } = ( 0 . 1 , 0 . 9 )$ .
423
+
424
+ comparison we use the same $\lambda _ { 0 }$ of lin-opt. The learning rates $\eta$ in all algorithms and the parameter $\alpha$ in DR-OMMD follow the corresponding theories (e.g., Theorem 4.6). In this experiment, since the loss functions are manually designed, the value of $V _ { T }$ can be directly calculated. Note that in some scenarios where $V _ { T }$ is unknown, we can conduct a grid search and utilize a meta-algorithm to handle the unknown $V _ { T }$ [37, 1], similar to the single-objective setting. From the results in Figure 1 (b), we find that DR-OMMD achieves the lowest PSG, showing its ability to track the Pareto front; meanwhile, min-norm appears very unstable in the online setting, even worse than linearization.
425
+
426
+ # 5.2 Convex Experiments: Adaptive Regularization via Multi-Objective Optimization
427
+
428
+ In many real-world online scenarios, regularization is often adopted to avoid overfitting. A standard way is to add a term $r ( x )$ to the loss $f _ { t } ( x )$ at each round and optimize the regularized loss $f _ { t } ( x ) +$ $\sigma r ( x )$ [24], where $\sigma$ is treated as a hyperparameter that needs to be fixed beforehand. The formalism of multi-objective online learning provides a novel way to realize regularization. Since $r ( x )$ measures the complexity of $x$ , it can be regarded as the second objective alongside the primary goal $f _ { t } ( x )$ . We can construct a vector loss $F _ { t } ( \bar { x ) = ( f _ { t } ( x ) , r ( x ) ) }$ at each round and thereby cast regularized online learning into a bi-objective online optimization problem. Compared to fixed regularization, the new approach effectively chooses the regularization strength $\sigma _ { t } = \bar { \lambda } _ { t } ^ { 2 } / \lambda _ { t } ^ { 1 }$ in an adaptive way.
429
+
430
+ 353 We use two large-scale online benchmark datasets. (i) protein is a bioinformatics dataset for protein
431
+ 354 type classification [31], which has 17 thousand instances with 357 features. (ii) covtype is a biological
432
+ 355 dataset collected from a non-stationary environment for forest cover type prediction [3], which has
433
+ 356 50 thousand instances with 54 features. For both tasks, we set the logistic loss of classification as
434
+ 357 the first objective, and the squared $L 2$ -norm of model parameters as the second objective. Since the
435
+ 358 ultimate goal of regularization is to enhance predictive performance, we adopt the average loss as the
436
+ 359 performance metric, namely $\textstyle \sum _ { t \leq T } l _ { t } ( x _ { t } ) / { \bar { T } }$ , where $l _ { t } ( x _ { t } )$ is the classification loss at round $t$ .
437
+
438
+ We adopt a $L 2$ -norm ball centered at the origin with diameter $K = 1 0 0$ as the decision set. The learning rates are decided by a grid search over $\{ 0 . 1 , 0 . 2 , \ldots , 3 . 0 \}$ . For DR-OMMD, the parameter $\alpha$ is simply set as 0.1. For fixed regularization, the strength $\sigma = ( 1 - \lambda _ { 0 } ^ { 1 } ) / \lambda _ { 0 } ^ { 1 }$ is determined by the some preference $\lambda _ { 0 } ^ { 1 } \in [ 0 , 1 ]$ , which is essentially linearization with weights $\overset { \vartriangle } { \lambda _ { 0 } } = ( \lambda _ { 0 } ^ { 1 } , 1 - \lambda _ { 0 } ^ { \bar { 1 } } )$ . We run both algorithms with varying initial weights $\lambda _ { 0 } ^ { 1 } \in \{ 0 , 0 . 1 , . . . , 1 \}$ . In Figure 2, we plot (a) their final performance w.r.t. the choice of $\lambda _ { 0 }$ and (b) their learning curves with desirable $\lambda _ { 0 }$ (e.g., (0.1, 0.9) on protein). Other results are deferred to the appendix due to the lack of space. The results show that DR-OMMD consistently outperforms fixed regularization.
439
+
440
+ # 6 Conclusions
441
+
442
+ In this paper, we give a systematic study of multi-objective optimization in the online setting. We first formulate the framework of Multi-Objective Online Convex Optimization. Then we devise the Doubly Regularized Online Mirror Multiple Descent algorithm, which has a special design for gradient composition in online learning, namely min-regularized-norm. We provide non-trivial regret bounds for DR-OMMD and conduct extensive experiments to demonstrate its effectiveness.
443
+
444
+ Limitations. As the first step of studying multiple gradient algorithm in online learning, we conduct our analysis in the convex setting. Although it does not affect the usage in the non-convex setting (see empirical validation in Appendix F), we can give a formal non-convex analysis in the future.
445
+
446
+ References
447
+ [1] Dheeraj Baby and Yu-Xiang Wang. Optimal dynamic regret in exp-concave online learning. In Conference on Learning Theory, pages 359–409. PMLR, 2021.
448
+ [2] Omar Besbes, Yonatan Gur, and Assaf Zeevi. Non-stationary stochastic optimization. Operations Research, 63(5):1227–1244, 2015.
449
+ [3] Jock A Blackard and Denis 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, 1999.
450
+ [4] Lucas Bradstreet. The hypervolume indicator for multi-objective optimisation: calculation and use. University of Western Australia Perth, 2011.
451
+ [5] Nicolò Campolongo and Francesco Orabona. A closer look at temporal variability in dynamic online learning. arXiv preprint arXiv:2102.07666, 2021.
452
+ [6] Kalyanmoy Deb. Multi-objective optimization. In Search methodologies, pages 403–449. 2014.
453
+ [7] Jean-Antoine Désidéri. Multiple-gradient descent algorithm for multiobjective optimization. Comptes Rendus Mathematique, 350(5-6):313–318, 2012.
454
+ [8] John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. Journal of machine learning research, 12(7), 2011.
455
+ [9] Jörg Fliege and Benar Fux Svaiter. Steepest descent methods for multicriteria optimization. Mathematical Methods of Operations Research, 51(3):479–494, 2000.
456
+ [10] Eric Hall and Rebecca Willett. Dynamical models and tracking regret in online convex programming. In International Conference on Machine Learning, pages 579–587, 2013.
457
+ [11] Elad Hazan et al. Introduction to online convex optimization. Foundations and Trends® in Optimization, 2(3-4):157–325, 2016.
458
+ [12] Xinyu Huang, Peng Wang, Xinjing Cheng, Dingfu Zhou, Qichuan Geng, and Ruigang Yang. The apolloscape open dataset for autonomous driving and its application. IEEE Transactions on Pattern Analysis and Machine Intelligence, 42(10):2702–2719, 2019.
459
+ [13] Ali Jadbabaie, Alexander Rakhlin, Shahin Shahrampour, and Karthik Sridharan. Online optimization: Competing with dynamic comparators. In Artificial Intelligence and Statistics, pages 398–406, 2015.
460
+ [14] Martin Jaggi. Revisiting Frank-Wolfe: Projection-free sparse convex optimization. In International Conference on Machine Learning, pages 427–435, 2013.
461
+ [15] Alex Kendall, Yarin Gal, and Roberto Cipolla. Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. In IEEE Conference on Computer Vision and Pattern Recognition, pages 7482–7491, 2018.
462
+ [16] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
463
+ [17] Xi Lin, Hui-Ling Zhen, Zhenhua Li, Qing-Fu Zhang, and Sam Kwong. Pareto multi-task learning. In Advances in Neural Information Processing Systems, pages 12060–12070, 2019.
464
+ [18] Bo Liu, Xingchao Liu, Xiaojie Jin, Peter Stone, and Qiang Liu. Conflict-averse gradient descent for multi-task learning. arXiv preprint arXiv:2110.14048, 2021.
465
+ [19] Shiyin Lu, Guanghui Wang, Yao Hu, and Lijun Zhang. Multi-objective generalized linear bandits. In International Joint Conference on Artificial Intelligence, pages 3080–3086, 2019.
466
+ [20] Weixin Lu, Yao Zhou, Guowei Wan, Shenhua Hou, and Shiyu Song. L3-net: Towards learning based lidar localization for autonomous driving. In IEEE Conference on Computer Vision and Pattern Recognition, pages 6389–6398, 2019.
467
+ [21] Jiaqi Ma, Zhe Zhao, Xinyang Yi, Jilin Chen, Lichan Hong, and Ed H Chi. Modeling task relationships in multi-task learning with multi-gate mixture-of-experts. In International Conference on Knowledge Discovery & Data Mining, pages 1930–1939, 2018.
468
+ [22] Xiao Ma, Liqin Zhao, Guan Huang, Zhi Wang, Zelin Hu, Xiaoqiang Zhu, and Kun Gai. Entire space multi-task model: An effective approach for estimating post-click conversion rate. In International ACM SIGIR Conference on Research & Development in Information Retrieval, pages 1137–1140, 2018.
469
+ [23] R Timothy Marler and Jasbir S Arora. Survey of multi-objective optimization methods for engineering. Structural and Multidisciplinary Optimization, 26(6):369–395, 2004.
470
+ [24] Brendan McMahan. Follow-the-regularized-leader and mirror descent: Equivalence theorems and L1 regularization. In International Conference on Artificial Intelligence and Statistics, pages 525–533, 2011.
471
+ [25] H Brendan McMahan. A survey of algorithms and analysis for adaptive online learning. The Journal of Machine Learning Research, 18(1):3117–3166, 2017.
472
+ [26] Tadahiko Murata, Hisao Ishibuchi, et al. MOGA: multi-objective genetic algorithms. In IEEE International Conference on Evolutionary Computation, pages 289–294, 1995.
473
+ [27] Francesco Orabona. A modern introduction to online learning. arXiv preprint arXiv:1912.13213, 2019.
474
+ [28] Sashank J Reddi, Satyen Kale, and Sanjiv Kumar. On the convergence of Adam and beyond. In International Conference on Learning Representations, 2018.
475
+ [29] Ozan Sener and Vladlen Koltun. Multi-task learning as multi-objective optimization. In Advances in Neural Information Processing Systems, pages 525–536, 2018.
476
+ [30] Eralp Turgay, Doruk Oner, and Cem Tekin. Multi-objective contextual bandit problem with similarity information. In International Conference on Artificial Intelligence and Statistics, pages 1673–1681, 2018.
477
+ [31] Jung-Ying Wang. Application of support vector machines in bioinformatics. PhD thesis, National Taiwan University, 2002.
478
+ [32] Tianbao Yang, Lijun Zhang, Rong Jin, and Jinfeng Yi. Tracking slowly moving clairvoyant: Optimal dynamic regret of online learning with true and noisy gradient. In International Conference on Machine Learning, pages 449–457, 2016.
479
+ [33] Tianhe Yu, Saurabh Kumar, Abhishek Gupta, Sergey Levine, Karol Hausman, and Chelsea Finn. Gradient surgery for multi-task learning. In Advances in Neural Information Processing Systems, pages 5824–5836, 2020.
480
+ [34] Lijun Zhang, Shiyin Lu, and Zhi-Hua Zhou. Adaptive online learning in dynamic environments. In Advances in Neural Information Processing Systems, pages 1330–1340, 2018.
481
+ [35] Lijun Zhang, Tianbao Yang, Zhi-Hua Zhou, et al. Dynamic regret of strongly adaptive methods. In International Conference on Machine Learning, pages 5882–5891, 2018.
482
+ [36] Richard Zhang and Daniel Golovin. Random hypervolume scalarizations for provable multiobjective black box optimization. In International Conference on Machine Learning, pages 11096–11105, 2020.
483
+ [37] Peng Zhao, Yu-Jie Zhang, Lijun Zhang, and Zhi-Hua Zhou. Dynamic regret of convex and smooth functions. Advances in Neural Information Processing Systems, 33:12510–12520, 2020.
484
+ [38] Martin Zinkevich. Online convex programming and generalized infinitesimal gradient ascent. In International Conference on Machine Learning, pages 928–936, 2003.
485
+ [39] Eckart Zitzler and Lothar Thiele. Multiobjective evolutionary algorithms: A comparative case study and the strength Pareto approach. IEEE transactions on Evolutionary Computation, 3(4):257–271, 1999.
486
+
487
+ 1. For all authors...
488
+
489
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
490
+ (b) Did you describe the limitations of your work? [Yes] See Section 6.
491
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A] Our work is concerning a general problem in online learning.
492
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
493
+
494
+ 2. If you are including theoretical results...
495
+
496
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 4.3. (b) Did you include complete proofs of all theoretical results? [Yes] See Appendix G, H, I.
497
+
498
+ 3. If you ran experiments...
499
+
500
+ (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] They are included in the supplementary materials.
501
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.
502
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A] We conduct online learning experiments, where the learning process is deterministic.
503
+ (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 E.
504
+
505
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
506
+
507
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We cite the source of datasets.
508
+ (b) Did you mention the license of the assets? [Yes] In the supplemental material.
509
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] Our codes are provided in the supplemental material.
510
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] We only use publicly available benchmark datasets.
511
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] We only use publicly available benchmark datasets.
512
+
513
+ 5. If you used crowdsourcing or conducted research with human subjects...
514
+
515
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
516
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
517
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/o4uFFg9_TpV/o4uFFg9_TpV.md ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Visual Prompting via Image Inpainting
2
+
3
+ Amir Bar∗ 1,2, Yossi Gandelsman∗ 1, Trevor Darrell1, Amir Globerson2,3, Alexei A. Efros1
4
+
5
+ 1UC Berkeley
6
+
7
+ 2Tel Aviv University
8
+
9
+ 3Google Research
10
+
11
+ # Abstract
12
+
13
+ How does one adapt a pre-trained visual model to novel downstream tasks without task-specific finetuning or any model modification? Inspired by prompting in NLP, this paper investigates visual prompting: given input-output image example(s) of a new task at test time and a new input image, the goal is to automatically produce the output image, consistent with the given examples. We show that posing this problem as simple image inpainting – literally just filling in a hole in a concatenated visual prompt image – turns out to be surprisingly effective, provided that the inpainting algorithm has been trained on the right data. We train masked auto-encoders on a new dataset that we curated $- 8 8 \mathrm { k }$ unlabeled figures from academic papers sources on Arxiv. We apply visual prompting to these pretrained models and demonstrate results on various downstream image-to-image tasks, including foreground segmentation, single object detection, colorization, edge detection, etc.1
14
+
15
+ # 1 Introduction
16
+
17
+ In the past few years, self-supervised learning has gained popularity in computer vision and natural language processing (NLP). The growing capacity of modern deep learning models made them prone to overfitting when trained on relatively small labeled datasets. Self-supervised learning provides a solution to this problem by generating “free labels” for any dataset, without the need for manual annotation, addressing the data hunger in these high-capacity deep learning models. However, features learned via self-supervision are not “ready for use” – they typically need to be adapted for a given downstream task by fine-tuning on some labeled dataset. Could this fine-tuning be avoided?
18
+
19
+ In NLP, prompting [5] has recently emerged as a way to employ a model for a new task without any additional training. A common way of task-prompting for a specific language understanding task at test time is to provide the trained model with an input corresponding to example(s) of the target task together with the query. E.g., typing the following input prompt:
20
+
21
+ Je suis désolé J’adore la glace
22
+
23
+ I’m sorry
24
+
25
+ will prompt the model [5] to perform the task of French-to-English translation, returning: I love ice cream
26
+
27
+ Can this idea of test-time task prompting be generalized to the visual domain? That is, instead of the current situation in computer vision, where each trained model serves its predefined task (e.g. segmentation, detection, classification), can we have a single general model that can perform a wide range of user-specified tasks without any fine-tuning (i.e., weight modification)?
28
+
29
+ In this paper we take a step toward this goal by demonstrating that large-capacity image inpainting models, when trained on the right data, can be surprisingly effective tools for visual prompting.
30
+
31
+ ![](images/fec7d4f1c4f22fc04019a2d3145f43606b948aaba229095b8b23ad7299c7715b.jpg)
32
+ Figure 1: Visual prompting via Image Inpainting. Top: Prompting Image Inpainting Models. Given inputoutput example(s) $( x _ { 1 } , y _ { 1 } )$ and image query $x _ { q }$ , we construct a grid-like single image called a visual prompt $x _ { v p }$ . The visual prompt is composed of the desired task example(s) and a new query image (all in green). The inpainting model goal is then to predict the masked region (red) such that it is consistent with the example(s). Bottom: an inpainting model can solve this way various computer vision tasks, given that it was trained on the right data. The model predictions are annotated in red.
33
+
34
+ As shown in Figure 1, we define each task by constructing a new grid-like image that contains an input-output example(s) of the task and a novel query (green border). The input-output example describes the task, and the image query defines a new input. The model then produces the result by simply inpainting the rest of the image (red border). This setting is most similar to the classic Image Analogies [22] formulation, but is less constrained: instead of explicitly defining the A, A’, and B images separately, we simply concatenate them into a single image with a hole (hence, visual prompting is not exactly an analogy since there is no implied left-to-right ordering). Our goal is also not dissimilar from the aims of meta-learning and few-shot learning methods, except that we make no distinction between tasks and example pairs. The only requirement of our formulation is that the tasks must be defined as image-to-image translations, which is a very large subset of vision problems.
35
+
36
+ To obtain training data that is most useful for our framework, we utilize a domain that spans across a variety of computer vision tasks - figures and infographics from computer vision articles available on Arxiv. We build a large dataset of 88 thousand figures, many of which contain grids of images and their corresponding task results (e.g. images and their segmentation masks/stylized versions/edges, etc.). We then train large-capacity inpainting models to predict randomly masked patches from figures given other patches from the same figure.
37
+
38
+ Our main contributions are as follows. First, we present a simple yet surprisingly powerful general approach for visual prompting. We show that various computer vision tasks can be treated as grid inpainting problems, given a few examples of task inputs and outputs and a query image. Second, we provide a new dataset that allows a model to learn such grid structures without any labeling, task descriptions, or any additional information about the grid structure. Finally, we show that while using our new dataset for training is essential, adding more generic image data from other sources (e.g. ImageNet) further improves the results.
39
+
40
+ # 2 Related Work
41
+
42
+ Natural Image Inpainting. Filling empty regions in an image has been widely explored for natural images. Earlier methods used data from the input image itself for inpainting [14, 4, 11, 3, 49], whereas later works utilized datasets of images as source data [19, 38, 56, 30, 31]. Recent methods have attempted to apply transformers to visual synthesis tasks [8, 58, 15, 57, 7]. Due to the exponentially large number of completion options for a single output patch, these approaches rely on a discrete latent codebook [51, 40, 15] which serves as a smaller yet expressive vocabulary. To tackle the multimodal nature of synthesis, different approaches have been proposed to model the distribution over possible completions [15, 57, 7]. For example, [15, 57] proposed to synthesize images line-by-line using an autoregressive model and [7] have proposed iterative parallel decoding. While the standard inpainting task typically aims to complete blank parts in natural images, our focus is on completing grid-like visual prompts, which require reasoning across multiple images within the visual prompt image.
43
+
44
+ Hole-filling as a Pretext task. Recent work has shown that self-supervised pretraining can generate powerful representations for transfer learning, even outperforming its supervised counterparts on challenging vision benchmarks [37, 18, 9, 21, 6, 10, 35, 16]. Pathak et al. [38] first proposed using hole-filling as a pretext task for self-supervision with Context Encoders, where the goal is to predict an random image region given its context. Based on the recent success of Vision Transformers (ViTs) [13], multiple works have proposed to hole-filling a self-supervised pretext task for ViTs [1, 20, 54]. For example, in MAE [20], the goals is to reconstruct the image given a small subset of input patches. After pretraining on unlabeled data, MAE can produce representations that transfer well when fine-tuned on downstream tasks. Here, we use visual prompting to adapt these models to downstream tasks without any finetuning.
45
+
46
+ Few-Shot Learning. In this setting, the algorithm is trained on a labeled dataset of base classes, from which it should transfer to a set of novel classes given only a few training examples (like 10 or 30) [36, 27, 32, 53, 55, 48, 59, 2]. Unlike Few-Shot approaches, here we do not assume access to a large training set of base-classes, and our architecture is not task-specific. Our approach is Few-Shot only in the sense that we construct a visual prompt that contains one or two task examples.
47
+
48
+ Image Analogies. Hertzmann et. al. [22] proposed the framework of Image Analogies for texture synthesis, where the algorithm is given a pair of training images (A and A’) and a query image (B). The goal is to synthesize a new image (B’) conditioned on the query, following the relationship inferred from the training pair. Other works have used analogies in style transfer [50], and as a supervised image synthesis task [41]. Predicting the correct completion was previously modeled as a classification problem [43, 23], and other works have explored analogies in the context of learning different transformations between pairs of images [34, 46]. Unlike these approaches, we use inpainting MAE models that learn from data, without assuming any predefined analogies structure.
49
+
50
+ Prompting in NLP. With the recent success of large unsupervised language models [44, 12], Brown et al. [5] presented how a variety of NLP problems can be reformulated to a text completion problem given a predefined prompt, which can be used to solve different tasks without any finetuning. Prompting was shown to be a useful tool for solving various NLP tasks and benchmarks [39, 5]. More recently different approaches to prompting have emerged including Prompt Engineering [5, 33], Prompt Ensembling [25], and Prompt Prefix Tuning [29, 28]. Inspired by the success of prompting in NLP, we aim to study prompting in computer vision where prompting hasn’t been widely explored.
51
+
52
+ # 3 Visual Prompting via Image Inpainting
53
+
54
+ We turn to describe how to perform visual prompting using Image Inpainting models. In Section 3.1, we describe our proposed inpainting model, which is a combination of MAE and VQGAN. We then proceed to discuss visual prompting and propose different ways to create visual prompts in Section 3.2 (see example in Figure 1). Finally, we describe the dataset we collected for training our model in Section 3.3. The training process is illustrated in Figure 2
55
+
56
+ ![](images/ecffaf0dad8bf931711f0f0e8faef13d41e8dba16c073af72f769f0c6689dbcc.jpg)
57
+ Figure 2: MAE-VQGAN Architecture. During training, an input image is patchified, masked and fed into an MAE [20]. For each masked token, the decoder outputs a distribution over a pretrained VQGAN [15] codebook. The model is trained using cross entropy loss.
58
+
59
+ # 3.1 Inpainting using MAE-VQGAN
60
+
61
+ Given an input image $\boldsymbol { x } \in \mathbb { R } ^ { H \times W \times 3 }$ and a binary mask $\bar { m } \in \{ 0 , 1 \} ^ { H \times W }$ , the goal of an inpainting function $f$ is to synthesize a new image $\mathbf { \chi } _ { y } ^ { \star } \in \mathbb { R } ^ { \breve { H } \times W \times 3 }$ , with the masked regions filled:
62
+
63
+ $$
64
+ y = f ( x , m )
65
+ $$
66
+
67
+ To implement $f$ with a neural network, it is necessary to consider design choices like the network architecture, how to train it, and whether it outputs a distribution over possible completions or pixels. We propose the MAE-VQGAN model, which combines ideas from MAE [20] and VQGAN [15]. Following the design of MAE, the model is based on ViT [52, 13] and it is trained via masked auto-encoding by randomly masking image patches and then applying $f$ to reconstruct the image from the non-masked parts. MAE-VQGAN models the distribution $p _ { \theta } ( z _ { i } | x , m )$ , where $z _ { i } \in V$ is a visual token from a VQGAN vocabulary $V$ that corresponds to the $i ^ { t h }$ ViT patch. For simplicity, we use a fixed ImageNet pretrained VQGAN codebook.2 Unlike MAE which directly predicts pixels, MAE-VQGAN assigns probabilities to visual tokens via a softmax layer, which is better suited for capturing ambiguities. During training, we obtain ground truth visual tokens by mapping the image to visual tokens indices using the VQGAN encoder. The model is trained using cross entropy loss.
68
+
69
+ Let $\hat { z } = ( { \hat { z } } _ { 1 } , . . . , { \hat { z } } _ { k } )$ be the ordered set of predicted visual tokens. To obtain $\hat { z } _ { i }$ , we use argmax:
70
+
71
+ $$
72
+ \hat { z } _ { i } = \arg \operatorname* { m a x } _ { z _ { i } } p _ { \theta } ( z _ { i } | x , m )
73
+ $$
74
+
75
+ Then, to decode the visual tokens to pixels, we apply VQGAN decoder to $\hat { z }$ to obtain $y$
76
+
77
+ # 3.2 Prompting Inpainting Models
78
+
79
+ To prompt an inpainting model, we construct a visual prompt, a grid-like image composed of task input-output example(s), and a new query image. The model then has to inpaint the rest of the image such that it is consistent with the task defined in the examples (see Figure 1).
80
+
81
+ Let $S = \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { n }$ be the set of input-output examples where $x _ { i }$ is an image and $y _ { i }$ is a function of $x _ { i }$ (e.g $y _ { i }$ is a segmentation mask). We assume $n$ is small (one or few examples). Then, given $S$ and a new input query $x _ { q }$ , the goal is to predict the corresponding label $y _ { q }$ . To prompt the inpainting model discussed in Section 3.1, we need to define a function $g$ that maps the examples set $S$ and query image $x _ { q }$ to a new image and a mask:
82
+
83
+ $$
84
+ [ x _ { v p } , m ] = g ( S , x _ { q } )
85
+ $$
86
+
87
+ The image $x _ { v p }$ is the visual prompt and the mask $m$ defines the masked region $f$ has to predict. For a given task, there might exist multiple implementations of $g$ that can be considered. The goal of the inpainting model is to reason about the visual prompt $x _ { v p }$ , and output a plausible completion without performing any additional training:
88
+
89
+ $$
90
+ y _ { v p } = f ( x _ { v p } , m )
91
+ $$
92
+
93
+ To obtain $y _ { q }$ , we just take the part of $y _ { v p }$ corresponding to the mask $m$ .
94
+
95
+ Visual Prompt Engineering. For the visual prompting to work, $g$ should output a good visual prompt, composed of the examples $S$ and query image $x _ { q }$ . Therefore, $g$ has to determine where and how to embed the inputs in the visual prompt image, considering the nature of the completion task. All the functions $g$ used in this work were hard-coded and manually engineered. In most cases, $g$ stacks the examples and image query horizontally by creating an image grid of $( n + 1 ) \times 2$ cells, where the $i ^ { t h }$ example is placed in the $i ^ { t h }$ row, and the image query is in the last row. The grid has a fixed size, and therefore before populating it the input-output example pair(s) and query are first resized. Another consideration is how to draw every $( x _ { i } , y _ { i } )$ pair. For example, if $y _ { i }$ is a segmentation mask, we can choose to use different colors to draw it. In Section 4.4, we describe different prompt design choices and their effect on the results.
96
+
97
+ Visual Prompt Ensembling. There could be multiple options to define $g$ . The idea in prompt ensembling, inspired by NLP [25, 28], is to construct multiple different prompts, apply the inpainting model $f$ on each prompt individually to obtain a set of predictions. The final prediction can be determined, for example, via majority voting, or weighted average. For simplicity, here we use a simple average.
98
+
99
+ # 3.3 The Computer Vision Figures Dataset
100
+
101
+ The images produced by $g$ are by construction not natural. Specifically, these images have a grid-like figure structure that stitches together images coming from different distributions, like natural images and segmentation masks. Therefore, a model trained on a standard dataset (e.g., ImageNet [42]) might struggle to process these grid-like images. To mitigate the domain gap, we collected a new dataset.
102
+
103
+ ![](images/8a7b2296c82977e9981ac9504467bad93e2894c68e0e878e8fa9b9751d4e0448.jpg)
104
+ Figure 3: Random images from our Computer Vision Figures dataset. We curated a dataset of 88k unlabeled figures from Computer Vision academic papers. During training, we randomly sample crops from these figures, without any additional parsing.
105
+
106
+ The Computer Vision Figures (Figures) dataset consists of 88, 645 images that more closely resemble the structure of our visual prompts. The dataset was collected from Arxiv, the open-access web archive for scholarly articles from a variety of academic fields. Arxiv sources are publicly available to download starting from 2010. We downloaded all paper sources from 2010 to 2022 and selected the Computer-Vision partition “cs.CV” sources, as they contain images that more closely resemble a grid structure, as shown in Figure 3. To remove unrelated source images like graphs or charts, we manually tagged 2000 images and trained a binary image classifier to assign a high score to source images in a figure-like structure with at least one natural image. We then used the classifier over the entire data to keep only the most informative source images, coming from 23, 302 different papers. We randomly partitioned $9 0 \%$ of the data to train and left the rest for validation. We include a datasheet with more information in the Supplementary Material.
107
+
108
+ # 4 Experiments and Results
109
+
110
+ To study visual prompting, we pretrain different models (see Section 4.1) on ImageNet and on the Figures dataset, then quantitatively evaluate the models using different prompts on simple downstream computer vision tasks (see Section 4.2). Using a synthetic dataset, we assess how the choice of model and data affect the success of visual prompting in Section 4.3, and explore different prompting design choices in Section 4.4. We provide a large variate of qualitative results both in this section as well as in the Supplementary Material.
111
+
112
+ # 4.1 Models and Baselines
113
+
114
+ To study the effect of model choice on prompting results, we experiment using different models, including MAE-VQGAN (see Section 3.1) and several other inpainting models briefly described below.
115
+
116
+ VQGAN [15] is an autoregressive transformer model used for inpainting and image generation. Visual tokens are predicted sequentially, line-by-line, and the model is trained using cross-entropy loss. The VQGAN model codebook is used to encode visual tokens, and it is trained beforehand using perceptual loss [26] and GAN loss [17]. We train it on ImageNet and our Figures dataset, following hyperparams in [15], and use a pretrained codebook with a vocabulary of size $| V | = 1 0 2 4$
117
+
118
+ BEiT [1] is a masked auto-encoder. The model maps each input $1 6 \times 1 6$ patch to a visual token from a d-VAE [40] vocabulary of size 8192. To encode each visual token, the image is first resized to $1 1 2 \times 1 1 2$ and then mapped to 196 tokens. We use the publicly available BEiT large model, pretrained on ImageNet-21k. We also pretrain a large BEiT model on Figures for 1000 epochs.
119
+
120
+ MAE [20]. Similar to BEiT, MAEs attempt to reconstruct a masked input image. Unlike in BEiT, the model directly regresses pixels and it is trained with l2 loss. During pretraining, only non-masked tokens are fed into the encoder, which results in a faster training time. We use a publicly released checkpoint pretrained on ImageNet, and pretrain another model for 1000 epochs on our dataset.
121
+
122
+ Table 1: Visual prompting results on computer vision tasks. For Foreground Segmentation and Single Object Detection, we report the mIOU score. For Colorization, we report the MSE.
123
+
124
+ <table><tr><td rowspan="2">Model</td><td colspan="4">Foreground Segmentation ↑</td><td colspan="3">Single Object Detection ↑</td><td colspan="3">Colorization↓</td></tr><tr><td>Split 0</td><td>Split 1</td><td>Split 2</td><td>Split 3</td><td>Split 1</td><td>Split 2</td><td>Split 3</td><td>Split 4</td><td>MSE</td><td>LPIPS</td></tr><tr><td>Copy</td><td>12.92</td><td>17.90</td><td>13.52</td><td>15.29</td><td>12.14</td><td>13.50</td><td>13.03</td><td>12.38</td><td>2.63</td><td>0.75</td></tr><tr><td>BEiT (IN-21k)</td><td>0.38</td><td>0.93</td><td>0.90</td><td>0.95</td><td>0.24</td><td>0.32</td><td>0.19</td><td>0.10</td><td>1.25</td><td>0.73</td></tr><tr><td>VQGAN (IN-1k)</td><td>6.96</td><td>10.55</td><td>9.59</td><td>9.43</td><td>5.19</td><td>4.99</td><td>5.09</td><td>5.10</td><td>2.44</td><td>0.66</td></tr><tr><td>MAE (IN-1k)</td><td>1.92</td><td>6.76</td><td>3.85</td><td>4.57</td><td>1.37</td><td>1.98</td><td>1.62</td><td>1.62</td><td>1.13</td><td>0.87</td></tr><tr><td>MAE-VQGAN (IN-1k)</td><td>2.22</td><td>7.07</td><td>5.48</td><td>6.28</td><td>3.34</td><td>3.21</td><td>2.80</td><td>2.80</td><td>3.31</td><td>0.75</td></tr><tr><td>BEiT (Figures)</td><td>5.38</td><td>3.94</td><td>3.20</td><td>3.29</td><td>0.17</td><td>0.02</td><td>0.14</td><td>0.16</td><td>0.60</td><td>0.70</td></tr><tr><td>VQGAN (Figures)</td><td>12.56</td><td>17.51</td><td>14.27</td><td>15.06</td><td>2.27</td><td>2.37</td><td>2.48</td><td>1.99</td><td>1.50</td><td>0.56</td></tr><tr><td>MAE (Figures)</td><td>17.42</td><td>25.70</td><td>18.64</td><td>16.53</td><td>5.49</td><td>4.98</td><td>5.24</td><td>5.84</td><td>0.43</td><td>0.55</td></tr><tr><td>MAE-VQGAN (Figures)</td><td>27.83</td><td>30.44</td><td>26.15</td><td>24.25</td><td>24.19</td><td>25.20</td><td>25.36</td><td>25.23</td><td>0.67</td><td>0.40</td></tr></table>
125
+
126
+ Copy Example. This simple baseline simply replicates the first example label as the output.
127
+
128
+ Implementation Details. All the models we describe are large transformer-based models [52, 13], with patch size $1 6 \times 1 6$ , embedding dim 1024, 24 layers, and 16 heads. For training, we used a machine with 8 Quadro RTX 6000 GPUs, with a batch size of 48. The input image size is $2 2 4 \times 2 2 4$
129
+
130
+ # 4.2 Downstream Computer Vision Tasks
131
+
132
+ We quantitatively evaluate the inpainting models described above on computer vision tasks.
133
+
134
+ Visual Prompt. Given one example pair and a query image, we structure the prompt in the same fashion for all tasks. We construct a grid of $2 \times 2$ sub-images, where the example pair is embedded in the first row, and the query image appears in the bottom left cell. See the example in Figure 1.
135
+
136
+ Computer vision tasks. We evaluate the inpainting models on standard image to image tasks like Foreground Segmentation, Single Object Detection and Colorization.
137
+
138
+ • Foreground Segmentation. The goal is to binary-segment the query image to Foreground and Background. The example is an image and corresponding binary segmentation mask. The query is a new image, and the goal is to complete a corresponding segmentation mask. We use the Pascal-5i [45] dataset, which is comprised of 4 different image splits where every split contains between 346 and 725 images and associated segmentation masks. For each class, the data contains a few image-mask pairs, together with held-out image queries. For every image query, we choose one random example pair. To evaluate, every pixel in the completed image is first mapped to the nearest Foreground or Background color. Finally, we report the mean IOU (mIOU) metric.
139
+
140
+ • Single Object Detection. Similarly to Foreground Segmentation, the goal here is to binary-segment the object that appears in the query image. However, this task is more challenging than Foreground Segmentation because the example mask is obtained from a bounding box which is more coarse than a segmentation mask. We use the Pascal VOC 2012 dataset using images and their associated detection boxes. For simplicity, we use Pascal annotations to include only images with a single object and filter out trivial images that have an object covering more than $5 0 \%$ of the image. We randomly select an example pair and image query of the same object class and repeat the process with 4 different random seeds. For evaluation, we follow a similar process as in Foreground Segmentation to obtain a binary segmentation mask. Then we keep the connected component with the largest area using morphological operations and draw a bounding box around it. We report the mIOU results.
141
+
142
+ • Colorization. The goal is to map a gray-scale image to a color image. The example pair is a grayscaled image and the corresponding color image, as shown in Figures 1 and 4. We randomly sampled 1000 example pairs and image query from ImageNet [42] validation set and converted them to grayscale to obtain gray-scale and color version for each image. We report the MSE loss and LPIPS [60].
143
+
144
+ Results. We include quantitative results in Table 1, and qualitative completion results in Figure 4. Training on the Figures dataset improves the results for most models in all the downstream tasks. MAE-VQGAN outperforms the other models by a large margin for detection and segmentation and generates much sharper images than the MAE. We find that VQGAN struggles to output accurate results, likely due to sequential decoding. The BEiT model is outperformed by MAE, most likely because its training process is less sample efficient. For more results, see the Supplementary Material.
145
+
146
+ ![](images/50fc9c05fe7bec156e23b7112259dfe11ed57bb88e120d184fd3d871bb6d1c68.jpg)
147
+ Figure 4: Visual prompting prediction examples. Each visual prompt was fed to an MAE-VQGAN model trained on the Figures dataset. For each visual prompt, the result is marked in red.
148
+
149
+ ![](images/406ff3ca2c3f93e1221d153ed3058b7c8ae47bbc249b604c59a3b16e52b67037.jpg)
150
+ Figure 5: Synthetic data study results. MAE-VQGAN predictions are annotated with a red square.
151
+
152
+ # 4.3 Synthetic Data Study
153
+
154
+ To assess the compositional prediction capabilities of inpainting models, we created a set of 3 simple synthetic tasks and 3 of their combinations, and evaluated each model on 100 examples per task.
155
+
156
+ Visual Prompt. Given two example pairs and a query image, we structure the prompt in the same fashion for all tasks. We construct a grid of $3 \times 2$ sub-images, where the example pairs are embedded in the first two rows, and the query image in the bottom left cell. We include examples in Figure 5.
157
+
158
+ Change prediction tasks. Each example pair is an image of a colored shape, and a corresponding image with an introduced change. The change can be either in color, shape, size or a combination of two changes. Next, we describe each individual task in more detail.
159
+
160
+ • Resize. Each example pair contains an image of a circle, and a corresponding image with the circle smaller in size. The goal is to predict the image with the resized version given image query.
161
+ • Shape. Here every example pair is an image with circle, and a corresponding image with a rectangle. Both are similar in size and appear in the same location. The goal is to predict the image with rectangle, given a new image query.
162
+ • Color. Each example pair contains an image of a circle appearing in the same location, with the color changed from green to blue. Given a new image query, the goal is to predict the corresponding image with the circle colored in blue.
163
+
164
+ Evaluation. We map each predicted pixel to its nearest neighbor color from a predefined set of options: black, white, blue, or green. We then measure and report the color-aware mIOU, by considering pixel predictions that appear in the ground-truth shape color as foreground and treat the rest as background.
165
+
166
+ Table 2: Synthetic data study results. We report the color-aware mIOU on the six tasks.
167
+
168
+ <table><tr><td></td><td>Color</td><td>Shape</td><td>Size</td><td>Color &amp; Shape</td><td>Color &amp; Size</td><td>Shape &amp; Size</td></tr><tr><td>Copy</td><td>5.53</td><td>6.71</td><td>1.17</td><td>6.74</td><td>1.17</td><td>1.86</td></tr><tr><td>VQGAN (IN-1k)</td><td>0.91</td><td>6.51</td><td>6.24</td><td>2.40</td><td>0.70</td><td>6.53</td></tr><tr><td>BEiT (IN-22k)</td><td>15.99</td><td>9.08</td><td>1.26</td><td>7.23</td><td>2.84</td><td>2.66</td></tr><tr><td>MAE (IN-1k)</td><td>0.00</td><td>2.07</td><td>1.20</td><td>0.00</td><td>0.00</td><td>1.56</td></tr><tr><td>MAE-VQGAN (IN-1k)</td><td>0.13</td><td>2.94</td><td>3.71</td><td>0.00</td><td>0.01</td><td>3.60</td></tr><tr><td>VQGAN (Figures)</td><td>6.96</td><td>19.11</td><td>16.21</td><td>7.40</td><td>2.24</td><td>18.41</td></tr><tr><td>BEiT (Figures)</td><td>40.92</td><td>31.43</td><td>7.12</td><td>33.10</td><td>21.21</td><td>12.98</td></tr><tr><td>MAE (Figures)</td><td>70.23</td><td>43.99</td><td>34.72</td><td>19.30</td><td>18.99</td><td>46.02</td></tr><tr><td>MAE-VQGAN (Figures)</td><td>40.40</td><td>46.53</td><td>42.04</td><td>20.41</td><td>18.27</td><td>40.33</td></tr></table>
169
+
170
+ Table 3: Comparison to Fine Tuning and Classic 1-Shot Segmentation baselines. MAE-VQGAN image query and output resolution is $1 1 1 \times 1 1 1$ . CyCTR and FWB resolution is $4 7 3 \times 4 7 3$ and $5 1 2 \times 5 1 2$ , both approach utilize Pascal 5i labeled baseclasses data.
171
+
172
+ <table><tr><td>Pretraining</td><td># Labeled Images</td><td># Shots</td><td>Model</td><td>Split 0</td><td>Split 1</td><td>Split 2</td><td>Split3</td></tr><tr><td rowspan="3">Unlabeled ImageNet</td><td>1 4</td><td>1</td><td rowspan="3">Finetune MAE</td><td>11.1</td><td>13.4</td><td>13.0</td><td>12.3</td></tr><tr><td></td><td>4</td><td>12.9</td><td>15.8</td><td>14.3</td><td>15.0</td></tr><tr><td>16</td><td>16</td><td>13.7</td><td>16.1</td><td>16.8</td><td>17.1</td></tr><tr><td>Unlabeled Figures</td><td>1</td><td>1</td><td>MAE-VQGAN</td><td>32.5</td><td>33.8</td><td>32.7</td><td>27.2</td></tr><tr><td rowspan="2">Labeled Pascal 5i (Segmentation masks)</td><td rowspan="2">2086-5883</td><td>1</td><td>FWB [36]</td><td>51.3</td><td>64.5</td><td>56.7</td><td>52.2</td></tr><tr><td>1</td><td>CyCTR [59]</td><td>67.2</td><td>71.1</td><td>57.6</td><td>59.0</td></tr></table>
173
+
174
+ Results. The results are presented in Table 2, for MAE-VQGAN prediction examples see Figure 5. Without training on the Figures dataset, inpainting models fail to generalize to these previously unseen tasks. The performance of all models improves when they are trained on the Figures dataset. Yet, the same models struggle with combinations of tasks due to the increasing complexity. The VQGAN model utilizes sequential decoding and therefore lacks context, which leads to poor performance. The MAE model outperforms MAE-VQGAN on color, and BEiT performs poorly in size. These models rely on pretrained codebooks (VQGAN and dVAE) that are likely not geared towards these tasks.
175
+
176
+ ![](images/4d479f20ec0adabd6774aab11ac2476fb287114cc60ec55bf15ccb2bad7e6151.jpg)
177
+ Figure 6: More examples, better results. Left: we construct visual prompts with increasing number of inputoutput pair examples, for a fixed query image (inpaintings annotated in red). Right: We observe that more examples improve the overall mIOU results on the four Pascal-5i splits.
178
+
179
+ # 4.4 Analysis
180
+
181
+ Comparison to finetuning and Few-Shot baselines. We include a comparison to baselines that utilize $K = \{ 1 , 4 , 1 6 \}$ training examples for each target class. For completeness, we also include the results of FWB [36] and CyCTR [59], classic 1-shot baselines, which we view as an upper-bound of our approach. FWB and CyCTR utilize a fully labeled base classes train set (2086 to 5883 on different Pascal 5i splits). Additionally, their architecture was designed for the foreground segmentation task (e.g, they operate in higher resolution). The results in Table 3 indicate that the Visual Prompting results of MAE-VQGAN trained on Figures are significantly superior to standard finetuning baselines of MAEs pretrained on unlabeled ImageNet. FWB [36] and CyCTR [59] outperform Visual Prompting, mainly because they pretrain on a large tagged base classes dataset and utilize architectures that are specific to image segmentation.
182
+
183
+ Dataset effect. We evaluate the effect of pretraining on a larger and more diverse dataset. We compare training on ImageNet only, Figures only, and a combination of the two. We report the mIOU results on Pascal 5i for Foreground Segmentation in Figure 7. The MAE-VQGAN trained on ImageNet achieves a consistently low $\sim 5$ points mIOU. The model trained on the combined dataset performs best, which demonstrates that MAE-VQGAN can benefit from additional amounts of unlabeled images.
184
+
185
+ More examples, better results. We study how increasing the number of input-output pair examples in the visual prompt affects the results. Intuitively, we expect that including more examples should reduce ambiguities and lead to better results. We use an MAE-VQGAN pretrained on the Figures dataset, and use data from PASCAL-5i. We construct a large grid that can populate up to 8 examples and an image query. We randomly choose different numbers of examples and randomize the placements. The results in Figure 6 confirm that using more examples leads to better segmentation results.
186
+
187
+ ![](images/5b45da93e6131f551712beeb89669a58ba627d761ff1210e58753c722072bc3e.jpg)
188
+ Figure 7: Training MAE-VQGAN on more data improves visual prompting results. Foreground Segmentation results on Pascal5i, when trained over the Figures dataset and on the combined Figuresand ImageNet dataset.
189
+
190
+ Prompt Engineering. We explore the effect of constructing different visual prompts for Foreground Segmentation and their corresponding MAE-VQGAN results (see Figure 8.a-b). The model generates plausible completions when changing the prompt layout (e.g. horizontal order vs. vertical order) and when changing the mask colors, texture or using only edges (see Figure 9). The mIOU results in Table 4 indicate that the model performs better with a vertical layout and when the segmentation mask colors are black and white. Interestingly, by analyzing the average attention heads of a masked patch token, we observe that the attention changes following the change in the prompts layout (see Figures 8.d-e).
191
+
192
+ Prompt Ensembling. Inspired by Prompt Ensembling in NLP [28], given the same example pair and image query, we construct multiple different visual prompts (e.g, horizontal and vertical layouts, see Figure 8.a-b). We then average the completion results. The results in Table 4 on the Synthetic Study tasks demonstrate that utilizing multiple prompts can lead to improved, and more stable performance.
193
+
194
+ ![](images/77bec893e9ddaa82e5ff92d096e940d40c9d7807bcd2a29f7903fed058b30fc8.jpg)
195
+ Figure 8: Prompt layout design. Two prompt orderings, and the corresponding average attention maps of the selected patch (annotated with black bounding box). The highest attention values appear on similar (corresponding) areas in the query image.
196
+
197
+ Style/content extrapolation. Inspired by the classic example from Tenenbaum and Freeman [47] (on the task originally suggested by Hofstadter [24]), we use MAE-VQGAN to extrapolate letter sequences printed in different fonts (see Figure 10). We find that the model can extrapolate given style and new content (Figure 10a) but that it struggles to extrapolate new content (Figure 10b). The model also struggles to extrapolate more complex letter sequences; the performance deteriorates even if both style and content are given (Figure 10 c-d).
198
+
199
+ Limitations. The focus of this work is to present a proof of concept that shows it is possible to visually prompt simple image inpainting models trained on noisy, unlabeled data. Specifically, we demonstrate how to pre-train a network once, then prompt it to perform reasonably well on many tasks. The fact that this is possible is surprising and scientifically interesting, although this approach is not competitive with supervised task-specific models. For visual prompting to work, the inpainting models require training on the Computer Vision Figures dataset. However, our initial experiments suggest that it can benefit from training on additional natural image data (see Figure 7). Other limitations include ambiguities in the task definition, reliance on a pretrained VQGAN decoder, and worse performance when the input-output example(s) are not aligned (see examples in Figure 11).
200
+
201
+ ![](images/9b26e80b8533e1e791b620e9e99bb0d8ae1c1b03809149bdcab2c09bcad72cfe.jpg)
202
+ Figure 9: Task performance under different label choices. Prompting results when using different mask colors (e.g, purple/yellow vs. green/red), when drawing full mask compared to edges only, and when changing the mask texture. Compared to other alternatives, purple/yellow and black/white (see Figure 8) masks works best.
203
+
204
+ Table 4: Prompt Engineering. Foreground Segmentation mIOU results on Pascal-5i when using different prompt colors.
205
+
206
+ <table><tr><td></td><td>Horizontal</td><td>Vertical</td></tr><tr><td>Black/White</td><td>27.17</td><td>31.57</td></tr><tr><td>Purple/Yellow</td><td>23.44</td><td>28.47</td></tr></table>
207
+
208
+ Table 5: Prompt Ensembling. We report here color-aware mIOU. In every line, the result is based on an ensemble of all previous prompts.
209
+
210
+ <table><tr><td>Prompt Layout</td><td>Color</td><td>Shape</td><td>Size</td></tr><tr><td>Horizontal</td><td>39.97</td><td>46.54</td><td>42.01</td></tr><tr><td>+ Vertical</td><td>41.31</td><td>54.71</td><td>46.18</td></tr><tr><td>+ Vertical w/ Rows Swap</td><td>44.14</td><td>60.42</td><td>49.42</td></tr></table>
211
+
212
+ ![](images/f72269bb4b1dfe33e456cc91aca8532c2467560cd63dbebe6b8e5aeff5c72189.jpg)
213
+ Figure 10: Style and content extrapolation using MAE-VQGAN. The model can extrapolate the style of a new content (a), but fails to predict a new content (b). The model struggles to extrapolate new style and content of longer sequences (c-e).
214
+
215
+ ![](images/5c145695da893b1cc8057206066e75a10d2b1e2224940ab735f49ec32149595b.jpg)
216
+ Figure 11: Limitations and failure cases. Single input-output example might be ambiguous and can lead to unintended completions. The MAE-VQGAN model performs worse given non-aligned input-output example, and by using a VQGAN vocabulary, it is limited in synthesizing out-of-distribution pixels (like blurry images).
217
+
218
+ # 5 Discussion
219
+
220
+ Why does our proposed method, despite its simplicity, perform so well on a large subset of visual tasks? At this point, we do not have a good answer. Clearly, the specific training data we use plays an important role, but the amount of generalization observed is still surprising. Perhaps some of these image-to-image tasks are actually simpler than we believed. But it’s also evident that contemporary large-scale inpainting models are learning quite sophisticated long-range co-occurrences and symmetries in the data which can often enable impressive visual reasoning. We hope that our work will encourage further research to better our understanding of what is being learned by inpainting.
221
+
222
+ Acknowledgements: We would like to thank Assaf Shocher for insightful discussions and ideas related to the Figures dataset. We thank Aaron Hertzmann, Sanjay Subramanian, Ofir Press and Ben Bogin for helpful feedback on the manuscript. This project has received funding from the European Research Council (ERC) under the European Unions Horizon 2020 research and innovation programme (grant ERC HOLI 819080). Prof. Darrell’s group was supported in part by DoD including DARPA’s LwLL and/or SemaFor programs, as well as BAIR’s industrial alliance programs. Prof. Efros’s group was supported by in part by DoD including DARPA’s MCS and/or ONR MURI, as well as funding from SAP.
223
+
224
+ # References
225
+
226
+ [1] Bao, H., Dong, L., Wei, F.: Beit: Bert pre-training of image transformers. arXiv preprint arXiv:2106.08254 (2021)
227
+ [2] Bar, A., Wang, X., Kantorov, V., Reed, C.J., Herzig, R., Chechik, G., Rohrbach, A., Darrell, T., Globerson, A.: Detreg: Unsupervised pretraining with region priors for object detection. arXiv preprint arXiv:2106.04550 (2021) [3] Barnes, C., Shechtman, E., Finkelstein, A., Goldman, D.B.: Patchmatch: A randomized correspondence algorithm for structural image editing. ACM Trans. Graph. 28(3), 24 (2009) [4] Bertalmio, M., Sapiro, G., Caselles, V., Ballester, C.: Image inpainting. In: Proceedings of the 27th annual conference on Computer graphics and interactive techniques. pp. 417–424 (2000)
228
+ [5] Brown, T.B., Mann, B., Ryder, N., Subbiah, M., Kaplan, J., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., Agarwal, S., Herbert-Voss, A., Krueger, G., Henighan, T., Child, R., Ramesh, A., Ziegler, D.M., Wu, J., Winter, C., Hesse, C., Chen, M., Sigler, E., Litwin, M., Gray, S., Chess, B., Clark, J., Berner, C., McCandlish, S., Radford, A., Sutskever, I., Amodei, D.: Language models are few-shot learners. CoRR abs/2005.14165 (2020), https://arxiv.org/abs/2005.14165 [6] Caron, M., Misra, I., Mairal, J., Goyal, P., Bojanowski, P., Joulin, A.: Unsupervised learning of visual features by contrasting cluster assignments. NeurIPS (2020)
229
+ [7] Chang, H., Zhang, H., Jiang, L., Liu, C., Freeman, W.T.: Maskgit: Masked generative image transformer. arXiv preprint arXiv:2202.04200 (2022)
230
+ [8] Chen, M., Radford, A., Child, R., Wu, J., Jun, H., Luan, D., Sutskever, I.: Generative pretraining from pixels. In: International Conference on Machine Learning. pp. 1691–1703. PMLR (2020)
231
+ [9] Chen, T., Kornblith, S., Norouzi, M., Hinton, G.: A simple framework for contrastive learning of visual representations. arXiv preprint arXiv:2002.05709 (2020)
232
+ [10] Chen, X., Fan, H., Girshick, R., He, K.: Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297 (2020)
233
+ [11] Criminisi, A., Pérez, P., Toyama, K.: Region filling and object removal by exemplar-based image inpainting. IEEE Transactions on image processing 13(9), 1200–1212 (2004)
234
+ [12] Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805 (2018)
235
+ [13] Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., et al.: An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929 (2020)
236
+ [14] Efros, A.A., Leung, T.K.: Texture synthesis by non-parametric sampling. In: IEEE International Conference on Computer Vision. pp. 1033–1038. Corfu, Greece (September 1999)
237
+ [15] Esser, P., Rombach, R., Ommer, B.: Taming transformers for high-resolution image synthesis. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 12873–12883 (2021)
238
+ [16] Gidaris, S., Bursuc, A., Komodakis, N., Pérez, P., Cord, M.: Learning representations by predicting bags of visual words. In: CVPR (2020)
239
+ [17] Goodfellow, I., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., Bengio, Y.: Generative adversarial nets. Advances in neural information processing systems 27 (2014)
240
+ [18] Goyal, P., Mahajan, D., Gupta, A., Misra, I.: Scaling and benchmarking self-supervised visual representation learning. In: ICCV (2019)
241
+ [19] Hays, J., Efros, A.A.: Scene completion using millions of photographs. ACM Transactions on Graphics (SIGGRAPH 2007) 26(3) (2007)
242
+ [20] He, K., Chen, X., Xie, S., Li, Y., Dollár, P., Girshick, R.B.: Masked autoencoders are scalable vision learners. CoRR abs/2111.06377 (2021), https://arxiv.org/abs/2111.06377
243
+ [21] He, K., Fan, H., Wu, Y., Xie, S., Girshick, R.: Momentum contrast for unsupervised visual representation learning. In: CVPR (2020)
244
+ [22] Hertzmann, A., Jacobs, C.E., Oliver, N., Curless, B., Salesin, D.H.: Image analogies. In: Proceedings of the 28th annual conference on Computer graphics and interactive techniques. pp. 327–340 (2001)
245
+ [23] Hill, F., Santoro, A., Barrett, D.G., Morcos, A.S., Lillicrap, T.: Learning to make analogies by contrasting abstract relational structure. arXiv preprint arXiv:1902.00120 (2019)
246
+ [24] Hofstadter, D.R.: Fluid concepts and creative analogies: Computer models of the fundamental mechanisms of thought. Basic books (1995)
247
+ [25] Jiang, Z., Xu, F.F., Araki, J., Neubig, G.: How can we know what language models know? Transactions of the Association for Computational Linguistics 8, 423–438 (2020)
248
+ [26] Johnson, J., Alahi, A., Fei-Fei, L.: Perceptual losses for real-time style transfer and super-resolution. In: European conference on computer vision. pp. 694–711. Springer (2016)
249
+ [27] Kang, B., Liu, Z., Wang, X., Yu, F., Feng, J., Darrell, T.: Few-shot object detection via feature reweighting. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 8420–8429 (2019)
250
+ [28] Lester, B., Al-Rfou, R., Constant, N.: The power of scale for parameter-efficient prompt tuning. CoRR abs/2104.08691 (2021), https://arxiv.org/abs/2104.08691
251
+ [29] Li, X.L., Liang, P.: Prefix-tuning: Optimizing continuous prompts for generation. arXiv preprint arXiv:2101.00190 (2021)
252
+ [30] Liu, G., Reda, F.A., Shih, K.J., Wang, T.C., Tao, A., Catanzaro, B.: Image inpainting for irregular holes using partial convolutions. In: Proceedings of the European conference on computer vision (ECCV). pp. 85–100 (2018)
253
+ [31] Liu, G., Reda, F.A., Shih, K.J., Wang, T.C., Tao, A., Catanzaro, B.: Image inpainting for irregular holes using partial convolutions. In: Proceedings of the European Conference on Computer Vision (ECCV) (September 2018)
254
+ [32] Liu, Y., Zhang, X., Zhang, S., He, X.: Part-aware prototype network for few-shot semantic segmentation. In: European Conference on Computer Vision. pp. 142–158. Springer (2020)
255
+ [33] Lu, Y., Bartolo, M., Moore, A., Riedel, S., Stenetorp, P.: Fantastically ordered prompts and where to find them: Overcoming few-shot prompt order sensitivity. arXiv preprint arXiv:2104.08786 (2021)
256
+ [34] Memisevic, R., Hinton, G.: Unsupervised learning of image transformations. In: 2007 IEEE Conference on Computer Vision and Pattern Recognition. pp. 1–8. IEEE (2007)
257
+ [35] Misra, I., Maaten, L.v.d.: Self-supervised learning of pretext-invariant representations. In: CVPR (2020)
258
+ [36] Nguyen, K., Todorovic, S.: Feature weighting and boosting for few-shot segmentation. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 622–631 (2019)
259
+ [37] Van den Oord, A., Li, Y., Vinyals, O.: Representation learning with contrastive predictive coding. arXiv e-prints pp. arXiv–1807 (2018)
260
+ [38] Pathak, D., Krahenbuhl, P., Donahue, J., Darrell, T., Efros, A.A.: Context encoders: Feature learning by inpainting. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 2536–2544 (2016)
261
+ [39] Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., Sutskever, I., et al.: Language models are unsupervised multitask learners. OpenAI blog 1(8), 9 (2019)
262
+ [40] Ramesh, A., Pavlov, M., Goh, G., Gray, S., Voss, C., Radford, A., Chen, M., Sutskever, I.: Zero-shot text-to-image generation. In: International Conference on Machine Learning. pp. 8821–8831. PMLR (2021)
263
+ [41] Reed, S.E., Zhang, Y., Zhang, Y., Lee, H.: Deep visual analogy-making. Advances in neural information processing systems 28 (2015)
264
+ [42] Russakovsky, O., Deng, J., Su, H., Krause, J., Satheesh, S., Ma, S., Huang, Z., Karpathy, A., Khosla, A., Bernstein, M., Berg, A.C., Fei-Fei, L.: ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV) 115(3), 211–252 (2015). https://doi.org/10.1007/s11263-015-0816-y
265
+ [43] Sadeghi, F., Zitnick, C.L., Farhadi, A.: Visalogy: Answering visual analogy questions. Advances in Neural Information Processing Systems 28 (2015)
266
+ [44] Sarzynska-Wawer, J., Wawer, A., Pawlak, A., Szymanowska, J., Stefaniak, I., Jarkiewicz, M., Okruszek, L.: Detecting formal thought disorder by deep contextualized word representations. Psychiatry Research 304, 114135 (2021)
267
+ [45] Shaban, A., Bansal, S., Liu, Z., Essa, I., Boots, B.: One-shot learning for semantic segmentation. CoRR abs/1709.03410 (2017), http://arxiv.org/abs/1709.03410
268
+ [46] Taylor, G.W., Fergus, R., LeCun, Y., Bregler, C.: Convolutional learning of spatio-temporal features. In: European conference on computer vision. pp. 140–153. Springer (2010)
269
+ [47] Tenenbaum, J.B., Freeman, W.T.: Separating style and content with bilinear models. Neural computation 12(6), 1247–1283 (2000)
270
+ [48] Tian, Z., Zhao, H., Shu, M., Yang, Z., Li, R., Jia, J.: Prior guided feature enrichment network for few-shot segmentation. IEEE transactions on pattern analysis and machine intelligence (2020)
271
+ [49] Ulyanov, D., Vedaldi, A., Lempitsky, V.: Deep image prior. arXiv:1711.10925 (2017)
272
+ [50] Upchurch, P., Snavely, N., Bala, K.: From a to z: supervised transfer of style and content using deep neural network generators. arXiv preprint arXiv:1603.02003 (2016)
273
+ [51] Van Den Oord, A., Vinyals, O., et al.: Neural discrete representation learning. Advances in neural information processing systems 30 (2017)
274
+ [52] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, Ł., Polosukhin, I.: Attention is all you need. Advances in neural information processing systems 30 (2017)
275
+ [53] Wang, X., Huang, T.E., Darrell, T., Gonzalez, J.E., Yu, F.: Frustratingly simple few-shot object detection. arXiv preprint arXiv:2003.06957 (2020)
276
+ [54] Xie, Z., Zhang, Z., Cao, Y., Lin, Y., Bao, J., Yao, Z., Dai, Q., Hu, H.: Simmim: A simple framework for masked image modeling. arXiv preprint arXiv:2111.09886 (2021)
277
+ [55] Yang, B., Liu, C., Li, B., Jiao, J., Ye, Q.: Prototype mixture models for few-shot semantic segmentation. In: European Conference on Computer Vision. pp. 763–778. Springer (2020)
278
+ [56] Yang, C., Lu, X., Lin, Z., Shechtman, E., Wang, O., Li, H.: High-resolution image inpainting using multi-scale neural patch synthesis. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 6721–6729 (2017)
279
+ [57] Yu, J., Li, X., Koh, J.Y., Zhang, H., Pang, R., Qin, J., Ku, A., Xu, Y., Baldridge, J., Wu, Y.: Vector-quantized image modeling with improved vqgan. arXiv preprint arXiv:2110.04627 (2021)
280
+ [58] Yu, Y., Zhan, F., Wu, R., Pan, J., Cui, K., Lu, S., Ma, F., Xie, X., Miao, C.: Diverse image inpainting with bidirectional and autoregressive transformers. In: Proceedings of the 29th ACM International Conference on Multimedia. pp. 69–78 (2021)
281
+ [59] Zhang, G., Kang, G., Yang, Y., Wei, Y.: Few-shot segmentation via cycle-consistent transformer. Advances in Neural Information Processing Systems 34 (2021)
282
+ [60] Zhang, R., Isola, P., Efros, A.A., Shechtman, E., Wang, O.: The unreasonable effectiveness of deep features as a perceptual metric. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 586–595 (2018)
md/dev/pfNyExj7z2/pfNyExj7z2.md ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # VECTOR-QUANTIZED IMAGE MODELING WITH IMPROVED VQGAN
2
+
3
+ Jiahui Yu Xin Li Jing Yu Koh Han Zhang Ruoming Pang James Qin Alexander Ku Yuanzhong Xu Jason Baldridge Yonghui Wu
4
+
5
+ Google Research
6
+
7
+ jiahuiyu@google.com
8
+
9
+ # ABSTRACT
10
+
11
+ Pretraining language models with next-token prediction on massive text corpora has delivered phenomenal zero-shot, few-shot, transfer learning and multi-tasking capabilities on both generative and discriminative language tasks. Motivated by this success, we explore a Vector-quantized Image Modeling (VIM) approach that involves pretraining a Transformer to predict rasterized image tokens autoregressively. The discrete image tokens are encoded from a learned Vision-Transformerbased VQGAN (ViT-VQGAN). We first propose multiple improvements over vanilla VQGAN from architecture to codebook learning, yielding better efficiency and reconstruction fidelity. The improved ViT-VQGAN further improves vectorquantized image modeling tasks, including unconditional, class-conditioned image generation and unsupervised representation learning. When trained on ImageNet at $2 5 6 \times 2 5 6$ resolution, we achieve Inception Score (IS) of 175.1 and Frechet Inception Distance (FID) of 4.17, a dramatic improvement over the vanilla ´ VQGAN, which obtains 70.6 and 17.04 for IS and FID, respectively. Based on ViT-VQGAN and unsupervised pretraining, we further evaluate the pretrained Transformer by averaging intermediate features, similar to Image GPT (iGPT). This ImageNet-pretrained VIM-L significantly beats iGPT-L on linear-probe accuracy from $6 0 . 3 \%$ to $7 3 . 2 \%$ for a similar model size. ViM-L also outperforms iGPT-XL which is trained with extra web image data and larger model size.
12
+
13
+ # 1 INTRODUCTION
14
+
15
+ Natural language processing (NLP) has recently experienced dramatic improvements from learning general-purpose representations by pretraining language models on unlabeled text corpora. This strategy has produced large performance gains for a wide range of natural language generation (NLG) and natural language understanding (NLU) tasks (Dai & Le, 2015; Radford et al., 2018; 2019; Brown et al., 2020). Conceptually, generative pretraining models the data density $P ( X )$ in a tractable way, with the hope of also helping discriminative tasks of $P ( { Y \vert } X )$ (Lasserre et al., 2006); importantly, there are no limitations on whether the signals are from the language domain or others, such as vision.
16
+
17
+ In computer vision, in contrast, most recent unsupervised or self-supervised learning research focuses on applying different random augmentations to images, with the pretraining objective to distinguish image instances (Chen et al., 2020b; He et al., 2020; Chen et al., 2020d; Grill et al., 2020; Chen et al., $2 0 2 0 \mathrm { c }$ ; Caron et al., 2021). The quality of learned representation relies on manually chosen augmentations, such as random brightness, cropping, blurring, and others. Chen et al. (2020a) explored GPT-style (Radford et al., 2018) generative pretraining on images by autoregressively predicting pixels without incorporating knowledge of the 2D structure. Each pixel is represented as a 9-bit value created by clustering (R, G, B) pixel values, using k-means with $_ { \mathrm { k } = 5 1 2 }$ . Unfortunately, this color encoding does not scale to typical image resolutions as it entails very long sequences to represent the image (e.g., $2 2 4 \times 2 2 4$ resolution leads to 50,176 tokens per image), and this demands much more memory and computation for training, compared to language models. As a result, iGPT’s maximum resolution is $6 4 \times 6 4$ for image recognition at scale—which severely limits its representation capabilities.
18
+
19
+ ![](images/dcffd61f6310583296baec12b1619c518511d41255d7c41866c6e4b3aab1f278.jpg)
20
+ Figure 1: Overview of ViT-VQGAN (left) and Vector-quantized Image Modeling (right) for both image generation and image understanding.
21
+
22
+ Remarkable image generation results have been achieved by pre-quantizing images into discrete latent variables and modeling them autoregressively, including VQVAE (Oord et al., 2017), DALLE (Ramesh et al., 2021) and VQGAN (Esser et al., 2021). In these approaches, a convolution neural network (CNN) is learned to auto-encode an image and a second stage CNN or Transformer is learned to model the density of encoded latent variables. These have been proved effective for image generation, but few studies have evaluated the learned representation in discriminative tasks (Ramesh et al., 2021; Esser et al., 2021).
23
+
24
+ We explore an approach we refer to as Vector-quantized Image Modeling (VIM) and apply it to both image generation and image understanding tasks. VIM follows a two-stage approach:
25
+
26
+ • Stage 1: Image Quantization. Given an image of resolution $2 5 6 \times 2 5 6$ , a VisionTransformer-based VQGAN encodes it into $3 2 \times 3 2$ discretized latent codes where the codebook size is 8192. We propose multiple improvements–from architecture to codebook learning–to VQGAN (Esser et al., 2021). The resulting ViT-VQGAN is more efficient and improves reconstruction fidelity in terms of pixel-wise reconstruction metrics, Inception Score (IS) and Frechet Inception Distance (FID). ViT-VQGAN is trained end-to-end on ´ image-only data with combined objective functions of logit-laplace loss, $\ell _ { 2 }$ loss, adversarial loss and perceptual loss (Johnson et al., 2016; Zhang et al., 2018). • Stage 2: Vector-quantized Image Modeling. We train a Transformer model to predict rasterized $3 2 \times 3 2 = 1 0 2 4$ image tokens autoregressively, where image tokens are encoded by a learned Stage 1 ViT-VQGAN. For unconditional image synthesis or unsupervised learning, we pretrain a decoder-only Transformer model to predict the next token. For class-conditioned image synthesis, a class-id token is prepended before the image tokens. To evaluate the quality of unsupervised learning, we average the intermediate Transformer features and learn a linear head to predict the logit of the classes (a.k.a., linear-probe).
27
+
28
+ We show that one key component for improving both image generation and image understanding with VIM is to have a better image quantizer with respect to both computational efficiency and reconstruction quality. An efficient quantizer can speed up Stage 2 training, where random augmentations are applied first to an image, followed by the encoder of image quantizer to obtain the input tokens. Moreover, an image quantizer with better reconstruction quality can reduce information loss compared with the original image in pixel space, which is critical for image understanding tasks.
29
+
30
+ The evaluations of our proposed ViT-VQGAN and VIM are studied with three aspects. (1) We evaluate the image quantizer based on reconstruction quality metrics including $\ell _ { 1 }$ distance, $\ell _ { 2 }$ distance, log-laplace distance, as well as Inception Score (IS) and Frechet Inception Distance (FID) ´ of reconstructed images. (2) We evaluate the capabilities of the learned quantizer for unconditional or class-conditioned image synthesis based on FID and IS, and compare with other methods. (3) We rely on linear-probe accuracy to evaluate representations with the common intuition that good features should linearly separate the classes of downstream tasks.
31
+
32
+ # 2 RELATED WORK
33
+
34
+ Image Synthesis. Image generation has received much attention with the progress of deep generative models, including Generative Adversarial Networks (GANs) (Goodfellow et al., 2014; Zhang et al., 2019b), Variational Autoencoders (VAEs) (Kingma & Welling, 2014; Vahdat & Kautz, 2020), Diffusion Models (Song & Ermon, 2019; Dhariwal & Nichol, 2021) and Autoregressive Models (van den Oord et al., 2016; Parmar et al., 2018). Unlike many autogressive methods which generate sequence directly in pixel space, VQVAE (van den Oord et al., 2017; Razavi et al., 2019) decomposes the image generation process into two stages: the first stage trains a vector quantized autoencoder with image reconstruction objective to convert an image into a shorter sequence of discrete tokens. Then the second stage learns an autoregressive model, e.g., PixelSNAIL (Chen et al., 2018), to model the underlying distribution of token sequences. Driven by the effectiveness of VQVAE and progress in sequence modeling (Vaswani et al., 2017; Devlin et al., 2019), many approaches follow the two-stage paradigm. DALL-E (Ramesh et al., 2021) improves token prediction in second stage by using Transformers (Vaswani et al., 2017), resulting in a strong text-to-image synthesis model. VQGAN (Esser et al., 2021) further uses adversarial loss and perceptual loss (Johnson et al., 2016; Zhang et al., 2018) to train a better autoencoder in the first stage to synthesize greater detail in images.
35
+
36
+ Image Recognition with Generative Pretraining. Many image generation models (Goodfellow et al., 2014; Kingma & Welling, 2014; Radford et al., 2016; Donahue et al., 2017; Higgins et al., 2017) have been studied for their capabilities in representation learning. However, their performance is usually not superior to competing self-supervised approaches that solve auxiliary classification tasks (Noroozi & Favaro, 2016a; Gidaris et al., 2018a; van den Oord et al., 2018). BigBiGAN (Donahue & Simonyan, 2019a) first demonstrated that a generation-based model can match other self-supervised methods in representation learning on ImageNet. iGPT (Chen et al., 2020a) uses the autoregressive objective to learn a giant transformer that directly predicts pixel values, producing even more competitive results. Compared to iGPT, our method first tokenizes the original image into discrete image tokens and then trains a transformer to predict them. As a result, our approach obtains comparable results with smaller model and less data. Similar to our method in predicting image tokens, BEiT (Bao et al., 2021) follows pre-training scheme of BERT Devlin et al. (2019) by learning to recover randomly masked image tokens with a bidirectional transformer. Unlike BEiT, we explore vector-quantized image modeling for image generation in addition to image recognition.
37
+
38
+ # 3 VECTOR-QUANTIZED IMAGES WITH VIT-VQGAN
39
+
40
+ The Vector-quantized Variational AutoEncoder (VQVAE) (van den Oord et al., 2017) is a CNNbased auto-encoder whose latent space is a matrix of discrete learnable variables, trained end-to-end via straight-through estimation. Esser et al. (2021) introduce VQGAN, a model which improves upon VQVAE by introducing an adversarial loss produced by a discriminator. Below, we introduce further improvements to VQGAN that boost efficiency and enhance reconstruction quality.
41
+
42
+ # 3.1 VQGAN WITH VISION TRANSFORMERS
43
+
44
+ The core network architectures used by both VQVAE and VQGAN to encode and reconstruct images are CNNs. VQGAN introduces transformer-like elements in the form of non-local attention block (Zhang et al., 2019a), allowing it to capture distant interactions with fewer layers. We propose taking this approach one step further by replacing the CNN encoder and decoder with Vision Transformer (ViT) (Dosovitskiy et al., 2020), as shown in Figure 1. Given sufficient data (for which unlabeled image data is plentiful) we find that ViT-VQGAN is less constrained by the inductive priors imposed by convolutions. Furthermore, ViT-VQGAN yields better computational efficiency on accelerators, and produces higher quality reconstructions, as shown in Table 1.
45
+
46
+ The encoder of ViT-VQGAN first maps $8 \times 8$ non-overlapping image patches into image tokens, followed by Transformer blocks, encoding a $2 5 6 \times 2 5 6$ resolution image into a $3 2 \times 3 2 { = } 1 0 2 4$ token sequence. The decoder performs the inverse operation, mapping each image token from latent variables back to $8 \times 8$ image patches and regrouping them into a $2 5 6 \times 2 5 6$ image (see Figure 1). At the output of transformer blocks, we apply a two-layer feed-forward network with a tanh activation layer in the middle. No activation is applied at the output of ViT-VQGAN encoder or decoder. We find that this simple approach yields high quality reconstructions without any noticeable grid artifacts.
47
+
48
+ Table 1: ViT-VQGAN achieves better speed-quality trade-offs compared with CNN-VQGAN. This in turn further speeds up Stage 2 training. Throughputs are benchmarked with the same 128 CloudTPUv4 devices.
49
+
50
+ <table><tr><td>Architecture</td><td>Model Size (encoder-decoder)</td><td>Throughput 个 (imgs/sec)</td><td>l2loss (1e-2)</td><td>Logit-Laplace loss ↓</td><td>FID↓</td><td>IS↑</td></tr><tr><td>ViT-VQGAN</td><td>Small-Small</td><td>1520</td><td>3.34</td><td>-2.44</td><td>1.99</td><td>184.4</td></tr><tr><td>CNN-VQGAN</td><td>Channels ×1</td><td>946</td><td>3.81</td><td>-2.36</td><td>2.26</td><td>178.7</td></tr><tr><td>ViT-VQGAN</td><td>Base-Base</td><td>960</td><td>3.09</td><td>-2.54</td><td>1.55</td><td>190.2</td></tr><tr><td>CNN-VQGAN</td><td>Channels × 2</td><td>400</td><td>3.44</td><td>-2.46</td><td>1.91</td><td>183.4</td></tr><tr><td>ViT-VQGAN</td><td> Small-Large</td><td>384</td><td>2.88</td><td>-2.58</td><td>1.28</td><td>192.3</td></tr></table>
51
+
52
+ # 3.2 CODEBOOK LEARNING
53
+
54
+ Vanilla VQVAEs usually suffer from low codebook usage due to the poor initialization of the codebook. Therefore, during training a significant portion of codes are rarely used, or dead. The reduction in effective codebook size results in worse reconstructions in stage 1 quantizer training and poor diversity in stage 2 for image synthesis. As a result, VQGAN (Esser et al., 2021) relies on top$k$ and top- $p$ (nucleus) sampling heuristics (Holtzman et al., 2020) with a default codebook size of 1024 to obtain best results for image synthesis. We propose two improvements that can significantly encourage the codebook usage even with a larger codebook size of 8192. During image synthesis, we perform simple sampling with temperature of 1.0 without top- $k$ and top- $p$ heuristics.
55
+
56
+ The training objective of vector-quantization is defined as follows:
57
+
58
+ $$
59
+ L _ { \mathrm { V Q } } = \| \mathbf { s g } [ z _ { e } ( x ) ] - e \| _ { 2 } ^ { 2 } + \beta \| z _ { e } ( x ) - \mathbf { s g } [ e ] \| _ { 2 } ^ { 2 } .
60
+ $$
61
+
62
+ Here, $\operatorname { s g } ( x ) \equiv x$ , $\begin{array} { r } { { \frac { \mathrm { d } } { \mathrm { d } x } } \mathrm { s g } ( x ) \equiv 0 } \end{array}$ is the stop-gradient operator, $\beta$ is a commitment loss hyperparameter set to 0.25 in all our experiments, and $e$ is the codebook vector. The quantized codebook index is determined by looking up the codebook vector closest to the input features $z _ { e } ( x )$ in terms of the Euclidean distance, yielding $i = \mathrm { a r g m i n } _ { j } \| z _ { e } ( x ) - e _ { j } \| _ { 2 } ^ { 2 }$ .
63
+
64
+ Factorized codes. We introduce a linear projection from the output of the encoder to a lowdimensional latent variable space for code index lookup (e.g., reduced from a 768-d vector to a 32-d or 8-d vector per code) and find it has an immediate boost of codebook usage. The factorization can be viewed as decoupling code lookup and code embedding: we lookup the the closest variable encoded from input on a lower-dimensional lookup space and then project the matched latent code to the high-dimensional embedding space. Our experiments show reducing dimension of lookup space from 256-d to 32-d consistently improves reconstruction quality. A detailed illustration is provided in the supplementary materials.
65
+
66
+ $\ell _ { 2 }$ -normalized codes. We also apply $\ell _ { 2 }$ normalization on the encoded latent variables $z _ { e } ( x )$ and codebook latent variables $e$ . The codebook variables are initialized from a normal distribution. By mapping all latent variables on a sphere, the Euclidean distance of $\ell _ { 2 }$ -normalized latent variables $| | \ell _ { 2 } ( \bar { z } _ { e } ( \bar { x } ) ) - \ell _ { 2 } ( e _ { j } ) | | _ { 2 } ^ { 2 }$ evolves to the cosine similarity of two vectors between $z _ { e } ( x )$ and $e$ , further improving training stability and reconstruction quality shown in our experiments.
67
+
68
+ # 3.3 VIT-VQGAN TRAINING LOSSES
69
+
70
+ We use a combination of logit-laplace loss, $\ell _ { 2 }$ loss, perceptual loss (Johnson et al., 2016; Zhang et al., 2018) based on VGG network (Simonyan & Zisserman, 2014) and GAN loss with architecture of StyleGAN discriminator (Karras et al., 2020). Loss balancing weights are configured with a hyper-parameter sweep to optimize image reconstruction quality, codebook usage, FID and Inception Score. After the sweep, we apply the same set of hyper-parameters of training losses to all datasets including CelebA-HQ, FFHQ, and ImageNet. Logit-Laplace loss can be viewed as normalized $\ell _ { 1 }$ loss which assumes the noise at the pixel level is laplace-distributed while $\ell _ { 2 }$ loss assumes the noise is of a Gaussian distribution. We find logit-laplace loss contributes to codebook usage while $\ell _ { 2 }$ loss and perceptual loss significantly contribute to FID. The final loss combination we used by default is $L = L _ { \mathrm { { V Q } } } + 0 . 1 L _ { \mathrm { { A d v } } } + 0 . 1 L _ { \mathrm { { P e r c e p t u a l } } } + 0 . 1 L _ { \mathrm { { L o g i t } \mathrm { { - } \mathrm { { l a p l a c e } } } } } + 1 . 0 L _ { \mathrm { { 2 } } } .$ .
71
+
72
+ Table 2: Transformer architectures of Stage 1 ViT-VQGAN and Stage 2 VIM.
73
+
74
+ <table><tr><td>Model</td><td>Size</td><td>#Params</td><td>#Blocks</td><td>#Heads</td><td>Model Dim</td><td>Hidden Dim</td><td>Dropout</td><td>#Tokens</td></tr><tr><td>ViT-VQGAN</td><td>Small</td><td>32M</td><td>8</td><td>8</td><td>512</td><td>2048</td><td>0.0</td><td>1024</td></tr><tr><td>ViT-VQGAN</td><td>Base</td><td>91M</td><td>12</td><td>12</td><td>768</td><td>3072</td><td>0.0</td><td>1024</td></tr><tr><td>ViT-VQGAN</td><td>Large</td><td>599M</td><td>32</td><td>16</td><td>1280</td><td>5120</td><td>0.0</td><td>1024</td></tr><tr><td>VIM</td><td>Base</td><td>650M</td><td>24</td><td>16</td><td>1536</td><td>6144</td><td>0.1</td><td>1024</td></tr><tr><td>VIM</td><td>Large</td><td>1697M</td><td>36</td><td>32</td><td>2048</td><td>8192</td><td>0.1</td><td>1024</td></tr></table>
75
+
76
+ One caveat on the VGG-based perceptual loss is that the VGG network is pretrained with supervised classification loss, so the supervision might leak into Stage 2 for linear-probe accuracy measurement. Thus, for all of our reported unsupervised learning results, we exclude the perceptual loss during ViT-VQGAN training. For all unconditional and class-conditioned image synthesis, we use ViTVQGAN quantizers trained with perceptual loss, as it leads to higher-fidelity reconstructions.
77
+
78
+ # 4 VECTOR-QUANTIZED IMAGE MODELING
79
+
80
+ With a learned ViT-VQGAN, images are encoded into discrete latent code ids flattened in the raster order, similar to Image GPT (Chen et al., 2020a). A decoder-only Transformer model is used to model the density of image data $P ( x )$ autoregressively as
81
+
82
+ $$
83
+ P ( x ) = \prod _ { i = 1 } ^ { n } P ( x _ { i } | x _ { 1 } , x _ { 2 } , . . . , x _ { i - 1 } ; \theta ) ,
84
+ $$
85
+
86
+ where $\theta$ is learnable weights. The training objective is to minimize the negative log-likelihood of the data $L = \mathbb { E } _ { x \in X } [ - l o g P ( x ) ]$ .
87
+
88
+ Table 2 summarizes the architecture configurations for the Transformers. We first embed discrete image token ids into a learnable embedding space at each position, with an additive learnable 2D positional embedding. Both embedding dimensions are the same as model dimension. We apply a stack of Transformer blocks to the inputs with causal attention over the entire sequence. A dropout ratio of 0.1 is used in all residual, activation and attention outputs. At the final layer of all Transformer blocks, we apply an additional layer normalization.
89
+
90
+ # 4.1 IMAGE SYNTHESIS
91
+
92
+ With a pretrained generative Transformer model, unconditional image generation is achieved by simply sampling token-by-token from the output softmax distribution. All samples used for both qualitative and quantitative results are obtained without temperature reduction. The sampled tokens are then fed into the decoder of ViT-VQGAN to decode output images. Our default Stage 1 ViTVQGAN encodes input images of resolution $2 5 6 \times 2 5 6$ into $3 2 \times 3 2$ latent codes with a codebook size 8192, while Stage 2 Transformer takes the flattened image tokens with total a length of 1024.
93
+
94
+ Class-conditioned ImageNet generation is also a widely used benchmark for measuring capabiltiy of models for image synthesis. We extend the unconditional generation to class-conditioned generation by prepending a class-id token before the image tokens. Separate embedding layers are learned from scratch for class-id token and image tokens, with the embedding dimension the same as the Transformer model dimension. During sampling, a class-id token is provided at the first position to decode the remaining image tokens autoregressively.
95
+
96
+ # 4.2 UNSUPERVISED LEARNING
97
+
98
+ For the image understanding task, we feed all image tokens of the input into a pretrained Transformer, and get a sequence of 1024 token features. Similar to Image GPT (Chen et al., 2020a), we take a layer output at a specific block $l$ over total blocks $L$ , average over the sequence of token features (frozen) and insert a softmax layer (learnable) projecting averaged feature to class logits. We only take one specific Transformer block output instead of concatenating different block outputs as in iGPT (Chen et al., 2020a). We find that most discriminating feature for the linear-probe is typically near the middle of all Transformer blocks.
99
+
100
+ Table 3: Frechet Inception Distance (FID) between reconstructed validation split and original val- ´ idation split on ImageNet, CelebA-HQ and FFHQ. ∗ denotes models trained with Gumbel-Softmax reparameterization as in Ramesh et al. (2021). ∗∗ denotes models trained with multi-scale hierarchical codebook as in Razavi et al. (2019).
101
+
102
+ <table><tr><td>Model</td><td>Dataset</td><td>Latent Size</td><td>dimZ</td><td>FID on Validation</td></tr><tr><td>DALL-E dVAE</td><td>Web data</td><td>32 ×32</td><td>8192</td><td>32.00</td></tr><tr><td>VQGAN</td><td>ImageNet</td><td>16 ×16</td><td>1024</td><td>7.94</td></tr><tr><td>VQGAN</td><td>ImageNet</td><td>16 ×16</td><td>16384</td><td>4.98</td></tr><tr><td>VQGAN*</td><td>ImageNet</td><td>32 × 32</td><td>8192</td><td>1.49</td></tr><tr><td>VQGAN**</td><td>ImageNet</td><td>64×64&amp;32×32</td><td>512</td><td>1.45</td></tr><tr><td>ViT-VQGAN (Ours)</td><td>ImageNet</td><td>32×32</td><td>8192</td><td>1.28</td></tr><tr><td>ViT-VQGAN (Ours)</td><td>CelebA-HQ</td><td>32 ×32</td><td>8192</td><td>4.66</td></tr><tr><td>ViT-VQGAN (Ours)</td><td>FFHQ</td><td>32 ×32</td><td>8192</td><td>3.13</td></tr></table>
103
+
104
+ # 5 EXPERIMENTS
105
+
106
+ # 5.1 IMAGE QUANTIZATION
107
+
108
+ We train the proposed ViT-VQGAN on three datasets separately, CelebA-HQ (Karras et al., 2019), FFHQ (Karras et al., 2019), and ImageNet (Krizhevsky et al., 2012). For CelebA-HQ and FFHQ, we follow the default train and validation split as VQGAN (Esser et al., 2021).1 For Stage 1 image quantization, three different architecture sizes are experimented, Small, Base and Large for either encoder or decoder, as defined in Table 2. The smallest ViT-VQGAN-SS has a Small-size encoder and Small-size decoder, while ViT-VQGAN-BB has a Base-size encoder and Base-size decoder. The largest ViT-VQGAN-SL has an asymmetric Small-size encoder and Large-size decoder, with the motivation that Stage 2 training only requires forward propagation of the encoder of ViT-VQGAN (in inference/decoding for image synthesis, the decoder of ViT-VQGAN is still required to decode images from codes predicted during Stage 2).
109
+
110
+ We train all ViT-VQGAN models with a training batch size of 256 distributed across 128 CloudTPUv4 for a total 500,000 training steps. For both ViT-VQGAN and StyleGAN discriminator, Adam optimizer (Kingma & Ba, 2014) is used with $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 9$ with the learning rate linearly warming up to a peak value of $1 \times 1 0 ^ { - 4 }$ over 50,000 steps and then decaying to $5 \times \mathrm { \overline { { 1 } } 0 ^ { - 5 } }$ over the remaining 450,000 steps with a cosine schedule. We use a decoupled weight decay (Loshchilov & Hutter, 2017) of $1 \dot { \times } 1 0 ^ { - 4 }$ for both ViT-VQGAN and StyleGAN discriminator. All models are trained with an input image resolution $2 5 6 \times 2 5 6$ on CloudTPUv4.
111
+
112
+ Table 3 shows FID between reconstructed images and original images in the validation split on ImageNet, CelebA-HQ and FFHQ datasets. Without multi-scale hierarchical codebook or gumbelsoftmax, ViT-VQGAN is able to achieve better FID with a large codebook size of 8192 compared with vanilla VQGAN.
113
+
114
+ Table 4 provides extensive ablations on the proposed modifications, with empirical results on mean $\ell _ { 1 }$ distance, $\ell _ { 2 }$ distance, logit-laplace distance, Inception Score and FID on ImageNet. Among different model sizes, ViT-VQGAN-SS (small-encoder, small-decoder) performs worse than ViTVQGAN-BB (base-encoder, base-decoder) and ViT-VQGAN-SL (small-encoder, large-decoder), but achieves much better throughput. The CNN-based VQGAN architecture is worse in both quality and throughput compared with ViT-based VQGAN. The StyleGAN-based discriminator (Karras et al., 2019) is more stable and yields better reconstruction quality than PatchGAN (Isola et al., 2017)
115
+
116
+ Table 4: Ablation study on ViT-VQGAN. The codebook usage is calculated as the percentage of used codes given a batch of 256 test images averaged over the entire test set.
117
+
118
+ <table><tr><td></td><td>groe ereerg rrr repeeeg</td><td>JAeeettect</td><td>Jirrriisi</td><td></td><td>pineg Lir aeaer</td><td>↑(2-0)</td><td>↑(-01)</td><td> 9der-18g</td><td></td><td>→ D</td><td>eeesn googopeg</td><td>↑ndysnou</td></tr><tr><td>Ablation on</td><td>Base</td><td>Base</td><td>ViT</td><td>StyleGAN</td><td>32</td><td>√</td><td>3.06</td><td>3.09 -2.54</td><td>190.2</td><td></td><td>1.55 96%</td><td>960</td></tr><tr><td>Model Size</td><td>Small Small</td><td>Small</td><td>ViT ViT</td><td>StyleGAN</td><td>32</td><td>√ 3.22</td><td>3.34</td><td>-2.44</td><td>184.4</td><td>1.99</td><td>95%</td><td>1520</td></tr><tr><td rowspan="2"></td><td rowspan="2"></td><td rowspan="2">Large</td><td rowspan="2"></td><td rowspan="2">StyleGAN</td><td rowspan="2">32</td><td rowspan="2">√ 2.93</td><td rowspan="2">2.88</td><td rowspan="2">-2.58</td><td rowspan="2">192.3</td><td rowspan="2">1.28</td><td rowspan="2">95%</td><td rowspan="2">384</td></tr><tr><td>√ 3.45 2.82</td></tr><tr><td>Architecture</td><td>1 Base</td><td>1 Base</td><td>CNN ViT</td><td>StyleGAN PatchGAN</td><td>32 32</td><td>√</td><td>3.81 2.58</td><td>-2.36 -2.62</td><td>178.7 165.6</td><td>2.26 3.88</td><td>63% 89%</td><td>946 1227</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>4.28</td><td>-2.38</td><td>160.1</td><td>3.68</td><td>4%</td><td></td></tr><tr><td rowspan="8">Codebook Learning</td><td>Base</td><td>Base</td><td>ViT</td><td>StyleGAN</td><td>256 128</td><td>1</td><td>3.60 3.41</td><td></td><td></td><td></td><td></td><td>954</td></tr><tr><td>Base</td><td>Base</td><td>ViT</td><td>StyleGAN</td><td></td><td></td><td>3.93</td><td>-2.44</td><td>173.9</td><td>2.77</td><td>14%</td><td>960</td></tr><tr><td>Base</td><td>Base</td><td>ViT</td><td>StyleGAN</td><td>64</td><td></td><td>3.18 3.37</td><td>-2.49</td><td>179.5 191.2</td><td>2.50</td><td>37%</td><td>960</td></tr><tr><td>Base</td><td>Base</td><td>ViT</td><td>StyleGAN</td><td>16</td><td></td><td>3.00</td><td>2.96 -2.54</td><td></td><td>1.50</td><td>95%</td><td>960</td></tr><tr><td>Base</td><td>Base</td><td>ViT</td><td>StyleGAN</td><td>8</td><td></td><td>2.98</td><td>2.92 -2.55</td><td>189.5</td><td>1.52</td><td>96%</td><td>960</td></tr><tr><td>Base</td><td>Base</td><td>ViT</td><td>StyleGAN</td><td>4</td><td></td><td>3.55</td><td>4.18 -2.37</td><td>143.8</td><td>3.68 5.44</td><td>96%</td><td>960</td></tr><tr><td>Base</td><td>Base</td><td>ViT</td><td>StyleGAN</td><td>32</td><td>&gt;&gt;&gt;&gt;&gt;x</td><td>4.13</td><td>5.41</td><td>-2.20</td><td>123.6</td><td>2%</td><td>960</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
119
+
120
+ Table 5: FID comparison with unconditional image synthesis on CelebA-HQ and FFHQ.
121
+
122
+ <table><tr><td colspan="2">CelebA-HQ 256 × 256</td><td colspan="2">FFHQ 256× 256</td></tr><tr><td>Method</td><td>FID↓</td><td>Method</td><td>FID↓</td></tr><tr><td>GLOW (Kingma &amp; Dhariwal, 2018)</td><td>69.0</td><td>VDVAE (t = 0.7) (Child,2021)</td><td>38.8</td></tr><tr><td>NVAE (Vahdat &amp; Kautz,2020)</td><td>40.3</td><td>VDVAE (t = 1.0)</td><td>33.5</td></tr><tr><td>PIONEER (Heljakka etal.,2018)</td><td>25.3</td><td>VDVAE (t = 0.8)</td><td>29.8</td></tr><tr><td>NCPVAE (Aneja et al.,2020)</td><td>24.8</td><td>VDVAE (t = 0.9)</td><td>28.5</td></tr><tr><td>VAEBM (Xiao et al., 2021)</td><td>20.4</td><td>VQGAN+P.SNAIL</td><td>21.9</td></tr><tr><td>Style ALAE (Pidhorskyi et al., 2020)</td><td>19.2</td><td>BigGAN</td><td>12.4</td></tr><tr><td>DC-VAE (Parmar et al., 2021)</td><td>15.8</td><td>U-Net GAN (Schonfeld et al., 2020)</td><td>10.9</td></tr><tr><td>PGGAN(Karras et al.,2018)</td><td>8.0</td><td>StyleGAN2 (Karras etal., 2020)</td><td>3.8</td></tr><tr><td>VQGAN (w/ top-k sampling)</td><td>10.2</td><td>VQGAN (w/ top-k sampling)</td><td>9.6</td></tr><tr><td>ViT-VQGAN (Ours)</td><td>7.0</td><td>ViT-VQGAN (Ours)</td><td>5.3</td></tr></table>
123
+
124
+ (which was used for VQGAN). For codebook learning, factorized codes with low-dimensional latent variables consistently achieve better reconstruction quality when the latent dimension is reduced from 256 to 16 or 8. Moreover, removing $\ell _ { 2 }$ -normalization leads to much worse results.
125
+
126
+ # 5.2 IMAGE SYNTHESIS
127
+
128
+ On top of the pre-learned ViT-VQGAN image quantizer, we train stage 2 transformer models for unconditional and class-conditioned image synthesis and compare with previous work. We use a default model size of ViT-VQGAN-SS (small-encoder, small-decoder) for stage 1 and VIM-Large for stage 2 (model architectures are listed in Table 2), as we find it beneficial to put more computation in stage 2 while keeping stage 1 transformers lightweight. We also present a model size ablation study and comparison with VQGAN in the Appendix. Models are trained with a global training batch size of 1024 for a total of 450,000 training steps. We use Adam optimizer (Kingma & Ba, 2014) with $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 6$ with the learning rate linearly warming up to a peak constant value of $4 . 5 \times 1 0 ^ { - 4 }$ over the first 5000 steps and then exponentially decaying to $1 \times \mathrm { 1 0 ^ { - 5 } }$ starting from 80,000 steps. To save memory, we use a factorized version of Adam, Adafactor (Shazeer & Stern, 2018), with the first moment quantized into Int8 and factorized second moments. No other techniques like mixed-precision training, model sharding, or gradient compression is used. All models are trained with an input image resolution $2 5 6 \times 2 5 6$ on CloudTPUv4.
129
+
130
+ <table><tr><td>Model</td><td>Acceptance Rate</td><td>FID</td><td>IS</td></tr><tr><td>Validation data</td><td>1.0</td><td>1.62</td><td>235.0</td></tr><tr><td>DCTransformer (Nash et al.,2021)</td><td>1.0</td><td>36.5</td><td>n/a</td></tr><tr><td>BigGAN (Brock et al.,2019)</td><td>1.0</td><td>7.53</td><td>168.6</td></tr><tr><td>BigGAN-deep</td><td>1.0</td><td>6.84</td><td>203.6</td></tr><tr><td>IDDPM (Nichol &amp; Dhariwal,2021)</td><td>1.0</td><td>12.3</td><td>n/a</td></tr><tr><td>ADM-G, no guid. (Dhariwal &amp; Nichol, 2021)</td><td>1.0</td><td>10.94</td><td>101.0</td></tr><tr><td>ADM-G, 1.0 guid.</td><td>1.0</td><td>4.59</td><td>186.7</td></tr><tr><td>VQVAE-2 (Razavi et al.,2019)</td><td>1.0</td><td>~31</td><td>~45</td></tr><tr><td>VQGAN (Esser et al.,2021)</td><td>1.0</td><td>17.04</td><td>70.6</td></tr><tr><td>VQGAN</td><td>0.5</td><td>10.26</td><td>125.5</td></tr><tr><td>VQGAN</td><td>0.25</td><td>7.35</td><td>188.6</td></tr><tr><td>ViT-VQGAN (Ours)</td><td>1.0</td><td>4.17</td><td>175.1</td></tr><tr><td>ViT-VQGAN (Ours)</td><td>0.5</td><td>3.04</td><td>227.4</td></tr></table>
131
+
132
+ Table 6: FID comparison for class-conditional image synthesis on ImageNet with resolution $2 5 6 \times$ 256. Acceptance rate shows results based on ResNet-101 classifier-based rejection sampling.
133
+
134
+ ![](images/2d4bd8b401b7977b3c4ee742b5204d1709b675afa13b9a6ea9cac79c8b6d5b86.jpg)
135
+ Figure 2: Uncurated set of samples from class-conditioned image generation trained on ImageNet. Top row shows sampled class ids while bottom row shows fine-grained dog species from class id 184 to 189. More samples are shown in Appendix.
136
+
137
+ Our main results on unconditional image synthesis on CelebA-HQ and FFHQ are summarized in Table 5. Without top- $k$ and top- $p$ (nucleus) sampling heuristics, we achieve FID of 7.0 on CelebAHQ and 5.3 on FFHQ, significantly better than VQGAN (Esser et al., 2021). Table 6 shows classconditioned image synthesis models on ImageNet, following Section 4.1. Based on ViT-VQGANSS, we achieve IS of 175.1 and FID of 4.17, improving over the IS of 70.6 and FID of 17.04 with vanilla VQGAN. When applied with classifier-based rejection sampling, the ViT-VQGAN based model further achieves best FID of 3.04 and best Inception Score of 321.7. Qualitative results are sampled and shown in Figure 2 (see the Appendix for more).
138
+
139
+ # 5.3 UNSUPERVISED LEARNING
140
+
141
+ After the generative pretraining to autoregressively model the density of ViT-VQGAN quantized image tokens, we evaluate the learned representation under the common linear protocol on ImageNet classification. We follow the same training hyper-parameters as the unconditional image synthesis models on ImageNet, and use ViT-VQGAN-SS image quantizer for better training throughput. As discussed in Section 3.3, the ViT-VQGAN-SS image quantizer is trained without perceptual loss for unsupervised learning (perceptual loss is based on a supervised VGG network trained on ImageNet, which may make comparison unfair). We apply an average pooling over the token features at a specific transformer block $l$ from totally $L$ blocks. Similar to findings reported in iGPT (Chen et al., 2020a), the representations from the middle transformer blocks has better linear-probe accuracy (more study can be found in Appendix). Specifically, we use the Transformer block of index 15 (36 blocks in total) for VIM-Large and index 10 (24 blocks in total) for VIM-Base (architecture configurations are listed in Table 2).
142
+
143
+ Table 7: Linear-probe accuracy with different unsupervised learning methods on ImageNet. DALLE dVAE (Ramesh et al., 2021) image quantizer is trained with extra image data. VIM-Large is trained without dropout in transformers.
144
+
145
+ <table><tr><td>Method</td><td></td><td>#Tokens</td><td>Features</td><td>Params</td><td>Top-1 ↑</td></tr><tr><td rowspan="15">Brirrniir irnrriiiirig</td><td>Jigsaw (Noroozi &amp; Favaro,2016b)</td><td></td><td>4096</td><td>94M</td><td>44.6</td></tr><tr><td>RelativePosition (Doersch et al., 2015)</td><td></td><td>4096</td><td>94M</td><td>51.4</td></tr><tr><td>Rotation (Gidaris et al.,2018b)</td><td></td><td>8192</td><td>86M</td><td>55.4</td></tr><tr><td>AMDIM (Bachman et al.,2019)</td><td></td><td>8192</td><td>626M</td><td>68.1</td></tr><tr><td>CPC v2 (Henaff, 2020)</td><td></td><td>4096</td><td>303M</td><td>71.5</td></tr><tr><td>MoCo (He et al.,2020)</td><td></td><td>8192</td><td>375M</td><td>68.6</td></tr><tr><td>SimCLR (Chen et al., 2020b)</td><td></td><td>8192</td><td>375M</td><td>76.5</td></tr><tr><td>SwAV (Caron et al., 2020)</td><td></td><td>2048</td><td>93M</td><td>75.3</td></tr><tr><td>DINO (Caron et al., 2021)</td><td></td><td>2048</td><td>85M</td><td>75.3</td></tr><tr><td>BYOL (Grill et al., 2020)</td><td></td><td>8192</td><td>375M</td><td>78.6</td></tr><tr><td rowspan="4">Greeeed rierieeg</td><td>BiGAN (Donahue et al., 2016)</td><td></td><td>512</td><td>138M</td><td>31.0</td></tr><tr><td>BigBiGAN (Donahue &amp; Simonyan,2019b)</td><td></td><td>4096</td><td>86M</td><td>56.6</td></tr><tr><td>BigBiGAN</td><td>=</td><td>16384</td><td>344M</td><td>61.3</td></tr><tr><td>iGPT-L (Chen et al., 2020a)</td><td>32× 32</td><td>1536</td><td>1362M</td><td>60.3</td></tr><tr><td>iGPT-L</td><td></td><td>48×48</td><td>1536</td><td>1362M</td><td>65.2</td></tr><tr><td>iGPT-XL (extra data)</td><td></td><td>64×64</td><td>3072</td><td>6801M</td><td>68.7</td></tr><tr><td></td><td> iGPT-XL (extra data, feature ensemble)</td><td>64 × 64</td><td>5×3072</td><td>6801M</td><td>72.0</td></tr><tr><td></td><td>VIM-Base (Ours)</td><td>32 × 32</td><td>1024</td><td>650M</td><td>65.1</td></tr><tr><td></td><td>VIM-Large (Ours)</td><td>32 × 32</td><td>2048</td><td>1697M</td><td>73.2</td></tr><tr><td></td><td>VIM-Base + DALL-E dVAE quantizer</td><td>32 ×32</td><td>1024</td><td>650M</td><td>63.8 (-1.3)</td></tr><tr><td></td><td>VIM-Base + CNN-VQGAN quantizer</td><td>32×32</td><td>1024</td><td>650M</td><td>61.8 (-3.3)</td></tr></table>
146
+
147
+ Table 7 shows the comparisons among different approaches divided into two categories: discriminative pretraining methods to distinguish among cropped or augmented image patches; and generative pretraining methods to generate image pixels or patches. The linear-probe accuracy of our proposed VIM with ViT-VQGAN are superior to other generative pretraining approaches like iGPT, and competitive with discriminative pretraining methods like BYOL (Grill et al., 2020) and DINO (Caron et al., 2021). Specifically, ImageNet-pretrained VIM-L significantly improves over iGPT-L, increasing linear-probe accuracy from $6 0 . 3 \%$ to $7 3 . 2 \%$ for a similar model size. VIM-L also outperforms iGPT-XL, which is larger and trained with extra web image data. Moreover, we also compare different stage 1 quantizers including CNN-based VQGAN and pretrained DALL-E dVAE (trained with extra web-scale image data)2 in Table 7; these results are all worse than ViT-VQGAN quantizer, suggesting the importance of the multiple changes defined in Section 3.
148
+
149
+ # 6 ETHICS
150
+
151
+ Tasks involving generation raise a number of issues that should be considered, such as possible biases in underlying models and data—especially with respect to capabilities for people with different demographic backgrounds. The three datasets used in this paper–ImageNet, CelebA-HQ, and FFHQ–are all widely used in the literature, but it is worthwhile highlighting their unique natures and recent scholarship around them.
152
+
153
+ The FFHQ dataset3 contains 70,000 images collected from Flickr, all of which have licenses appropriate for sharing, and the data maintainers provide means for individuals to opt-out of inclusion in the dataset. FFHQ was specifically collected to cover a broad range of demographics with respect to faces of people. This is confirmed in our models’ generated examples, which cover a broad range of perceived ages, genders and ethnicities. Nevertheless, Balakrishnan et al. (2020) provide an extensive analysis of multiple forms of bias in datasets (including CelebA-HQ and FFHQ) and algorithms for face generation; not only do they find imbalances in skin tone in FFHQ, but also correlations between multiple attributes such as skin tone and hair length. Based on this and other factors such as privacy and copyright, they argue that synthetically-created face datasets, for which multiple attributes can be controlled, is an important direction of investment and general inquiry.
154
+
155
+ The CelebA-HQ dataset covers celebrities, which brings a consequent bias toward images of attractive people who are mostly in age range of twenty to forty years old. Esser et al. (2020) discusses these biases in details, and they furthermore project images from the FFHQ dataset onto CelebAHQ: the main effect of which is to produce images of younger people with features conforming more to norms of celebrities popular in the United States of America. Our model’s generations appear to have a similar bias as derived from training on CelebA-HQ. Neverethless, they do show broad coverage of different perceived genders and ethnicities, but with age skewed to the 20-40 year old range.
156
+
157
+ ImageNet is, of course, quite pervasive in computer vision. In this paper, we learn to generate images given ImageNet class labels; these labels mostly concern animals, plants and things. People are sometimes generated when conditioning on classes such as sunglasses since the training data images contain people wearing sunglasses, but the generated images contain few depictions of people overall. Nevertheless, it is important to recognize that ImageNet itself was created with biases in terms of image selection and label annotation as a result of its process of creation (Denton et al., 2021). Given this, results present on ImageNet cover a significant, but nonetheless biased, sample of the kinds of scenes and objects one might encounter across the entire world.
158
+
159
+ There are also potential problematic aspects of image generation models, as demonstrated with biases found in the PULSE model (Menon et al., 2020) (see Section 6) and in model correlations with human biases found in social psychology (Steed & Caliskan, 2021), as well as with possible uses of such models to create fake media (Westerlund, 2019).
160
+
161
+ # REFERENCES
162
+
163
+ Jyoti Aneja, Alexander G. Schwing, Jan Kautz, and Arash Vahdat. NCP-VAE: variational autoencoders with noise contrastive priors. CoRR, abs/2010.02917, 2020. URL https://arxiv. org/abs/2010.02917.
164
+ Philip Bachman, R Devon Hjelm, and William Buchwalter. Learning representations by maximizing mutual information across views. arXiv preprint arXiv:1906.00910, 2019.
165
+ Guha Balakrishnan, Yuanjun Xiong, Wei Xia, and Pietro Perona. Towards causal benchmarking of bias in face analysis algorithms, 2020.
166
+ Hangbo Bao, Li Dong, and Furu Wei. Beit: BERT pre-training of image transformers. arXiv preprint arXiv:2106.08254, 2021.
167
+ Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. In ICLR, 2019.
168
+ Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
169
+ Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. arXiv preprint arXiv:2006.09882, 2020.
170
+ Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, Julien Mairal, Piotr Bojanowski, and ´ Armand Joulin. Emerging properties in self-supervised vision transformers. arXiv preprint arXiv:2104.14294, 2021.
171
+ 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, pp. 1691– 1703. PMLR, 2020a.
172
+ Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pp. 1597–1607. PMLR, 2020b.
173
+
174
+ Ting Chen, Simon Kornblith, Kevin Swersky, Mohammad Norouzi, and Geoffrey Hinton. Big selfsupervised models are strong semi-supervised learners. arXiv preprint arXiv:2006.10029, 2020c.
175
+
176
+ Xi Chen, Nikhil Mishra, Mostafa Rohaninejad, and Pieter Abbeel. Pixelsnail: An improved autoregressive generative model. In Jennifer G. Dy and Andreas Krause (eds.), ICML, 2018.
177
+
178
+ Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020d.
179
+
180
+ Rewon Child. Very deep {vae}s generalize autoregressive models and can outperform them on images. In International Conference on Learning Representations, 2021. URL https: //openreview.net/forum?id ${ . } = { }$ RLRXCV6DbEJ.
181
+
182
+ Andrew M Dai and Quoc V Le. Semi-supervised sequence learning. Advances in neural information processing systems, 28:3079–3087, 2015.
183
+
184
+ Emily Denton, Alex Hanna, Razvan Amironesei, Andrew Smart, and Hilary Nicole. On the genealogy of machine learning datasets: A critical history of imagenet. Big Data & Society, 8(2): 20539517211035955, 2021. doi: 10.1177/20539517211035955. URL https://doi.org/ 10.1177/20539517211035955.
185
+
186
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. In Jill Burstein, Christy Doran, and Thamar Solorio (eds.), NAACL-HLT, 2019.
187
+
188
+ Prafulla Dhariwal and Alex Nichol. Diffusion models beat gans on image synthesis. arXiv preprint arXiv:2105.05233, 2021.
189
+
190
+ Carl Doersch, Abhinav Gupta, and Alexei A Efros. Unsupervised visual representation learning by context prediction. In Proceedings of the IEEE international conference on computer vision, pp. 1422–1430, 2015.
191
+
192
+ Jeff Donahue and Karen Simonyan. Large scale adversarial representation learning. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alche-Buc, Emily B. Fox, and Roman ´ Garnett (eds.), NeurIPS, 2019a.
193
+
194
+ Jeff Donahue and Karen Simonyan. Large scale adversarial representation learning. arXiv preprint arXiv:1907.02544, 2019b.
195
+
196
+ Jeff Donahue, Philipp Krahenb ¨ uhl, and Trevor Darrell. Adversarial feature learning. ¨ arXiv preprint arXiv:1605.09782, 2016.
197
+
198
+ Jeff Donahue, Philipp Krahenb ¨ uhl, and Trevor Darrell. Adversarial feature learning. In ¨ ICLR, 2017.
199
+
200
+ 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. arXiv preprint arXiv:2010.11929, 2020.
201
+
202
+ Patrick Esser, Robin Rombach, and Bjorn Ommer. A note on data biases in generative models. In ¨ NeurIPS 2020 Workshop on Machine Learning for Creativity and Design, 2020. URL https: //arxiv.org/abs/2012.02516.
203
+
204
+ Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image ¨ synthesis. In CVPR, 2021.
205
+
206
+ Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations. In ICLR, 2018a.
207
+
208
+ Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations. arXiv preprint arXiv:1803.07728, 2018b.
209
+
210
+ Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron C. Courville, and Yoshua Bengio. Generative adversarial nets. In NeurIPS, 2014.
211
+
212
+ Jean-Bastien Grill, Florian Strub, Florent Altche, Corentin Tallec, Pierre H Richemond, Elena ´ Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Daniel Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent: A new approach to self-supervised learning. arXiv preprint arXiv:2006.07733, 2020.
213
+
214
+ 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.
215
+
216
+ Ari Heljakka, Arno Solin, and Juho Kannala. Pioneer networks: Progressively growing generative autoencoder. In Asia conference on computer vision, 2018.
217
+
218
+ Olivier Henaff. Data-efficient image recognition with contrastive predictive coding. In International Conference on Machine Learning, pp. 4182–4192. PMLR, 2020.
219
+
220
+ Irina Higgins, Lo¨ıc Matthey, Arka Pal, Christopher Burgess, Xavier Glorot, Matthew Botvinick, Shakir Mohamed, and Alexander Lerchner. beta-vae: Learning basic visual concepts with a constrained variational framework. In ICLR, 2017.
221
+
222
+ Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. In International Conference on Learning Representations, 2020. URL https: //openreview.net/forum?id $=$ rygGQyrFvH.
223
+
224
+ Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A. Efros. Image-to-image translation with conditional adversarial networks. In 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 5967–5976, 2017. doi: 10.1109/CVPR.2017.632.
225
+
226
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In European conference on computer vision, pp. 694–711. Springer, 2016.
227
+
228
+ Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of GANs for improved quality, stability, and variation. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $=$ Hk99zCeAb.
229
+
230
+ Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2019.
231
+
232
+ Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and improving the image quality of stylegan. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8110–8119, 2020.
233
+
234
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
235
+
236
+ Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In ICLR, 2014.
237
+
238
+ Durk P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 31. Curran Associates, Inc., 2018. URL https://proceedings.neurips.cc/paper/2018/file/ d139db6a236200b21cc7f752979132d0-Paper.pdf.
239
+
240
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 25:1097–1105, 2012.
241
+
242
+ Julia A Lasserre, Christopher M Bishop, and Thomas P Minka. Principled hybrids of generative and discriminative models. In 2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR’06), volume 1, pp. 87–94. IEEE, 2006.
243
+
244
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
245
+
246
+ Sachit Menon, Alex Damian, McCourt Hu, Nikhil Ravi, and Cynthia Rudin. Pulse: Self-supervised photo upsampling via latent space exploration of generative models. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
247
+
248
+ Charlie Nash, Jacob Menick, S. Dieleman, and P. Battaglia. Generating images with sparse representations. ICML, abs/2103.03841, 2021.
249
+
250
+ Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pp. 8162–8171. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr.press/v139/ nichol21a.html.
251
+
252
+ Mehdi Noroozi and Paolo Favaro. Unsupervised learning of visual representations by solving jigsaw puzzles. In Bastian Leibe, Jiri Matas, Nicu Sebe, and Max Welling (eds.), ECCV, 2016a.
253
+
254
+ Mehdi Noroozi and Paolo Favaro. Unsupervised learning of visual representations by solving jigsaw puzzles. In European conference on computer vision, pp. 69–84. Springer, 2016b.
255
+
256
+ Aaron van den Oord, Oriol Vinyals, and Koray Kavukcuoglu. Neural discrete representation learning. arXiv preprint arXiv:1711.00937, 2017.
257
+
258
+ Gaurav Parmar, Dacheng Li, Kwonjoon Lee, and Zhuowen Tu. Dual contradistinctive generative autoencoder. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 823–832, June 2021.
259
+
260
+ Niki Parmar, Ashish Vaswani, Jakob Uszkoreit, Lukasz Kaiser, Noam Shazeer, Alexander Ku, and Dustin Tran. Image transformer. In Jennifer G. Dy and Andreas Krause (eds.), ICML, 2018.
261
+
262
+ Stanislav Pidhorskyi, Donald A Adjeroh, and Gianfranco Doretto. Adversarial latent autoencoders. In Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR), 2020. [to appear].
263
+
264
+ Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. In Yoshua Bengio and Yann LeCun (eds.), ICLR, 2016.
265
+
266
+ Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
267
+
268
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
269
+
270
+ Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In Marina Meila and Tong Zhang (eds.), ICML, 2021.
271
+
272
+ Ali Razavi, Aaron van den Oord, and Oriol Vinyals. Generating diverse high-fidelity images with ¨ VQ-VAE-2. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alche-Buc, ´ Emily B. Fox, and Roman Garnett (eds.), NeurIPS, 2019.
273
+
274
+ Edgar Schonfeld, Bernt Schiele, and Anna Khoreva. A u-net based discriminator for generative adversarial networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8207–8216, 2020.
275
+
276
+ Noam Shazeer and Mitchell Stern. Adafactor: Adaptive learning rates with sublinear memory cost. In International Conference on Machine Learning, pp. 4596–4604. PMLR, 2018.
277
+
278
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
279
+
280
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alche-Buc, Emily B. ´ Fox, and Roman Garnett (eds.), NeurIPS, 2019.
281
+
282
+ Ryan Steed and Aylin Caliskan. Image representations learned with unsupervised pre-training contain human-like biases. In The 2021 ACM Conference on Fairness, Accountability, and Transparency (ACM FAccT 2021), 2021. URL https://arxiv.org/abs/2010.15052.
283
+
284
+ Arash Vahdat and Jan Kautz. NVAE: A deep hierarchical variational autoencoder. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin (eds.), NeurIPS, 2020.
285
+
286
+ Aaron van den Oord, Nal Kalchbrenner, Lasse Espeholt, Koray Kavukcuoglu, Oriol Vinyals, and ¨ Alex Graves. Conditional image generation with pixelcnn decoders. In Daniel D. Lee, Masashi Sugiyama, Ulrike von Luxburg, Isabelle Guyon, and Roman Garnett (eds.), NeurIPS, 2016.
287
+
288
+ Aaron van den Oord, Oriol Vinyals, and Koray Kavukcuoglu. Neural discrete representation learn- ¨ ing. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett (eds.), NeurIPS, 2017.
289
+
290
+ Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predic- ¨ tive coding. arXiv preprint arXiv:1807.03748, abs/1807.03748, 2018.
291
+
292
+ 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.
293
+
294
+ Mika Westerlund. The emergence of deepfake technology: A review. Technology Innovation Management Review, 9:40–53, 11/2019 2019. ISSN 1927-0321. doi: http://doi.org/10.22215/ timreview/1282. URL timreview.ca/article/1282.
295
+
296
+ Zhisheng Xiao, Karsten Kreis, Jan Kautz, and Arash Vahdat. $\{ { \mathrm { V A E B M } } \}$ : A symbiosis between variational autoencoders and energy-based models. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id ${ . } =$ 5m3SEczOV8L.
297
+
298
+ Han Zhang, Ian Goodfellow, Dimitris Metaxas, and Augustus Odena. Self-attention generative adversarial networks. In International conference on machine learning, pp. 7354–7363. PMLR, 2019a.
299
+
300
+ Han Zhang, Ian J. Goodfellow, Dimitris N. Metaxas, and Augustus Odena. Self-attention generative adversarial networks. In ICML, 2019b.
301
+
302
+ 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, pp. 586–595, 2018.
303
+
304
+ # A LINEAR-PROBE ON IMAGENET
305
+
306
+ We show linear-probe accuracy from different layers in a pretrained VIM-Base Transformer model in Figure 3. Similar to iGPT (Chen et al., 2020a), we also find the last few layers may not be the best layers for discriminative features, as the generative pretraining objective is to recover the original image tokens. The linearprobe accuracy increases quickly from the first transformer output, reaches its peak at middle layers, and finally decreases for the last few blocks. Interestingly, we find for both VIMBase and VIM-Large, the middle transformer block has the near-best result. This observation connects the transformer model to an encoderdecoder model where the encoder encodes image tokens into high-level semantic features and the decoder takes feature information to gener
307
+
308
+ ![](images/1d84e809d5636b23d7ceb5e8d59293c393c6e1ce9679abdcb3fefcdce313b433.jpg)
309
+ Figure 3: Linear-probe accuracy from different layers in a pretrained VIM-Base Transformer model.
310
+
311
+ ate output image tokens. We leave for future study regrading the interpretability of pretrained VIM models.
312
+
313
+ # B MODEL SIZES OF CLASS-CONDITIONED IMAGENET SYNTHESIS
314
+
315
+ We also present results of different sizes of Stage 2 Transformers for class-conditioned image synthesis and compare with VQGAN (Esser et al., 2021)4 summarized in Table 8.
316
+
317
+ <table><tr><td>Model</td><td>Stage-2 Transformer Size</td><td>#Tokens</td><td>FID</td><td>IS</td></tr><tr><td>Validation data</td><td>/</td><td>=</td><td>1.62</td><td>235.0</td></tr><tr><td>VQGAN (Esser et al.,2021)</td><td>1.4B</td><td>16 ×16</td><td>17.04</td><td>70.6</td></tr><tr><td>ViT-VQGAN+VIM-Base</td><td>650M</td><td>16 ×16</td><td>11.20</td><td>97.2</td></tr><tr><td>ViT-VQGAN + VIM-Large</td><td>1.7B</td><td>16 ×16</td><td>5.3</td><td>149.9</td></tr><tr><td>ViT-VQGAN + VIM-Base</td><td>650M</td><td>32 × 32</td><td>8.81</td><td>110.8</td></tr><tr><td>ViT-VQGAN + VIM-Large</td><td>1.7B</td><td>32 ×32</td><td>4.17</td><td>175.1</td></tr></table>
318
+
319
+ Table 8: FID comparison for class-conditional image synthesis on ImageNet with different Transformer sizes in Stage 2. Results are reported without rejection sampling.
320
+
321
+ # C IMPLEMENTATION DETAILS OF FACTORIZED CODEBOOK
322
+
323
+ As we introduced in Section 3.2, we use a linear projection to reduce the encoded embedding to a low-dimensional variable space for code lookup. A detailed illustration is shown in Figure 4.
324
+
325
+ ![](images/808468d18686ea4c5749fcf0e24a77e6508b7620f5bbe5bc1144fb5f4eb09778.jpg)
326
+ Figure 4: Illustration of factorized codes and codebook details.
327
+
328
+ ![](images/0cf2583848d23fed0a25567a05ff4f7a7593c2be749af32a27ee19d63132e4bd.jpg)
329
+ Figure 5: Uncurated set of samples from class-conditioned generation trained on ImageNet.
330
+
331
+ Scale
332
+
333
+ ![](images/2260824a7c774887327e7ed39a63230563e7ec24f408abf7f020883a92447b17.jpg)
334
+ Figure 6: Uncurated set of samples from class-conditioned generation trained on ImageNet.
md/dev/rwE8SshAlxw/rwE8SshAlxw.md ADDED
@@ -0,0 +1,464 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UNSUPERVISED DISCOVERY OF OBJECT RADIANCE FIELDS
2
+
3
+ Hong-Xing Yu Stanford University
4
+
5
+ Leonidas J. Guibas Stanford University
6
+
7
+ Jiajun Wu Stanford University
8
+
9
+ # ABSTRACT
10
+
11
+ We study the problem of inferring an object-centric scene representation from a single image, aiming to derive a representation that is learned without supervision, explains the image formation process, and captures the scene’s 3D nature. Most existing methods on scene decomposition lack one or more of these characteristics, due to the fundamental challenge in integrating powerful unsupervised inference schemes like deep networks with the complex 3D-to-2D image formation process. In this paper, we propose unsupervised discovery of Object Radiance Fields (uORF), integrating recent progresses in neural 3D scene representations and rendering with deep inference networks for unsupervised 3D scene decomposition. Trained on only multi-view RGB images, uORF learns to decompose complex scenes with diverse, textured background from a single image. We show that uORF enables novel tasks, such as scene segmentation and editing in 3D, and it performs well on these tasks and on novel view synthesis on three datasets\*.
12
+
13
+ # 1 INTRODUCTION
14
+
15
+ Building factorized, object-centric scene representations is a fundamental ability in human vision and a constant topic of interest in computer vision and machine learning. We identify that such representations should bear three characteristics: they should be learned without supervision or prior knowledge about object categories, and therefore applicable to environments where object categories are unknown; they should explain the image formation process, addressing questions like ‘what if the object is not there?’; they should be 3D-aware, capturing geometric and physical object properties for navigation, interaction, and manipulation.
16
+
17
+ For decades, researchers have attempted to solve the problems from various angles. Inspiring as they are, these methods each lack in one or more of the three aspects (Table 1). Computer vision research on unsupervised object discovery has achieved great success on deriving object segments from real images, but it doesn’t capture the image formation process, nor is it 3D-aware (Rubinstein et al., 2013; Zhu et al., 2012). Recent work on deep probabilistic inference for visual scene decomposition is unsupervised and generative (Burgess et al., 2019; Engelcke et al., 2019; Locatello et al., 2020), though most still formulate the problem as 2D segmentation and work on simple scenes of geometric primitives, ignoring the complex 3D nature of realistic visual scenes. A few recent papers on ‘scene de-rendering’ have attempted to reconstruct 3D, object-centric representations by leveraging the forward rendering procedure (Yao et al., 2018; Ost et al., 2021); they are however supervised, relying on annotations of specific object and scene categories, such as cars and road scenes.
18
+
19
+ The fundamental challenge that prevents these systems from acquiring all three desired properties is that the image formation process from 3D to 2D is complex and non-differentiable (e.g., due to occlusion). Thus, for a long time, it has been unclear how it may be integrated with powerful deep inference schemes. But most recently, progresses in neural rendering (Tewari et al., 2020) have demonstrated that their continuous, implicit representation works well with gradient-based inference models, such as deep networks. In particular, Neural Radiance Fields (NeRFs) (Mildenhall et al., 2020) recover a 3D scene from a set of RGB images via differentiable volume rendering. Such encouraging advances in generative modeling suggest a promising route for inferring 3D, generative, and object-centric scene representations without supervision.
20
+
21
+ In this paper, we propose unsupervised discovery of Object Radiance Fields (uORF), integrating conditional NeRFs as 3D object representations with deep inference networks for unsupervised 3D scene decomposition. uORF infers a set of object radiance fields and a background radiance field; thus, uORF represents a 3D scene as a composition of object radiance fields (Figure 1). During training, such radiance fields are neurally rendered in multiple views, with reconstruction losses in pixel space as training supervision; during testing, uORF infers the set of object radiance fields from a single image. Learning uORF does not require explicit supervision of 3D geometry or object segmentation, but only sparse multi-view RGB images of training scenes.
22
+
23
+ ![](images/5432514a57bb1445597c05650057330b2b9697276ff3dd9a74da2b03e6d6dc26.jpg)
24
+ Figure 1: Illustration of unsupervised discovery of Object Radiance Fields. We aim to infer factorized object and background radiance fields from a single view, allowing reconstructing and editing of the scene.
25
+
26
+ The integration of NeRFs allows us to work with more realistic scenes with complex object shapes and diverse background environments, beyond simple scenes such as those in multi-dSprites (Greff et al., 2019) and CLEVR (Johnson et al., 2017), as considered by most current unsupervised scene decomposition methods. We further make two innovations to improve uORF’s performance. First, as background geometry and appearance can be quite different from foreground objects in 3D, we design uORF with explicit modeling of both components. This background-aware design not only facilitates learning on complex scenes, but also allows single-image scene editing including moving individual objects and changing background. Second, as volume rendering requires massive queries to render a single pixel for the recomposed scene, a practical challenge of learning uORF lies in the computational inefficiency. We tackle this issue by proposing a novel progressive coarse-to-fine training which improves representation quality while remaining affordable computational cost.
27
+
28
+ We evaluate uORF on factorized scene representation learning (e.g., segmentation in 3D) and scene generation (e.g., novel view synthesis, scene editing in 3D). Our evaluation is on three datasets with a gradually increasing complexity: first, CLEVR-like scenes with primitives foreground shapes; second, room scenes with complex chair shapes and textured backgrounds; third, more diverse room scenes with various foreground shapes and backgrounds. Our results show that uORF learns factorized representations that can segment 3D scenes into objects with fine shape details (e.g., thin chair legs) and backgrounds with well-recovered appearance details (e.g., irregular textures of a wooden floor).
29
+
30
+ In summary, our contributions are three-fold. First, we propose the problem of inferring an unsupervised, factorized, generative, and 3D-aware scene representation from a single image. Second, we introduce unsupervised discovery of Object Radiance Fields (uORF) that infers individual 3D object radiance fields from a single view for the proposed problem. Third, we demonstrate that uORF enables novel tasks such as scene segmentation and editing in 3D, and we show that it generalizes to novel scene arrangement and unseen combinations of object properties.
31
+
32
+ # 2 RELATED WORK
33
+
34
+ Co-segmentation and object discovery. Our work is closely related to traditional computer vision methods on object discovery, which aims to locate (visually similar) objects in a collection of images. These methods typically model objects as visual words and adopted methods from topic modeling to localize objects (Russell et al., 2006; Sivic et al., 2005; 2008), or cluster and group image patches (Grauman & Darrell, 2006; Joulin et al., 2010; Rubio et al., 2012; Vicente et al., 2011; Rubinstein et al., 2013; Cho et al., 2015). Recent works have integrated the clustering-based strategy with deep learning (Li et al., 2019; Vo et al., 2020). Nevertheless, they do not explain image formation process nor are they 3D-aware.
35
+
36
+ <table><tr><td>Approach</td><td>Unsup.Gen. 3D</td><td></td><td></td></tr><tr><td>Co-segmentation</td><td></td><td></td><td>xx</td></tr><tr><td>Deep prob. infer.</td><td></td><td></td><td></td></tr><tr><td>Scene&quot;de-render&quot;</td><td></td><td></td><td></td></tr><tr><td>Ours</td><td></td><td></td><td></td></tr></table>
37
+
38
+ Table 1: Comparison to existing methods.
39
+
40
+ ![](images/b771ad360722e178944c575023b7fc9d95a1b5d37ba0b3fe34ca525f2399a212.jpg)
41
+ Figure 2: Overview. I. Our model learns to infer a set of latents in a single forward pass. II. Each object/background radiance field consists of a latent and a shared conditional NeRF. III. During training, we recompose the scene and re-render images for supervision. We train our model on different scenes. At test time, we use a single image of an unseen scene for reconstruction or editing.
42
+
43
+ Deep probabilistic inference for scene decomposition. Our method is also closely related to deep probabilistic inference for scene decomposition. Most works formulate the problem as compositional generative modeling, where a visual scene is represented by a set of latent codes that either correspond to localized object-centric patches (Eslami et al., 2016; Crawford & Pineau, 2019; Kosiorek et al., 2018; Lin et al., 2020; Jiang et al., 2019) or scene mixture components (Burgess et al., 2019; Greff et al., 2019; 2016; 2017; Engelcke et al., 2019). Recently, Locatello et al. (2020) proposed the Slot Attention module to simplify the inference by a slot-based encoder. Besides these inference models, Monnier et al. (2021) formulated scene decomposition as layered image decomposition and demonstrated it on real images. However, these methods do not account for the 3D nature of scenes.
44
+
45
+ A few methods have recently been proposed for unsupervised 3D scene decomposition. Elich et al. (2020) infer object shapes from a single scene image, but they require pretraining on groundtruth shapes. Chen et al. (2020) extend Generative Query Network (Eslami et al., 2018) to decompose 3D scenes, but they require multi-view images during inference. The closest to our work is a concurrent work by Stelzner et al. (2021) which also utilizes a slot-based encoder and NeRFs as 3D representations. However, Stelzner et al. (2021) relies on groundtruth multi-view dense depth in addition to images in training. Moreover, we explicitly model the separation of objects and background to address various complex shapes and textured backgrounds, while they only demonstrate scenes with a single textureless background.
46
+
47
+ Scene de-rendering. A few recent works have shown reconstructing 3D object-centric representations by incorporating forward image rendering process (Wu et al., 2017; Yao et al., 2018; Kundu et al., 2018; Ost et al., 2021). Yao et al. (2018) de-render an image into semantic segments and geometric object attributes, which enable 3D scene manipulation. Most recently, Ost et al. (2021) propose Neural Scene Graph to represent dynamic scenes into a scene graph where each node encodes object-centric information. However, these methods rely on manual annotations of specific objects (such as cars) and scene categories (such as street scenes).
48
+
49
+ Neural scene representations and rendering. Our method is related to recent progresses in neural continuous scene representations (Sitzmann et al., 2019) and neural rendering (Tewari et al., 2020). Neural scene representations parameterize 3D scenes with a deep network (Sitzmann et al., 2019). Combined with differentiable neural rendering techniques (Kato et al., 2020; Tewari et al., 2020), they can be learned from only 2D images (Niemeyer et al., 2020). In particular, Neural Radiance Fields (NeRFs) (Mildenhall et al., 2020) have shown impressive novel view synthesis. Related follow-up works include those that infer NeRFs from a single image (Yu et al., 2020; Kosiorek et al., 2021; Jang & Agapito, 2021) and those that incorporate NeRFs into generative models (Schwarz et al., 2020; Niemeyer & Geiger, 2021; Chan et al., 2020). Different from these works which cope with single objects or holistic scenes, we learn object NeRFs via decomposing a multi-object scene without segmentation annotations. GIRAFFE (Niemeyer & Geiger, 2020) generates object NeRFs and thus compose 3D scenes in an adversarial framework. However, it targets at unconditional generation and cannot tackle inference (see Appendix E), while we focus on single-image inference of multi-object scenes. Thus, we address a fundamentally different problem compared to GIRAFFE.
50
+
51
+ # 3 APPROACH
52
+
53
+ Our goal is to infer from a single image a set of object-centric 3D representations to generate the underlying 3D scene. We show an illustration in Figure 2. Our object representation is a conditional object radiance field. Thus, we learn to infer object-centric latents from a single image (Figure 2- I). The inferred latents are used to condition a network to yield the 3D object and background radiance fields (Figure 2-II), forming our 3D-aware, generative and factorized scene representation. In training, we compose all object and background radiance fields and render the recomposed scene from multiple views. We obtain supervision by comparing rendered images to reference images (Figure 2-III) without needing 3D geometry or segmentation annotations. We describe each of our model components in the following and leave implementation details in Appendix B.
54
+
55
+ # 3.1 OBJECT-CENTRIC LATENT INFERENCE
56
+
57
+ Our goal is to infer latent object-centric representations from a single input image. We assume that an underlying 3D scene is composed of a background environment and no more than $K$ foreground objects. Thus, the output of our object-centric latent inference process is a latent $\mathbf { z } ^ { b }$ for background and a set of latents $\{ \mathbf { z } _ { i } ^ { f } \} _ { i = 1 } ^ { K }$ for foreground objects (empty objects are allowed). To encourage unsupervised object-wise factorization, we adopt a slot-based formulation (Locatello et al., 2020). The assumption in this formulation is that objects should share a common prior latent space. The main idea include three steps. The first step is to sample all object latents (i.e., slots) from the same prior
58
+
59
+ ![](images/614299cdcf3735001f5da11d5324b929532aabf1f5fb87b68e70b315fe7a4d2a.jpg)
60
+ Figure 3: Our object-centric latent inference. The attention binds each object’s features to a slot.
61
+
62
+ distribution (background is a special object) to encourage representational uniformity across all slots (“sampling”). Then each slot is bound to an object region via an attention module (“binding”). In the last step each slot gets updated by the bound object features to specialize for that object (“updating”). Locatello et al. (2020) have demonstrated success on segmenting 2D images.
63
+
64
+ However, in 3D scenes, the geometry and appearance of the background are highly different from those of foreground objects. Modeling them indistinguishably often leads to object representations entangled with blurry background segments (Burgess et al., 2019; Locatello et al., 2020), which impedes applications such as scene editing and re-composition. Thus, we propose a backgroundaware slot attention module (Figure 3) that separately models objects and environment to better capture the compositional structure of 3D scenes.
65
+
66
+ Background-aware slot attention for sampling and binding. In the sampling step, we model the latent prior distribution of foreground objects by a Gaussian with learnable mean and variance, i.e., we sample $\mathbf { s } \mathbf { 1 } \mathsf { o t } \mathbf { s } ^ { f } \sim \mathcal { N } ^ { f } ( \mu ^ { f } , \mathsf { d i a g } ( \sigma ^ { f } ) \bar { ) } \in \mathbb { R } ^ { \bar { K } \times D }$ for $K$ objects. For latent prior of backgrounds, we learn another Gaussian and sample a single slot from it, i.e., $\mathbf { s } \mathbf { 1 } \mathbf { o t } ^ { b } \sim \mathcal { N } ^ { b } ( \dot { \mu ^ { b } } , \mathbf { d i a g } ( \sigma ^ { b } ) ) \stackrel { \smile } { \in } \mathbb { R } ^ { 1 \times D }$ .
67
+
68
+ To bind slots to image features, we let all the slots to compete for explaining the input image representation. To do this, we flatten the convolutional feature map (we include details about convolutional encoder in Appendix B.1) into a set of $N$ input feature vectors, feat $\in \mathbb { R } ^ { N \times D }$ . The slot competition is modeled by a key-query attention (Bahdanau et al., 2014):
69
+
70
+ $$
71
+ \mathrm { a t } { \bf u } _ { i , j } : = \frac { \exp ( M _ { i , j } ) } { \sum _ { l } \exp ( M _ { i , l } ) } , \quad \mathrm { w h e r e } \quad M : = \frac { 1 } { \sqrt { D } } k ( \mathbf { f e a t } ) \cdot \left[ \boldsymbol { q } ^ { b } ( \mathbf { s } \mathbf { l o t } \boldsymbol { \bf s } ^ { b } ) \right] ^ { T } \in \mathbb { R } ^ { N \times ( K + 1 ) } .
72
+ $$
73
+
74
+ Here $k$ and $q ^ { b } / q ^ { f }$ are learnable linear mappings √ $\mathbb { R } ^ { D D }$ for computing dot-product similarity (Luong et al., 2015), and $\sqrt { D }$ is a fixed softmax temperature (Vaswani et al., 2017). One can see this process as a soft K-means, where $\tt a t t r a _ { i }$ softly assigns a feature $i$ to the slots (centroids). The background slot is expected to capture the modality of background features and bind all of them, allowing foreground slots to focus only on the objects without explaining background segments (Figure 3). Besides the representation design, we further encourage disentanglement between background and foregrounds by two additional designs: (1) We represent and query foreground/background (during the neural rendering process) in different coordinate frames. (2) To discourage object slots from fitting background, we impose a locality constraint in early training. We set a foreground box and enforce that every foreground query point outside the box has zero density. We include details in Appendix B.2.
75
+
76
+ Updating slots to infer latents. With the attention weights, we form the update signal by aggregating input values via a weighted mean pooling updatesb := W bT · vb(feat) ∈ R1×D, where $\bar { W } _ { i , 1 } ^ { b } : = \mathsf { a t t n } _ { i , 1 } / ( \sum _ { l = 1 } ^ { N } \bar { \mathsf { a t t n } _ { l , 1 } } )$ , and up $\mathsf { i a t e s } ^ { f } : = W ^ { f T } \cdot v ^ { f } ( \mathsf { f e a t } ) \in \mathbb { R } ^ { K \times D }$ , where $W _ { i , j } ^ { f } ~ : = ~ \mathsf { a t t n } _ { i , j + 1 } / ( \sum _ { l = 1 } ^ { N } \mathsf { a t t n } _ { l , j + 1 } ) .$ Slots are then updated using the update signals via a learnable rule parameterized by a Gated Recurrent Unit (GRU) (Cho et al., 2014), so that $\mathbf { s } \mathbf { 1 } { \mathsf { o t s } } ^ { f } \gets \mathsf { G R U } ^ { f } \big ( \mathbf { s } \mathbf { 1 } { \mathsf { o t s } } ^ { f } , \mathbf { u p d a t } \bar { \mathsf { e s } } ^ { f } \big )$ ) and $\mathbf { s } 1 0 \mathbf { t } ^ { b } \gets \mathsf { G R U } ^ { b } ( \mathsf { s } 1 0 \mathbf { t } ^ { b } , \mathsf { u p d a t e s } ^ { b } )$ ). We repeat the attention computation and updating for 3 iterations, and output all the slots as the final latents $\mathbf { z } ^ { b }$ and $\{ \mathbf { z } _ { i } ^ { f } \} _ { i = 1 } ^ { K }$ . We show pseudo-code of our background-aware slot attention in Appendix (Alg. 1).
77
+
78
+ # 3.2 COMPOSITIONAL NEURAL RENDERING
79
+
80
+ We represent a 3D object as a conditional neural radiance field. A NeRF is a continuous mapping $g : ( \bar { \mathbf { x } , \mathbf { d } } ) ( \mathbf { c } , \sigma )$ from spatial location $\mathbf { x }$ and viewing direction d to emitted color c and volume density $\sigma$ used for volume rendering (Max, 1995). This mapping is parameterized by an MLP network. We adopt a conditional NeRF $g ( \mathbf { x } , \mathbf { d } | \mathbf { z } )$ for our inference scheme (detailed in Appendix B.3). The MLP parameters are shared across all objects $g ^ { f } ( \mathbf { x } , \mathbf { d } | \mathbf { z } _ { i } ^ { f } )$ , but not the background $g ^ { b } ( \mathbf { x } , \mathbf { d } | \mathbf { z } ^ { b } )$ due to its distinct geometry and appearance distribution.
81
+
82
+ To compose individual objects and background into the holistic scmodel and use density-weighted mean to combine all components: $\begin{array} { r } { \bar { \boldsymbol { \sigma } } = \sum _ { i = 0 } ^ { K } w _ { i } \sigma _ { i } , \bar { \mathbf { c } } = \sum _ { i = 0 } ^ { K } w _ { i } \mathbf { c } _ { i } } \end{array}$ , where $w _ { i } = \sigma _ { i } / \sum _ { j = 0 } ^ { K } \sigma _ { j }$ . Here $\bar { \sigma }$ and c¯ are the combined density and color, respectively. The color $C ( \mathbf { r } )$ of a camera ray $\mathbf { r } ( t ) = \mathbf { o } + \mathbf { d } ( t )$ is then estimated via numerical integration of volume rendering, using $S$ discrete combined samples along a ray (Max, 1995): $\begin{array} { r } { C ( \mathbf { r } ) = \bar { \sum _ { i = 1 } ^ { S } } T _ { i } [ 1 - \exp ( - \bar { \sigma } _ { i } \delta _ { i } ) ] \bar { \mathbf { c } } _ { i } } \end{array}$ where $\begin{array} { r } { T _ { i } = \exp \left( - \sum _ { j = 1 } ^ { i - 1 } \bar { \sigma } _ { j } \delta _ { j } \right) } \end{array}$ . Here $\delta _ { j }$ is the distance between adjacent samples along a ray.
83
+
84
+ # 3.3 MODEL LEARNING
85
+
86
+ Loss functions. As shown in Figure 2, during training we input a single image of a scene, infer object and background radiance fields, render multiple views from the recomposed scene, and compare them to reference images for loss computation. We train our model across multiple scenes. Our training loss function comprises of a reconstruction loss, a perceptual loss, and an adversarial loss: ${ \mathcal { L } } = { \mathcal { L } } _ { \mathrm { { r e c o n } } } + \lambda _ { \mathrm { { p e r c e p t } } } { \mathcal { L } } _ { \mathrm { { p e r c e p t } } } - \lambda _ { \mathrm { { a d v } } } { \mathcal { L } } _ { \mathrm { { a d v } } }$ , where $\lambda$ are weights. The reconstruction loss is $\mathcal { L } _ { \mathrm { r e c o n } } = \| \pmb { I } - \hat { \pmb { I } } \| ^ { 2 }$ , where $\pmb { I }$ and $\hat { I }$ denote the reference image and rendered image, respectively.
87
+
88
+ Since we estimate 3D radiance fields from a single view, there can be uncertainties about the appearance from other views (e.g., the back view). For example, regarding visual appearance of objects, inaccurate global lighting estimation leads to uncertainties in brightness and shadows from occluded views even if the object shapes can be well estimated. To address this, we incorporate a perceptual loss (Johnson et al., 2016) which is tolerant to mild appearance changes. The perceptual loss is defined by $\| \mathcal { L } _ { \mathrm { p e r c e p t } } = p ( I ) - p ( \hat { I } ) \| ^ { 2 }$ where $p$ is a deep feature extractor (See Appendix B.4).
89
+
90
+ In addition to appearance, there can be even higher uncertainties in estimating object shapes from a single view, which is a multi-modal distribution. In this case, the unimodal reconstruction loss leads to blurry results (“mean shape”). We mitigate this issue by adding an adversarial loss which can deal with multi-modal distributions:
91
+
92
+ $$
93
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { a d v } } = \mathbb { E } [ f ( D ( \hat { \cal I } ) ) ] + \mathbb { E } [ f ( - D ( { \cal I } ) ) + \lambda _ { R } \| \nabla D ( { \cal I } ) \| ^ { 2 } ] , \quad \mathrm { w h e r e } \quad f ( t ) = - \log ( 1 + \exp ( - t ) ) . } \end{array}
94
+ $$
95
+
96
+ Here we adopt the R1 regularization (Mescheder et al., 2018) to stabilize training. $D$ denotes a discriminator to distinguish rendered images $\hat { I }$ and reference images $\pmb { I }$ . We iterate between training the discriminator by minimizing ${ \mathcal { L } } _ { \mathrm { a d v } }$ and training our inference model (Figure 2) by minimizing $\mathcal { L }$ .
97
+
98
+ Coarse-to-fine Progressive Training. A practical challenge in training compositional NeRFs lies in the computational cost of neural volume rendering, as it requires massive queries to render a single pixel. While there have been attempts on fast inference (Liu et al., 2020; Rebain et al., 2020; Neff et al., 2021; Garbin et al., 2021; Reiser et al., 2021; Yu et al., 2021), high space complexity in training remains a challenge. Further, because our perceptual and adversarial losses depend on image patches, the system has to render a large enough patch (instead of a single pixel) at the same time, which further increases its space demand.
99
+
100
+ To allow training on a higher resolution, we propose a coarse-to-fine progressive training. In a coarse training stage, we bilinearly downsample reference images to a low resolution (e.g., $6 4 \times 6 4 )$ , and train uORF on these downsampled images. Although the coarsely trained model can already decompose the 3D scenes and recover rough object radiance fields, fine details (e.g., thin legs of chairs) might be missing. Thus, in a following fine training stage, we replace the low-resolution reference images with image patches randomly cropped from high-resolution images (Figure 2-III), and render the correspondingly located patches from our recomposed scene radiance fields to compute the loss. We include further training details in Appendix B.4.
101
+
102
+ # 4 EXPERIMENTS
103
+
104
+ We evaluate uORF on both scene representation (via scene segmentation in 3D) and scene generation (via novel view synthesis and scene editing) on three datasets.
105
+
106
+ Data. We build three synthetic datasets with gradually increasing complexity. For each scene in the dataset, we point the camera to the scene center and render four images with a randomly chosen azimuth angle and a fixed elevation angle. We describe more details in Appendix C.1.
107
+
108
+ CLEVR-567. The first dataset includes scenes of 5–7 CLEVR objects (Johnson et al., 2017), with a random position and orientation on a clean background. Foreground object shapes include three geometric primitives (i.e., cubes, spheres and cylinders). Since there is intrinsic ambiguity in estimating specularity from a single image, we use only the largely diffuse “Rubber” material. There are 1,000 scenes for training and 500 for testing.
109
+
110
+ Room-Chair. The second dataset includes scenes of 3 to 4 chairs of the same shape in a room with three different textured backgrounds. There are 1,000 scenes for training and 500 for testing.
111
+
112
+ Room-Diverse. The third dataset includes scenes of diverse foreground object shapes and background appearances. Each scene includes 4 different chairs, whose shape is randomly sampled from 1,200 ShapeNet chair shapes (Chang et al., 2015), and the background is sampled from 50 floor textures from the web. There are 5,000 scenes for training and 500 for testing.
113
+
114
+ # 4.1 SCENE SEGMENTATION IN 3D
115
+
116
+ We first evaluate uORF’s factorized 3D scene representations via scene segmentation in 3D.
117
+
118
+ Baselines. Because there is no previous work focusing on the same setting as uORF, we compare to a 2D state-of-the-art scene decomposition model Slot Attention (Locatello et al., 2020) for unsupervised scene segmentation wherever possible (detailed in Appendix C.2). In addition, we compare to two ablated versions of uORF. First, we remove our background-aware modeling but keep the same number of slots. Second, we ablate our progressive training such that the training procedure only contains the coarse training stage. We refer to ablated models as “uORF (w/o background)” and “uORF (w/o prog. train.)”, respectively.
119
+
120
+ Metrics. We adopt the widely-used Adjusted Rand Index (ARI) as our metric. To evaluate scene segmentation in 3D, we consider three kinds of ARIs: (1) For direct comparison to 2D methods, we compute ARI on reconstructed images. (2) To reflect the 3D nature, we also compute ARI on synthesized novel views, denoted as “NV-ARI”. Note that each scene includes 4 views, and only one is used as input, and the other three are treated as novel views for this metric. (3) In line with previous 2D methods, we also report foreground ARI $\mathrm { F g }$ -ARI), computed only on foreground regions indicated by groundtruth masks. Yet, we note that $\mathrm { F g }$ -ARI cannot fully reflect the segmentation quality, because background segmentation is completely ignored.
121
+
122
+ Results. We volume-render a density map $\mathbf { d } ^ { i }$ for each slot . The segmentation label for each pixel $s _ { p }$ is given by $s _ { p } = \arg \operatorname* { m a x } _ { i = 1 } ^ { K + 1 } { \bf d } _ { p } ^ { i }$ . We show results on Table 2 and Figure 4 (more in Appendix D). For all segmentation metrics, we show mean and standard deviation for three runs. uORF outperforms all methods in terms of ARI and NV-ARI. From Figure 4, it is clear that uORF is able to discover the 3D objects from a single image. These results validate that uORF can learn well-factorized 3D object-centric scene representations. Also notice that uORF yields better ARI even in input views compared to 2D slot attention. This is likely due to our background-aware design, as our ablated model “uORF w/o background” has shown similar input-view results compared to slot attention (e.g., see 3rd and 4th columns in Figure 4).
123
+
124
+ # 4.2 NOVEL VIEW SYNTHESIS
125
+
126
+ We then show that uORF is 3D-aware and generative via evaluation on novel view synthesis.
127
+
128
+ ![](images/7783d6f6b011891979bd7aeefad251582074bc3420a9dbfabcca1cd7db9ef3af.jpg)
129
+
130
+ Figure 4: Examples on scene segmentation in 3D. Novel view images are for reference but not input.
131
+
132
+ <table><tr><td rowspan="5">Models</td><td colspan="3">CLEVR-567</td><td colspan="3">Room-Chair</td><td colspan="3">Room-Diverse</td></tr><tr><td>3D metric</td><td colspan="2">2D metric</td><td>3D metric</td><td colspan="2">2D metric</td><td>3D metric</td><td colspan="2">2D metric</td></tr><tr><td>NV-ARI↑</td><td>ARI↑</td><td>Fg-ARI个</td><td>NV-ARI个</td><td>ARI个</td><td>Fg-ARI↑</td><td>NV-ARI↑</td><td>ARI个</td><td>Fg-ARI↑</td></tr><tr><td>Slot Attention</td><td>N/A</td><td>3.5±0.7</td><td>93.2±1.5</td><td>N/A</td><td>38.4±18.4</td><td>40.2±4.5</td><td>N/A</td><td>17.4±11.3</td><td>43.8±11.7</td></tr><tr><td>uORF(w/o background)</td><td>10.5±3.6</td><td>11.7±4.6</td><td>86.4±2.8</td><td>40.4±9.2</td><td>42.3±10.6</td><td>93.3±1.9</td><td>21.0±8.1</td><td>24.0±9.9</td><td>78.9±3.1</td></tr><tr><td>uORF(w/o prog. train.)</td><td>81.1±0.7</td><td>83.7±0.8</td><td>84.2±0.5</td><td>62.3±2.5</td><td>65.4±2.6</td><td>81.0±3.0</td><td>53.8±1.4</td><td>63.7±1.7</td><td>66.9±4.1</td></tr><tr><td>uORF(ours)</td><td>83.8±0.3</td><td>86.3±0.1</td><td>87.4±0.8</td><td>74.3±1.9</td><td>78.8±2.6</td><td>88.8±2.7</td><td>56.9±0.2</td><td>65.6±1.0</td><td>67.9±1.7</td></tr></table>
133
+
134
+ Table 2: Scene segmentation results. “NV-ARI” refers to ARI evaluated on novel views. “Fg-ARI” refers to ARI evaluated with only foreground pixels. Slot Attention (Locatello et al., 2020) is a state-of-the-art 2D method.
135
+
136
+ Setup. For each test scene, we randomly pick one image as input and the remaining three images as groundtruth for novel view synthesis. As Slot Attention is purely in 2D and does not support novel view synthesis, we compare to a conditional NeRF (Mildenhall et al., 2020), equipped with a convolutional encoder similar to uORF, termed as “NeRF-AE” (see Appendix C.2). For fair comparison, we increase the latent dimension for NeRF-AE to guarantee approximately the same computational cost, and we use the same training strategy and losses as uORF. Thus, NeRF-AE can also be seen as a monolithic alternative model to uORF. We also compare with the ablated models, “uORF (w/o background)” and “uORF (w/o prog. train.)”. We use the perceptual metric LPIPS (Zhang et al., 2018), together with SSIM (Wang et al., 2004) and PSNR, as our evaluation metrics.
137
+
138
+ Results. Quantitative results are in Table 3 and qualitative results are in Figure 5 (more in Appendix D). Quantitatively, uORF outperforms all compared methods on all metrics. From the qualitative comparison in Figure 5, we highlight three advantages of uORF. First, compared with NeRF-AE, which has a monolithic latent structure for the entire scene, uORF better preserves the features of each object: for example, see how NeRF-AE fuses object colors in the first two rows, while uORF does not. This shows the advantage of factorized scene representations to structurally describe a visual scene. Second, compared with uORF (w/o background), one can clearly see how our background-aware modeling helps recovering background appearances: uORF can accurately recover background appearance of the Room-Chair example, while uORF (w/o background) does not. It also facilitates learning on complex scenes with diverse, textured background: uORF can learn to roughly recover object shapes in the Room-Diverse example. Third, compared with uORF (w/o prog. train.), we highlight that the fine training on image patches indeed improves both visual quality and representation quality: the full uORF tries to recover sharp edges of cubes, while uORF (w/o prog. train.) cannot distinguish cube from sphere.
139
+
140
+ ![](images/232183a9d35988986c77d1a94fc50b45dc9cf79f1c2590ae6196917d9c3ce14c.jpg)
141
+
142
+ Figure 5: Qualitative results on scene decomposition and novel view synthesis. Within every two rows, the first is reconstruction and the second is a novel view.
143
+
144
+ <table><tr><td rowspan="2">Models</td><td colspan="3">CLEVR-567</td><td colspan="3">Room-Chair</td><td colspan="3">Room-Diverse</td></tr><tr><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td></tr><tr><td>NeRF-AE</td><td>0.1288</td><td>0.8658</td><td>27.16</td><td>0.1166</td><td>0.8265</td><td>28.13</td><td>0.2458</td><td>0.6688</td><td>24.80</td></tr><tr><td>uORF (w/o background)</td><td>0.0919</td><td>0.8924</td><td>28.93</td><td>0.1671</td><td>0.7852</td><td>27.86</td><td>0.2231</td><td>0.6924</td><td>25.90</td></tr><tr><td>uORF(w/o prog. train.)</td><td>0.1044</td><td>0.8894</td><td>28.84</td><td>0.1573</td><td>0.8287</td><td>28.33</td><td>0.2123</td><td>0.6760</td><td>25.19</td></tr><tr><td>uORF (ours)</td><td>0.0859</td><td>0.8971</td><td>29.28</td><td>0.0821</td><td>0.8722</td><td>29.60</td><td>0.1729</td><td>0.7094</td><td>25.96</td></tr></table>
145
+
146
+ Table 3: Comparison on novel view synthesis from a single image.
147
+
148
+ Overall, the novel view synthesis results suggest that uORF can learn to represent 3D scenes with reasonable fidelity, even with the presence of complex foreground object shapes, such as chairs and different textured backgrounds.
149
+
150
+ # 4.3 SCENE DESIGN AND EDITING IN 3D
151
+
152
+ Being object-centric and 3D-aware, uORF is able to edit 3D scene radiance fields inferred from a single view, and generate novel scene images.
153
+
154
+ Setup. We test uORF’s ability to edit scenes and synthesize novel images on the Room-Chair dataset. We consider both moving foreground objects and changing background appearance. For object moving, we randomly pick one object in a test scene and move it to a random position. We render 4 images for each of the 500 test scenes. For background changing, we replace the current background texture to a different one and also render 4 images for evaluation. To indicate the new background, we re-pick and re-put foreground objects such that the resultant background indicator image is different from the groundtruth image.
155
+
156
+ For uORF and Slot Attention (Locatello et al., 2020), we use groundtruth masks of the input view only for ease of evaluation. We determine which slot to move by picking the one with largest mask IoU. For NeRF-AE (Mildenhall et al., 2020) to do editing, we back-project the masks to frustums to determine the 3D regions to be moved/replaced. We use LPIPS, SSIM, and PSNR as our metrics.
157
+
158
+ Results. We show results in Table 4 and Figure 6 (more in Appendix D). Again, uORF outperforms all compared methods on all metrics. As Figure 6 depicts, images synthesized by uORF show least artifacts and highest quality and fidelity.
159
+
160
+ Table 4: Comparison on scene editing.
161
+
162
+ <table><tr><td rowspan="2">Models</td><td colspan="3">Moving objects</td><td colspan="3">Changing background</td></tr><tr><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR个</td></tr><tr><td>NeRF-AE</td><td>0.2451</td><td>0.7284</td><td>23.18</td><td>0.2185</td><td>0.7132</td><td>25.42</td></tr><tr><td>Slot Attention</td><td>0.3941</td><td>0.7134</td><td>23.06</td><td>0.3689</td><td>0.7283</td><td>23.94</td></tr><tr><td>uORF(w/o background)</td><td>0.2206</td><td>0.7448</td><td>24.55</td><td>0.1879</td><td>0.7719</td><td>26.68</td></tr><tr><td>uORF(w/o prog.train.)</td><td>0.1583</td><td>0.8313</td><td>28.19</td><td>0.1586</td><td>0.8306</td><td>28.27</td></tr><tr><td>uORF (ours)</td><td>0.0855</td><td>0.8711</td><td>29.26</td><td>0.0822</td><td>0.8729</td><td>29.53</td></tr></table>
163
+
164
+ # 4.4 GENERALIZATION AND ANALYSIS
165
+
166
+ Finally we explore the generalization ability of uORF. We consider generalization on unseen, challenging spatial arrangement of objects, as well as generalization on unseen object appearances.
167
+
168
+ ![](images/069d7fc72a2cb4c001e4eae3b974f2c9acaac825ec3bf24b12d1c6a9ced3338f.jpg)
169
+ Figure 6: Qualitative results on single-image 3D scene manipulation. The first two rows are for moving object and the second two rows are for changing background.
170
+
171
+ <table><tr><td>Models</td><td>NV-ARI个</td><td>ARI个</td></tr><tr><td>Slot Attention</td><td>N/A</td><td>2.2±0.6</td></tr><tr><td>uORF (ours)</td><td>85.0±0.3</td><td>87.4±0.4</td></tr><tr><td>uORF (oracle)</td><td>85.5±0.3</td><td>87.5±0.3</td></tr></table>
172
+
173
+ <table><tr><td>Loss functions</td><td>ARI↑</td><td>LPIPS↓</td></tr><tr><td>Rec.</td><td>59.1±0.5</td><td>0.3610</td></tr><tr><td>Rec.+Percept.</td><td>65.2±0.8</td><td>0.2156</td></tr><tr><td>Rec.+ Adv.</td><td>60.4±2.2</td><td>0.2288</td></tr><tr><td>Rec.+ Percept. + Adv.</td><td>65.6±1.0</td><td>0.1729</td></tr></table>
174
+
175
+ Table 5: Generalization to novel Table 6: Generalization to unseen Table 7: Ablation study for losses on the challenging spatial arrangements. combinations of color and shape. Room-Diverse dataset.
176
+
177
+ <table><tr><td>Models</td><td>ARI个</td><td>LPIPS↓</td></tr><tr><td>Slot Attention</td><td>5.7±0.3</td><td>N/A</td></tr><tr><td>NeRF-AE</td><td>N/A</td><td>0.2201</td></tr><tr><td>uORF (ours)</td><td>83.2±0.6</td><td>0.1540</td></tr></table>
178
+
179
+ Generalizing to challenging spatial arrangements. We build a new test dataset, packed-CLEVR11, where each scene has 11 objects that are closely packed into a cluster. Therefore, each scene bears an unseen number of objects in an unseen challenging arrangement. We test models trained on CLEVR-567, report results in Table 5 and Appendix Figure 19. Despite uORF never sees such object arrangements, it still achieves a reasonable performance and outperforms baselines.
180
+
181
+ Generalizing to new combination of shape and color. For unseen object appearances, we consider generalization in a systematic way such that the model can deal with unseen combination of object color and shape. Thus, we build a new training set similar to CLEVR-567, but we remove red cylinders and blue spheres from the object candidate pool. Then we test trained models on another dataset with only red cylinders and blue spheres in the candidate pool. We show results in Table 6 and examples in Appendix Figure 20. We see that although uORF has never seen any of the test set objects, it achieves similar results to the one trained on a normal CLEVR-567 dataset (denoted as “uORF (oracle)”). This suggests uORF’s ability for systematic generalization to unseen combinations of object color and shape. We further validate generalization to unseen object shapes in Appendix D.
182
+
183
+ Evaluating loss functions. uORF uses perceptual and adversarial losses to combat intrinsic uncertainties in single-image inference of 3D representations. We show ablation results on novel view synthesis in Table 7 and Appendix Figure 18. Both losses significantly improve image quality.
184
+
185
+ # 5 CONCLUSION
186
+
187
+ In this work, we propose unsupervised discovery of Object Radiance Fields (uORF), which learns to infer object-centric 3D radiance fields from a single image of complex multi-object scenes. We demonstrate uORF’s ability on scene segmentation and scene generation in 3D. Our positive results suggest a promising direction to integrate neural rendering into deep probabilistic inference scheme, allowing learning factorized 3D object-centric scene representations from only RGB images.
188
+
189
+ # ACKNOWLEDGMENTS
190
+
191
+ This work was in part supported by Qualcomm Innovation Fellowship (QIF), Stanford Institute for Human-Centered AI (HAI), Stanford Center for Integrated Facility Engineering (CIFE), Toyota Research Institute, a Vannevar Bush faculty fellowship, Amazon, Autodesk, Google, and Bosch.
192
+
193
+ # REPRODUCIBILITY STATEMENT
194
+
195
+ To ensure reproducibility of our work, we have provided the training and test code repository†, together with all three synthetic datasets, and pre-trained models on all three datasets. We have also provided a detailed instruction on using our code as well as training on new datasets. In Appendix B, we describe details for re-implementing our work.
196
+
197
+ # ETHICS STATEMENT
198
+
199
+ Learning object-centric scene representations is a long-standing topic in vision and it finds various applications in downstream tasks. We represent a 3D scene as a composition of simple radiance fields, which only models object appearances and entangles their physical properties that may be crucial to downstream tasks in a non-interpretable way. However, we envision that careful designs in more structured 3D object representations for specific downstream applications could help improve transparency and human interpretability in model prediction and behavior, allowing both better performances and secure, fair usage. In our code release, we will explicitly specify allowable uses of our system with appropriate licenses. We will use techniques such as watermarking to identify and label visual contents generated by our system.
200
+
201
+ # REFERENCES
202
+
203
+ Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. arXiv:1409.0473, 2014. 4
204
+ Christopher P Burgess, Loic Matthey, Nicholas Watters, Rishabh Kabra, Irina Higgins, Matt Botvinick, and Alexander Lerchner. Monet: Unsupervised scene decomposition and representation. arXiv:1901.11390, 2019. 1, 3, 4
205
+ Eric R Chan, Marco Monteiro, Petr Kellnhofer, Jiajun Wu, and Gordon Wetzstein. Pi-gan: Periodic implicit generative adversarial networks for 3d-aware image synthesis. arXiv:2012.00926, 2020. 3
206
+ Angel X Chang, Thomas Funkhouser, Leonidas Guibas, Pat Hanrahan, Qixing Huang, Zimo Li, Silvio Savarese, Manolis Savva, Shuran Song, Hao Su, et al. Shapenet: an information-rich 3d model repository. arXiv:1512.03012, 2015. 6, 16
207
+ Chang Chen, Fei Deng, and Sungjin Ahn. Learning to infer 3d object models from images. arXiv:2006.06130, 2020. 3
208
+ Kyunghyun Cho, Bart Van Merrienboer, Caglar Gulcehre, Dzmitry Bahdanau, Fethi Bougares, Holger Schwenk, ¨ and Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical machine translation. arXiv:1406.1078, 2014. 5
209
+ Minsu Cho, Suha Kwak, Cordelia Schmid, and Jean Ponce. Unsupervised object discovery and localization in the wild: Part-based matching with bottom-up region proposals. In CVPR, 2015. 2
210
+ Eric Crawford and Joelle Pineau. Spatially invariant unsupervised object detection with convolutional neural networks. In AAAI, 2019. 3
211
+ Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas. Attention is not all you need: Pure attention loses rank doubly exponentially with depth. arXiv:2103.03404, 2021. 18
212
+ Cathrin Elich, Martin R Oswald, Marc Pollefeys, and Jorg St ¨ uckler. Semi-supervised learning of multi-object 3d ¨ scene representations. arXiv:2010.04030, 2020. 3
213
+ Martin Engelcke, Adam R Kosiorek, Oiwi Parker Jones, and Ingmar Posner. Genesis: Generative scene inference and sampling with object-centric latent representations. arXiv:1907.13052, 2019. 1, 3
214
+ SM Eslami, Nicolas Heess, Theophane Weber, Yuval Tassa, David Szepesvari, Koray Kavukcuoglu, and Geoffrey E Hinton. Attend, infer, repeat: Fast scene understanding with generative models. arXiv:1603.08575, 2016. 3
215
+ SM Ali Eslami, Danilo Jimenez Rezende, Frederic Besse, Fabio Viola, Ari S Morcos, Marta Garnelo, Avraham Ruderman, Andrei A Rusu, Ivo Danihelka, Karol Gregor, et al. Neural scene representation and rendering. Sci., 2018. 3
216
+ Stephan J. Garbin, Marek Kowalski, Matthew Johnson, Jamie Shotton, and Julien Valentin. Fastnerf: Highfidelity neural rendering at 200fps. arXiv:2103.10380, 2021. 5
217
+ Kristen Grauman and Trevor Darrell. Unsupervised learning of categories from sets of partially matching image features. In CVPR, 2006. 2
218
+ Klaus Greff, Antti Rasmus, Mathias Berglund, Tele Hotloo Hao, Jurgen Schmidhuber, and Harri Valpola. Tagger: ¨ Deep unsupervised perceptual grouping. arXiv:1606.06724, 2016. 3
219
+ Klaus Greff, Sjoerd Van Steenkiste, and Jurgen Schmidhuber. Neural expectation maximization. ¨ arXiv:1708.03498, 2017. 3
220
+ Klaus Greff, Raphael Lopez Kaufman, Rishabh Kabra, Nick Watters, Christopher Burgess, Daniel Zoran, Loic ¨ Matthey, Matthew Botvinick, and Alexander Lerchner. Multi-object representation learning with iterative variational inference. In ICML, 2019. 2, 3
221
+ Wonbong Jang and Lourdes Agapito. Codenerf: Disentangled neural radiance fields for object categories. arXiv:2109.01750, 2021. 3
222
+ Jindong Jiang, Sepehr Janghorbani, Gerard de Melo, and Sungjin Ahn. Scalable object-oriented sequential generative models. arXiv:1910.02384, 2019. 3
223
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and superresolution. In ECCV, 2016. 5
224
+ Justin Johnson, Bharath Hariharan, Laurens Van Der Maaten, Li Fei-Fei, C Lawrence Zitnick, and Ross Girshick. Clevr: a diagnostic dataset for compositional language and elementary visual reasoning. In CVPR, 2017. 2, 6, 15
225
+ Armand Joulin, Francis Bach, and Jean Ponce. Discriminative clustering for image co-segmentation. In CVPR, 2010. 2
226
+ Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and improving the image quality of stylegan. In CVPR, 2020. 14
227
+ Hiroharu Kato, Deniz Beker, Mihai Morariu, Takahiro Ando, Toru Matsuoka, Wadim Kehl, and Adrien Gaidon. Differentiable rendering: A survey. arXiv:2006.12057, 2020. 3
228
+ Adam R Kosiorek, Hyunjik Kim, Ingmar Posner, and Yee Whye Teh. Sequential attend, infer, repeat: Generative modelling of moving objects. arXiv:1806.01794, 2018. 3
229
+ Adam R Kosiorek, Heiko Strathmann, Daniel Zoran, Pol Moreno, Rosalia Schneider, Sona Mokr ˇ a, and Danilo J ´ Rezende. Nerf-vae: A geometry aware 3d scene generative model. arXiv:2104.00587, 2021. 3
230
+ Abhijit Kundu, Yin Li, and James M Rehg. 3d-rcnn: Instance-level 3d object reconstruction via render-andcompare. In CVPR, 2018. 3
231
+ Bo Li, Zhengxing Sun, Qian Li, Yunjie Wu, and Anqi Hu. Group-wise deep object co-segmentation with co-attention recurrent neural network. In CVPR, 2019. 2
232
+ Zhixuan Lin, Yi-Fu Wu, Skand Vishwanath Peri, Weihao Sun, Gautam Singh, Fei Deng, Jindong Jiang, and Sungjin Ahn. Space: Unsupervised object-oriented scene representation via spatial attention and decomposition. arXiv:2001.02407, 2020. 3
233
+ Lingjie Liu, Jiatao Gu, Kyaw Zaw Lin, Tat-Seng Chua, and Christian Theobalt. Neural sparse voxel fields. In NeurIPS, 2020. 5
234
+ Francesco Locatello, Dirk Weissenborn, Thomas Unterthiner, Aravindh Mahendran, Georg Heigold, Jakob Uszkoreit, Alexey Dosovitskiy, and Thomas Kipf. Object-centric learning with slot attention. arXiv:2006.15055, 2020. 1, 3, 4, 6, 7, 8, 15, 16
235
+ Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-based neural machine translation. arXiv:1508.04025, 2015. 4
236
+ Nelson Max. Optical models for direct volume rendering. IEEE TVCG, 1995. 5
237
+ Lars Mescheder, Andreas Geiger, and Sebastian Nowozin. Which training methods for gans do actually converge? In ICML, 2018. 5
238
+ Ben Mildenhall, Pratul P Srinivasan, Matthew Tancik, Jonathan T Barron, Ravi Ramamoorthi, and Ren Ng. Nerf: Representing scenes as neural radiance fields for view synthesis. arXiv:2003.08934, 2020. 1, 3, 7, 8, 17
239
+
240
+ Tom Monnier, Elliot Vincent, Jean Ponce, and Mathieu Aubry. Unsupervised layered image decomposition into object prototypes. arXiv:2104.14575, 2021. 3
241
+ Thomas Neff, Pascal Stadlbauer, Mathias Parger, Andreas Kurz, Chakravarty R. Alla Chaitanya, Anton Kaplanyan, and Markus Steinberger. Donerf: Towards real-time rendering of neural radiance fields using depth oracle networks. arXiv:2103.03231, 2021. 5
242
+ Michael Niemeyer and Andreas Geiger. Giraffe: Representing scenes as compositional generative neural feature fields. arXiv:2011.12100, 2020. 3, 13, 18
243
+ Michael Niemeyer and Andreas Geiger. Campari: Camera-aware decomposed generative neural radiance fields. arXiv:2103.17269, 2021. 3
244
+ Michael Niemeyer, Lars Mescheder, Michael Oechsle, and Andreas Geiger. Differentiable volumetric rendering: Learning implicit 3d representations without 3d supervision. In CVPR, 2020. 3
245
+ Julian Ost, Fahim Mannan, Nils Thuerey, Julian Knodt, and Felix Heide. Neural scene graphs for dynamic scenes. In CVPR, 2021. 1, 3
246
+ Daniel Rebain, Wei Jiang, Soroosh Yazdani, Ke Li, Kwang Moo Yi, and Andrea Tagliasacchi. DeRF: Decomposed radiance fields. arXiv:2011.12490, 2020. 5
247
+ Christian Reiser, Songyou Peng, Yiyi Liao, and Andreas Geiger. Kilonerf: Speeding up neural radiance fields with thousands of tiny mlps. arXiv:2103.13744, 2021. 5
248
+ Michael Rubinstein, Armand Joulin, Johannes Kopf, and Ce Liu. Unsupervised joint object discovery and segmentation in internet images. In CVPR, 2013. 1, 2
249
+ Jose C Rubio, Joan Serrat, Antonio Lopez, and Nikos Paragios. Unsupervised co-segmentation through region ´ matching. In CVPR, 2012. 2
250
+ Bryan C Russell, William T Freeman, Alexei A Efros, Josef Sivic, and Andrew Zisserman. Using multiple segmentations to discover objects and their extent in image collections. In CVPR, 2006. 2
251
+ Katja Schwarz, Yiyi Liao, Michael Niemeyer, and Andreas Geiger. Graf: Generative radiance fields for 3d-aware image synthesis. arXiv:2007.02442, 2020. 3
252
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv:1409.1556, 2014. 14
253
+ Vincent Sitzmann, Michael Zollhofer, and Gordon Wetzstein. Scene representation networks: Continuous ¨ 3d-structure-aware neural scene representations. In NeurIPS, 2019. 3
254
+ Josef Sivic, Bryan C Russell, Alexei A Efros, Andrew Zisserman, and William T Freeman. Discovering objects and their location in images. In ICCV, 2005. 2
255
+ Josef Sivic, Bryan C Russell, Andrew Zisserman, William T Freeman, and Alexei A Efros. Unsupervised discovery of visual object class hierarchies. In CVPR, 2008. 2
256
+ Karl Stelzner, Kristian Kersting, and Adam R Kosiorek. Decomposing 3d scenes into objects via unsupervised volume segmentation. arXiv:2104.01148, 2021. 3
257
+ Maxim Tatarchenko, Stephan R Richter, Rene Ranftl, Zhuwen Li, Vladlen Koltun, and Thomas Brox. What do ´ single-view 3d reconstruction networks learn? In CVPR, 2019. 13
258
+ Ayush Tewari, Ohad Fried, Justus Thies, Vincent Sitzmann, Stephen Lombardi, Kalyan Sunkavalli, Ricardo Martin-Brualla, Tomas Simon, Jason Saragih, Matthias Nießner, et al. State of the art on neural rendering. CGF, 2020. 1, 3
259
+ 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. 4
260
+ Sara Vicente, Carsten Rother, and Vladimir Kolmogorov. Object cosegmentation. In CVPR, 2011. 2
261
+ Huy V Vo, Patrick Perez, and Jean Ponce. Toward unsupervised, multi-object discovery in large-scale image ´ collections. In ECCV, 2020. 2
262
+ Zhou Wang, Alan C Bovik, Hamid R Sheikh, and Eero P Simoncelli. Image quality assessment: From error visibility to structural similarity. IEEE TIP, 2004. 7
263
+ Jiajun Wu, Joshua B Tenenbaum, and Pushmeet Kohli. Neural scene de-rendering. In CVPR, 2017. 3
264
+ Weihao Xia, Yulun Zhang, Yujiu Yang, Jing-Hao Xue, Bolei Zhou, and Ming-Hsuan Yang. Gan inversion: A survey. arXiv:2101.05278, 2021. 19
265
+ Shunyu Yao, Tzu Ming Harry Hsu, Jun-Yan Zhu, Jiajun Wu, Antonio Torralba, William T Freeman, and Joshua B Tenenbaum. 3d-aware scene manipulation via inverse graphics. arXiv:1808.09351, 2018. 1, 3
266
+ Alex Yu, Vickie Ye, Matthew Tancik, and Angjoo Kanazawa. Pixelnerf: Neural radiance fields from one or few images. arXiv:2012.02190, 2020. 3, 13
267
+ Alex Yu, Ruilong Li, Matthew Tancik, Hao Li, Ren Ng, and Angjoo Kanazawa. Plenoctrees for real-time rendering of neural radiance fields. arXiv:2103.14024, 2021. 5
268
+ Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In CVPR, 2018. 7
269
+ Yi Zhou, Connelly Barnes, Jingwan Lu, Jimei Yang, and Hao Li. On the continuity of rotation representations in neural networks. In CVPR, 2019. 19
270
+ Jun-Yan Zhu, Jiajun Wu, Yichen Wei, Eric Chang, and Zhuowen Tu. Unsupervised object class discovery via saliency-guided multiple class learning. In CVPR, 2012. 1
271
+
272
+ # A SUPPLEMENTARY MATERIAL OVERVIEW
273
+
274
+ In the following supplementary document, we first provide implementation details on unsupervised discovery of Object Radiance Fields in Section B. We then describe details on datasets and baseline architectures in Section C. We show additional results in in Section D, including results on generalization to unseen object shapes, a demonstration on real photos, an analysis on the sensitivity to slot initialization, and additional qualitative results on all experiments of the main paper and failure cases. In Section E, we show comparison to GIRAFFE (Niemeyer & Geiger, 2020) to demonstrate that it focus on a fundamentally different problem (unconditional generation) than our work (conditional inference). All mathematical and algorithmic notations are the same as those in the main manuscript.
275
+
276
+ In the supplementary video, we provide an overview of our paper.
277
+
278
+ # B IMPLEMENTATION
279
+
280
+ Here, we provide implementation details of our uORF model.
281
+
282
+ B.1 OBJECT-CENTRIC LATENT INFERENCE
283
+
284
+ We show a pseudo code of inferring object-centric latents with the background-aware slot attention in Algorithm 1.
285
+
286
+ Convolutional feature extraction. The convolutional net extracts features from the input image for updating the latent slots. Our convolutional encoder is a simple U-net. We show our encoder architecture in Table 8 and Table 9. Since we want the model to generalize to decompose unseen images, it is natural to represent foreground objects position and pose in the viewer coordinate system. As identified in previous studies (Tatarchenko et al., 2019), this facilitates the learning of 3D object position and helps generalization. In order for the object-centric representations to include such information in the viewer coordinate system, we can inform the encoder of position information by feeding pixel coordinates and viewer-space ray directions as additional input channels. In our experiments we assume fixed camera focal length. In this case, the ray direction does not provide additional information to the pixel coordinates, and thus we only feed pixel coordinates as input channels in addition to the input RGB image. Each of the $X Y$ pixel coordinates is normalized to $[ - 1 , 1 ]$ in both directions, leading to 4 additional channels to RGB.
287
+
288
+ B.2 COORDINATE SPACE AND LOCALITY CONSTRAINT FOR BETTER FORE-/BACK-GROUND DISENTANGLEMENT
289
+
290
+ Coordinate space. We represent foreground objects in the viewer space. Regarding background environment, we represent it in the world coordinate space for two reasons. Firstly, since it is difficult to estimate full geometry from a single view (e.g., the geometry behind the camera), our model assumes a similar background geometry across scenes and aggregates information about background geometry from multiple sparse views. Representing background in a fixed world space facilitates this aggregation process and empirically leads to better performance. We show a quantitative comparison in Table 10, Table 11 and a visual comparison in Figure 7. Modeling the background in world space provides more details than modeling it in viewer space. Incorporating multi-view images as inference input might relax this assumption (Yu et al., 2020), but we leave it as future exploration.
291
+
292
+ Table 8: Encoder architecture for the CLEVR-567 dataset and the Room-Chair dataset. All convolutional kernel sizes are $3 \times 3$ . All activation functions for convolutional layers are ReLU.
293
+
294
+ <table><tr><td>Layer name</td><td>Input shape</td><td>Output shape</td><td>Stride</td><td>Note</td></tr><tr><td>Conv1</td><td>64×64×7</td><td>64×64×64</td><td>2</td><td>Skip to Conv6</td></tr><tr><td>Conv2</td><td>64×64×64</td><td>32×32×64</td><td>2</td><td>Skip to Conv5</td></tr><tr><td>Conv3</td><td>32×32×64</td><td>16×16×64</td><td>2</td><td></td></tr><tr><td>Conv4</td><td>16×16×64</td><td>16×16×64</td><td>1</td><td></td></tr><tr><td>Upsample</td><td>16×16×64</td><td>32×32×64</td><td></td><td>Bilinear upsampling</td></tr><tr><td>Conv5</td><td>32×32×128</td><td>32×32×64</td><td>1</td><td></td></tr><tr><td>Upsample</td><td>32×32×64</td><td>64×64×64</td><td></td><td>Bilinear upsampling</td></tr><tr><td>Conv6</td><td>64×64×128</td><td>64×64×64</td><td>1</td><td></td></tr></table>
295
+
296
+ Table 9: Encoder architecture for the Room-Diverse dataset. All convolutional kernel sizes are $3 \times 3$ . All activation functions for convolutional layers are ReLU.
297
+
298
+ <table><tr><td>Layer name</td><td>Input shape</td><td>Output shape</td><td>Stride</td><td>Note</td></tr><tr><td>ConvO</td><td>128×128×7</td><td>128×128×64</td><td>1</td><td></td></tr><tr><td>Conv1</td><td>128×128×64</td><td>64×64×64</td><td>2</td><td>Skip to Conv6</td></tr><tr><td>Conv2</td><td>64×64×64</td><td>32×32×64</td><td>2</td><td>Skip to Conv5</td></tr><tr><td>Conv3</td><td>32×32×64</td><td>16×16×64</td><td>2</td><td></td></tr><tr><td>Conv4</td><td>16×16×64</td><td>16×16×64</td><td>1</td><td></td></tr><tr><td>Upsample</td><td>16×16×64</td><td>32×32×64</td><td></td><td>Bilinear upsampling</td></tr><tr><td>Conv5</td><td>32×32×128</td><td>32×32×64</td><td>1</td><td></td></tr><tr><td>Upsample</td><td>32×32×64</td><td>64×64×64</td><td></td><td>Bilinear upsampling</td></tr><tr><td>Conv6</td><td>64×64×128</td><td>64×64×64</td><td>1</td><td></td></tr></table>
299
+
300
+ Secondly, this design also encourages the disentanglement between foreground objects and background by preventing the background slot from decoding foreground objects, because the positional information provided in the encoder is represented in viewer space.
301
+
302
+ Foreground locality. To further encourage the disentanglement, we add a locality constraint during early training to prevent foreground slots to represent the background environment. Specifically, considering that “foreground” objects should be largely visible in sight, we set a foreground box and enforce that every foreground-querying point outside the box has zero density. The foreground box is defined such that its projection in image space can engage roughly $9 0 \%$ pixels. The locality constraint is imposed for the first 100K iterations, and it empirically helps prevent the foreground slots from fitting the background. We show a visual comparison in Figure 8, which from we can observe that the model without foreground locality design attaches some background segments to each object.
303
+
304
+ # B.3 NEURAL RADIANCE FIELD ARCHITECTURE.
305
+
306
+ We show our conditional object radiance field architecture in Figure 9.
307
+
308
+ # B.4 MODEL LEARNING
309
+
310
+ Loss functions. We set $\lambda _ { \mathrm { p e r c e p t } } = 0 . 0 0 6$ , $\lambda _ { \mathrm { a d v } } = 0 . 0 1$ , $\lambda _ { R } = 1 0$ . For perceptual loss, we implement the feature extractor $p$ by using the output of the 4-th convolutional block in a VGG16 (Simonyan & Zisserman, 2014) pretrained on ImageNet. For the adversarial discriminator, we follow the architecture of StyleGAN2 (Karras et al., 2020) with slight modification such that the maximum channel number is 128. We also use the lazy R1 regularization (Karras et al., 2020). We use Adam optimizer for discriminator with learning rate 0.001, $\beta _ { 1 } = 0$ and $\beta _ { 2 } = 0 . 9$ . The adversarial loss is incorporated after 100K iterations. Since shape uncertainty only appears in the Room-Diverse
311
+
312
+ # Algorithm 1: Object-centric latent inference with background-aware slot attention.
313
+
314
+ Input: feat ∈ RN×D
315
+ Learnable: $\mu ^ { b } , \sigma ^ { b } , \mu ^ { f } , \sigma ^ { f }$ : prior parameters, $k , q ^ { b } , q ^ { f } , v ^ { b } , v ^ { f }$ : linear mappings, GRUb, GRUf , MLPb, MLPf slotb ∼ N b ∈ R1×D // Sampling slots from priors. slotsf ∼ N f ∈ RK×D for t = 1, · · · , T slot prevb = slotb, slots prevf = slotsf attn = Softmax √D 1 k(feat) · qb(slotb)f f T , dim=‘slot’! // Binding slots to object features. attn $^ b =$ attn[0], attnf = attn[1:end] updates $^ { b } =$ WeightedMean(weights=attnb, values $= \boldsymbol { v } ^ { b }$ (inputs)) // Aggregating update signals. updates $f _ { = }$ WeightedMean(weights=attnf , values $\scriptstyle \operatorname { \mathsf { \Omega } } _ { 3 } = v ^ { f }$ (inputs)) slot ${ \ v O } ^ { b } = \mathtt { G R U } ^ { b }$ (state=slot prevb, inputs=updatesb) // Updating slots. slotsf = GRUf (state slots prevf , inputs=updatesf ) $\mathsf { s } \mathsf { l o t } ^ { b } + = \mathsf { M L P } ^ { b } ( \mathsf { s } \mathsf { l o t } ^ { b } )$ , slotsf + = MLPf (slotsf ) // Residual update. return slotb, slotsf
316
+
317
+ Table 10: Ablation for background coordinate space on novel view synthesis on Room-Chair dataset.
318
+
319
+ <table><tr><td>Models</td><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td></tr><tr><td>uORF w/ view-space Backg.</td><td>0.151</td><td>0.799</td><td>27.86</td></tr><tr><td>uORF (ours)</td><td>0.082</td><td>0.872</td><td>29.60</td></tr></table>
320
+
321
+ Table 11: Ablation for background coordinate space on segmentation on Room-Chair dataset.
322
+
323
+ <table><tr><td rowspan="2">Models</td><td>3D metric</td><td colspan="2">2D metric</td></tr><tr><td>NV-ARI↑</td><td>ARI个</td><td>Fg-ARI个</td></tr><tr><td>uORF w/ view-space Backg.</td><td>73.5</td><td>78.0</td><td>89.0</td></tr><tr><td>uORF (ours)</td><td>74.3</td><td>78.8</td><td>88.8</td></tr></table>
324
+
325
+ dataset, we only impose the adversarial loss on the Room-Diverse dataset but not on CLEVR-567 or Room-Chair. Both perceptual loss and adversarial loss are added after the first 100K iterations.
326
+
327
+ Coarse-to-fine progressive training. For coarse training, we bilinearly downsample supervision images to $6 4 \times 6 4$ . The coarse training lasts for 600K iterations. For fine training, we randomly crop $6 4 \times 6 4$ patches from $1 2 8 \times 1 2 8$ images. The fine training lasts for 600K iterations. Our model is trained on a single Nvidia RTX 3090 GPU for about 6 days. For all networks except discriminator, we use Adam optimizer with learning rate 0.0003, $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } ~ = ~ 0 . 9 9 9$ . Learning rate is exponentially decreased by half for every 200K iterations until after 600K iterations. We also adopt the learning rate warm-up from the slot attention paper (Locatello et al., 2020) for the first 1K iterations. We initialize decoder networks with Xavier’s initialization. In each batch, we input one image and neurally render 4 images for supervision. We render each pixel with 64 samples.
328
+
329
+ # C EXPERIMENTS
330
+
331
+ In this section we provide further details on experiment settings.
332
+
333
+ # C.1 DATA
334
+
335
+ For the construction of all three datasets, the training/testing sets share the same pool of textures, shapes, and colors. The scenes in both sets differ in the spatial arrangement of objects, as well as the appearance differences induced by soft shadows and inter-reflections due to global illumination effects.
336
+
337
+ CLEVR-567. In the CLEVR-567 dataset, each object’s shape is randomly chosen from three geometric primitives (i.e., cylinder, cube and sphere). The color is randomly chosen from {red, blue, purple, gray, cyan, yellow, green, brown}. There are two possible sizes for each object. When rendering images, we use the same camera intrinsic as original CLEVR dataset (Johnson et al., 2017). We do not use the visibility check due to our 360 degree multi-view setting, so we increase elevation angle by $\pi / 1 5$ to increase the chance of object visibility. Rendering setting is the same for all datasets.
338
+
339
+ For CLEVR-567 dataset we set the latent dimension $D = 4 0$ and the maximum number of objects $K = 8$ .
340
+
341
+ ![](images/86827f15238e9fd22616cf13abe4aa97a44a41899cbda2d6a55ff8ca68513a13.jpg)
342
+ Figure 7: Visual comparison for representing background on view-space on novel view synthesis.
343
+
344
+ ![](images/d4b9384222b30c14917df03f0898acd42366ba5482f07c370cfbd81fe1b4c4a6.jpg)
345
+ Figure 8: Visual comparison on ablation for foreground locality constraint. We show examples in CLEVR-567 testset. We can see that our foreground locality box helps prevent object slots from fitting background segments.
346
+
347
+ Room-Chair. For the object shape we use a chair model‡ from ShapeNet (Chang et al., 2015). We use the same material and colors as CLEVR-567. For Room-Chair and Room-Diverse datasets, we set the latent dimension $D = 6 4$ and the maximum number of objects $K = 5$ .
348
+
349
+ Room-Diverse. All object shapes are randomly chosen from 1,200 ShapeNet chairs. For each shape, we normalize it into a unit cube according to vertex coordinates. We also use 8 colors $\{ { \tt r e d }$ , blue, purple, gray, cyan, yellow, green, $\mathtt { b l a c k } \}$ with diffuse material. Since shape uncertainty only appears in this dataset, we only impose the adversarial loss on this dataset.
350
+
351
+ # C.2 BASELINE ARCHITECTURES
352
+
353
+ Slot attention. We use the encoder-decoder architecture in the slot attention paper (Locatello et al., 2020) used for object discovery experiments on the CLEVR dataset. Basically it has 6 convolutional layers for encoder and 6 convolution-transpose layers for decoder. The number of channels for each layer is 64. All models are trained on $1 2 8 \times 1 2 8$ images.
354
+
355
+ NeRF-AE. We follow NeRF implementation without view direction as input and set the highest frequency to 5. The encoder is similar to ours in Figure 9, but the basic number of channels is increased from 64 to 256 (and thus the number of channels of inputs to Conv5 and Conv6 is 512). The number of slot is set to 1.
356
+
357
+ # D ADDITIONAL RESULTS
358
+
359
+ Generalization to unseen objects. In the main paper we demonstrate systematic generalization to unseen combination of shape and color, here we further validate our model’s generalization to unseen object shapes. To this end, we construct another test set for Room-Diverse. All test objects in the new test set are drawn from a pool of 500 shapenet chairs that are completely disjoint from the 1200 training chairs. All other settings are the same as the original test set. We show quantitative results in Table 12 for novel view synthesis and in Table 13 for segmentation. As we can see, our model yields the same level of performances even on the unseen shape test set, suggesting its generalization to unseen object shapes.
360
+
361
+ ![](images/ce1a42408946a0969581380d8e3057950c3abdf0f8bbe5b0bf72ac5204eb2412.jpg)
362
+ Figure 9: Illustration for foreground decoder architecture. We follow the architecture in NeRF (Mildenhall et al., 2020) but with fewer parameters to decrease space demand. We set the highest positional embedding frequency to 5, so that the positional embedding input dimension is $5 \times 2 \times 3 + \mathbf { \breve { 3 } } = 3 3$ . The background decoder is slightly different in that it does not have the second last layer and third last layer. Density $\sigma$ is activated by ReLU. Since estimating specularity from a single image is intrinsically ambiguous, we assume Lambertian surfaces and do not use the ray direction as input.
363
+
364
+ Table 12: Novel view synthesis results on unseen/seen shape testset of Room-Diverse.
365
+
366
+ <table><tr><td>Models</td><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td></tr><tr><td>uORF on seen shape testset</td><td>0.1729</td><td>0.7094</td><td>25.96</td></tr><tr><td>uORF on unseen shape testset</td><td>0.1771</td><td>0.7125</td><td>26.16</td></tr></table>
367
+
368
+ Table 13: Unsupervised segmentation in 3D results on unseen/seen shape testset of Room-Diverse.
369
+
370
+ <table><tr><td rowspan="2">Models</td><td>3D metric</td><td colspan="2">2D metric</td></tr><tr><td>NV-ARI↑</td><td>ARI个</td><td>Fg-ARI↑</td></tr><tr><td>uORF on seen shape testset</td><td>56.9</td><td>65.6</td><td>67.9</td></tr><tr><td>uORF on unseen shape testset</td><td>57.0</td><td>66.1</td><td>67.7</td></tr></table>
371
+
372
+ Generalization to real images. We also take a step further to test our pretrained model’s generalization on real photos. To do this, we use uORF trained on Room-Diverse. We take a few real photos by a cellphone, providing an input image and a few reference images. We show the visual results in Figure 10. Although the real photo has a different imaging process and consists of unseen objects and background, uORF is able to discover all objects with roughly correct positions and orientations, yielding plausible segmentation results and object-moving results.
373
+
374
+ Analysis on the sensitivity to slot initialization. We test the robustness of our model to the slot initialization on the Room-Chair dataset. For each test scene, we now use 5 different random seeds for sampling initial centers. We compute the mean $\mu$ and std $\sigma$ of ARI over the 5 seeds. We average them over the 500 test scenes. The averaged mean $\bar { \mu }$ of ARI is $7 8 . 8 \%$ and $\bar { \sigma }$ is $1 . 7 \%$ . The mean ARI suggests good segmentation results (very close to $7 8 . 8 \%$ as reported in Table 2 in our main paper), and $\bar { \sigma } = 1 . 7 \%$ indicates that different seeds all lead to results close to such good ARI performance.
375
+
376
+ Additional qualitative results. We show additional qualitative results for our experiments in the main manuscript. We show additional examples for scene segmentation in Figure 11 and Figure 12, for novel view synthesis in Figure 13, Figure 14 and Figure 15, for scene editing in Figure 16 and Figure 17, for evaluating losses in Figure 18, for generalization to challenging spatial arrangement in Figure 19 (note that in the packed-CLEVR-11 dataset we only use a single size for higher object visibility), and for generalization to unseen object appearance in Figure 20.
377
+
378
+ Failure case. In our experiments, we observed a type of failure which we call “attention rankcollapse”. We show examples in Figure 21.
379
+
380
+ ![](images/10704020334297855d27e977f22568e81b87c24a9887ad3cc58086fc89b6e228.jpg)
381
+ Figure 10: Demonstration on generalization to real photos. We use uORF pretrained on Room-Diverse and take photos by a cellphone.
382
+
383
+ “Attention rank-collapse” refers to that all the foreground object slots have (nearly) the same attention map and collapse to the same representation. Each collapsed slot decodes simply nothing (or all the foreground objects). This “attention rank-collapse” happens when the initialization is prompt to a degenerate solution for the slot attention. It occasionally happens and empirically changing the initialization seed can address it. A related rank-collapse problem is discussed in Dong et al. (2021), which suggests that adding some architectural inductive bias can largely alleviate the problem. We hope future research can address this problem fundamentally.
384
+
385
+ # E COMPARISON TO GIRAFFE
386
+
387
+ Our work has a fundamentally different focus compared to GIRAFFE (Niemeyer & Geiger, 2020). While GIRAFFE focuses on unconditional generation and enables multi-object scene synthesis and rendering, the goal of our uORF is to simultaneously infer 3D multi-object scene representations from a single image, in addition to using those representations for rendering and editing as in GIRAFFE.
388
+
389
+ # E.1 COMPARISONS BETWEEN OUR UORF AND GIRAFFE
390
+
391
+ To demonstrate that the inference of such multi-object scenes is highly non-trivial, we compare with GIRAFFE on both CLEVR-567 and Room-Chair (we cannot compare on their datasets because they only have a single image for each scene). To train GIRAFFE on our datasets, we use the official repo§ and the same hyper-parameters that GIRAFFE authors used for their CLEVR-2345 dataset, except for a few adaptive changes to our datasets: (1) We try different sizes for the object slot, because CLEVR-2345 only uses small objects while our datasets both contain larger objects. Specifically, we try $2 \times$ , $1 . 5 \times$ , and $1 \times$ original size, and use the one with the lowest FID for each dataset. (2) We adjust the camera elevation angle and focal lengths to match our datasets. (3) We set the number of objects to 4 for the Room-Chair dataset because each scene has no more than 4 chairs. We train the GIRAFFE models for around 500K iterations on 128-by-128 images, such that FID does not drop anymore.
392
+
393
+ For GIRAFFE to do inference, we sample object (including background) latents and positions in the same manner as training, and then we optimize for L2 reconstruction loss for both the latents and the positions. We use Adam and do a learning rate sweep to select the one that leads to the best reconstruction loss. We divide the learning rate by 10 when the loss plateaus. We do this learning rate decay twice. We sweep in $\{ 0 . 1 , 0 . 0 1 , 0 . 0 0 1 , 0 . 0 0 0 1 \}$ and find that 0.01 works best. Since each scene has an unknown number of objects, we set the number to the maximum number across all scenes. It converges at around 150 iterations on CLEVR-567 and around 300 iterations on Room-Chair. Thus we set the maximum iteration to 300 and 500 for them, respectively.
394
+
395
+ We also compare with a GIRAFFE model that is pretrained on CLEVR-2345. The pretrained model is provided by the authors. The pretrained model yields $\mathrm { F I D = 8 2 }$ on CLEVR-567 $\mathrm { { F I D } = 6 1 }$ on CLEVR-2345), indicating that it could be a valid baseline even though the two datasets are mildly different.
396
+
397
+ We show input-view reconstruction and novel view synthesis results in Table 14 and Table 15, and we show qualitative comparison in Figure 22 and Figure 23. We can see that GIRAFFE fails in reconstructing the multi-object scenes from a single image, as well as novel view synthesis. Let alone segmentation in 3D.
398
+
399
+ Table 14: Inference comparison with GIRAFFE on CLEVR-567.
400
+
401
+ <table><tr><td rowspan="2">Models</td><td colspan="3">Input view reconstruction</td><td colspan="3">Novel view synthesis</td></tr><tr><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td></tr><tr><td>GIRAFFE (trained on CLEVR-567)</td><td>0.330</td><td>0.815</td><td>23.75</td><td>0.549</td><td>0.672</td><td>16.65</td></tr><tr><td>GIRAFFE (author-pretrained model on CLEVR-2345)</td><td>0.382</td><td>0.780</td><td>21.76</td><td>0.643</td><td>0.348</td><td>11.70</td></tr><tr><td>uORF (ours)</td><td>0.085</td><td>0.901</td><td>29.33</td><td>0.086</td><td>0.897</td><td>29.28</td></tr></table>
402
+
403
+ Table 15: Inference comparison with GIRAFFE on Room-Chair.
404
+
405
+ <table><tr><td rowspan="3">Models</td><td colspan="3">Input view reconstruction</td><td colspan="3">Novel view synthesis</td></tr><tr><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td><td>LPIPS↓</td><td>SSIM↑</td><td>PSNR↑</td></tr><tr><td rowspan="2">GIRAFFE (trained on Room-Chair) uORF (ours)</td><td>0.414</td><td>0.597</td><td>20.90</td><td>0.588</td><td>0.538</td><td>18.53</td></tr><tr><td>0.085</td><td>0.876</td><td>29.65</td><td>0.082</td><td>0.872</td><td>29.60</td></tr></table>
406
+
407
+ # E.2 GIRAFFE INFERENCE ON CLEVR-2345
408
+
409
+ While we have compared with GIRAFFE on our datasets, we further evaluate the author-provided pretrained model on the simpler dataset CLEVR-2345 from the GIRAFFE paper itself. We found that while GIRAFFE does well on unconditional scene synthesis, it cannot perform novel view synthesis on their own dataset, either. This shows that GIRAFFE focuses on problems very different from ours.
410
+
411
+ We first show that inference/reconstruction is challenging for GIRAFFE, even on the simpler dataset. We do inference on the author-provided CLEVR-2345 dataset using the author-provided pretrained model. We show randomly sampled examples through the iterative inference process in Figure 24.
412
+
413
+ Then we show that GIRAFFE fails in wide-baseline novel view synthesis. We use the author-provided pretrained model to sample from its latent space and unconditionally generate one image. Then we keep all the variables the same, but circularly move cameras to render novel views. We show 10 random examples of this circular novel view synthesis in Figure 25. We see that when the viewpoint changes become significant, GIRAFFE fails novel view synthesis, because its neural renderer is based on 2D feature maps and it’s not inherently 3D.
414
+
415
+ # E.3 DISCUSSION AND SUMMARY
416
+
417
+ In general, inverting GAN latent space even for the holistic image is non-trivial and needs architecturalspecific designs (we refer the reader to the discussion and references in a recent survey on GAN inversion (Xia et al., 2021)). As for inverting compositional multi-object scenes, it becomes even harder due to ambiguous correspondences (“which slot corresponds to which object?”), number of objects (“how many slots should I put?”), object position constraints (“there are two objects overlapping in the image, but they should not be overlapping in 3D”), optimization issues (e.g., optimizing rotation is notoriously difficult (Zhou et al., 2019)), etc.
418
+
419
+ In summary, it is highly non-trivial for GIRAFFE to do inference for multi-object scenes due to complexities such as ambiguous correspondences, the number of objects, and optimization issues. We will include more discussions on the difference between the two methods in the following separate thread. In short, our uORF tries to solve a fundamentally different problem from GIRAFFE, i.e., we aim at inferring the joint distribution of objects from a single image while GIRAFFE targets extrinsiccontrollable image generation. Therefore, our method enables novel tasks such as unsupervised segmentation and editing in 3D, where prior methods including GIRAFFE are not able to do.
420
+
421
+ ![](images/19bf08acd7353a7c9385d698a984b8b5c0759f03d3b1774d2225a741527fd8c1.jpg)
422
+ Figure 11: Additional qualitative results for segmentation in 3D on Room-Chair dataset.
423
+
424
+ ![](images/bd2a4d2ae18efdcb9369f41480871a7b72686149f57cfe0d080cceb138a3634d.jpg)
425
+ Figure 12: Additional qualitative results for segmentation in 3D on Room-Diverse dataset.
426
+
427
+ ![](images/7f11f0075116b24fa763ba70d24eb0da2a808b01a2aae55d6cedd47fd586ebc5.jpg)
428
+ Figure 13: Additional qualitative results for novel view synthesis on CLEVR-567 dataset.
429
+
430
+ ![](images/6732c3707108a7215523aa0aab2d594d084b80d65f3caf91d949fd239674a93f.jpg)
431
+ Figure 14: Additional qualitative results for novel view synthesis on Room-Chair dataset.
432
+
433
+ ![](images/0bd7e49728394bdea1ceedd8afe5868ee007f1eabcad44e04453c24b860ce8c8.jpg)
434
+ Figure 15: Additional qualitative results for novel view synthesis on Room-Diverse dataset.
435
+
436
+ ![](images/f72aaf5006162684a910793f433975c574de0f5bce37b5bd1b11a3d274d2f6b1.jpg)
437
+ Figure 16: Additional qualitative results for scene editing.
438
+
439
+ ![](images/4c8330edf5fb11a16f63770f6848eebfb9cb033975419fc998c5c2edf839e70c.jpg)
440
+ Figure 17: Additional qualitative results for scene editing.
441
+
442
+ ![](images/8dd48691313a75ab7bef33e0d771bf027b1f5e311f6c683f28eeceb5fd80e85f.jpg)
443
+ Figure 18: Qualitative results for loss evaluations. Using both perceptual loss and adversarial loss improves image quality.
444
+
445
+ ![](images/77c2ae606c705e289945f2d9b7f4b938d53ac98fd76b919265110f2c5a04c0ca.jpg)
446
+ Figure 19: Qualitative results for generalization to unseen spatial arrangement.
447
+
448
+ ![](images/4ce7657ad278b85ed9b36f70f6db2402cc7e50a8dec2652cc73fcba81755eed1.jpg)
449
+ Figure 20: Qualitative results for generalization to unseen combination of color and shape.
450
+
451
+ ![](images/cf07e024fed74d4886761556aa25aae43b9209aa30b4c6c92d86a8797cd5c5ed.jpg)
452
+ Figure 21: Failure case of our model, which we call “attention rank-collapse”. All foreground slots share the same attention map. Every foreground slot decodes to the same radiance field (empty radiance here) rather than specializing to an object. Here we only show one object slot, as all others look the same.
453
+
454
+ ![](images/57181a60bae40d182b210a94ce21422bc1d3b9329328919ce329da14a2593641.jpg)
455
+ Figure 22: Visual comparison with GIRAFFE for inference on CLEVR-567 dataset. GIRAFFE fails inference.
456
+
457
+ ![](images/2446417d4976de23655f3793d84d6e65c2457b1d8431a89c2c0ab594542cd5c5.jpg)
458
+ Figure 23: Visual comparison with GIRAFFE for inference on Room-Chair dataset. GIRAFFE fails inference.
459
+
460
+ ![](images/9ae9b21e90622cea96eb2a94ea8b22a4e1278f91ddada0da20d98cb5b82c6c52.jpg)
461
+ Figure 24: Inference trajectory of GIRAFFE using author-provided models on the author-provided dataset CLEVR-2345.
462
+
463
+ ![](images/fa168c3931e2e67cb5b01ebf98eafa9f0a78ab3e23515eb651e8fcf4a3d3f352.jpg)
464
+ Figure 25: Novel view synthesis on randomly generated examples using author-provided pretrained GIRAFFE model on CLEVR-2345. GIRAFFE fails inference of these multi-object scenes. GIRAFFE cannot synthesize novel views with large rotations.
md/dev/tGHi1HFNBx1/tGHi1HFNBx1.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/toR64fsPir/toR64fsPir.md ADDED
@@ -0,0 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Structure-Preserving Embedding of Multi-layer Networks
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 This paper investigates structure-preserving embedding for multi-layer networks
11
+ 2 with community structure. We propose a novel generative tensor-based latent space
12
+ 3 model (TLSM) that allows heterogeneity among vertices. It embeds vertices into
13
+ 4 a low-dimensional latent space so that vertices within the same community are
14
+ 5 close to each other in the ambient space, and captures layer heterogeneity through
15
+ 6 a layer-effect factor matrix. With a general and flexible tensor decomposition
16
+ 7 on the expected network adjacency tensor, TLSM is dedicated to preserving the
17
+ 8 original vertex relations and layer-specific effects in the network embedding. An
18
+ 9 efficient alternative updating scheme is developed to estimate the model parameters
19
+ 10 and conduct community detection simultaneously. Theoretically, we establish the
20
+ 11 asymptotic consistencies of TLSM in terms of both multi-layer network estimation
21
+ 12 and community detection. The theoretical results are supported by extensive
22
+ 13 numerical experiments on both synthetic and real-life multi-layer networks.
23
+
24
+ # 14 1 Introduction
25
+
26
+ 15 Network has arisen as one of the most common structures to represent the relations among entities.
27
+ 16 In many complex systems, entities can be multi-relational in that they may interact with each other
28
+ 17 under various circumstances. A multi-layer network, which consists of a common vertex set across all
29
+ 18 network layers representing the entities and an edge set at each layer to characterize a particular type
30
+ 19 of relation among entities, is faithful to represent these relations. Examples of multi-layer networks
31
+ 20 include social networks of multiple interaction channels [42, 15], biological networks of different
32
+ 21 collaboration schemes [49, 31, 29] and world trading networks [1, 37] of various goods.
33
+ 22 In this paper, we propose a structure-preserving embedding framework for multi-layer networks
34
+ 23 via a tensor-based latent space model. Specifically, TLSM utilizes the factorization of network
35
+ 24 adjacency tensor as a building block, embeds the vertices into a low dimensional latent space, and
36
+ 25 captures the heterogeneity among different layers through a layer-effect factor matrix. Consequently,
37
+ 26 the community structure of the multi-layer network can be detected from a network embedding
38
+ 27 perspective, such that vertices within the same community are closer to one another in the ambient
39
+ 28 space than those in different communities. In addition, one key feature of TLSM is that it introduces
40
+ 29 a sparsity factor into the vanilla logit transformation of the network adjacency tensor, which allows
41
+ 30 TLSM to model sparse multi-layer networks in a more explicit fashion and accommodate relatively
42
+ 31 sparser multi-layer networks as the ones considered in literature [22]. More importantly, this sparsity
43
+ 32 factor can be estimated from the network adjacency tensor directly.
44
+ 33 The main contribution of this paper is three-fold. First, the proposed TLSM is flexible and general
45
+ 34 in that it includes many popular network models as special cases. It also relaxes the layer-wise
46
+ 35 positive semi-definite condition that has been frequently employed in literature [6, 35]. Second, a
47
+ 36 joint modeling framework is constructed for TLSM, consisting of the multi-layer network likelihood
48
+ 37 and a clustering type penalty, to estimate the multi-layer network and conduct community detection
49
+ 38 simultaneously. Its advantages are supported by extensive numerical experiments on both synthetic
50
+ 39 and real-life multi-layer networks. Third, the asymptotic consistencies of TLSM are established in
51
+ 40 terms of both multi-layer network estimation and community detection. Notably, the established
52
+ 41 theoretical results imply that the proposed methods can accommodate the sparsest multi-layer
53
+ 42 networks considered in literature.
54
+ 43 The rest of the paper is organized as follows. The remaining of Section 1 discusses related works and
55
+ 44 introduces necessary notations. Section 2 presents the proposed TLSM and its estimation scheme with
56
+ 45 an efficient algorithm. In Section 3, we establish the asymptotic consistencies of TLSM. Extensive
57
+ 46 numerical performance of TLSM on synthetic and real-life multi-layer networks as well as ablation
58
+ 47 studies on two novel components of the proposed method are carried out in Section 4. Section 5
59
+ 48 concludes the paper. The supplementary materials contains technique proofs and necessary lemmas,
60
+ 49 additional simulation studies, detailed parameter tuning process, among others.
61
+
62
+ # 50 1.1 Related work
63
+
64
+ 51 While there is a growing number of literature focusing on community detection in single-layer
65
+ 52 network [48, 28, 13], community detection in multi-layer network is still in its infancy. One classical
66
+ 53 approach is to detect community structure in each layer separately [4, 5], which fails to leverage
67
+ 54 the homogeneity across different layers. Another approach is to aggregate multi-layer networks
68
+ 55 into a single-layer one [41, 12, 35], which heavily relies on the assumption of homogeneous linking
69
+ 56 pattern across multiple layers. Recently, [26] proposed to aggregate the biased-adjusted version of
70
+ 57 the squared adjacency matrix in each layer to alleviate the information loss in aggregation. yet it
71
+ 58 requires the average node degree to grow at a sub-optimal order.
72
+ 59 In terms of multi-layer network generative models, [34] extended the seminal stochastic block
73
+ 60 model (SBM; 19) to the multi-layer stochastic block model (MLSBM; 34), where the probability for
74
+ 61 any two vertices to form an edge in a given layer depends only on their community memberships.
75
+ 62 Clearly, MLSBM heavily relies on the assumption of homogeneous vertices within communities.
76
+ 63 The framework of MLSBM has also been incorporated in degree-corrected network estimation [36],
77
+ 64 spectral clustering [6, 35, 26], least square estimation [27] and likelihood-based approaches [45]. In
78
+ 65 addition, network response regression model [46] and tensor factorization methods [8, 22] have also
79
+ 66 been proposed to detect community structures in multi-layer networks.
80
+ 67 To allow heterogeneous vertices, the latent space model [18] and random dot product graph model
81
+ 68 [3] have been extended to multi-layer networks[47, 32, 2]. In addition, graph neural network and
82
+ 69 graph convolutional networks has been extended to multi-layer network for learning the multi-layer
83
+ 70 network embedding [14, 23, 17, 39].
84
+
85
+ # 71 1.2 Notations
86
+
87
+ 72 Throughout the paper, we use boldface calligraphic Euler scripts $( A )$ to denote tensors, boldface
88
+ 73 capital letters $( A )$ or Greece letters $( \alpha , \beta )$ to denote matrices, boldface lowercase letters $( a )$ to
89
+ 74 denote vectors, and regular letters $( a )$ to denote scalars. For an order three tensor $\pmb { \mathcal { A } } \in \mathbb { R } ^ { I _ { 1 } \times I _ { 2 } \times I _ { 3 } }$ ,
90
+ 75 $\mathcal { A } _ { i , . , . } \in \mathbb { R } ^ { I _ { 2 } \times I _ { 3 } } , \mathcal { A } _ { . , j , \cdot } \in \mathbb { R } ^ { I _ { 1 } \times I _ { 3 } }$ , and $\pmb { \mathscr { A } } _ { . , . , m } \in \mathbb { R } ^ { I _ { 1 } \times I _ { 2 } }$ are the $i$ -th horizontal slide, $j$ -th lateral slide
91
+ 76 and $m$ -th frontal slide of $\mathcal { A }$ , respectively. Similarly, for a matrix $\pmb { A }$ , $A _ { i , }$ . denotes its $i$ -th row and $A _ { . , j }$
92
+ 77 denotes its $j$ -th column. For a vector $\textbf { \em a }$ , $\mathrm { d i a g } ( a )$ stands for the diagonal matrix whose diagonal is $\textbf { \em a }$ .
93
+ 78 We use $| | \cdot | | , | | \cdot | | _ { \infty }$ , and $| | \cdot | | _ { F }$ to denote the $l _ { 2 }$ -norm, $l _ { \infty }$ -norm of a vector, and the Frobenius norm
94
+ 79 of matrix or tensor, respectively. For any integer $n$ , denote $[ n ] = \{ 1 , 2 , . . . , n \}$ .
95
+
96
+ 80 81 1 product betsuch that its or -th $\pmb { \mathcal { A } } \in \mathbb { R } ^ { I _ { 1 } \times I _ { 2 } \times I _ { 3 } }$ an as $U \in \mathbb { R } ^ { J _ { 1 } \times I _ { 1 } }$ $\pmb { A } \times _ { 1 } \pmb { U } \in$ $\mathbb { R } ^ { J _ { 1 } \times I _ { 2 } \times I _ { 3 } }$ $( j _ { 1 } , i _ { 2 } , i _ { 3 } )$ $\begin{array} { r } { ( \pmb { \mathscr { A } } \times _ { 1 } \pmb { U } ) _ { j _ { 1 } , i _ { 2 } , i _ { 3 } } = \sum _ { i _ { 1 } = 1 } ^ { I _ { 1 } } \pmb { \mathscr { A } } _ { i _ { 1 } , i _ { 2 } , i _ { 3 } } U _ { j _ { 1 } , i _ { 1 } } } \end{array}$ The mode-2 or mode-3 product between $\pmb { A }$ and any matrix of appropriate dimension are defined 83 similarly. The CANDECOMP/PARAFAC (CP) decomposition of $\pmb { A }$ has the form
97
+
98
+ $$
99
+ \pmb { \mathcal { A } } = \sum _ { r = 1 } ^ { R } \pmb { a } ^ { ( r ) } \circ \pmb { b } ^ { ( r ) } \circ \pmb { c } ^ { ( r ) } ,
100
+ $$
101
+
102
+ where 84 $\pmb { a } ^ { ( r ) } \in \mathbb { R } ^ { I _ { 1 } }$ , $\boldsymbol { b } ^ { ( r ) } \in \mathbb { R } ^ { I _ { 2 } }$ , and $\boldsymbol { c } ^ { ( r ) } \in \mathbb { R } ^ { I _ { 3 } }$ for $r \in [ R ]$ , and $\circ$ stands for the vector outer product. The CP-rank [24] of the tensor 85 $\pmb { a } ^ { ( r ) } \circ \pmb { b } ^ { ( r ) } \circ \pmb { c } ^ { ( r ) }$ is defined to be 1, for $r \in [ R ]$ . The minimal number
103
+
104
+ 86 of rank-1 tensors in the CP decomposition of $\pmb { A }$ is called the CP-rank of $\pmb { A }$ . Let $\pmb { \mathcal { T } } \in \{ 0 , 1 \} ^ { R \times R \times R }$
105
+ 87 be the identity tensor such that $\pmb { \mathcal { T } } _ { i _ { 1 } , i _ { 2 } , i _ { 3 } } = 1$ if $i _ { 1 } = i _ { 2 } = i _ { 3 }$ and 0 otherwise, and let $\pmb { A } \in \mathbb { R } ^ { I _ { 1 } \times R }$ ,
106
+ 88 $\boldsymbol { B } \in \mathbb { R } ^ { I _ { 2 } \times R }$ , and $C \in \mathbb { R } ^ { I _ { 3 } \times R }$ such that $\mathbf { \boldsymbol { A } } _ { \cdot , r } = \mathbf { \boldsymbol { a } } ^ { ( r ) }$ , $\mathbf { \delta } _ { B _ { \cdot , r } } = \mathbf { \delta } _ { \mathbf { \delta } } \mathbf { \delta } _ { B _ { \cdot , r } } ^ { ( r ) }$ , and $\boldsymbol { C } _ { \cdot , r } = \boldsymbol { c } ^ { ( r ) }$ . Equation (1)
107
+ 89 then can be equivalently written as $\pmb { \mathcal { A } } = \pmb { \mathcal { T } } \times _ { 1 } \pmb { A } \times _ { 2 } \pmb { B } \times _ { 3 } \pmb { C }$ .
108
+
109
+ # 90 2 Structure-preserving embedding
110
+
111
+ 91 In this paper, we consider multi-layer networks that can be represented as an undirected and un
112
+ 92 weighted $M$ -layer graph $\mathcal { G } = ( V , \mathcal { E } )$ , where $V = [ n ]$ consists of the common $n$ vertices across
113
+ 93 different layers, and $\mathcal { E } = \{ E ^ { ( m ) } \} _ { m = 1 } ^ { M }$ with $E ^ { ( m ) } \subset V \times V$ representing the $m$ -th relation network
114
+ 94 among vertices. A order three adjacency tensor $\pmb { \mathcal { A } } = ( a _ { i , j , m } ) \in \{ 0 , 1 \} ^ { n \times n \times M }$ is then defined to
115
+ 95 represent $\mathcal { G }$ with entries $a _ { i , j , m } = 1$ if $( i , j ) \in E ^ { ( m ) }$ and 0 otherwise.
116
+
117
+ # 2.1 Tensor-based latent space model
118
+
119
+ 97 To fully characterize the multi-layer network structure, we propose the following generative tensor
120
+ 8 based latent space model (TLSM). For any $i \leq j \in [ n ]$ , and $m \in [ M ]$ ,
121
+
122
+ $$
123
+ \begin{array} { r l } & { a _ { i , j , m } = a _ { j , i , m } \overset { i n d . } { \sim } \mathrm { B e r n o u l l i } ( p _ { i , j , m } ) , \mathrm { ~ w i t h ~ } } \\ & { \theta _ { i , j , m } = \log \Big ( \frac { p _ { i , j , m } } { s _ { n } - p _ { i , j , m } } \Big ) , \mathrm { ~ a n d ~ } } \\ & { \Theta = \mathbb { Z } \times _ { 1 } \alpha \times _ { 2 } \alpha \times _ { 3 } \beta , \alpha \in \Omega _ { \alpha } , \beta \in \Omega _ { \beta } , } \end{array}
124
+ $$
125
+
126
+ 99 where $\boldsymbol { \mathscr { x } }$ is the order three $R$ -dimensional identity tensor. Basically, (2) follows the standard routine
127
+ 100 in the multi-layer network literature [34, 35, 27, 22] to model that $a _ { i , j , m } = a _ { j , i , m }$ are independently
128
+ 101 generated from a Bernoulli distribution, for $i \leq j \in [ n ]$ and $m \in [ M ]$ . Denote $\pmb { \mathcal { P } } = ( p _ { i , j , m } ) \in$
129
+ 102 $\mathbb { R } ^ { n \times n \times M }$ as the network underlying probability tensor, and then $\Theta = ( \theta _ { i , j , m } ) \in \mathbb { R } ^ { n \times n \times M }$ is
130
+ 103 the entry-wise transformation of $\mathcal { P }$ by (3). We call the transformation (3) as the modified logit
131
+ 104 transformation in that the constant 1 in the standard logit transformation is replaced by a sparsity
132
+ 105 factor $s _ { n }$ , which may vanish with $n$ and $M$ . We further assume all entries of $\mathcal { P }$ are of the order $s _ { n }$ ; that
133
+ 106 is, there exists a constant $\textstyle { \frac { 1 } { 2 } } \leq \xi < 1$ such that $( 1 - \xi ) s _ { n } \leq p _ { i , j , m } \leq \xi s _ { n }$ , for $i , j \in [ n ]$ and $m \in [ M ]$
134
+ 107 Thus, the in $s _ { n }$ essval $\begin{array} { r } { [ - \log \frac { \xi } { 1 - \xi } , \log \frac { \xi } { 1 - \xi } ] } \end{array}$ overall network sparsity and the entries of . More importantly, (4) models the CP d $\Theta$ are ensured toomposition of $\Theta$ cate inby the
135
+ 109 factor matrices $\pmb { \alpha } \in \mathbb { R } ^ { n \times R }$ and $\mathbf { \boldsymbol { \beta } } \in \mathbb { R } ^ { M \times R }$ with CP-rank $R$ , which can greatly reduce the number of
136
+ 110 free parameters from $n ( n + 1 ) M / 2$ to $( n + M ) R$ . Throughout the paper, the CP-rank $R$ is allowed
137
+ 111 to diverge with $n$ . In the CP decomposition of $\Theta$ , $_ \alpha$ is the vertex latent position matrix with each row
138
+ 112 $\alpha _ i , $ . serving as the embedding of vertex $i$ , and $\beta$ captures heterogeneity across different layers. Herein,
139
+ 113 we define the constraint sets for $_ { \pmb { \alpha } }$ and $\beta$ as $\begin{array} { r } { \Omega _ { \alpha } = \{ \alpha \in \mathbb { R } ^ { n \times R } : | | \alpha _ { i , \cdot } | | \leq \sqrt { \log \frac { \xi } { 1 - \xi } } } \end{array}$ , for $i \in [ n ] \}$
140
+ 114 and $\Omega _ { \beta } = \{ \beta \in \mathbb { R } ^ { M \times R } : | | \beta _ { \cdot , r } | | = 1 , r \in [ R ] \}$ . Note that the constraint on $\beta$ is necessary for
141
+ 115 model identification, and detailed discussion will be presented shortly. The constraint set $\Omega _ { \alpha } \times \Omega _ { \beta }$
142
+ 116 is sufficient to maintain the bounded condition of $\Theta$ since a general Hölder inequality yields that
143
+ 117 $\begin{array} { r } { | \theta _ { i , j , m } | = | \pmb { \mathcal { Z } } \times _ { 1 } \pmb { \alpha } _ { i , . } ^ { T } \times _ { 2 } \pmb { \alpha } _ { j , . } ^ { T } \times _ { 3 } \beta _ { m , . } ^ { T } | \le | | \pmb { \alpha } _ { i , . } | | | | \pmb { \alpha } _ { j , . } | | | | \beta _ { m , . } | | _ { \infty } \le \log \frac { \xi } { 1 - \xi } } \end{array}$ . To conclude this
144
+ 118 paragraph, we remake that the parameter $\xi$ is introduced for theoretical purpose and it is not treated as
145
+ 119 a tuning parameter. One can choose $\xi$ sufficiently close to 1 in empirical studies so that the restriction
146
+ 120 on $_ { \pmb { \alpha } }$ will be alleviated.
147
+ 121 We make several essential observations of the proposed TLSM. First and foremost, TLSM is flexible
148
+ 122 and general. It includes the celebrated MLSBM [34, 43, 35, 27, 26, 36, 22] as special case. Specif
149
+ 123 ically, suppose the vertices comes form $K$ disjoint communities, the standard MLSBM assumes
150
+ 124 that the underlying network probability tensor ${ \pmb { \mathcal { P } } } = { \pmb { \mathcal { B } } } \times _ { 1 } { \pmb { Z } } \times _ { 2 } { \pmb { Z } }$ , where $\pmb { \mathscr { B } } \in \mathbb { R } ^ { K \times K \times M }$ is a
151
+ 125 semi-symmetric core probability tensor with $\pmb { \mathscr { B } } _ { k _ { 1 } , k _ { 2 } , m } = \pmb { \mathscr { B } } _ { k _ { 2 } , k _ { 1 } , m }$ for $k _ { 1 } , k _ { 2 } \in [ K ]$ and $m \in [ M ]$ ,
152
+ 126 and $Z \in \{ 0 , 1 \} ^ { n \times K }$ is the community membership matrix with $Z _ { i , k } = 1$ if vertex $i$ comes from the
153
+ 127 $k$ -th community and 0 otherwise. That is, the probability of any vertex pair to form an edge in a
154
+ 128 particular layer depends only on their community memberships. Equivalently, under the modified
155
+ 129 logit transformation (3), we have $\Theta = \widetilde { \pmb { \mathscr { B } } } \times _ { 1 } { Z } \times _ { 2 } { Z }$ , where $\widetilde { B }$ is the entry-wise transformation
156
+ 130 of $_ { \pmb { B } }$ under (3). Taking $R$ to be the CP-rank of $\widetilde { B }$ , the CP-decomposition of $\widetilde { B }$ then has the form
157
+ 131 $\widetilde { \pmb { \mathscr { B } } } = \pmb { \mathscr { T } } \times _ { 1 } \pmb { C } \times _ { 2 } \pmb { C } \times _ { 3 } \ \pmb { \beta }$ for some matrix $C \in \mathbb { R } ^ { K \times R }$ and $\beta \in \mathbb { R } ^ { M \times R }$ due to semi-symmetry.
158
+ 132 This leads to the CP decomposition of $\Theta$ has the form (4) with $\mathbf { \alpha } _ { \alpha } = Z C$ . It is clear that MLSBM
159
+ 133 requires vertices within the same community are homogeneous and exchangeable, while TLSM
160
+ 134 allows vertices to have different embeddings even when they are in the same community.
161
+ 135 Second, TLSM is identifiable when both $_ { \pmb { \alpha } }$ and $\beta$ have full column ranks. When both $_ { \pmb { \alpha } }$ and $\beta$
162
+ 136 have full column ranks, the Kruskal’s $\mathbf { k }$ -ranks [25] of $_ { \pmb { \alpha } }$ and $\beta$ satisfy $k _ { \alpha } = k _ { \beta } = R$ , then $\Theta$ has
163
+ 137 CP-rank $R$ . Hence, $k _ { \alpha } + k _ { \alpha } + k _ { \beta } \geq 2 R + 2$ as long as $R \geq 2$ . By Theorem 1 of [40], the fixed
164
+ 138 column $l _ { 2 }$ -norm constraint of $\beta$ implies that the tensor factorization in (4) is unique up to column
165
+ 139 permutations of $_ { \pmb { \alpha } }$ and $\beta$ and column sign flip of $_ \alpha$ . It is important to remark that the community
166
+ 140 structure encoded in $_ { \pmb { \alpha } }$ remains unchanged under any column permutation or sign flip.
167
+ 141 Third, introducing a sparsity factor $s _ { n }$ via a modified logit transformation into the TLSM is non
168
+ 142 trivial. We take a single-layer network as an example to illustrate the limitation of the standard
169
+ 143 logit transformation in handling sparse network. Suppose a vanilla logit link is used to connect
170
+ 144 the network underlying probability matrix $_ { r }$ and its transformation $\Theta$ , and the latent space model
171
+ 145 usually assumes that $\breve { \Theta } = \alpha \alpha ^ { T }$ . A sparse network requires the entries of $\Theta$ diverge to negative
172
+ 146 infinite due to the small magnitude of edge probability, which leads to unstable estimation of $_ { \pmb { \alpha } }$ in
173
+ 147 numerical experiments. Moreover, this may conflict with the assumption that vertices within the same
174
+ 148 community tend to be close in the embedding space and their inner product is likely to be positive.
175
+ 149 These difficulties can be naturally circumvented when an appropriate $s _ { n }$ is chosen in (3).
176
+
177
+ # 150 2.2 Regularized likelihood
178
+
179
+ Given a network adjacency tensor $\mathcal { A }$ and number of communities $K$ , our goal is to estimate the multi-layer network embedding $( \alpha , \beta )$ and conduct community detection on the vertices. Throughout this paper, we assume the number of potential communities $K$ is given and may diverge with $n$ . Under the TLSM framework, with slight abuse of notation, we denote the average negative log-likelihood function of the multi-layer network $\mathcal { G }$ is $\mathcal { L } ( \alpha , \beta ; \mathcal { A } ) = \mathcal { L } ( \Theta ; \mathcal { A } )$ with
180
+
181
+ $$
182
+ \mathcal { L } ( \Theta ; \pmb { A } ) = \frac { 1 } { \varphi ( n , M ) } \sum _ { m = 1 } ^ { M } \sum _ { i \leq j } L ( \theta _ { i , j , m } ; a _ { i , j , m } ) ,
183
+ $$
184
+
185
+ where 151 $\varphi ( n , M ) = { \textstyle { \frac { 1 } { 2 } } } n ( n { + } 1 ) M$ is the number of potential edges, and $\begin{array} { r } { L ( \theta ; a ) = \log \left( 1 + \frac { s _ { n } } { 1 - s _ { n } + e ^ { - \theta } } \right) - } \end{array}$ 152 $\begin{array} { r } { a \log \left( \frac { s _ { n } } { 1 - s _ { n } + e ^ { - \theta } } \right) } \end{array}$ is a negative log-density of a Bernoulli random variable $a$ . We now introduce a 153 novel regularization term to detect the potential communities in $\mathcal { G }$ ,
186
+
187
+ $$
188
+ J ( \alpha ) = \operatorname* { m i n } _ { Z \in \Gamma , C \in \mathbb { R } ^ { K \times R } } \frac { 1 } { n } \| \alpha - Z C \| _ { F } ^ { 2 } ,
189
+ $$
190
+
191
+ 154 where $C$ encodes the vertex embedding centers and ${ \Gamma } ~ \subset ~ \{ 0 , 1 \} ^ { n \times K }$ is the set of all possible
192
+ 155 community membership matrices; that is, for any $Z \in \Gamma$ , each row of $z$ consists of only one 1
193
+ 156 indicating the community membership and all others entries being 0. This leads to the proposed
194
+ 157 regularized cost function,
195
+
196
+ $$
197
+ \begin{array} { r } { \mathcal L _ { \lambda } ( \boldsymbol { \alpha } , \beta ; \boldsymbol { \mathcal { A } } ) = \mathcal L ( \boldsymbol { \alpha } , \beta ; \boldsymbol { \mathcal { A } } ) + \lambda _ { n } J ( \boldsymbol { \alpha } ) , } \end{array}
198
+ $$
199
+
200
+ 158 where $\lambda _ { n }$ is a positive tuning parameter that strikes the balance between network estimation and
201
+ 159 community detection in the cost function. It is clear that the embeddings of vertices with similar
202
+ 160 linking pattern will be pushed towards the same center, and thus close to each other in the ambient
203
+ 161 space, leading to the desired community structure in $\mathcal { G }$ .
204
+
205
+ # 2.3 Projected gradient descent algorithm
206
+
207
+ 163 We develop a scalable projected gradient descent (PGD) algorithm to optimize the penalized cost
208
+ 164 function (6), which is highly non-convex and can be solved only locally. PGD, which alternatively
209
+ 165 conducts gradient step and projection step, is one of the most popular and computationally fast
210
+ 166 algorithm in tackling non-convex optimization problem [7, 33, 47, 9].
211
+
212
+ To compute the gradients of 167 $_ \alpha$ and $\beta$ , we introduce the following notations. Define $\pmb { \mathcal { T } } \in \mathbb { R } ^ { n \times n \times M }$ with entries 168 $\begin{array} { r } { \pmb { \mathcal { T } } _ { i , j , m } = \frac { \exp ( - \theta _ { i , j , m } ) } { 1 - s _ { n } + \exp ( - \theta _ { i , j , m } ) } ( p _ { i , j , m } - a _ { i , j , m } ) } \end{array}$ , and $\boldsymbol { X } _ { \mathcal { T } ( 2 , 3 ) } ^ { \alpha , \beta } \in \mathbb { R } ^ { n \times R }$ whose $i$ -th row
213
+
214
+ 169 170 al elements of the slic. Similarly, we define $( \mathcal { T } \times _ { 2 } \alpha ^ { T } \times _ { 3 } \beta ^ { T } ) _ { i , . , . }$ $X _ { \mathcal { T } ( 2 , 3 ) } ^ { \alpha , \beta } ( i , r ) ~ =$ $( \pmb { \mathcal { T } } \times _ { 2 } \pmb { \alpha } ^ { T } \times _ { 3 } \beta ^ { T } ) _ { i , r , r }$ $X _ { \mathcal { T } ( 1 , 2 ) } ^ { \alpha , \alpha } \in \mathbb { R } ^ { R \times M }$ $\boldsymbol { X } _ { \mathcal { T } ( 3 ) } ^ { \beta } \in \mathbb { R } ^ { n \times R }$ $X _ { T ( 1 , 2 ) } \in$ 171 $\mathbb { R } ^ { n \times M }$ , such that $X _ { \mathcal { T } ( 1 , 2 ) } ^ { \alpha , \alpha } ( r , m ) = ( \mathcal { T } \times _ { 1 } \alpha ^ { T } \times _ { 2 } \alpha ^ { T } ) _ { r , r , m }$ , $X _ { \mathcal { T } ( 3 ) } ^ { \beta } ( i , r ) = ( \mathcal { T } \times _ { 3 } \beta ^ { T } ) _ { i , i , r }$ , and 172 $X _ { \mathcal { T } ( 1 , 2 ) } ( i , m ) = \mathcal { T } _ { i , i , m }$ . Consequently, when the vertex membership matrix $z$ and the community 173 center matrix $C$ are fixed, we can derive the gradients of $\mathcal { L } _ { \lambda } ( \alpha , \beta ; \mathcal { A } )$ with respect to $_ { \pmb { \alpha } }$ and $\beta$ , as $\frac { 1 } { \varphi ( n , M ) } \big ( X _ { \mathcal { T } ( 2 , 3 ) } ^ { \alpha , \beta } + X _ { \mathcal { T } ( 3 ) } ^ { \beta } \ast \alpha \big ) + 2 \lambda _ { n } ( \alpha - Z C )$ and $\frac { 1 } { 2 \varphi ( n , M ) } \big ( ( X _ { \mathcal { T } ( 1 , 2 ) } ^ { \alpha , \alpha } ) ^ { T } + X _ { \mathcal { T } ( 1 , 2 ) } ^ { T } ( \alpha * \alpha ) \big ) ,$ 174 respectively. Herein, \* denotes the Hadamard product (entry-wise product) between two matrices.
215
+
216
+ Let 175 $( { \tilde { \alpha } } , { \tilde { \beta } } )$ denote the solution given by one-step gradient descent, we then project $( { \tilde { \alpha } } , { \tilde { \beta } } )$ onto 176 $\Omega _ { \alpha } \times \Omega _ { \beta }$ in the following steps.
217
+
218
+ Step 1. Multiply the $r$ -th column of $\tilde { \alpha } _ { . , r }$ by $| | \tilde { \beta } _ { . , r } | | ^ { 1 / 2 }$ for $r \in [ R ]$ . Denote the resultant matrix as $\tilde { \alpha } ^ { \prime }$
219
+
220
+ Step 2. Regularize each row of $_ { \pmb { \alpha } }$ as $\begin{array} { r } { \pmb { \alpha } _ { i , . } = \tilde { \pmb { \alpha } } _ { i , . } ^ { \prime } \operatorname* { m i n } \{ \sqrt { \log \frac { \xi } { 1 - \xi } } , | | \tilde { \pmb { \alpha } } _ { i , . } ^ { \prime } | | \} / | | \tilde { \pmb { \alpha } } _ { i , . } ^ { \prime } | | , \mathbf { f } } \end{array}$ or $i \in [ n ]$ .
221
+
222
+ Step 3. Normalize the columns of 179 $\beta$ as $\beta _ { . , r } = \tilde { \beta } _ { . , r } / | | \tilde { \beta } _ { . , r } | |$ , for $r \in [ R ]$ .
223
+
224
+ Next, when $( \alpha , \beta )$ are given, we apply a $( 1 + \delta )$ -approximation K-means algorithm on $\tilde { \alpha }$ to update the vertex community membership matrix $z$ and community center matrix $C$ .
225
+
226
+ 182 The above steps will be alternatively conducted until convergence or reaching the maximum number
227
+ 183 of iterations. We further summarized the developed alternative updated scheme in Algorithm 1 in
228
+ 184 Appendix A of the supplementary materials
229
+ 185 Several remarks on the algorithm are in order. First, Algorithm 1 can only be guaranteed to converge
230
+ 186 to a stationary point but not any local minimizer. We hence employ a transformed higher order
231
+ 187 orthogonal iteration (HOOI) algorithm for warm initialization in all the numerical experiments in
232
+ 188 Section 4 and 5. Specifically, given a user-specific value $\tau$ , we define $\widetilde { \Theta }$ to mimic the magnitude
233
+ 189 of $\Theta$ such that $\widetilde { \Theta } _ { i , j , m } = - \tau$ if $a _ { i , j , m } = 0$ and $\widetilde { \Theta } _ { i , j , m } = \tau$ otherwise. A standard HOOI algorithm
234
+ 190 [11] is applied to $\Theta$ to obtain $\pmb { \alpha } ^ { ( 0 ) }$ and $\beta ^ { ( 0 ) }$ . We set $\tau = 1 0 0$ in all the numerical experiments.
235
+ 191 Second, the sparsity factor $s _ { n }$ is an intrinsic quantity of the multi-layer network data, and it should be
236
+ 192 estimated from the network directly. Note that the minimal and maximal probabilities for any vertex
237
+ 193 pair to form an edge in any layer are $p _ { \operatorname* { m i n } } = ( 1 - \xi ) s _ { n }$ and $p _ { \operatorname* { m a x } } = \xi s _ { n }$ , respectively. Interestingly,
238
+ 194 $p _ { \operatorname* { m i n } } + p _ { \operatorname* { m a x } } = s _ { n }$ , which does not depend on $\xi$ any more. Therefore, we propose to estimate $s _ { n }$ as
239
+
240
+ $$
241
+ \hat { s } _ { n } = \operatorname* { m i n } _ { i \in [ n ] } \frac { 1 } { n M } \sum _ { m = 1 } ^ { M } \sum _ { j = 1 } ^ { n } a _ { i , j , m } + \operatorname* { m a x } _ { i \in [ n ] } \frac { 1 } { n M } \sum _ { m = 1 } ^ { M } \sum _ { j = 1 } ^ { n } a _ { i , j , m } ,
242
+ $$
243
+
244
+ 195 which is the sum of the minimal and maximal frequencies of a vertex to form edges with all other
245
+ 196 vertices in all layers. Third, to optimally choose $\lambda _ { n }$ , we extend the network cross-validation by
246
+ 197 edge sampling scheme in [30] to multi-layer networks. The detailed tuning procedure is relegated to
247
+ 198 Appendix B in the supplementary materials.
248
+
249
+ # 3 Asymptotic theory
250
+
251
+ # 3.1 Consistency in estimating $\Theta ^ { * }$
252
+
253
+ 201 Let $\begin{array} { r } { \lambda = \left\{ \Theta = \mathbb { Z } \times _ { 1 } { \pmb \alpha } \times _ { 2 } { \pmb \alpha } \times _ { 3 } \beta : { \pmb \alpha } \in \Omega _ { \pmb { \alpha } } , \beta \in \Omega _ { \beta } \right\} } \end{array}$ } be the parameter space of the problem and
254
+ 202 203 $\Theta ^ { * } = \mathcal { T } \times _ { 1 } \pmb { \alpha } ^ { * } \times _ { 2 } \pmb { \alpha } ^ { * } \times _ { 3 } \beta ^ { * }$ $\begin{array} { r } { K L ( \boldsymbol { \Theta } ^ { * } | | \boldsymbol { \Theta } ) = \varphi ^ { - 1 } ( n , M ) \sum _ { m = 1 } ^ { M } \sum _ { i \leq j } E \bigl ( L ( \theta _ { i , j , m } ; a _ { i , j , m } ) - L ( \theta _ { i , j , m } ^ { * } ; a _ { i , j , m } ) \bigr ) } \end{array}$ ty tensor. Denote be the averaged
255
+ 204 Kullback–Leibler divergence of the network generation distributions parametrized by and , for
256
+ 205 any $\mathbf { \Theta } \Theta \in \Omega$ . The following large deviation inequality is derived to quantify the behavior of $\mathcal { L } _ { \lambda } ( \Theta ; \mathbf { \mathcal { A } } )$
257
+ 206 for any $\Theta$ in the neighborhood of $\Theta ^ { * }$ defined by $\dot { K } L ( \Theta ^ { * } | | \Theta )$ .
258
+
259
+ Proposition 1. Suppose 207 $\lambda _ { n } J ( \alpha ^ { * } ) \leq \epsilon _ { n }$ , and $( n + M ) R \varphi ^ { - 1 } ( n , M ) \epsilon _ { n } ^ { - 1 } \log ( \epsilon _ { n } ^ { - 1 / 2 } ) \leq c _ { 1 }$ for some constant 208 $c _ { 1 }$ . Then with probability at lease $\begin{array} { r } { 1 - 2 \exp \Big ( - \frac { \varphi ( n , M ) \epsilon _ { n } } { 1 5 6 \frac { \xi } { 1 - \xi } + 2 8 \log 2 } \Big ) } \end{array}$ , we have
260
+
261
+ $$
262
+ \mathcal { L } _ { \lambda } ( \Theta ^ { * } ; \mathcal { A } ) \leq \operatorname* { i n f } _ { \substack { \{ \Theta \in \Omega \vert K L ( \Theta ^ { * } \vert \vert \Theta ) \geq 4 \epsilon _ { n } \} } } \mathcal { L } _ { \lambda } ( \Theta ; \mathcal { A } ) - \epsilon _ { n } .
263
+ $$
264
+
265
+ 209 Proposition 1 basically states that any estimators with sufficiently small objective value should
266
+ 210 be close enough to $\Theta ^ { * }$ in terms of $K \dot { L } ( \Theta ^ { * } | | \Theta )$ . We next study the asymptotic behavior of these
267
+ 211 estimators more precisely. Let $( \hat { \alpha } , \hat { \beta } ) \in \Omega _ { \alpha } \times \Omega _ { \beta }$ be any estimator of $( \alpha ^ { * } , \beta ^ { * } )$ such that
268
+
269
+ $$
270
+ \begin{array} { r } { \mathcal L _ { \lambda } ( \hat { \alpha } , \hat { \beta } ; \mathcal A ) \le \mathcal L _ { \lambda } ( \alpha ^ { * } , \beta ^ { * } ; \mathcal A ) + \epsilon _ { n } , } \end{array}
271
+ $$
272
+
273
+ and denote 212 $\widehat { \Theta } = \mathcal { T } \times _ { 1 } \hat { \alpha } \times _ { 2 } \hat { \alpha } \times _ { 3 } \hat { \beta }$ . we have the following theorem.
274
+
275
+ Theorem 1. Under the condition of Proposition $^ { l }$ , $i f \left( { \hat { \alpha } } , { \hat { \beta } } \right)$ satisfies (8), then with probability at least $\begin{array} { r } { 1 - 2 \exp \Big ( - \frac { \varphi ( n , M ) \epsilon _ { n } } { 1 5 6 \frac { \xi } { 1 - \xi } + 2 8 \log 2 } \Big ) } \end{array}$ , we have
276
+
277
+ $$
278
+ \frac { 1 } { n \sqrt { M } } \| \widehat { \Theta } - \Theta ^ { * } \| _ { F } \leq \frac { 4 \sqrt { 2 } \sqrt { \epsilon _ { n } } } { ( 1 - \xi ) \sqrt { \xi s _ { n } } } .
279
+ $$
280
+
281
+ 213 The condition that $\lambda _ { n } J ( \Theta ^ { * } ) ~ \le ~ \epsilon _ { n }$ in Proposition 1 is mild. It implies that the true em
282
+ 214 beddings of vertices within the same community are close to one another. We remark that
283
+ 215 $\lambda _ { n } J ( \Theta ^ { * } )$ exactly equals to zero under the MLSBM discussed in Section 2.2. The condition that
284
+ 216 $( n + M ) R \varphi ^ { - 1 } ( n , M ) \epsilon _ { n } ^ { - 1 } \log ( \epsilon _ { n } ^ { - 1 / 2 } )$ vanishes with $n$ is also mild. When $R = O ( 1 )$ , we can take any
285
+ 217 ϵn such that ϵn ≫ log nn min{n,M} . Consequently, to ensure $\widehat { \Theta }$ converges to $\Theta ^ { * }$ , Theorem 1 implies the
286
+ 218 smallest sparsity factor one can take is $\begin{array} { r } { s _ { n } \gg \epsilon _ { n } \gg \frac { \log n } { n \operatorname* { m i n } \{ n , M \} } } \end{array}$ log nn min{n,M} , which means that the average degree
287
+ 219 of a vertex in any particular layer can be as small as $n s _ { n }$ . We remark that a common assumption
288
+ 220 $M = O ( n )$ that appears in literature, such as [27] and [22], is not necessary in our theory. If we
289
+ 221 further assume $\bar { M } \stackrel { } { = } O ( n )$ , we find that the average degree of a vertex in any layer under the
290
+ 222 proposed TLSM set up can be smaller than that in [27] by a factor $( M \log n ) ^ { - 1 / 2 }$ and in [22] by a
291
+ 223 factor $( \log n ) ^ { - 3 }$ , showing that our theoretical result accommodates sparser multi-layer networks.
292
+
293
+ # 3.2 Consistency in community detection
294
+
295
+ We now turn to establish the consistency of community detection in multi-layer network $\mathcal { G }$ . Let $\psi ^ { * } : [ n ] \ \longrightarrow \ [ K ]$ be the true community assignment function such that $\begin{array} { r l } { \psi ^ { * } } & { { } = } \end{array}$ $\begin{array} { r l } & { \arg \operatorname* { m i n } _ { \psi } \operatorname* { m i n } _ { C _ { 1 } , \ldots , C _ { K } } \sum _ { i = 1 } ^ { n } \| \pmb { \alpha } _ { i } ^ { * } - C _ { \psi _ { i } } \| ^ { 2 } } \end{array}$ , and then the community detection error of any estimated community assignment function $\hat { \psi }$ can be evaluated by the minimum scaled Hamming distance between $\hat { \psi }$ and $\psi ^ { * }$ under permutations, which is defined as
296
+
297
+ $$
298
+ \operatorname { e r r } ( \psi ^ { * } , \hat { \psi } ) = \operatorname* { m i n } _ { \pi \in S _ { K } } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \mathbf { 1 } \{ \psi _ { i } ^ { * } \neq \pi ( \hat { \psi } _ { i } ) \} ,
299
+ $$
300
+
301
+ 230 where $\mathbf { 1 } \{ \cdot \}$ is the indicator function and $S _ { K }$ is the symmetric group of degree $K$ . Such a scaled
302
+ 231 or unscaled Hamming distance has become a popular metric in quantifying the performance of
303
+ 232 community detection [21, 22].
304
+ 233 Denote $N _ { k } ^ { * } = \{ i : \psi _ { i } ^ { * } = k \}$ be the $k$ -th true underlying community whose cardinality is $n _ { k }$ . Let
305
+ 234 $C ^ { * } \in \mathbb { R } ^ { K \times R }$ be the true underlying community centers of the network embedding with $C _ { k . } ^ { * } =$
306
+ 235 $\begin{array} { r } { \frac { 1 } { n _ { k } } \sum _ { \psi _ { i } ^ { * } = k } \alpha _ { i . } ^ { * } } \end{array}$ , and let $\pmb { \mathcal { B } } ^ { \ast } = \pmb { \mathcal { T } } \times _ { 1 } \pmb { C } ^ { \ast } \times _ { 2 } \pmb { C } ^ { \ast } \times _ { 3 } \pmb { \beta } ^ { \ast }$ . The following assumptions are made to ensure
307
+ 236 that communities within the multi-layer networks are asymptotically identifiable.
308
+
309
+ Assumption A. Assume the difference between any two distinct horizontal slides of 37 ${ \pmb { \beta } } ^ { * }$ satisfies that
310
+
311
+ $$
312
+ \operatorname* { m i n } _ { k , k ^ { \prime } \in [ K ] , k \neq k ^ { \prime } } \frac { 1 } { \sqrt { K M } } \| \pmb { \mathscr { B } } _ { k , . , . } ^ { * } - \pmb { \mathscr { B } } _ { k ^ { \prime } , . , . } ^ { * } \| _ { F } \geq \gamma _ { n } ,
313
+ $$
314
+
315
+ 238 where $\gamma _ { n } > 0$ may vanish with $n$
316
+
317
+ Assumption B. Assume the tuning parameter $\lambda _ { n }$ satisfies that
318
+
319
+ $$
320
+ \begin{array} { r } { \lambda _ { n } \epsilon _ { n } s _ { n } ^ { - 2 } ( \log s _ { n } ^ { - 1 } ) ^ { - 1 } \geq c _ { 2 } , } \end{array}
321
+ $$
322
+
323
+ for an absolute constant $c _ { 2 }$ that does not depend on any model parameter.
324
+
325
+ Assumption C. Denote $n _ { \mathrm { m i n } } = \mathrm { m i n } _ { k \in [ K ] } n _ { k }$ as the minimal community size. Assume
326
+
327
+ $$
328
+ \frac { \gamma _ { n } n _ { \mathrm { m i n } } \sqrt { \cal K } } { n } \geq c _ { \xi } \sqrt { \frac { \epsilon _ { n } } { s _ { n } } } ,
329
+ $$
330
+
331
+ where cξ =240 $\begin{array} { r } { c _ { \xi } = \frac { 4 \sqrt 2 } { ( 1 - \xi ) \sqrt \xi } + c _ { 3 } \sqrt { \frac { ( 1 + \delta ) \operatorname* { m i n } \{ M , R \} } { M } } } \end{array}$ and $c _ { 3 }$ is a constant that depends on $\xi$ only.
332
+
333
+ 241 Assumption A is the minimal community separation requirement, and similar assumption has been
334
+ 242 employed in [27] with a constant $\gamma _ { n }$ . Together with the condition $\lambda _ { n } J ( \alpha ^ { * } ) \leq \epsilon _ { n }$ in Proposition 1,
335
+ 243 Assumption B gives a feasible interval for $\lambda _ { n }$ . Assumption $\textrm { C }$ allows for unbalanced communities
336
+ 244 with vanishing $n _ { \mathrm { m i n } } / n$ if the network is not too sparse. Note that $c _ { \xi }$ can be further bounded by
337
+ 245 $\begin{array} { r } { \frac { 4 \sqrt { 2 } } { ( 1 - \xi ) \sqrt { \xi } } + c _ { 3 } \sqrt { 1 + \delta } } \end{array}$ , and the first term of $c _ { \xi }$ will dominate the second term if $R = o ( M )$ .
338
+
339
+ Theorem 2. Suppose all the assumptions in Theorem $^ { l }$ as well as Assumptions $A , B$ and $C$ are satisfied, it holds true that
340
+
341
+ $$
342
+ e r r ( \psi ^ { * } , \hat { \psi } ) \leq \frac { c _ { \xi } ^ { 2 } n \epsilon _ { n } } { n _ { \mathrm { m i n } } K \gamma _ { n } ^ { 2 } s _ { n } } ,
343
+ $$
344
+
345
+ with probability at least 246 $\begin{array} { r } { 1 - \frac { 1 } { n ^ { 2 } } - 2 \exp \Big ( - \frac { \varphi ( n , M ) \epsilon _ { n } } { 1 5 6 \frac { \xi } { 1 - \xi } + 2 8 \log 2 } \Big ) . } \end{array}$
346
+
347
+ Theorem 2 assures that the community structure in a multi-layer network can be consistently recovered by the proposed TLSM. As a theoretical example, we consider a sparse case with $\begin{array} { r } { s _ { n } = \dot { \frac { ( \log n ) ^ { 1 + \tau _ { 1 } } } { n \operatorname* { m i n } \{ n , M \} } } } \end{array}$ , where $0 < \tau _ { 1 } < 1$ , $n _ { \mathrm { m a x } } = O ( n _ { \mathrm { m i n } } )$ , $\begin{array} { r } { \frac { 1 } { \sqrt { n } } | | \alpha ^ { * } - Z ^ { * } C ^ { * } | | _ { F } \leq ( \log n ) ^ { - 3 / 2 } } \end{array}$ , and both $\gamma _ { n }$ , $R$ and $K$ are of constant orders. With $\begin{array} { r } { \lambda _ { n } = \frac { ( \log n ) ^ { 2 + 2 \tau _ { 1 } } } { n \operatorname* { m i n } \{ n , M \} } } \end{array}$ , Theorems 1 and 2 imply that $\begin{array} { r } { \epsilon _ { n } = \frac { ( \log n ) ^ { 1 + \tau _ { 2 } } } { n \operatorname* { m i n } \{ n , M \} } } \end{array}$ with $0 < \tau _ { 2 } < \tau _ { 1 }$ and $e r r ( \psi ^ { * } , \hat { \psi } ) = o _ { p } ( 1 )$ .
348
+
349
+ # 52 4 Numerical experiments
350
+
351
+ In this section, we evaluate the numerical performance of the proposed TLSM in a variety of synthetic as well as real-life multi-layer networks, compare it against four competitors in literature, including the mean adjacency spectral embeddings (MASE; 16), least square estimation (LSE; 27), Tucker decomposition with HOSVD initialization (HOSVD-Tucker; 22), and spectral kernel (SPECK; 35), and conduct some ablation studies. The implementations of LSE and SPECK are available at the authors’ personal websites, HOSVD-Tucker is implemented in the routine “tucker" of the Python package “tensorly", and TLSM and MASE are implemented in Python by ourselves.
352
+
353
+ # 4.1 Synthetic networks
354
+
355
+ The multi-layer network $\mathcal { A } = ( a _ { i , j , m } ) \in \{ 0 , 1 \} ^ { n \times n \times M }$ is generated as follows. First, we randomly select $K = 4$ elements uniformly from $\{ 2 . 5 * ( b _ { 1 } , b _ { 2 } , \ldots , b _ { R } ) : b _ { r } \in \{ - 1 , 1 \} , r \in [ R ] \}$ as community centers, which are denoted as $c _ { k }$ , $k \in [ K ]$ . Second, the latent space embedding of vertex $i$ is generated as $\pmb { \alpha } _ { i } = \pmb { c } _ { \psi _ { i } } + \pmb { e } _ { i }$ with $\pmb { e } _ { i } \sim N ( \mathbf { 0 } _ { R } , 1 . 5 * I _ { R } )$ , and $\psi _ { i } \in [ K ]$ are independently drawn from the multinomial distribution $\mathbf { M u l t i } ( 1 ; \frac { 1 } { K } \mathbf { 1 } _ { K } )$ . Third, we generate $\beta = [ \beta _ { 1 } , \ldots , \beta _ { M } ] ^ { T }$ with $\beta _ { m , r }$ being independent standard normal random varibeles, for $m \in [ M ]$ and $r \in [ R ]$ . We then rescale the column norms of $\beta$ to be 1 for model identifiability. Finally, we generate $\mathcal { A }$ according to the proposed TLSM with $s _ { n } = 0 . 1$ . For the sake of fair comparisons, the embedding dimension $R$ is set as $K$ in all scenarios. We aim to illustrate the community detection performance of all methods as the number of vertices and number of layers increase. To this end, we consider $( n , M ) \in \{ 2 0 0 , 4 0 0 , 6 0 0 , 8 0 0 \} \times \{ 5 , 1 0 , 1 5 , 2 0 \}$ . The averaged hamming errors and their standard errors over 50 independent experiments of all methods are reported in Table 1.
356
+
357
+ 273 It is evident that TLSM consistently outperforms its competitors, and the performances of LSE
358
+ 274 and HOSVD-Tucker are better than those of MASE and SPECK. This is expected since TLSM,
359
+ 275 LSE and HOSVD-Tucker work on the multi-layer network adjacency tensor directly, while MASE
360
+ 276 and SPECK are matrix aggregation methods that suffer form information loss. Furthermore, as the
361
+ 277 number of vertices and number of layers increase, the community detection errors of all methods
362
+ 278 decrease rapidly. Notably, TLSM and LSE converge faster than the other methods, and attain stable
363
+ 279 performance even for relatively small $n$ and $M$ . Additional simulation studies for various network
364
+ 280 sparsity and unbalanced community sizes are relegated to Appendix C in the supplementary materials.
365
+
366
+ # 4.2 Real-life networks
367
+
368
+ 282 We also apply the proposed TLSM method to analyze three real-life multi-layer networks, including
369
+ 283 a social network in the department of Computer Science at Aarhus University (AUCS) [38], a yeast
370
+ 284 Saccharomyces cerevisiae gene co-expression (YSCGC) network [44], and a worldwide agriculture
371
+ 285 trading network (WAT) [10]. Specifically, we conduct community detection on the first two networks
372
+ 286 whose vertex community memberships are available, and carry out a link prediction task on the third
373
+ 287 network whose vertex community memberships are unavailable.
374
+
375
+ Table 1: The averaged hamming errors of various methods with their standard errors in Scenario I. The best performer in each case is bold-faced.
376
+
377
+ <table><tr><td>n</td><td>M</td><td>TLSM</td><td>LSE</td><td>MASE</td><td>HOSVD-Tucker</td><td>SPECK</td></tr><tr><td rowspan="4">200</td><td>5</td><td>0.1180(0.0147)</td><td>0.1405(0.0118)</td><td>0.5086(0.0136)</td><td>0.1623(0.0126)</td><td>0.4254(0.0138)</td></tr><tr><td>10</td><td>0.0585(0.0046)</td><td>0.0751(0.0050)</td><td>0.4949(0.0131)</td><td>0.1148(0.0106)</td><td>0.2996(0.0141)</td></tr><tr><td>15</td><td>0.0551(0.0067)</td><td>0.0593(0.0045)</td><td>0.4910(0.0176)</td><td>0.1040(0.0115)</td><td>0.2505(0.0142)</td></tr><tr><td>20</td><td>0.0510(0.0037)</td><td>0.0588(0.0043)</td><td>0.4977(0.0161)</td><td>0.1023(0.0110)</td><td>0.1942(0.0156)</td></tr><tr><td rowspan="4">400</td><td>5</td><td>0.0653(0.0066)</td><td>0.1019(0.0087)</td><td>0.3845(0.0193)</td><td>0.1220(0.0106)</td><td>0.3766(0.0195)</td></tr><tr><td>10</td><td>0.0608(0.0063)</td><td>0.0636(0.0037)</td><td>0.3859(0.0160)</td><td>0.1012(0.0092)</td><td>0.2244(0.0191)</td></tr><tr><td>15</td><td>0.0511(0.0031)</td><td>0.0595(0.0036)</td><td>0.3844(0.0221)</td><td>0.0787(0.0051)</td><td>0.1490(0.0123)</td></tr><tr><td>20</td><td>0.0536(0.0047)</td><td>0.0551(0.0036)</td><td>0.3985(0.0185)</td><td>0.0795(0.0063)</td><td>0.1409(0.0131)</td></tr><tr><td rowspan="4">600</td><td>5</td><td>0.0607(0.0029)</td><td>0.0909(0.0040)</td><td>0.3665(0.0186)</td><td>0.1221(0.0108)</td><td>0.3038(0.0193)</td></tr><tr><td>10</td><td>0.0567(0.0029)</td><td>0.0688(0.0031)</td><td>0.3726(0.0179)</td><td>0.1003(0.0081)</td><td>0.1651(0.0127)</td></tr><tr><td>15</td><td>0.0558(0.0027)</td><td>0.0630(0.0030)</td><td>0.3803(0.0167)</td><td>0.0918(0.0076)</td><td>0.1231(0.0076)</td></tr><tr><td>20</td><td>0.0548(0.0028)</td><td>0.0586(0.0029)</td><td>0.3814(0.0185)</td><td>0.0883(0.0078)</td><td>0.1150(0.0088)</td></tr><tr><td rowspan="4">800</td><td>5</td><td>0.0556(0.0056)</td><td>0.0768(0.0055)</td><td>0.3012(0.0194)</td><td>0.1003(0.0103)</td><td>0.2733(0.0171)</td></tr><tr><td>10</td><td>0.0560(0.0063)</td><td>0.0583(0.0034)</td><td>0.3004(0.0177)</td><td>0.0788(0.0065)</td><td>0.1424(0.0127)</td></tr><tr><td>15</td><td>0.0498(0.0030)</td><td>0.0539(0.0033)</td><td>0.3179(0.0195)</td><td>0.0812(0.0068)</td><td>0.1146(0.0098)</td></tr><tr><td>20</td><td>0.0485(0.0031)</td><td>0.0516(0.0032)</td><td>0.3184(0.0218)</td><td>0.0803(0.0075)</td><td>0.0979(0.0078)</td></tr></table>
378
+
379
+ The AUCS dataset is publicly available at http://multilayer.it.uu.se/datasets.html, and it is a $6 1 \times 6 1 \times 5$ multi-layer network that records pairwise relationships of 5 types among 61 persons in AUCS, including current working relationships, repeated leisure activities, regularly eating lunch together, co-authorship of a publication, and friendship on Facebook. Since 54 persons in the dataset come from 7 research groups and the other 7 persons do not belong to any group, the dataset consists of 8 communities corresponding to 7 research groups and an outlier community. Applying TLSM and its competitors to the dataset, the number of misclassified vertices by TLSM, LSE, MASE, HOSVD-Tucker and SPECK, are 8, 21, 19, 23, 18, respectively. Clearly, TLSM significantly outperforms its competitors by at least reducing $1 6 . 3 9 \%$ of community detection error.
380
+
381
+ The YSCGC dataset is publicly available at https://www.ncbi.nlm.nih.gov/pmc/articles/ $\mathtt { P M C 1 5 6 5 9 0 } /$ , and contains 205 genes of 4 functional categories, including protein metabolism and modification, carbohydrate metabolism and catabolism, nucleobase, nucleoside, nucleotide and nucleic acide metabolism, as well as transportation. We regard these four functional category labels as the community memberships of the genes. Further, the gene expression responses are measured by 20 systematic perturbations with varying genetic and environmental conditions in 4 replicated hybridizations. We thus constructed a gene co-expression network $\mathcal { A } = ( a _ { i , j , m } ) \in$ $\mathbb { R } ^ { 2 0 \bar { 5 } \times 2 0 5 \times 4 }$ based on the similarities of their expressions, where each layer represents one replicated hybridization. Specifically, the similarity between genes $i$ and $j$ in the $m$ -th replication is measured by $w _ { i , j , m } = \mathrm { e x p } \big ( - \| \pmb { x } _ { i } ^ { ( m ) } - \pmb { x } _ { j } ^ { ( m ) } \| \big )$ , where $\pmb { x } _ { i } ^ { ( m ) } \in \mathbb { R } ^ { 2 0 }$ contains the expression levels of 20 perturbations in the $m$ -th replicated hybridization for $i \in [ 2 0 5 ]$ and $m \in [ 4 ]$ . The binary value $a _ { i , j , m }$ is obtained by thresholding $w _ { i , j , m }$ with the thresholding value being the $60 \%$ quantile of all elements in $\{ w _ { i , j , m } : i \le j \in [ 2 0 5 ] , m \in [ 4 ] \}$ . Applying TLSM and its competitors to this dataset, the number of misclassified vertices by TLSM, LSE, MASE, HOSVD-Tucker and SPECK, are 6, 9, 12, 48, 13, respectively. TLSM again outperforms its competitors in this YSCGC dataset.
382
+
383
+ 312 The WAT dataset is publicly available at http://www.fao.org, and includes 364 agriculture
384
+ 313 product trading relationships among 214 countries in 2010. To process the data, we extract 130 major
385
+ 314 countries whose average degrees are greater than 9 from the 32 densest connected agriculture product
386
+ 315 trading relations, leading to a $1 3 0 \times 1 3 0 \times 3 2$ multi-layer network. Investigating the eigen-structure
387
+ 316 of the mode-1 matricization of the network adjacency tensor, we identify an elbow point [20] at the
388
+ 317 7th largest eigen-value, suggesting there are 6 potential communities among the countries, and thus
389
+ 318 we set $K = 6$ . The corresponding eigen-value plot is attached in Appendex D of the supplementary
390
+ 319 materials. We then randomly selected $8 0 \%$ of the entries of the adjacency tensor as the training set,
391
+ 320 and conduct link prediction on the remaining $2 0 \%$ of the entries. Specifically, we employ TLSM
392
+ 321 and the adaptations of its competitors to estimate the network expected tensor $\mathcal { P }$ and generate
393
+ 322 estimations for the missing entries by independent Bernoulli random variables accordingly. The
394
+ 323 averaged link prediction accuracy of TLSM, LSE, MASE, HOSVD-Tucker and SPECK over 50
395
+ 324 independent replications are $7 9 . 6 0 \%$ , $7 6 . 6 6 \%$ , $7 5 . 9 6 \%$ , $7 7 . 7 8 \%$ and $7 9 . 0 8 \%$ , respectively, where the
396
+ 325 link prediction accuracy is defined as the percentile of the correctly predicted entries. Clearly, all 5
397
+ 326 methods are comparative in terms of link prediction, while TLSM still deliver highest averaged link
398
+ 327 prediction accuracy.
399
+
400
+ # 328 4.3 Ablation studies
401
+
402
+ In this subsection, we carry out some ablation studies on two novel components of the proposed method, namely the sparsity factor $s _ { n }$ and the community-inducing regularizer $J ( \alpha )$ . To study the effectiveness of $s _ { n }$ , we generate a $3 0 0 \times 3 0 0 \times 5$ multi-layer network with 3 communities and the true network sparsity $s _ { n } = 0 . 3$ . The blue curve in the left panel of Figure 1 shows the average Hamming error of 50 independent replications given by the proposed method when employing $\hat { s } _ { n } \in \{ 0 . 0 5 i : i \in [ 2 0 ] \}$ in the optimization algorithm, and the red line indicates the averaged Hamming error of the proposed method with $\hat { s } _ { n }$ estimated via the proposed data-adapted estimation scheme. It is clear that the Hamming error at $s _ { n } = 1$ is much larger than that when $s _ { n }$ is close to 0.3, showing the advantages of the modified logit transformation by $s _ { n }$ over the standard logit transformation when the network indeed reveals sparse pattern. Moreover, we observe that the red line is even lower than the minimum Hamming error in the blue curve. This further confirms the effectiveness of the proposed data-adapted estimation scheme for estimating $s _ { n }$ .
403
+
404
+ ![](images/c331ba0dbd825a27deb1e7af3e215fd861180ab5cae8dc4dc8e45ed78969d719.jpg)
405
+ Figure 1: Ablation studies on $s _ { n }$ (left) and community-inducing regularizer (right).
406
+
407
+ 341 To study the effectiveness of the community-inducing regularizer in the proposed objective function,
408
+ 342 we generate an $n \times n \times 5$ multi-layer network with 2 communities, for $\overline { { n } } \in \{ 5 0 , 1 0 \mathrm { { 0 } } , 2 0 0 , 4 0 0 \}$ . In
409
+ 343 the right panel of Figure 1, the black pillars indicate the network estimation error $\frac { 1 } { n \sqrt { 5 } } \| \widehat { \Theta } - \Theta ^ { * } \| _ { F }$
410
+ 344 given by the proposed method with $\lambda _ { n } = 0$ which corresponds to the absence of $J ( \alpha )$ , while the
411
+ 345 red ones indicate the counterparts given by the proposed method with $\lambda _ { n }$ is selected by network
412
+ 346 cross-validation. There is a clear improvement when the community-inducing regularizer is enforced
413
+ 347 in all scenarios, particularly for small $n$ . This showcases the helpfulness of the community-inducing
414
+ 348 regularizer in detecting network community structure.
415
+
416
+ # 349 5 Conclusions
417
+
418
+ 50 In this paper, we propose a novel tensor-based latent space model for community detection in
419
+ 51 multi-layer networks. The model embeds vertices into a low-dimensional latent space and views
420
+ 52 the community structure from an network embedding perspective, so that heterogeneous structures
421
+ 53 in different network layers can be properly integrated. The proposed model is formulated as a
422
+ 54 regularization framework, which conducts multi-layer network estimation and community detection
423
+ 55 simultaneously. The advantages of the proposed method are supported by extensive numerical
424
+ 56 experiments and theoretical results. Particularly, the asymptotic consistencies of the proposed method
425
+ 57 are established in terms of both multi-layer network estimation and community detection, even for
426
+ 58 relatively sparse networks.
427
+
428
+ 359 References [1] Luiz GA Alves, Giuseppe Mangioni, Isabella Cingolani, Francisco Aparecido Rodrigues, Pietro Panzarasa, and Yamir Moreno. The nested structural organization of the worldwide trade multi-layer network. Scientific reports, 9(1):1–14, 2019. [2] Jesús Arroyo, Avanti Athreya, Joshua Cape, Guodong Chen, Carey E Priebe, and Joshua T Vogelstein. Inference for multiple heterogeneous networks with a common invariant subspace. Journal of Machine Learning Research, 22(142):1–49, 2021. [3] Avanti Athreya, Donniell E Fishkind, Minh Tang, Carey E Priebe, Youngser Park, Joshua T Vogelstein, Keith Levin, Vince Lyzinski, and Yichen Qin. Statistical inference on random dot product graphs: a survey. The Journal of Machine Learning Research, 18(1):8393–8484, 2017. [4] Matteo Barigozzi, Giorgio Fagiolo, and Giuseppe Mangioni. Identifying the community structure of the international-trade multi-network. Physica A: statistical mechanics and its applications, 390(11):2051–2066, 2011. [5] Michele Berlingerio, Fabio Pinelli, and Francesco Calabrese. Abacus: frequent pattern miningbased community discovery in multidimensional networks. Data Mining and Knowledge Discovery, 27(3):294–320, 2013. [6] Sharmodeep Bhattacharyya and Shirshendu Chatterjee. Spectral clustering for multiple sparse networks: I. arXiv preprint arXiv:1805.10594, 2018. [7] Han Chen, Garvesh Raskutti, and Ming Yuan. Non-convex projected gradient descent for generalized low-rank tensor regression. Journal of Machine Learning Research, 20:1–37, 2019. [8] Zitai Chen, Chuan Chen, Zibin Zheng, and Yi Zhu. Tensor decomposition for multilayer networks clustering. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 3371–3378, 2019. [9] Eric C Chi, Brian R Gaines, Will Wei Sun, Hua Zhou, and Jian Yang. Provable convex co-clustering of tensors. Journal of Machine Learning Research, 21(214):1–58, 2020. [10] Manlio De Domenico, Vincenzo Nicosia, Alexandre Arenas, and Vito Latora. Structural reducibility of multilayer networks. Nature communications, 6(1):1–9, 2015.
429
+ 386 [11] Lieven De Lathauwer, Bart De Moor, and Joos Vandewalle. On the best rank-1 and rank-(r 1, r 2,..., rn) approximation of higher-order tensors. SIAM journal on Matrix Analysis and Applications, 21(4):1324–1342, 2000. [12] Xiaowen Dong, Pascal Frossard, Pierre Vandergheynst, and Nikolai Nefedov. Clustering with multi-layer graphs: A spectral perspective. IEEE Transactions on Signal Processing, 60(11):5820–5831, 2012. [13] Junxian Geng, Anirban Bhattacharya, and Debdeep Pati. Probabilistic community detection with unknown number of communities. Journal of the American Statistical Association, 114(526):893–905, 2019.
430
+ 395 [14] Mahsa Ghorbani, Mahdieh Soleymani Baghshah, and Hamid R Rabiee. Mgcn: semi-supervised classification in multi-layer graphs with graph convolutional networks. In Proceedings of the 2019 IEEE/ACM International Conference on Advances in Social Networks Analysis and Mining, pages 208–211, 2019. [15] Derek Greene and Pádraig Cunningham. Producing a unified graph representation from multiple social network views. In Proceedings of the 5th annual ACM web science conference, pages 118–121, 2013. [16] Qiuyi Han, Kevin Xu, and Edoardo Airoldi. Consistent estimation of dynamic and multi-layer block models. In International Conference on Machine Learning, pages 1511–1520. PMLR, 2015. [17] Xin He, Qiong Liu, and You Yang. Mv-gnn: Multi-view graph neural network for compression artifacts reduction. IEEE Transactions on Image Processing, 29:6829–6840, 2020.
431
+ [18] Peter D Hoff, Adrian E Raftery, and Mark S Handcock. Latent space approaches to social network analysis. Journal of the American Statistical Association, 97(460):1090–1098, 2002.
432
+ [19] Paul W Holland, Kathryn Blackmond Laskey, and Samuel Leinhardt. Stochastic blockmodels: First steps. Social networks, 5(2):109–137, 1983.
433
+ [20] Pengsheng Ji and Jiashun Jin. Coauthorship and citation networks for statisticians. The Annals of Applied Statistics, 10(4):1779–1812, 2016.
434
+ [21] Jiashun Jin. Fast community detection by score. Ann. Statist., 43(1):57–89, 02 2015.
435
+ [22] Bing-Yi Jing, Ting Li, Zhongyuan Lyu, and Dong Xia. Community detection on mixture multilayer networks via regularized tensor decomposition. The Annals of Statistics, 49(6):3181– 3205, 2021.
436
+ [23] Muhammad Raza Khan and Joshua E Blumenstock. Multi-gcn: Graph convolutional networks for multi-view networks, with applications to global poverty. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 606–613, 2019.
437
+ [24] Tamara G. Kolda and Brett W. Bader. Tensor decompositions and applications. SIAM Review, 51:455–500, 2009.
438
+ [25] Joseph B Kruskal. Three-way arrays: rank and uniqueness of trilinear decompositions, with application to arithmetic complexity and statistics. Linear algebra and its applications, 18(2):95– 138, 1977.
439
+ [26] Jing Lei. Tail bounds for matrix quadratic forms and bias adjusted spectral clustering in multi-layer stochastic block models. arXiv preprint arXiv:2003.08222, 2020.
440
+ [27] Jing Lei, Kehui Chen, and Brian Lynch. Consistent community detection in multi-layer network data. Biometrika, 107(1):61–73, 2020.
441
+ [28] Jing Lei and Alessandro Rinaldo. Consistency of spectral clustering in stochastic block models. The Annals of Statistics, 43(1):215–237, 2015.
442
+ [29] Dong Li, Zhisong Pan, Guyu Hu, Graham Anderson, and Shan He. Active module identification from multilayer weighted gene co-expression networks: a continuous optimization approach. IEEE/ACM transactions on computational biology and bioinformatics, 2020.
443
+ [30] Tianxi Li, Elizaveta Levina, and Ji Zhu. Network cross-validation by edge sampling. Biometrika, 107(2):257–276, 2020.
444
+ [31] Xueming Liu, Enrico Maiorino, Arda Halu, Kimberly Glass, Rashmi B Prasad, Joseph Loscalzo, Jianxi Gao, and Amitabh Sharma. Robustness and lethality in multilayer biological molecular networks. Nature communications, 11(1):1–12, 2020.
445
+ [32] Zhongyuan Lyu, Dong Xia, and Yuan Zhang. Latent space model for higher-order networks and generalized tensor decomposition. arXiv preprint arXiv:2106.16042, 2021.
446
+ [33] Zhuang Ma, Zongming Ma, and Hongsong Yuan. Universal latent space model fitting for large networks with edge covariates. Journal of Machine Learning Research, 21(4):1–67, 2020.
447
+ [34] Subhadeep Paul and Yuguo Chen. Consistent community detection in multi-relational data through restricted multi-layer stochastic blockmodel. Electronic Journal of Statistics, 10(2):3807–3870, 2016.
448
+ [35] Subhadeep Paul and Yuguo Chen. Spectral and matrix factorization methods for consistent community detection in multi-layer networks. Ann. Statist., 48(1):230–250, 02 2020.
449
+ [36] Subhadeep Paul and Yuguo Chen. Null models and community detection in multi-layer networks. Sankhya A, pages 1–55, 2021.
450
+ [37] Zhuo-Ming Ren, An Zeng, and Yi-Cheng Zhang. Bridging nestedness and economic complexity in multilayer world trade networks. Humanities and Social Sciences Communications, 7(1):1–8, 2020.
451
+ [38] Luca Rossi and Matteo Magnani. Towards effective visual analytics on multiplex and multilayer networks. Chaos, Solitons & Fractals, 72:68–76, 2015.
452
+ [39] Uday Shankar Shanthamallu, Jayaraman J Thiagarajan, Huan Song, and Andreas Spanias. Gramme: Semisupervised learning using multilayered graph attention models. IEEE transactions on neural networks and learning systems, 31(10):3977–3988, 2019.
453
+ [40] Nicholas D Sidiropoulos and Rasmus Bro. On the uniqueness of multilinear decomposition of n-way arrays. Journal of Chemometrics: A Journal of the Chemometrics Society, 14(3):229–239, 2000.
454
+ [41] Wei Tang, Zhengdong Lu, and Inderjit S Dhillon. Clustering with multiple graphs. In 2009 Ninth IEEE International Conference on Data Mining, pages 1016–1021. IEEE, 2009.
455
+ [42] Edwin JCG Van Den Oord and Ronan Van Rossem. Differences in first graders’ school adjustment: The role of classroom characteristics and social structure of the group. Journal of School Psychology, 40(5):371–394, 2002.
456
+ [43] James D Wilson, John Palowitch, Shankar Bhamidi, and Andrew B Nobel. Community extraction in multilayer networks with heterogeneous community structure. The Journal of Machine Learning Research, 18(1):5458–5506, 2017.
457
+ [44] Ka Yee Yeung, Mario Medvedovic, and Roger E Bumgarner. Clustering gene-expression data with repeated measurements. Genome biology, 4(5):1–17, 2003.
458
+ [45] Yubai Yuan and Annie Qu. Community detection with dependent connectivity. The Annals of Statistics, 49(4):2378–2428, 2021.
459
+ [46] Jingfei Zhang, Will Wei Sun, and Lexin Li. Network response regression for modeling population of networks with covariates. arXiv preprint arXiv:1810.03192, 2018.
460
+ [47] Xuefei Zhang, Songkai Xue, and Ji Zhu. A flexible latent space model for multilayer networks. In International Conference on Machine Learning, pages 11288–11297. PMLR, 2020.
461
+ [48] Yunpeng Zhao, Elizaveta Levina, and Ji Zhu. Consistency of community detection in networks under degree-corrected stochastic block models. The Annals of Statistics, 40(4):2266–2292, 2012.
462
+ [49] Wei Zheng, Dingjie Wang, and Xiufen Zou. Control of multilayer biological networks and applied to target identification of complex diseases. BMC bioinformatics, 20(1):1–12, 2019.
463
+
464
+ # Checklist
465
+
466
+ 1. For all authors...
467
+
468
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See the abstract and the third paragrath of the introduction.
469
+ (b) Did you describe the limitations of your work? [Yes] The optimization algorithm can only be guaranteed to converge to a stationary point.
470
+ (c) Did you discuss any potential negative societal impacts of your work? [No] There should be no negative societal impacts.
471
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
472
+
473
+ 2. If you are including theoretical results...
474
+
475
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 3. (b) Did you include complete proofs of all theoretical results? [Yes] All technical proofs are provided in Appendix E of the supplementary materials.
476
+
477
+ 3. If you ran experiments...
478
+
479
+ (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 URLs for data are included in Section 4.2, and codes with instructions are included in the supplementary materials.
480
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 2.3 and Appendix B in the supplementary materials.
481
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We show the standard erros in Table 1 and $9 5 \%$ confident intervals of additional simulation studies in Appendix C in the supplementary materials.
482
+ (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]
483
+
484
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
485
+
486
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We used publicly available datasets and cite the creators.
487
+ (b) Did you mention the license of the assets? [Yes] All datasets we used are publicly available.
488
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
489
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
490
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] All data we used do not contains personally identifiable information or offensive content.
491
+
492
+ 5. If you used crowdsourcing or conducted research with human subjects...
493
+
494
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
495
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
496
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/uy602F8cTrh/uy602F8cTrh.md ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CAUSALDYNA: IMPROVING GENERALIZATION OF DYNA-STYLE REINFORCEMENT LEARNING VIA COUNTERFACTUAL-BASED DATA AUGMENTATION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Deep reinforcement learning agents trained in real-world environments with a limited diversity of object properties to learn manipulation tasks tend to suffer overfitting and fail to generalize to unseen testing environments. To improve the agents’ ability to generalize to object properties rarely seen or unseen, we propose a dataefficient reinforcement learning algorithm, CausalDyna, that exploits structural causal models (SCMs) to model the state dynamics. The learned SCM enables us to counterfactually reason what would have happened had the object had a different property value. This can help remedy limitations of real-world environments or avoid risky exploration of robots (e.g., heavy objects may damage the robot). We evaluate our algorithm in the CausalWorld robotic-manipulation environment. When augmented with counterfactual data, our CausalDyna outperforms state-ofthe-art model-based algorithm, MBPO and model-free algorithm, SAC in both sample efficiency by up to $17 \%$ and generalization by up to $30 \%$ . Code will be made publicly available.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Classical model-free reinforcement learning approaches require a massive amount of data collected in the environment to work, which slows down its success in tasks where data collection is timeconsuming or costly, like robot manipulation. Model-based reinforcement learning (MBRL) methods alleviate this issue by maintaining a world model that simulates the real environment. The world model can serve as a surrogate of the real environment for the agent to interact with to reduce the amount of the required time-consuming interaction in the real environment. MBRL methods (Kaelbling et al., 1996; Wang et al., 2019; Janner et al., 2019) learn from model rollouts of previously observed states. Recently, CTRL (Lu et al., 2020) takes a structural causal model (SCM) approach that can generate samples counterfactually had a different action had been taken for a state previously observed. However, these methods are limited for robotic manipulation tasks since the environment is often the key limiting factor. In this paper, we perform counterfactual reasoning on the object properties. For example, when the task manipulates objects with different masses, the real environment may not have a uniform distribution of object masses. Furthermore, to avoid damaging the robot, certain exploration of the gripper torque may be limited during training.
12
+
13
+ To this end, we propose a Dyna-style MBRL method, CausalDyna in robotics that improves the policy performance by counterfactual reasoning of physics properties of objects and enriching the diversity of the generated rollouts. We leverage the structural causal model (SCM) to model the state dynamics. CausalDyna can be applied to generate episodes with unseen or rarely seen objects to improve the sample efficiency and generalization of the policy.
14
+
15
+ Our contributions are summarized as follows.
16
+
17
+ • We introduce a novel Dyna-style causal reinforcement learning algorithm, dubbed as CausalDyna that learns from counterfactually generated episodes with intervened object property values. • We compare with state-of-the-art model based reinforcement learning algorithm, MBPO and model free algorithm, SAC on the CausalWorld environment. Experimental results show that CausalDyna outperforms MBPO and SAC on sample efficiency by up to $17 \%$ and generalization by up to $30 \%$ when manipulating objects with unseen or rarely seen properties.
18
+
19
+ ![](images/1fe3984bb406fc8def7ea8b40a25b5f4092376e757249f210522ee2712f02696.jpg)
20
+ Figure 1: In classical Dyna-style methods, the world model generates episodes starting from a real environment state. Then, our robot can practice in the world model and learn how to manipulate the original object. To improve the generalization of the learned policy, we further modified the object property in the state. So the robot has the chance to play with objects with more diverse properties.
21
+
22
+ # 2 RELATED WORK
23
+
24
+ Causal Inference in Reinforcement Learning There is an increasing interest in causal inference in the field of reinforcement learning. Counterfactually-Guided Policy Search (CF-GPS) (Buesing et al., 2018) assumes that the real transition, observation, and reward functions are all known. They show that any partially observable Markov decision process (POMDP) can be represented as a structural causal model (SCM). Therefore, counterfactual inference can be applied to improve the offpolicy evaluation and policy-guided search. CounTerfactual Reinforcement Learning (CTRL) (Lu et al., 2020) leverages bidirectional conditional GAN to model the environment dynamic for data augmentation. The model takes a noise vector as input besides the state and action to model the randomness of the environment. Before generating counterfactual data given alternative actions, they first infer the value of this noise vector. Then, the inferred noise is used to generate predictions with new actions. Causal Partial Models (CPM) (Rezende et al., 2020) studies the causal incorrectness of world models that don’t condition on the full observation. To fix this issue, CPM introduces a backdoor variable that helps the rollout of the model to be causally correct. We propose an SCM framework to model the physics properties of objects across the temporal dimension. In addition, we show that generating episodes with counterfactual object properties helps improve the generalization of the learned policy.
25
+
26
+ Model-Based Reinforcement Learning Model-based Reinforcement Learning (MBRL) approaches have shown a potential to improve the sample efficiency by a large margin compared to classical model-free approaches (Kaelbling et al., 1996; Wang et al., 2019). Autoencoder-based algorithms like World Models (Ha & Schmidhuber, 2018) and Dreamer (Hafner et al., 2019; 2020) use the world model to better represent the visual observation and faster the policy training. Policy Search with Backpropagation algorithms like PILCO (Deisenroth & Rasmussen, 2011; Deisenroth et al., 2013; Kamthe & Deisenroth, 2018) and GPS (Levine & Koltun, 2013; Levine & Abbeel, 2014; Montgomery & Levine, 2016) train the policy by maximizing the simulated return of the policy in the world model. Because the world model is differentiable, the policy can be directly trained by gradient descent. Shooting algorithms like PETS-RS (Chua et al., 2018) and MB-MF (Nagabandi et al., 2018) alleviate the receding horizon problem in model predictive control (MPC). Recent works include Ross & Bagnell (2012), MOPO, (Yu et al., 2020) and Morel (Kidambi et al., 2020) show that MBRL can work well in the offline RL setting. Unlike the traditional MBRL that approximates the local transition function, $L ^ { 3 } P$ (Zhang et al., 2021) builds the world model as a graph of states for better reasoning ability. Dyna-style algorithms (Sutton, 1990; 1991a;b) use the learned world model to roll out simulated episodes to reduce the demand for real data for policy training. As a recent development of Dyna-style algorithms, ME-TRPO (Kurutach et al., 2018) uses an ensemble of world models to catch the epistemic uncertainty; MB-MPO (Clavera et al., 2018) viewed each model in the ensemble as a task and meta-learn a policy that adapts quickly to handle the model-bias issue; MBPO (Janner et al., 2019) rolls out short episodes branched from real data to improve the generation quality. Our method follows the Dyna-style framework and targets designing and using a causal world model to generate better and more diverse rollouts in robotic environments.
27
+
28
+ ![](images/3df83d14df549a7acc4d51cb383977289414fcb2422ffaf5d756792bd5daca98.jpg)
29
+ Figure 2: The structure causal model of a robot environment. The time-invariant property is modeled as a node $_ { \mathbf { \nabla } } \mathbf { m } _ { \mathbf { \nabla } }$ across the temporal dimension that affects all the causal mechanisms. $s _ { - m , t }$ and $\mathbf { } \mathbf { a } _ { t }$ denotes the time-variant state and the action at the step $t$ , respectively.
30
+
31
+ # 3 BACKGROUND
32
+
33
+ # 3.1 STRUCTURAL CAUSAL MODEL
34
+
35
+ Structural Causal Model (SCM) is a widely used framework to describe the causal mechanism of a system. Let’s denote $\mathbb { X } = \{ \mathbf { x } _ { 1 } , . . . , \mathbf { x } _ { N } \}$ as the set of $N$ variables in a system. Knowing their causal relationships allows us to build a directed acyclic causal graph to describe this system. Each node represents a variable, which is directly caused by its parent nodes. In this way, a node ${ \bf x } _ { n }$ can be modeled as the following function:
36
+
37
+ $$
38
+ { \bf x } _ { n } = f _ { i } ( P a _ { 0 \mathrm { b s } } ( { \bf x } _ { n } ) , { \bf u } _ { n } )
39
+ $$
40
+
41
+ Here, $P a _ { \mathrm { o b s } } ( \mathbf { x } _ { n } )$ denotes the observed parent nodes of ${ \bf x } _ { n }$ . $\mathbf { u } _ { n }$ is a noise that represents the effect of omitted factors. This function is also called a causal mechanism. SCM is the set of these causal mechanisms that describes the whole system. SCM defines a joint distribution of the variables $p ( \mathbf { x } _ { 1 } , . . . , \mathbf { x } _ { N } )$ following the causal Markov assumption: given its direct causes, each variable ${ \bf x } _ { n }$ is independent of other indirect causal variables.
42
+
43
+ # 3.2 DYNA-STYLE MODEL-BASED REINFORCEMENT LEARNING
44
+
45
+ Dyna-style model-based reinforcement learning uses the world model to roll out simulated episodes, which can be viewed as data augmentation. The training of Dyna-style MBRL is composed of three steps: First, the agent interacts with the real environment and collects real data to train the world model. Then, this world model is used as a simulator of the real environment for the agent to interact and collect simulated data. After that, the agent can be trained together with the real and the simulated data using classical model-free reinforcement learning algorithms. These three steps are executed repeatedly until the training converges. In case we apply Dyna-Style algorithm on RL algorithms with experience-replay buffers and would like to collect whole simulated episodes, as the world model is trained to only approximate the transition of the environment $p ( \pmb { s } _ { t + 1 } | \pmb { s } _ { t } , \pmb { a } _ { t } )$ , we need an initial state to start the simulated episodes. A usual way to solve it is using the first state or a randomly sampled state $\mathbf { \Delta } _ { \mathbf { \mathcal { S } } _ { t } }$ from the collected real episodes as the start point of the simulated episodes. As the real episode already contains the future of $\mathbf { \boldsymbol { s } } _ { t }$ under the original action sequence $\{ a _ { t } , \pmb { a } _ { t + 1 } , . . . \}$ executed in this episode, generating new simulated episodes starting from $\mathbf { } _ \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf { }$ under different action sequences can be viewed as answering a counterfactual “what if” question: What would happen if the agent behave differently this time instead of doing $\{ a _ { t } , a _ { t + 1 } , \ldots \} \colon$ The world model gives the agent a chance to figure out the answer without interacting in the real environment, and helps the agent learn faster.
46
+
47
+ Data: Rollout length $K$ , Real experience buffer $\mathbb { D } _ { r }$ , Policy $p _ { \pi }$ , World model $p _ { W M }$ , Counterfactual property space $M$ , Empty episode buffer $\mathbb { B }$ Result: $\mathbb { B }$ 1 Sample a state $\pmb { s } = [ \pmb { s } _ { - m } ; m ]$ from the real experience buffer $\mathbb { D } _ { r }$ , $\mathbb { B }$ .append(s) 2 Sample a counterfactual property value $_ { \mathbf { \Omega } ^ { m } C F }$ from $M$ , set $\tilde { \pmb { s } } = \left[ \pmb { s } _ { - m } ; m _ { C F } \right]$ 3 for $K$ steps do 4 $\tilde { \mathbf { a } } \sim p _ { \pi } ( \mathbf { a } | \tilde { s } )$ , $\tilde { \pmb { s } } ^ { \prime } \sim p _ { W M } ( \pmb { s } ^ { \prime } | \tilde { \pmb { s } } , \tilde { \pmb { a } } )$ 5 $\mathbb { B }$ .append $( \tilde { \pmb { a } } , \tilde { \pmb { s } } ^ { \prime } )$ , $\tilde { s } \gets \tilde { s } ^ { \prime }$ 6 end
48
+
49
+ # 4 METHOD
50
+
51
+ # 4.1 STRUCTURE CAUSAL MODEL OF A ROBOT ENVIRONMENT
52
+
53
+ Let’s consider an environment where a robot needs to manipulate an object. We can describe this environment using different states. Many of these states are changing over time, including the object position and the end-effect position. It is important to model them as they directly contain the dynamic information of the environment. Some other states are time-invariant, like the object mass or the floor friction coefficient. Although their values are fixed, they determine the environment dynamics and affect how other time-variant states change. Let’s denote the total state at step $t$ as $\mathbf { \boldsymbol { s } } _ { t }$ . $\pmb { s } _ { t } = [ \pmb { s } _ { - m , t } ; \pmb { m } ]$ is the concatenation of the time-variant state $s _ { - m , t }$ at step $t$ and the object timeinvariant property $_ { m }$ . The motor torque to execute at step $t$ is denoted as $\mathbf { } \mathbf { a } _ { t }$ . As shown in Fig.2, we can build a structural causal model (SCM) to describe this environment. The time-invariant property $_ { m }$ is modeled as a fixed node across the temporal dimension, which affects all the causal mechanisms.
54
+
55
+ # 4.2 COUNTERFACTUAL PROPERTY GENERATION
56
+
57
+ Policy generalization ability is essential as the testing environment of the policy is not always the same as the training environment. For example, when learning to lift an object, the robot might only interact with objects whose masses are in a suitable range. Lifting frequently a too-heavy object might reduce its service life, and most reinforcement learning algorithms need a large amount of interaction data to work. However, knowing how to lift a heavy object is still desirable when deploying the robot. A typical Dyna-style method generates simulated rollouts branching from a starting state seen in previous real episodes. If the world model takes physics properties as input, it is possible to go a step further and intervene in these properties. For example, we could modify the mass of an object in the world model to make it heavier. So the agent can learn to manipulate them in the world model as much as we want without harming its service life. Inspired by this, we design a simple generation strategy to enrich the simulated rollouts by modifying the original object’s property to improve the policy generalization. Concretely, instead of taking a starting state $\pmb { s } _ { t } ~ = ~ [ \pmb { s } _ { - m , t } ; \pmb { m } ]$ sampled from real episodes as it is like most of the Dyna-style methods, we replace the object property $_ { m }$ by a desired counterfactual value $_ { \mathbf { \Omega } ^ { m } C F }$ sampled from a predefined counterfactual property space $M$ before rolling out the simulated episodes. We name this type of episodes generation as counterfactual property generation, illustrate it in Fig.1 and show the process in Alg.1.
58
+
59
+ # 4.3 TRAINING PROCEDURE
60
+
61
+ The training of our model follows the Dyna-style model-based reinforcement learning framework. The world model is an additional imperfect substitute for the real environment for the policy to interact with. The policy is still trained using the traditional model-free reinforcement learning approach, but the data for training is a mixture of the data from the real environment data and that from the world model. During the training procedure, we maintain two replay buffers. The real experience replay buffer $\mathbb { D } _ { r }$ stores the interaction data from the real environment. The world model is trained using the real experience replay buffer only. The simulated episodes from the world model
62
+
63
+ # Algorithm 2: Training Procedure
64
+
65
+ Data: Policy $p _ { \pi }$ , World model $p _ { W M }$ , Empty real experience replay buffer $\mathbb { D } _ { r }$ , Empty episode buffer $\mathbb { B }$ , Rollout length $K$ , Counterfactual property space $M$ , Counterfactual generation ratio $\alpha$ Result: Trained Policy $p _ { \pi }$ 1 Prefill $\mathbb { D } _ { r }$ by executing the untrained policy $p _ { \pi }$ in the environment 2 while Not Converge do 3 Split $\mathbb { D } _ { r }$ into a training set $\mathbb { D } _ { r , t r a i n }$ and holdout set $\mathbb { D } _ { r , h o l d o u t }$ randomly 4 Train the world model $p _ { W M }$ on $\mathbb { D } _ { r , t r a i n }$ until converge on $\mathbb { D } _ { r , h o l d o u t }$ 5 Empty the simulated experience buffer $\mathbb { D } _ { s }$ 6 Generate $\alpha \% \cdot N _ { f }$ simulated episodes with $K$ steps by counterfactual property generation as Alg.1 to $\mathbb { D } _ { s }$ 7 Generate $( 1 - \alpha \% ) \cdot N _ { f }$ simulated episodes with $K$ steps with original property to $\mathbb { D } _ { s }$ 8 for $E$ steps do 9 Collect a step of data in the real environment; add it to $\mathbb { D } _ { r }$ 10 Update policy parameters via SAC on the combination of $\mathbb { D } _ { r }$ and $\mathbb { D } _ { s }$ for $G$ steps 11 end 12 end
66
+
67
+ are stored in the simulated experience buffer $\mathbb { D } _ { s }$ , which is used to train the policy net and the real experience replay buffer $\mathbb { D } _ { r }$ . The whole training procedure is shown in Alg.2. The policy is trained via soft actor-critic (SAC) (Haarnoja et al., 2018) using the data from both the real experience buffer $\mathbb { D } _ { r }$ and the simulated buffer $\mathbb { D } _ { s }$ . As we generate the simulated episodes with counterfactual property and we following the Dyna-style MBRL framework, we name our model CausalDyna.
68
+
69
+ World Model Training Each time the world model is trained, the real experience replay buffer $\mathbb { D } _ { r }$ is split into a training set, and a holdout set randomly. The world model is trained to predict the next state $\mathbf { } s _ { t + 1 }$ by maximizing the log-likelihood given the current state $\mathbf { \boldsymbol { s } } _ { t }$ and the action $\mathbf { } \mathbf { a } _ { t }$ in the training set until converging measured by the holdout set.
70
+
71
+ Augment Data Collection We adopt the generation strategy of model-based policy optimization (MBPO) (Janner et al., 2019) to roll out the world model. The simulated episodes start from a real state randomly sampled from the real experience replay buffer $\mathbb { D } _ { r }$ and are rolled out for $K$ steps. We generate two types of simulated episodes: $\alpha \%$ of the rollouts are generated with counterfactual property generation, where we intervene the object property as described in Alg.1 to generate episodes with different objects. The remaining $( 1 - \alpha \% )$ episodes are generated using the original property. Each time $N _ { f }$ simulated episodes are generated in total. Note that each time we collect the simulated episodes, all the previous data in the simulated experience buffer $\mathbb { D } _ { s }$ is discarded as the world model generated them a few training steps before and are not ‘fresh’ anymore.
72
+
73
+ # 5 EXPERIMENTS
74
+
75
+ # 5.1 BENCHMARK
76
+
77
+ We evaluate our method CausalDyna on a recently proposed robotic benchmark CausalWorld (Ahmed et al., 2020). CausalWorld is designed for causal structure and transfer learning in a robotic manipulation environment. The robot in CausalWorld is a 3-finger gripper. Each finger has three joints. The mission of the robot is to move objects to specified target locations. The observations of the CausalWorld we use includes the time stamp $t$ , the robot state $\scriptstyle { \pmb { s } } _ { r }$ , the object state $\scriptstyle { \pmb { s } } _ { o }$ , the timeinvariant property $_ { \mathbf { \nabla } } \mathbf { m } _ { \mathbf { \nabla } }$ , and the goal information $s _ { g }$ . The robot state $\scriptstyle { \pmb { s } } _ { r }$ is consists of 9 joint positions, 9 joint velocities, and the Cartesian coordinates of the three end-effectors (fingertips). The object state $\scriptstyle { \pmb { s } } _ { o }$ contains the Cartesian coordinate, the velocity, the quaternion orientation, and the object’s angular velocity. The property $_ { \mathbf { \nabla } } \mathbf { m }$ includes the object mass and the friction coefficient. The goal information $s _ { g }$ contains the target location and orientation of the object.
78
+
79
+ Evaluated Models We evaluate three approaches in our experiments: Model-Based Policy Optimization (MBPO) (Janner et al., 2019), one of the state-of-the-art Dyna style methods with high sample efficiency, Soft Actor-Critic (SAC) (Haarnoja et al., 2018), a widely-used model-free approach, and our method CausalDyna.
80
+
81
+ Task Settings and Performance Metrics We define three settings to evaluate our method: Picking Mass, Pushing Mass, and Pushing Friction. In Picking Mass, the robot needs to pick up an object to a target location in the air. The object mass is different over different episodes. In contrast, the target locations in Pushing Mass and Pushing Friction are on the ground. The object mass and the floor friction in Pushing Mass and Pushing Friction are different over different episodes, respectively. We use the default reward signals of CausalWorld to train our method. The reward provides rich signals to encourage the robot to get close to the object and move it toward the target. The reward is a weighted sum over the reduction of the distance between the end effectors and the object and the distance between the object and the target. We evaluated our approach and competing methods using fractional success rate (FSR), which is defined as the overlapping ratio between the object and the target. We compute the FSR of a given episode as the average FSR over the last 20 steps. To quantify the sample efficiency in our benchmark, we propose a metric named Area-Under-theCurve Ratio (AUCRatio). Given a learning curve $\mathrm { F S R } = f _ { l e a r n } ( n _ { s t e p } )$ where $n _ { s t e p }$ denotes the number of the environment steps collected already, AUCRatio until step $N _ { s t e p }$ is computed as Eq.2. As $0 \leq \mathrm { F S R } \leq 1$ , a policy with AUCRatio $= 1$ means it can perform the task perfectly without training.
82
+
83
+ $$
84
+ \mathrm { A U C R a t i o } = \frac { 1 } { N _ { s t e p } } \sum _ { n _ { s t e p } = 1 } ^ { N _ { s t e p } } f _ { l e a r n } ( n _ { s t e p } )
85
+ $$
86
+
87
+ # 5.2 EXPERIMENTS WITH OUT-OF-DISTRIBUTION PROPERTY
88
+
89
+ An intelligent robot might encounter various objects when deploying. If the robot need to manipulate an object unseen during training, its performance might be reduced. This can be viewed as an outof-distribution problem: how to generalize well to the object not in the training distribution? The counterfactual property generation approach has the potential to increase the performance on objects with unseen property values if we roll out simulated episodes with object property that is out of the training range. To verify our assumption, we create an experiment to study whether our method helps improve the agent performance on objects whose property value is not encountered during training. In detail, in our Picking Mass and Pushing Mass setting, the robot is trained with objects of which the mass is uniformly distributed from $0 . 0 1 5 \mathrm { k g }$ to $0 . 0 4 5 \mathrm { k g }$ . But during the testing stage, the robot is asked to interact with heavier objects up to $0 . 1 \mathrm { k g }$ . In Pushing Friction setting, the friction coefficient is from 0.3 to 0.6 during training. And the robot is deployed to also handle friction from 0.6 to 0.8.
90
+
91
+ As we target the performance of the objects with unseen property value during training, we use our method here to imagine these objects. In detail, when the counterfactual property generation is applied, we replace the original property value with a counterfactual value uniformly sampled from the unseen test range. In this way, our agent can practice manipulating these unseen objects in the world model in advance.
92
+
93
+ Hyperparameters The length of the simulated episodes $K$ is 10. A bootstrap ensemble of world models is used following Kurutach et al. (2018) for both MBPO and our method. The ensemble size is 7. For each generation step, we randomly pick one model from the ensemble to predict the next state. When training the policy, $20 \%$ of the training data are from the real experience replay buffer. The remaining are from the simulated episodes. In our CausalDyna, $20 \%$ of the simulated episodes are generated by counterfactual property generation ( $\alpha$ in Alg.2). We use Adam (Kingma & Ba, 2014) as the training optimizer for all experiments. All the models we evaluated are trained for 1.2 million steps in Picking Mass and 600 thousand steps in Pushing Mass and Pushing Friction. Each model in this experiment has 5 training cases. The model architecture and the remaining hyperparameters can be found in Appx.A and Appx.B.
94
+
95
+ ![](images/a481eb6000e93b6057184f5d9a27951b69a655539f29f562b5fa64927b2da3b8.jpg)
96
+ Figure 3: Experimental results of counterfactual property generation in the out-of-distribution experiment. The vertical black line shows the boundary between the seen and unseen property values during training. The left part is the seen region. Counterfactually generating the simulated episodes with unseen property value helps alleviate the performance drop when evaluating unseen property during training. Numbers in the legend denote the average performance in the unseen value range. Each curve contains 5 training cases.
97
+
98
+ ![](images/11a2ef93d4c191d75cc898cafa5d7ae0e3484c9484b154b66de8280d5ccf474d.jpg)
99
+ Figure 4: The learning curve of the evaluated models on the training property range in the outof-distribution experiments. CausalDyna converges as fast as MBPO, although it generates $20 \%$ less simulated episodes in the training property range. Numbers in the legend denote the average AUCRatio.
100
+
101
+ Performance The experimental results are shown in Fig.3. The vertical black line denotes the boundary between the seen and unseen values during training. The left part is the seen region. In Picking Mass and Pushing Mass, the performance of all the methods declines when the object mass is out of the training range. Moreover, the performance reduction is more significant when the tested object mass is farther away from the training range. Our CausalDyna alleviates this performance reduction in the unseen range by a large margin compared to MBPO. In Picking Mass, CausalDyna improves the unseen FSR by $24 \%$ from 0.37 to 0.47. For Picking Mass it is $27 \%$ from 0.7 to 0.87. This indicates that hallucinating episodes with unseen objects during training helps improve the generalization ability of the policy. In Pushing Friction, CausalDyna achieves similar performance as MBPO since the unseen range performance reduction here is not obvious. As SAC is less sample efficiency than both model-based methods, SAC cannot achieve compatible results given the same training data as MBPO and CausalDyna. Note that in Picking Mass, although our CausalDyna performs better than MBPO in the out-of-distribution range, the absolute performance is not high when the object is too heavy (like $0 . 1 \mathrm { k g } { \cdot }$ . This might be caused by the reduced performance of the world model when counterfactually generating episodes with unseen objects. A better world model design that can better understand the physics and reason the future more causally might help alleviate this issue when combined with our method. We leave this for future research.
102
+
103
+ Sample Efficiency We show the learning curve of MBPO, CausalDyna, and SAC of this experiment in Fig.4. Although we augment $20 \%$ fewer simulated episodes in the original property range compared to MBPO, CausalDyna converges as fast as MBPO in the original training range. Results indicate that our method improves the out-of-distribution performance without sacrificing the sample efficiency. The model-free SAC training is much slower than MBPO and CausalDyna, as SAC doesn’t have simulated data to train on.
104
+
105
+ ![](images/bbdef68000ab8cd1e4a128091c7a34051ce89c079e106739e4e196900aff0ffe.jpg)
106
+ Figure 5: Experimental results of counterfactual property generation in the unbalanced distribution experiment. When counterfactually generating episodes where the object is less encountered during training, CausalDyna helps improve the policy performance on both the objects with head values and tail values. For each property, the median value occurs $90 \%$ of the time in the environment, and the rest two values share the remaining $10 \%$ equally. Numbers in the legend denote the average performance over the tail values. Each model has 6 training cases.
107
+
108
+ # 5.3 EXPERIMENTS WITH UNBALANCED TRAINING DISTRIBUTION
109
+
110
+ In real environments like warehouses, the numbers of different wares are unequal, and a sorting robot might manipulate some objects less frequently. This can be described as an unbalanced training distribution. If the training distribution is heavily unbalanced and some objects are significantly less encountered than others during training, counterfactually generating episodes with such objects might help improve the policy performance on them. We create a simple heavily unbalanced training distribution consisting of 1 head property value and two tail property values to verify this assumption. The object property in $90 \%$ of the training episodes equals the head value. The two tail values share the remaining $10 \%$ , each value obtains $5 \%$ . Concretely, in Picking Mass and Pushing Mass, we have three different objects with mass values $0 . 0 0 2 \mathrm { k g }$ , $0 . 0 1 \mathrm { k g }$ , and $0 . 0 5 \mathrm { k g }$ , respectively. $90 \%$ of the time, the robot sees and manipulates the object with the median mass value of $0 . 0 1 \mathrm { k g }$ . The robot plays with the heavy $0 . 0 5 \mathrm { k g }$ object and the light $0 . 0 0 2 \mathrm { k g }$ object equally in the remaining time. For Pushing Friction, the three friction coefficients are 0.3, 0.55, and 0.8 that occur in $5 \%$ , $90 \%$ , and $5 \%$ of the time, respectively. In the testing stage, models need to perform well on all three property values.
111
+
112
+ As the objects with tail values occur less frequently in the training stage, CausalDyna in this experiment imagines what would happen if the given head object is the tail. Concretely, when CausalDyna generating simulated episodes, the property value of original objects are counterfactually modified to one of the tail property values randomly. Therefore, the agent can interact with the tail objects more in the world model to improve the tail performance.
113
+
114
+ Hyperparameter In CausalDyna, 2/3 of the simulated episodes are generated by counterfactual property generation $\alpha$ in Alg.2). All the models on all the 3 settings are trained for 600 thousand steps. Each model in this experiment has 6 training cases. The remaining hyperparameters are the same as in the previous experiment.
115
+
116
+ Performance As shown in Fig.5, the performance on the head property value $( 0 . 0 1 \mathrm { k g }$ for mass and 0.55 for friction) is better than the tail property values for all the methods in all the 3 settings. However, CausalDyna improves the performance on the tail property and shows the smallest performance difference between the head and the tail among the three models. For example, the performance gap between the head and the tail of CausalDyna in Picking Mass is about 0.1, much smaller than MBPO (0.2-0.3), and the tail performance is increased by $30 \%$ from 0.56 to 0.73. Besides, we notice that CausalDyna improves the policy performance on both objects that are less frequently seen during training and the head objects compared to MBPO. This might be because learning how to behave well in the tail cases helps the model better understand the environment dynamics and improves overall performance. In addition, the performance variance in Pushing Mass and Pushing Friction of CausalDyna is much lower than the other two methods, which suggests that the performance of CausalDyna is more consistent than other methods. With the same amount of training data as MBPO and CausalDyna, the model-free SAC’s performance is worse than the model-based MBPO and CausalDyna, which is the same as the out-of-distribution experiment.
117
+
118
+ ![](images/490a3b62cc5d0f90c54c32703b1219dd57954fbfe56ec43ac1a7fccf30587fb7.jpg)
119
+ Figure 6: Average policy performance at different environment steps. Our method CausalDyna, which counterfactually generating episodes where the object is less frequently encountered during training, reduces the required amount of environment steps and shows the best sample efficiency in the unbalanced training distribution experiment. Numbers in the legend denote the average AUCRatio. Each model has 6 training cases.
120
+
121
+ Sample Efficiency The learning curves of the evaluated models are shown in Fig.6. The fractional success rate is uniformly averaged over all the property values. CausalDyna shows a better sample efficiency and converges faster. In all three settings, CausalDyna requires about $1 0 0 \mathrm { k }$ fewer environment steps to converge compared to MBPO and increase the sample effiency by about $17 \%$ . This might be because CausalDyna has more simulated episodes with the tail property values to train the agent, which helps the agent understand the task better and adapt to all the property values faster.
122
+
123
+ # 6 CONCLUSION AND FUTURE WORK
124
+
125
+ In this paper, we focus on improving the generalization ability of model-based reinforcement learning in robotic environments. We propose a novel Dyna-style causal reinforcement learning algorithm named CausalDyna that rollouts episodes with intervened object properties. CausalDyna leverages the diversity of the simulated episodes augmented by the world model and improves the generalization of the policy when manipulating objects with property unseen or rarely seen during training. Experiments show that our method helps the robot generalize to objects with unseen property values better. In addition, when the training distribution is unbalanced, our method requires fewer environment steps to converge and performs better with rarely seen objects.
126
+
127
+ To our knowledge, we are the first to propose counterfactual reasoning on environment properties to improve the generalization of reinforcement learning. We believe this is a promising direction to solve many complex reinforcement learning tasks where the policy generalization ability is essential. When combined with model predictive control and counterfactual reasoning on actions, it is possible to further improve sample efficiency and generalization of RL algorithms. One limitation of our method is that the quality of our counterfactual episodes depends on how well our world model understands the environment. We plan to design a better world model that takes prior knowledge like simple physics laws into account. Finally, we have assumed that the properties in our environment are fully observable in our current work. We plan to investigate causal models with latent variables representing unobserved properties of the environment.
128
+
129
+ # REFERENCES
130
+
131
+ Ossama Ahmed, Frederik Trauble, Anirudh Goyal, Alexander Neitz, Yoshua Bengio, Bernhard ¨ Scholkopf, Manuel W ¨ uthrich, and Stefan Bauer. Causalworld: A robotic manipulation bench- ¨ mark for causal structure and transfer learning. arXiv preprint arXiv:2010.04296, 2020.
132
+
133
+ Lars Buesing, Theophane Weber, Yori Zwols, Sebastien Racaniere, Arthur Guez, Jean-Baptiste Lespiau, and Nicolas Heess. Woulda, coulda, shoulda: Counterfactually-guided policy search. arXiv preprint arXiv:1811.06272, 2018.
134
+
135
+ Kurtland Chua, Roberto Calandra, Rowan McAllister, and Sergey Levine. Deep reinforcement learning in a handful of trials using probabilistic dynamics models. arXiv preprint arXiv:1805.12114, 2018.
136
+
137
+ Ignasi Clavera, Jonas Rothfuss, John Schulman, Yasuhiro Fujita, Tamim Asfour, and Pieter Abbeel. Model-based reinforcement learning via meta-policy optimization. In Conference on Robot Learning, pp. 617–629. PMLR, 2018.
138
+
139
+ Marc Deisenroth and Carl E Rasmussen. Pilco: A model-based and data-efficient approach to policy search. In Proceedings of the 28th International Conference on machine learning (ICML-11), pp. 465–472. Citeseer, 2011.
140
+
141
+ Marc Peter Deisenroth, Dieter Fox, and Carl Edward Rasmussen. Gaussian processes for dataefficient learning in robotics and control. IEEE transactions on pattern analysis and machine intelligence, 37(2):408–423, 2013.
142
+
143
+ David Ha and Jurgen Schmidhuber. World models. ¨ arXiv preprint arXiv:1803.10122, 2018.
144
+
145
+ Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In International Conference on Machine Learning, pp. 1861–1870. PMLR, 2018.
146
+
147
+ Danijar Hafner, Timothy Lillicrap, Jimmy Ba, and Mohammad Norouzi. Dream to control: Learning behaviors by latent imagination. In International Conference on Learning Representations, 2019.
148
+
149
+ Danijar Hafner, Timothy Lillicrap, Mohammad Norouzi, and Jimmy Ba. Mastering atari with discrete world models. arXiv preprint arXiv:2010.02193, 2020.
150
+
151
+ Michael Janner, Justin Fu, Marvin Zhang, and Sergey Levine. When to trust your model: Modelbased policy optimization. arXiv preprint arXiv:1906.08253, 2019.
152
+
153
+ Leslie Pack Kaelbling, Michael L Littman, and Andrew W Moore. Reinforcement learning: A survey. Journal of artificial intelligence research, 4:237–285, 1996.
154
+
155
+ Sanket Kamthe and Marc Deisenroth. Data-efficient reinforcement learning with probabilistic model predictive control. In International conference on artificial intelligence and statistics, pp. 1701– 1710. PMLR, 2018.
156
+
157
+ Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. Morel: Modelbased offline reinforcement learning. arXiv preprint arXiv:2005.05951, 2020.
158
+
159
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
160
+
161
+ Thanard Kurutach, Ignasi Clavera, Yan Duan, Aviv Tamar, and Pieter Abbeel. Model-ensemble trust-region policy optimization. arXiv preprint arXiv:1802.10592, 2018.
162
+
163
+ Sergey Levine and Pieter Abbeel. Learning neural network policies with guided policy search under unknown dynamics. In NIPS, volume 27, pp. 1071–1079. Citeseer, 2014.
164
+
165
+ Sergey Levine and Vladlen Koltun. Guided policy search. In International conference on machine learning, pp. 1–9. PMLR, 2013.
166
+
167
+ Chaochao Lu, Biwei Huang, Ke Wang, Jose Miguel Hern ´ andez-Lobato, Kun Zhang, and Bernhard ´ Scholkopf. Sample-efficient reinforcement learning via counterfactual-based data augmentation. ¨ arXiv preprint arXiv:2012.09092, 2020.
168
+
169
+ William H Montgomery and Sergey Levine. Guided policy search via approximate mirror descent. Advances in Neural Information Processing Systems, 29:4008–4016, 2016.
170
+
171
+ Anusha Nagabandi, Gregory Kahn, Ronald S Fearing, and Sergey Levine. Neural network dynamics for model-based deep reinforcement learning with model-free fine-tuning. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pp. 7559–7566. IEEE, 2018.
172
+
173
+ Vinod Nair and Geoffrey E Hinton. Rectified linear units improve restricted boltzmann machines. In Icml, 2010.
174
+
175
+ Prajit Ramachandran, Barret Zoph, and Quoc V Le. Searching for activation functions. arXiv preprint arXiv:1710.05941, 2017.
176
+
177
+ Danilo J Rezende, Ivo Danihelka, George Papamakarios, Nan Rosemary Ke, Ray Jiang, Theophane Weber, Karol Gregor, Hamza Merzic, Fabio Viola, Jane Wang, et al. Causally correct partial models for reinforcement learning. arXiv preprint arXiv:2002.02836, 2020.
178
+
179
+ Stephane Ross and J Andrew Bagnell. Agnostic system identification for model-based reinforcement learning. arXiv preprint arXiv:1203.1007, 2012.
180
+
181
+ Richard S Sutton. Integrated architectures for learning, planning, and reacting based on approximating dynamic programming. In Machine learning proceedings 1990, pp. 216–224. Elsevier, 1990.
182
+
183
+ Richard S Sutton. Dyna, an integrated architecture for learning, planning, and reacting. ACM Sigart Bulletin, 2(4):160–163, 1991a.
184
+
185
+ Richard S Sutton. Planning by incremental dynamic programming. In Machine Learning Proceedings 1991, pp. 353–357. Elsevier, 1991b.
186
+
187
+ Tingwu Wang, Xuchan Bao, Ignasi Clavera, Jerrick Hoang, Yeming Wen, Eric Langlois, Shunshi Zhang, Guodong Zhang, Pieter Abbeel, and Jimmy Ba. Benchmarking model-based reinforcement learning. arXiv preprint arXiv:1907.02057, 2019.
188
+
189
+ Tianhe Yu, Garrett Thomas, Lantao Yu, Stefano Ermon, James Zou, Sergey Levine, Chelsea Finn, and Tengyu Ma. Mopo: Model-based offline policy optimization. arXiv preprint arXiv:2005.13239, 2020.
190
+
191
+ Lunjun Zhang, Ge Yang, and Bradly C Stadie. World model as a graph: Learning latent landmarks for planning. In International Conference on Machine Learning, pp. 12611–12620. PMLR, 2021.
192
+
193
+ # A MODEL ARCHITECTURE
194
+
195
+ Here we list the architecture of the world model, the policy actor net and the policy critic net we use in all experiments for all methods. All the models are built using linear-layers. The world model uses Swish activation function (Ramachandran et al., 2017) and the policy uses ReLU (Nair & Hinton, 2010).
196
+
197
+ Table 1: Model Architecture
198
+
199
+ <table><tr><td>Modules</td><td>Hidden Layers</td><td>Neurons PerLayer</td></tr><tr><td>WorldModel</td><td>3</td><td>200</td></tr><tr><td>Policy Actor</td><td>2</td><td>256</td></tr><tr><td>Policy Critic</td><td>2</td><td>256</td></tr></table>
200
+
201
+ # B HYPERPARAMETER
202
+
203
+ The size of the real experience replay buffer $\mathbb { D } _ { r }$ is $1 0 0 \mathrm { k }$ for MBPO and our method CausalDyna in all three settings. For SAC, it is 1M as we notice SAC with $1 0 0 \mathrm { k }$ -size replay buffer cannot be trained well. For the world model training, The replay buffer $\mathbb { D } _ { r }$ is split randomly into a training set $\mathbb { D } _ { r , t r a i n }$ with $80 \%$ of the data and a holdout set $\mathbb { D } _ { r , h o l d o u t }$ containing the remaining data. We train the model once for every 250 real environment steps until converge is evaluated on the holdout set. The learning rate is 3e-4. Batch size is 256. For the policy training, the policy net is updated for 5 iterations per real environment step. The batch size is 256, and the learning rate is set to 1e-4.
204
+
205
+ # C QUALITATIVE RESULTS
206
+
207
+ Here we demonstrate episodes from CausalDyna and MBPO in the Pushing Mass setting in unbalanced training distribution experiments with the heavy tail object in Fig.7 and Fig.8. Both models are trained for $6 0 0 \mathrm { k }$ environment steps. The object to manipulate is in blue color. Target location is shown as the green shade. Each column corresponds to an episode. CausalDyna generalizes to the heavy tail object well and pick it to the location successfully shown in Fig.7, while MBPO fails to lift the object up in 2 episodes shown in Fig.8.
208
+
209
+ ![](images/8fb644fe4283c0a929a0a27ed342f1143efe04c8a2b832174437bd4caf6f675e.jpg)
210
+ Figure 7: CausalDyna with the heavy tail object. Pushing Mass, Unbalanced Training Distribution.
211
+
212
+ ![](images/d0a027c70828f6f5b65214e56027f49b60c91a0c3f993223ee406f3b1c1aa889.jpg)
213
+ Figure 8: MBPO with the heavy tail object. Pushing Mass, Unbalanced Training Distribution.
md/dev/voV_TRqcWh/voV_TRqcWh.md ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Poisson Flow Generative Models
2
+
3
+ Yilun Xu∗ , Ziming Liu∗ , Max Tegmark, Tommi Jaakkola Massachusetts Institute of Technology ylxu, zmliu, tegmark @mit.edu; tommi@csail.mit.edu
4
+
5
+ # Abstract
6
+
7
+ We propose a new “Poisson flow” generative model (PFGM) that maps a uniform distribution on a high-dimensional hemisphere into any data distribution. We interpret the data points as electrical charges on the $z = 0$ hyperplane in a space augmented with an additional dimension $z$ , generating a high-dimensional electric field (the gradient of the solution to Poisson equation). We prove that if these charges flow upward along electric field lines, their initial distribution in the $z \ = \ 0$ plane transforms into a distribution on the hemisphere of radius $r$ that becomes uniform in the $r \infty$ limit. To learn the bijective transformation, we estimate the normalized field in the augmented space. For sampling, we devise a backward ODE that is anchored by the physically meaningful additional dimension: the samples hit the (unaugmented) data manifold when the $z$ reaches zero. Experimentally, PFGM achieves current state-of-the-art performance among the normalizing flow models on CIFAR-10, with an Inception score of 9.68 and a FID score of 2.35. It also performs on par with the state-of-the-art SDE approaches while offering $1 0 \times$ to $2 0 \times$ acceleration on image generation tasks. Additionally, PFGM appears more tolerant of estimation errors on a weaker network architecture and robust to the step size in the Euler method. The code is available at https: //github.com/Newbeeer/poisson_flow.
8
+
9
+ # 1 Introduction
10
+
11
+ Deep generative models are a prominent approach for data generation, and have been used to produce high quality samples in image [1], text [2] and audio [35], as well as improve semi-supervised learning [20], domain generalization [25] and imitation learning [15]. However, current deep generative models also have limitations, such as unstable training objectives (GANs [1, 12, 17]) and low sample quality (VAEs [21], normalizing flows [6]). New techniques [12, 24] are introduced to stablize the training of CNN-based or ViT-based GAN models. Although recent advances on diffusion [16] and scored-based models [33] achieve comparable sample quality to GAN’s without adversarial training, these models have a slow stochastic sampling process. [33] proposes backward ODE samplers (normalizing flow) that speed up the sampling process but these methods have not yet performed on par with the SDE counterparts.
12
+
13
+ We present a new “Poisson flow” generative model (PFGM), exploiting a remarkable physics fact that generalizes to $N$ dimensions. As illustrated in Fig. 1(a), motion in a viscous fluid transforms any planar charge distribution into a uniform angular distribution. Specifically, we interpret $N$ - dimensional data points $\mathbf { x }$ (images, say) as positive electric charges in the $z \ = \ 0$ plane of an $N + 1$ -dimensional space (see Fig. 1(a)) filled with a viscous liquid (say honey). A positive charge with $z > 0$ will be repelled by the other charges and move in the direction of their repulsive force, eventually crossing an imaginary hemisphere of radius $r$ . We show that, remarkably, if the the original charge distribution is let loose just above $z = 0$ , this law of motion will cause a uniform distribution for their hemisphere crossings in the $r \infty$ limit.
14
+
15
+ ![](images/54726ebf34e46087bef020e3ddcf1a0c1fce7fffed017e15273765115d92e791.jpg)
16
+ Figure 1: (a) 3D Poisson field trajectories for a heart-shaped distribution (b) The evolvements of a distribution (top) or an (augmented) sample (bottom) by the forward/backward ODEs pertained to the Poisson field.
17
+
18
+ Our Poisson flow generative process reverses the forward process: we generate a uniform distribution of negative charges on the hemisphere, then track their motion back to the $z = 0$ plane, where they will be distributed as the data distribution. A Poisson flow can be viewed as a type of continuous normalizing flows [4, 10, 33] in the sense that it continuously maps between an arbitrary distribution and an easily sampled one: in the previous works an $N$ -dimensional Gaussian and in PFGM a uniform distribution on an $N$ -dimensional hemisphere. In practice, we implement the Poisson flow by solving a pair of forward/backward ordinary differential equations (ODEs) induced by the electric field (Fig. 1(b)) given by the $N$ -dimensional version of Coulomb’s law (the gradient of the solution to the Poisson’s equation with the data as sources). We will interchangeably refer to this gradient as the Poisson field, since electric fields normally refer to the special case $N = 3$ .
19
+
20
+ The proposed generative model PFGM has a stable training objective and empirically outperforms previously state-of-the-art continuous flow methods [30, 33]. As a different iterative method, PFGM offers two advantages compared to score-based methods [32, 33]. First, the ODE process of PFGM achieves faster sampling speeds than the SDE samplers in [33]. while retaining comparable performance. Second, our backward ODE exhibits better generation performance than the reverse-time ODEs of VE/VP/sub-VP SDEs [33], as well as greater stability on a weaker architecture NSCNv2 [32]. The rationale for robustness is that the time variables in these ODE baselines are strongly correlated with the sample norms during training time, resulting in a less error-tolerant inference. In contrast, the tie between the anchored variable and the sample norm in PFGM is much weaker.
21
+
22
+ Experimentally, we show that PFGM achieves current state-of-the-art performance on CIFAR-10 dataset in the normalizing flow family, with FID/Inception scores of $2 . { \bar { 4 } } 8 / 9 . 6 5$ (w/ $\mathrm { { D D P M + + } }$ [33]) and $2 . 3 5 / 9 . 6 8$ (w/ $\mathrm { { D D P M + + } }$ deep [33]). It performs competitively with current state-of-the-art SDE samplers [33] and provides $1 0 \times$ to $2 0 \times$ speed up across datasets. Notably, the backward ODE in PFGM is the only ODE-based sampler that can produce decent samples on its own on NCSNv2 [32], while other ODE baselines fail without corrections. In addition, PFGM demonstrates the robustness to the step size in the Euler method, with a varying number of function evaluations (NFE) ranging from 10 to 100. We further showcase the utility of the invertible forward/backward ODEs of the Poisson field on likelihood evaluation and image manipulations, and its scalability to higher resolution images on LSUN bedroom $2 5 6 \times 2 5 6$ dataset.
23
+
24
+ # 2 Background and Related works
25
+
26
+ Poisson equation Let $\mathbf { x } \in \mathbb { R } ^ { N }$ and $\rho ( \mathbf { x } ) : \mathbb { R } ^ { N } \mathbb { R }$ be a source function. We assume that the source function has a compact support, $\rho \in \mathcal { C } ^ { 0 }$ and $N \geq 3$ . The Poisson equation is
27
+
28
+ $$
29
+ \nabla ^ { 2 } \varphi ( \mathbf { x } ) = - \rho ( \mathbf { x } ) ,
30
+ $$
31
+
32
+ where $\varphi ( \mathbf { x } ) : \mathbb { R } ^ { N } \mathbb { R }$ is called the potential function, and $\begin{array} { r } { \bigtriangledown ^ { 2 } \equiv \sum _ { i = 1 } ^ { N } \frac { \partial ^ { 2 } } { \partial x _ { i } ^ { 2 } } } \end{array}$ is the Laplacian operator. It is usually helpful to define the gradient field $\mathbf { E } ( \mathbf { x } ) = - \nabla \varphi ( \mathbf { x } )$ and rewrite the Poisson equation as $\nabla \cdot \mathbf { E } = \rho$ , known in physics as Gauss’s law [11]. The Poisson equation is widely used in physics, giving rise to Newton’s gravitational theory [9] and the electrostatic theory [11], when $\rho ( \mathbf { x } )$ is interpreted as mass density or electric charge density, respectively. $\mathbf { E }$ is the $N$ -dimensional analog of the electric field. The Poisson equation Eq. (1) (with zero boundary condition at infinity) admits a unique simple integral solution 2:
33
+
34
+ $$
35
+ \varphi ( \mathbf { x } ) = \int G ( \mathbf { x } , \mathbf { y } ) \rho ( \mathbf { y } ) d \mathbf { y } , \quad G ( \mathbf { x } , \mathbf { y } ) = \frac { 1 } { ( N - 2 ) S _ { N - 1 } ( 1 ) } \frac { 1 } { | | \mathbf { x } - \mathbf { y } | | ^ { N - 2 } } ,
36
+ $$
37
+
38
+ where $S _ { N - 1 } ( 1 )$ is a geometric constant representing the surface area of the unit $( N - 1 )$ -sphere 3, and $G ( \mathbf { x } , \mathbf { y } )$ is the extension of Green’s function in $N$ -dimensional space (details in Appendix A.3). The negative gradient field of $\varphi ( \mathbf x )$ , referred as Poisson field of the source $\rho$ , is
39
+
40
+ $$
41
+ \mathbf { E } ( \mathbf { x } ) = - \nabla \varphi ( \mathbf { x } ) = - \int \nabla _ { \mathbf { x } } G ( \mathbf { x } , \mathbf { y } ) \rho ( \mathbf { y } ) d \mathbf { y } , \quad \nabla _ { \mathbf { x } } G ( \mathbf { x } , \mathbf { y } ) = - \frac { 1 } { S _ { N - 1 } ( 1 ) } \frac { \mathbf { x } - \mathbf { y } } { \left\| \mathbf { x } - \mathbf { y } \right\| ^ { N } } .
42
+ $$
43
+
44
+ Qualitatively, the Poisson field $\mathbf { E } ( \mathbf { x } )$ points away from sources, or equivalently $- \mathbf { E } ( \mathbf { x } )$ points towards sources, as illustrated in Fig. 1. It is straightforward to check that when $\rho ( { \bf x } ) \delta ( { \bf x - y } )$ , we get $\varphi ( \mathbf x ) G ( \mathbf x , \mathbf y )$ and $\mathbf { E } ( \mathbf { x } ) - \nabla _ { \mathbf { x } } G ( \mathbf { x } , \mathbf { y } )$ . This implies that $G ( \mathbf { x } , \mathbf { y } )$ and $- \nabla _ { \mathbf { x } } G ( \mathbf { x } , \mathbf { y } )$ can be interpreted as the potential function and the gradient field generated by a unit point source, e.g., a point charge, located at $\mathbf { y }$ . When $\rho ( \mathbf { x } )$ takes general forms but has bounded support, simple asymptotics exist for $\left\| \mathbf { x } \right\| \gg \left\| \mathbf { y } \right\|$ . To the lowest order, $\mathbf { E ( x ) } = \nabla _ { \mathbf { x } } G ( \mathbf { x } , \mathbf { y } ) | _ { \mathbf { y } = \mathbf { 0 } } \sim \mathbf { x } / \| \mathbf { x } \| ^ { N }$ behaves as if it were generated by a unit point source at $\mathbf y = 0$ . In physics, the power law decay is considered to be long-range (compared to exponential decay) [11].
45
+
46
+ Particle dynamics in a Poisson field The Poisson field immediately defines a flow model, where the probability distribution evolves according to the gradient flow $\partial p _ { t } ( \mathbf { x } ) / \partial t = - \nabla \cdot ( p _ { t } ( \mathbf { x } ) \mathbf { E } ( \mathbf { x } ) )$ . The gradient flow is a special case of the Fokker-Planck equation [28], where the diffusion coefficient is zero. Intuitively we can think of $p _ { t } ( \mathbf { x } )$ as represented by a population of particles. The corresponding (non-diffusion) case of the Ito process is the forward ODE ˆ $\begin{array} { r } { \frac { d \mathbf { x } } { d t } \ = \ \mathbf { E } ( \mathbf { x } ) } \end{array}$ . We can interpret the trajectories of the ODE as particles moving according to the Poisson field $\mathbf { E } ( x )$ , with initial states drawn from $p _ { 0 }$ . The physical picture of the forward ODE is a charged particle under the influence of electric fields in the overdamped limit (details in Appendix F).
47
+
48
+ The dynamics is also rescalable in the sense that the particle trajectory remains the same for $\pm f ( \mathbf { x } ) \mathbf { E } ( \mathbf { x } )$ for $f ( \mathbf { x } ) > 0 , f ( \mathbf { x } ) \in \mathcal { C } ^ { 1 }$ , because the time rescaling $d t \to f ( \mathbf { x } ( t ) ) d t$ recovers $\begin{array} { r } { \frac { d \mathbf { x } } { d t } \ = } \end{array}$ $\begin{array} { r } { \frac { d { \mathbf { x } } } { d t } = } \end{array}$ $\pm \mathbf { E } ( \mathbf { x } )$ . Note that the dynamics is stiff due to the power law factor in the denominator in Eq. (3), posing computational challenges. Luckily the rescalablility allows us to rescale $\mathbf { E } ( \mathbf { x } )$ properly to get new ODEs (formally defined later in Section 3.3) that are more amenable for sampling.
49
+
50
+ Generative Modeling via ODE Generative modeling can be done by transforming a base distribution to a data distribution via mappings defined by ODEs. The ODE-based samplers allow for adaptive sampling, exact likelihood evaluation and modeling of continuous-time dynamics [4, 33]. Previous works broadly fall into two lines. [4, 3] introduce a continuous-time normalizing flow model that can be trained with maximum likelihood by the instantaneous change-of-variables formula [4]. For sampling, they directly integrate the learned invertiable mapping over time. Another work [33] unifies the scored-based model [31, 32] and diffusion model [16] into a general diffusion process, and uses the reverse-time ODE of the diffusion process for sampling. They show that the reverse-time ODE produces high quality samples with improved architecture.
51
+
52
+ # 3 Poisson Flow Generative Models
53
+
54
+ In this section, we start with the properties of the Poisson flow in the augmented space and show how to draw samples from the data distribution by following the backward ODE of the Poisson flow (Section 3.1). We then discuss how to actually learn a normalized Poisson field from data samples through simulations of the forward ODE (Section 3.2) and present an equivalent backward ODE that allows for exponentially decay on $z$ (Section 3.3).
55
+
56
+ ![](images/e2f896cb7811162de5ce22a937be497e9cd000c7801fea03b15b727a4f369139.jpg)
57
+ Figure 2: (a) Poisson field (black arrows) and particle trajectories (blue lines) of a 2D uniform disk (red). Left (no augmentation, 2D): all particles collapse to the disk center. Right (augmentation, 3D): particles hit different points on the disk. (b) Proof idea of Theorem 1. By Gauss’s Law, the outflow flux $d \Phi _ { o u t }$ equals the inflow flux $d \Phi _ { i n }$ . The factor of two in $p ( \mathbf { x } ) d A / 2$ is due to the symmetry of Poisson fields in $z < 0$ and $z > 0$ .
58
+
59
+ # 3.1 Augment the data with additional dimension
60
+
61
+ We wish to generate samples $\mathbf { x } \in \mathbb { R } ^ { N }$ from a distribution $p ( \mathbf { x } )$ supported on a bounded region. We may set the source $\rho ( \mathbf { x } ) = p ( \mathbf { x } ) \in \mathcal { C } ^ { 0 \ }$ 4 and compute the resulting gradient field $\mathbf { E } ( \mathbf { x } )$ from Eq. (3). Since $- \mathbf { E } ( \mathbf { x } )$ points towards sources, the backward ODE ${ d { \bf x } } / { d t } = - { \bf E } ( { \bf x } )$ will take samples close to the sources. One may naively hope that the backward ODE is a generative model that recovers $p ( \mathbf { x } )$ . Unfortunately, the backward ODE has the problem of mode collapse. We illustrate this phenomenon with a 2D uniform disk. The reverse Poisson field $- \mathbf { E } ( \mathbf { x } )$ on the 2D $( x , y )$ -plane points towards the center of the disk $O$ (Fig. 2(a) left), so all particle trajectories (blue lines) will eventually hit $O$ . If we instead add an additional dimension $z$ (Fig. 2(a) right), particles can hit different points on the disk and faithfully recover the data distribution.
62
+
63
+ Consequently, instead of solving the Poisson equation $\nabla ^ { 2 } \varphi ( \mathbf { x } ) = - p ( \mathbf { x } )$ in the original data space, we solve the Poisson equation in an augmented space $\tilde { \mathbf { x } } = ( \mathbf { x } , z ) \in \mathbb { R } ^ { N + 1 }$ with an additional variable $z \in \mathbb { R }$ . We augment the training data $\tilde { \mathbf { x } }$ in the new space by setting $z = 0$ such that $\tilde { \mathbf { x } } = ( \mathbf { x } , 0 )$ . As a consequence, the data distribution in the augmented space is $\tilde { p } ( \tilde { \mathbf { x } } ) = p ( \mathbf { x } ) \delta ( z )$ , where $\delta$ is the Dirac delta function. By Eq. (3), the Poisson field by solving the new Poisson equation $\nabla ^ { 2 } \varphi ( \tilde { \mathbf { x } } ) = - \tilde { p } ( \tilde { \mathbf { x } } )$ has an analytical form:
64
+
65
+ $$
66
+ \forall \tilde { { \mathbf { x } } } \in \mathbb { R } ^ { N + 1 } , \mathbf { E } ( \tilde { { \mathbf { x } } } ) = - \nabla \varphi ( \tilde { { \mathbf { x } } } ) = \frac { 1 } { S _ { N } ( 1 ) } \int \frac { \tilde { { \mathbf { x } } } - \tilde { { \mathbf { y } } } } { \left\| \tilde { { \mathbf { x } } } - \tilde { { \mathbf { y } } } \right\| ^ { N + 1 } } \tilde { p } ( \tilde { { \mathbf { y } } } ) d \tilde { { \mathbf { y } } }
67
+ $$
68
+
69
+ The associated forward/backward ODEs of the Poisson field are $d \tilde { \mathbf { x } } / d t = \mathbf { E } ( \tilde { \mathbf { x } } ) , d \tilde { \mathbf { x } } / d t = - \mathbf { E } ( \tilde { \mathbf { x } } )$ . Intuitively, theses ODEs uniquely define trajectories of particles between the $z = 0$ hyperplane and an enclosing hemisphere (cf. Fig. 1(a)). In the following theorem, we show that the backward ODE defines a transformation between the uniform distribution on an infinite hemisphere and the data distribution $\tilde { p } ( \tilde { { \mathbf x } } )$ in the $z = 0$ plane. We present the formal proof to Appendix A, illustrated by Fig. 2(b). The proof is based on the idea that when the radius of hemisphere $r \infty$ , the data distribution $\tilde { p } ( \tilde { \mathbf { x } } )$ can be effectively viewed as a delta distribution at origin. Consequently, the Poisson field points in the radial direction at $r \infty$ , perpendicular to $S _ { N } ^ { + } ( r )$ (Green arrows in Fig. 2(b)).
70
+
71
+ Theorem 1. Suppose particles are sampled from a uniform distribution on the upper $( z > 0 ,$ half of the sphere of radius r and evolved by the backward ODE $\begin{array} { r } { \frac { d \tilde { \mathbf { x } } } { d t } = - \mathbf { E } \big ( \tilde { \mathbf { x } } \big ) } \end{array}$ until they reach the $z = 0$ hyperplane, where the Poisson field $\mathbf { E } ( \tilde { \mathbf { x } } )$ is generated by the source $\tilde { p } ( \tilde { { \mathbf x } } )$ . In the $r \infty$ limit, under some mild conditions detailed in Appendix $\cdot$ , this process generates a particle distribution $\tilde { p } ( \tilde { { \mathbf x } } )$ , i.e., a distribution $p ( \mathbf { x } )$ in the $z = 0$ hyperplane.
72
+
73
+ Proof sketch. Suppose the flux of the backward ODE connects a solid angle $d \Omega$ (on $S _ { N } ^ { + } ( r ) )$ with an area $d A$ (on $\operatorname { s u p p } ( \tilde { p } ( \tilde { \mathbf { x } } ) )$ . According to Gauss’s law, the outflow flux $d \Phi _ { o u t } = d \Omega / S _ { N } \bar { ( 1 ) }$ on the hemisphere (Green arrows in Fig. 2(b)) equals the inflow flux $d \Phi _ { i n } = p ( { \bf x } ) d A / 2$ on $\operatorname { s u p p } ( \tilde { p } ( \tilde { \mathbf { x } } ) )$ (Red arrows in Fig. 2(b)). $d \Phi _ { i n } = d \Phi _ { o u t }$ gives $d \Omega / d A = p ( \mathbf { x } ) S _ { N } ( 1 ) / 2 \propto \tilde { p } ( \mathbf { \tilde { x } } )$ . Together, by change-ofvariable, we conclude that the final distribution in the $z = 0$ hyperplane is $p ( \mathbf { x } )$ . □
74
+
75
+ The theorem states that starting from an infinite hemisphere, one can recover the data distribution $\tilde { p }$ by following the inverse Poisson field $- \mathbf { E } ( \tilde { \mathbf { x } } )$ . We defer the formal proof and technical assumptions of the theorem to Appendix A. The property allows generative modeling by following the Poisson flow of $\nabla ^ { 2 } \varphi ( \tilde { \mathbf { x } } ) = - \tilde { p } ( \tilde { \mathbf { x } } )$ .
76
+
77
+ # 3.2 Learning the normalized Poisson Field
78
+
79
+ Given a set of training data $\mathcal { D } = \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { n }$ i.i.d sampled from the data distribution $p ( \mathbf { x } )$ , we define the =empirical version of the Poisson field (Eq. (4)) as follows:
80
+
81
+ $$
82
+ \hat { \bf E } ( \tilde { \bf x } ) = c ( \tilde { \bf x } ) \sum _ { i = 1 } ^ { n } \frac { \tilde { \bf x } - \tilde { \bf x } _ { i } } { \| \tilde { \bf x } - \tilde { \bf x } _ { i } \| ^ { N + 1 } }
83
+ $$
84
+
85
+ where the gradient field is calculated on $n$ augmented datapoints $\{ \tilde { \mathbf { x } } _ { i } = ( \mathbf { x } _ { i } , 0 ) \} _ { i = 1 } ^ { n }$ , and $c ( \tilde { \mathbf { x } } ) =$ $\textstyle 1 / \sum _ { i = 1 } ^ { n } { \frac { 1 } { \left\| \tilde { \mathbf { x } } - \tilde { \mathbf { x } } _ { i } \right\| ^ { N + 1 } } }$ is the multiplier for numerical stability. We further normalize the field to resolve the variations in the magnitude of the norm $\Vert \hat { \textbf { E } } ( \tilde { \textbf { x } } ) \ \Vert _ { 2 }$ , and fit the neural network to the more amenable negative normalized field $\mathbf { v } ( \tilde { \mathbf { x } } ) = - \sqrt { N } \hat { \mathbf { E } } ( \tilde { \mathbf { x } } ) / \| \hat { \mathbf { E } } ( \tilde { \mathbf { x } } ) \| _ { 2 }$ . The Poisson field is rescalable (cf. Section 2) and thus trajectories of its forward/backward ODEs are invariant under normalization. We denote the empirical field calculated on batch data $\boldsymbol { B }$ by $\hat { \mathbf { E } } _ { B }$ and the negative normalized field as $\mathbf { v } _ { B } ( \tilde { \mathbf { x } } ) = - \sqrt { N } \hat { \mathbf { E } } _ { B } ( \tilde { \mathbf { x } } ) / \| \hat { \mathbf { E } } _ { B } ( \tilde { \mathbf { x } } ) \| _ { 2 }$ .
86
+
87
+ Similar to the scored-based models, we sample points inside the hemisphere by perturbing the augmented training data. Given a training point $\textbf { x } \in \mathcal { D }$ , we add noise to its augmented version $\{ \tilde { \mathbf { x } } _ { i } ^ { - } = ( \mathbf { x } _ { i } , 0 ) \} _ { i = 1 } ^ { n }$ to construct the perturbed point $( \mathbf { y } , z )$ :
88
+
89
+ $$
90
+ \mathbf { y } = \mathbf { x } + \parallel \epsilon _ { \mathbf { x } } \parallel ( 1 + \tau ) ^ { m } \mathbf { u } , \quad z = | \epsilon _ { z } | ( 1 + \tau ) ^ { m }
91
+ $$
92
+
93
+ where ${ \epsilon } = \left( { \epsilon } _ { \mathbf { x } } , { \epsilon } _ { z } \right) \sim \mathcal { N } ( 0 , \sigma ^ { 2 } I _ { N + 1 \times N + 1 } )$ , $\mathbf { u } \sim \mathcal { U } ( S _ { N - 1 } ( 1 ) )$ and $m \sim \mathcal { U } [ 0 , M ]$ . The upper limit $M$ , standard deviation $\sigma$ and $\tau$ are hyper-parameters. With fixed $\epsilon$ and $\mathbf { u }$ , the added noise increases exponentially with $m$ . The rationale behind the design is that points farther away from the data support play a less important role in generative modeling, sharing a similar spirit with the choice of noisy scales in score-based models [32, 33].
94
+
95
+ In practice, we sample the p ts urbing a mini-batch data $B = \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { | B | }$ each iteration. We $m$ $[ 0 , M ]$ =for each datapoint. We select a large $M$ 300) to ensure the perturbed points can reach a large enough hemisphere. We use a larger batch $\boldsymbol { B } _ { L }$ for the estimation of normalized field since the empirical normalized field is biased, which empirically gives better results. Denoting the set of perturbed points as $\{ \tilde { \mathbf { y } } _ { i } \} _ { i = 1 } ^ { | B | }$ , we train the neural network $f _ { \theta }$ =on these points to estimate the negative normalized field by minimizing the following loss:
96
+
97
+ $$
98
+ \mathcal { L } ( \boldsymbol { \theta } ) = \frac { 1 } { | \mathcal { B } | } \sum _ { i = 1 } ^ { | \mathcal { B } | } \parallel f _ { \boldsymbol { \theta } } \big ( \tilde { \mathbf { y } } _ { i } \big ) - \mathbf { v } _ { \mathcal { B } _ { L } } \big ( \tilde { \mathbf { y } } _ { i } \big ) \parallel _ { 2 } ^ { 2 }
99
+ $$
100
+
101
+ We summarize the training process in Algorithm 1. In practice, we add a small constant $\gamma$ to the denominator of the normalized field to overcome the numerical issue when $\exists i , \left\| \tilde { \mathbf { x } } - \tilde { \mathbf { x } } _ { i } \right\| \approx 0$ .
102
+
103
+ # 3.3 Backward ODE anchored by the additional dimension
104
+
105
+ After estimating the normalized field $\mathbf { v }$ , we can sample from the data distribution by the backward ODE $d { \tilde { \mathbf { x } } } = \mathbf { v } ( { \tilde { \mathbf { x } } } ) d t$ . Nevertheless, the boundary condition of the above ODE is unclear: the starting and terminal time $t$ of the ODE are both unknown. To remedy the issue, we propose an equivalent backward ODE in which $\mathbf { x }$ evolves with the augmented variable $z$ :
106
+
107
+ $$
108
+ d ( \mathbf { x } , z ) = ( \frac { d \mathbf { x } } { d t } \frac { d t } { d z } d z , d z ) = ( \mathbf { v } ( \tilde { \mathbf { x } } ) _ { \mathbf { x } } \mathbf { v } ( \tilde { \mathbf { x } } ) _ { z } ^ { - 1 } , 1 ) d z
109
+ $$
110
+
111
+ Algorithm 1 Learning the normalized Poisson Field
112
+
113
+ <table><tr><td>Input: Training iteration T,Initial model fe,dataset D,constant y,learning rate n. fort=1...Tdo</td></tr><tr><td>from BL |B|</td></tr><tr><td>Simulate the ODE: {yi = perturb(xi) Ji=1 Calculate the normalized field by BL: VB (yi)=-√NEB,(yi)/(ll EB (yi) Il2 +γ), ∀i</td></tr><tr><td>|l f(yi)-vBL(yi)l² i1</td></tr><tr><td>Update the model parameter: 0 = 0 - nVL(0)</td></tr><tr><td>end for</td></tr><tr><td>return fe</td></tr></table>
114
+
115
+ # Algorithm 2 perturb $\cdot$
116
+
117
+ <table><tr><td>Sample the power m ~U[0,M] Sample the initial noise (∈x,∈z)~N(O,σ²I(N+1)x(N+1))</td></tr><tr><td>Uniformly sample the vector from the unit ball u ~U(SN(1))</td></tr><tr><td>Construct training point y = x+ | x I (1 + 𝑇)mu, z = |∈zl(1 + T)m</td></tr><tr><td>return y = (y, z)</td></tr></table>
118
+
119
+ where $\mathbf { v } ( \tilde { \mathbf { x } } ) _ { \mathbf { x } } , \mathbf { v } ( \tilde { \mathbf { x } } ) _ { z }$ are the corresponding components of $\mathbf x , z$ in vector $\mathbf { v } ( \tilde { \mathbf { x } } )$ . In the new ODE, we replace the time variable $t$ with the physically meaningful variable $z$ , permitting explicit starting and terminal conditions: when $z = 0$ , we arrive at the data distribution and we can freely choose a large $z _ { \mathrm { m a x } }$ as the starting point in the backward ODE. The backward ODE is compatible with general-purpose ODE solvers, e.g., RK45 method [23] and forward Euler method. The popular black-box ODE solvers, such as the one in Scipy library [37], typically use a common starting time for the same batch of samples. Since the distribution on the $z = z _ { \mathrm { m a x } }$ hyperplane is no longer uniform, we derive the prior distribution by radially projecting uniform distribution on the hemisphere with radius $r = z _ { \mathrm { m a x } }$ to the $z = z _ { \mathrm { m a x } }$ hyperplane:
120
+
121
+ $$
122
+ p _ { \mathrm { p r i o r } } ( \mathbf { x } ) = { \frac { 2 z _ { \mathrm { m a x } } ^ { N + 1 } } { S _ { N } { \big ( } z _ { \mathrm { m a x } } { \big ) } { \big ( } \| \mathbf { x } \| _ { 2 } ^ { 2 } + z _ { \mathrm { m a x } } ^ { 2 } { \big ) } ^ { \frac { N + 1 } { 2 } } } } = { \frac { 2 z _ { \mathrm { m a x } } } { S _ { N } { \big ( } 1 { \big ) } { \big ( } \| \mathbf { x } \| _ { 2 } ^ { 2 } + z _ { \mathrm { m a x } } ^ { 2 } { \big ) } ^ { \frac { N + 1 } { 2 } } } }
123
+ $$
124
+
125
+ where $S _ { N } ( r )$ is the surface area of $N$ -sphere with radius $r$ . The reason behind the radial projection is that the Poisson field points in the radial direction at $r \infty$ . The new backward ODE also defines a bijective transformation between $p _ { \mathrm { p r i o r } } ( \mathbf { x } )$ on the infinite hyperplane $z _ { \mathrm { m a x } } \infty$ ) and the data distribution the norm (r $\tilde { p } ( \tilde { { \mathbf x } } )$ , analogous to Theorem ) from the distribution: $p _ { \mathrm { p r i o r } } ( \mathbf { x } )$ to sampleand then $p _ { \mathrm { r a d i u s } } ( \| \textbf { x } \| _ { 2 } ) \propto \| \textbf { x } \| _ { 2 } ^ { N - 1 } / ( \| \textbf { x } \| _ { 2 } ^ { 2 } + z _ { \operatorname* { m a x } } ^ { 2 } ) ^ { \frac { N + 1 } { 2 } }$ uniformly sample its angle. We provide detailed derivations and practical sampling procedure in Appendix A.4. We further achieve exponential decay on the $z$ dimension by introducing a new variable $t ^ { \prime }$ :
126
+
127
+ $$
128
+ \begin{array} { r l } { [ \mathrm { B a c k w a r d ~ O D E } ] } & { { } d ( \mathbf { x } , z ) = ( \mathbf { v } ( \tilde { \mathbf { x } } ) _ { \mathbf { x } } \mathbf { v } ( \tilde { \mathbf { x } } ) _ { z } ^ { - 1 } z , z ) d t ^ { \prime } } \end{array}
129
+ $$
130
+
131
+ The $z$ component in the backward ODE, i.e., $d z = z d t ^ { \prime }$ , can be solved by $z = e ^ { t ^ { \prime } }$ . Since $z$ reaches zero as $t ^ { \prime } \to - \infty$ , we instead choose a tiny positive number $z _ { \mathrm { m i n } }$ as the terminal condition. The corresponding starting/terminal time of the variable $t ^ { \prime }$ are $\log z _ { \operatorname* { m a x } } / \log z _ { \operatorname* { m i n } }$ respectively. Empirically, this simple change of variable leads to $2 \times$ faster sampling with almost no harm to the sample quality. In addition, we substitue the predicted $\mathbf { v } ( \tilde { \mathbf { x } } ) _ { z }$ with a more accurate one when $z$ is small (Appendix B.2.3). We defer more details of the simulation of backward ODE to Appendix B.2.
132
+
133
+ # 4 Generative Modeling via the Backward ODE
134
+
135
+ In this section, we demonstrate the effectiveness of the backward ODE associated with PFGM on image generation tasks. In Section 4.1, we show that PFGM achieves currently best in class performance in the normalizing flow family. In comparison to the existing state-of-the-art SDE or MCMC approaches, PFGM exhibits $1 0 \times$ or $2 0 \times$ acceleration while maintaining competitive or higher generation quality. Meanwhile, unlike existing ODE baselines that heavily rely on corrector to generate decent samples on weaker architectures, PFGM exhibits greater stability against error (Section 4.2). Finally, we show that PFGM is robust to the step size in the Euler method (Section 4.3), and its associated ODE allows for likelihood evaluation and image manipulation by editing the latent space (Section 4.4).
136
+
137
+ Table 1: CIFAR-10 sample quality (FID, Inception) and number of function evaluation (NFE).
138
+
139
+ <table><tr><td></td><td>Invertible?</td><td>Inception ↑</td><td>FID↓</td><td>NFE↓</td></tr><tr><td>PixelCNN[36]</td><td></td><td>4.60</td><td>65.9</td><td>1024</td></tr><tr><td>IGEBM[8]</td><td></td><td>6.02</td><td>40.6</td><td>60</td></tr><tr><td>ViTGAN [24]</td><td></td><td>9.30</td><td>6.66</td><td>1</td></tr><tr><td>StyleGAN2-ADA [17]</td><td></td><td>9.83</td><td>2.92</td><td>1</td></tr><tr><td>StyleGAN2-ADA (cond.) [17]</td><td>xxxxxxxxxx</td><td>10.14</td><td>2.42</td><td>1</td></tr><tr><td>NCSN[31]</td><td></td><td>8.87</td><td>25.32</td><td>1001</td></tr><tr><td>NCSNv2 [32]</td><td></td><td>8.40</td><td>10.87</td><td>1161</td></tr><tr><td>DDPM[16]</td><td></td><td>9.46</td><td>3.17</td><td>1000</td></tr><tr><td>NCSN++ VE-SDE[33]</td><td></td><td>9.83</td><td>2.38</td><td>2000</td></tr><tr><td>NCSN++ deep VE-SDE [33]</td><td></td><td>9.89</td><td>2.20</td><td>2000</td></tr><tr><td>Glow [19]</td><td></td><td>3.92</td><td>48.9</td><td>1</td></tr><tr><td>DDIM,T=50 [30]</td><td></td><td>-</td><td>4.67</td><td>50</td></tr><tr><td>DDIM, T=100 [30]</td><td></td><td>1</td><td>4.16</td><td>100</td></tr><tr><td>NCSN++ VE-ODE [33]</td><td></td><td>9.34</td><td>5.29</td><td>194</td></tr><tr><td>NCSN++ deep VE-ODE[33]</td><td></td><td>9.17</td><td>7.66</td><td>194</td></tr><tr><td colspan="5">DDPM++backbone</td></tr><tr><td>VP-SDE[33]</td><td></td><td>9.58</td><td>2.55</td><td>1000</td></tr><tr><td>sub-VP-SDE[33]</td><td>xx-</td><td>9.56</td><td>2.61</td><td>1000</td></tr><tr><td>VP-ODE [33]</td><td></td><td>9.46</td><td>2.97</td><td>134</td></tr><tr><td>sub-VP-ODE [33]</td><td></td><td>9.30</td><td>3.16</td><td>146</td></tr><tr><td>PFGM (ours)</td><td></td><td>9.65</td><td>2.48</td><td>104</td></tr><tr><td colspan="5">DDPM++ deep backbone</td></tr><tr><td>VP-SDE [33]</td><td></td><td>9.68</td><td>2.41</td><td>1000</td></tr><tr><td>sub-VP-SDE[33]</td><td>xx-</td><td>9.57</td><td>2.41</td><td>1000</td></tr><tr><td>VP-ODE [33]</td><td></td><td>9.47</td><td>2.86</td><td>134</td></tr><tr><td>sub-VP-ODE [33]</td><td></td><td>9.40</td><td>3.05</td><td>146</td></tr><tr><td>PFGM (ours)</td><td></td><td>9.68</td><td>2.35</td><td>110</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr></table>
140
+
141
+ # 4.1 Efficient image generation by PFGM
142
+
143
+ Setup For image generation tasks, we consider the CIFAR-10 [22], CelebA $6 4 \times 6 4$ [38] and LSUN bedroom $2 5 6 \times 2 5 6$ [39]. Following [32], we first center-crop the CelebA images and then resize them to $6 4 \times 6 4$ . We choose $M \ : = \ : 2 9 1$ CIFAR-10 and CelebA 356 LSUN bedroom , $\sigma ~ = ~ 0 . 0 1$ and $\tau { \it \Delta \phi } = 0 . 0 3$ for the perturbation Algorithm 2, and $z _ { \mathrm { m i n } } ~ = ~ 1 e \mathrm { ~ - ~ } 3$ , $\begin{array} { r l } { z _ { \operatorname* { m a x } } } & { { } = } \end{array}$ 40 CIFAR-10 60 CelebA $6 4 ^ { 2 }$ 100 LSUN bedroom for the backward ODE. We further clip the norms of initial samples into $( 0 , 3 0 0 0 )$ for CIFAR-10, $( 0 , 6 0 0 0 )$ for CelebA $6 4 ^ { 2 }$ and $( 0 , 3 0 0 0 0 )$ for LSUN bedroom. We adopt the $\mathrm { { D D P M + + } }$ and $\mathrm { { D D P M + + } }$ deep architectures [33] as our backbones. We add the scalar $z$ (resp. predicted direction on $z$ ) as input (resp. output) to accommodate the additional dimension. We take the same set of hyper-parameters, such as batch size, learning rate and training iterations from [33]. We provide more training details in Appendix B.1, and discuss how to set these hyper-parameters for general datasets in B.1.1 and B.2.1.
144
+
145
+ Baselines We compare PFGM to modern autoregressive model [36], GAN [17, 24], normalizing flow [19] and EBM [8]. We also compare with variants of score-based models such as DDIM [30] and current state-of-the-art SDE/ODE methods [33]. We denote the methods that use forward-time SDEs in [33] such as Variance Exploding (VE) SDE/Variance Preserving (VP) SDE/ sub-Variance Preserving (sub-VP), and the corresponding backward SDE/ODE, as A-B, where $\mathbf { A } \in \{ \mathrm { V E }$ , VP, sub- $\mathrm { V P } \}$ and $\mathbf { B } \in \{ \mathrm { S D E } , \mathrm { O D E } \}$ . We follow the model selection protocol in [33], which selects the checkpoint with the smallest FID score over the course of training every 50k iterations.
146
+
147
+ ![](images/765d37140b6f169aca43c335a32e1ca5fc5bf14d8e90ab0f9dcca04e90401859.jpg)
148
+ Figure 3: Uncurated samples on datasets of increasing resolution. From left to right: CIFAR-10 $3 2 \times 3 2$ , CelebA $6 4 \times 6 4$ and LSUN bedroom $2 5 6 \times 2 5 6$ .
149
+
150
+ Numerical Solvers The backward ODE (Eq. (6)) is compatible with any general purpose ODE solver. In our experiments, the default solver of ODEs is the black box solver in the Scipy library [37] with the RK45 [7] method (RK45), unless otherwise specified. For VE/VP/subVP-SDEs, we use the predictor-corrector (PC) sampler introduced in [33]. For VP/sub-VP-SDEs, we apply the predictor-only sampler, because its performance is on par with the PC sampler while requiring half computation.
151
+
152
+ Results For quantitative evaluation on CIFAR-10, we report the Inception [29] (higher is better) and FID [13] scores (lower is better) in Table 1. We also include our preliminary experimental results on a weaker architecture NCSNv2 [32] in Appendix D.2. We measure the inference speed by the average NFE (number of function evaluation). We also explicitly indicate which methods belong to the invertible flow family.
153
+
154
+ Our main findings are: (1) PFGM achieves the best Inception scores and FID scores among the normalizing flow models. Specifically, PFGM obtains an Inception score of 9.68 and a FID score of 2.48 using the $\mathrm { D D P M + + }$ deep architecture. To our best knowledge, these are the highest FID and Inception scores by flow models on CIFAR-10. (2) PFGM achieves a $1 0 \times \sim 2 0 \times$ faster inference speed than the SDE methods using the similar architectures, while retaining comparable sample quality. As shown in Table 1, PFGM requires NFEs of 110 whereas the SDE methods typically use $1 0 0 0 \sim 2 0 0 0$ inference steps. PFGM outperforms all the baselines on $\mathrm { { D D P M + + } }$ in all metrics. In addition, PFGM generally samples faster than other ODE baselines with the same RK45 solver. (3) The backward ODE in PFGM is compatible with architectures with varying capacities. PFGM consistently outperforms other ODE baselines on $\mathrm { D D P M + + }$ (Table 1) or NCSNv2 (Appendix D.2) backbones. (4) PFGM shows scalability to higher resolution datasets. In Appendix D.1, we show that PFGM are capable of scale-up to LSUN bedroom $2 5 6 \times 2 5 6$ . In particular, PFGM has comparable performance with VE-SDE with $1 5 \times$ fewer NFE.
155
+
156
+ In Fig. 3, we visualize the uncurated samples from PFGM on CIFAR-10, CelebA $6 4 \times 6 4$ and LSUN bedroom $2 5 6 \times 2 5 6$ . We provides more samples in Appendix E.
157
+
158
+ # 4.2 Failure of VE/VP-ODEs on NCSNv2 architecture
159
+
160
+ In our preliminary experiments on NCSNv2 architectures, we empirically observe that the VE/VP-ODEs have FID scores greater than 90 on CIFAR-10. In particular, VE/VP-ODEs can only generate decent samples when applying the Langevin dynamics corrector, and even then, their performances are still inferior to PFGM (Table 9, Table 10). The poor performance on NCSNv2 stands in striking contrast to their high sample quality on $\mathrm { N C S N + + / D D P M + + }$ in [33]. It indicates that the VE/VP-ODEs are
161
+
162
+ ![](images/b8860bcda32dab2d49f72ab93a489b264c43c232817b6c997c0142ac14f89d96.jpg)
163
+ Figure 4: Sample norm distributions with varying time variables $\sigma$ for VE-ODE and $z$ for PFGM)
164
+
165
+ ![](images/8f1d6bfd2fc3172f6a771fae4fc3892a6d968815e5d64788e0ff673cb1dd4cc0.jpg)
166
+ Figure 5: (a) Norm- $\cdot \sigma ( t )$ relation during the backward sampling of VE-ODE (Euler). (b) Norm- $z ( t ^ { \prime } )$ relation during the backward sampling of PFGM (Euler). The shaded areas mean the standard deviation of norms. (c) Number of steps versus FID score.
167
+
168
+ more susceptible to estimation errors than PFGM. We hypothesize that the strong norm- $\sigma$ correla tion seen during the training of score-based models causes the problem.
169
+
170
+ For score-based models, the $l _ { 2 }$ norms of perturbed training samples and the standard deviations $\sigma ( t )$ of Gaussian noises have strong correlation, e. $g . , l _ { 2 } \ \mathrm { n o r m } \approx \sigma ( t ) \sqrt { N }$ for large $\sigma ( t )$ in VE [33]. In contrast, as shown in Fig. 4, PFGM allocates high mass across a wide spectrum of the training sample norms. During sampling, VE/VP-ODEs could break down when the trajectories of backward ODEs deviate from the norm- $\cdot \sigma ( t )$ relation to which most training samples pertain. The weaker NCSNv2 backbone incurs larger errors and thus leads to their failure. The PFGM is more resistant to estimate errors because of the greater range of training sample norms.
171
+
172
+ To further verify the hypothesis above, we split a batch of VE-ODE samples into cleaner and noisier samples according to visual quality (Fig. 8(a)). In Fig. 5(a), we investigate the relation for cleaner and noisier samples during the forward Euler simulation of VE-ODE when $\sigma ( t ) < 1 5$ . We can see that the trajectory of cleaner samples stays close to the norm- $\sigma ( t )$ relation (the red dash line), whereas that of the noisier samples diverges from the relation. The Langevin dynamics corrector changes the trajectory of noisier samples to align with the relation. Fig. 5(b) further shows that the anchored variable $z ( t ^ { \prime } )$ and the norms in the backward ODE of PFGM are not strongly correlated, giving rise to the robustness against the imprecise estimation on NCSNv2. We defer more details to Appendix C.
173
+
174
+ # 4.3 Effects of step size in the forward Euler method
175
+
176
+ In order to accelerate the inference speed of ODEs, we can increase the step size (decrease the NFEs) in numerical solvers such as the forward Euler method. It also enables the trade-off between sample quality and computational efficiency in real-world deployment. We study the effects of increasing step size on PFGM, VP-ODE and DDIM [30] using the forward Euler method, with a varying NFE ranging from 10 to 100.
177
+
178
+ In Fig. 5(c), we report the sample quality measured by FID scores on CIFAR-10. As expected, all the methods have higher FID scores when decreasing the NFE. We observe that the sample quality of PFGM degrades gracefully as we decrease the NFE. Our method shows significantly better robustness to step sizes than the VP-ODE, especially when only taking a few Euler steps. In addition, PFGM obtains better FID scores than DDIM on most NFEs except for 10 where PFGM is marginally worse. This suggests that the PFGM is a promising method for accommodating instantaneous resource availability, as high-quality samples can be generated in limited steps.
179
+
180
+ # 4.4 Utilities of ODE: likelihood evaluation and latent representation
181
+
182
+ Similar to the family of discrete normalizing flows [6, 19, 14] and continuous probability flow [33], the forward ODE in PFGM defines an invertible mapping between the data space and latent space with a known prior. Formally, we define the invertible forward $\mathcal { M }$ mapping by integrating the corresponding forward ODE $\begin{array} { r } { \dot { d } ( \mathbf { x } , z ) = ( \mathbf { v } ( \tilde { \mathbf { x } } ) _ { \mathbf { x } } \mathbf { v } ( \tilde { \mathbf { x } } ) _ { z } ^ { - 1 } z , z ) d t ^ { \prime } } \end{array}$ of Eq. (6):
183
+
184
+ $$
185
+ \mathbf { x } ( \log z _ { \operatorname* { m a x } } ) = \mathcal { M } ( \mathbf { x } ( \log z _ { \operatorname* { m i n } } ) ) \equiv \mathbf { x } ( \log z _ { \operatorname* { m i n } } ) + \int _ { \log z _ { \operatorname* { m i n } } } ^ { \log z _ { \operatorname* { m a x } } } \mathbf { v } ( \mathbf { x } ( t ^ { \prime } ) ) _ { \mathbf { x } } \mathbf { v } ( \tilde { \mathbf { x } } ( t ^ { \prime } ) ) _ { z } ^ { - 1 } e ^ { t ^ { \prime } } d t ^ { \prime }
186
+ $$
187
+
188
+ where $\log z _ { \mathrm { m i n } } / \log z _ { \mathrm { m a x } }$ are the starting/terminal time in the forward ODE. The forward mapping transfers the data distribution to the prior distribution $p _ { \mathrm { p r i o r } }$ on the $z = z _ { \mathrm { m a x } }$ hyperplane (cf. Section 3.3): $p _ { \mathrm { p r i o r } } \big ( \mathbf { x } \big ( \log z _ { \mathrm { m a x } } \big ) \big ) = \mathcal { M } \big ( p ( \mathbf { x } ( \log \bar { z } _ { \mathrm { m i n } } ) ) \big )$ . The invertibility enables likelihood evaluation and creates a meaningful latent space on the $z = z _ { \mathrm { m a x } }$ hyperplane. In addition, we can adapt to the computational constraints by adjusting the step size or the precision in numerical ODE solvers.
189
+
190
+ Likelihood evaluation We evaluate the data likelihood by the instantaneous change-of-variable formula [4, 33]. In Table 2, we report the bits/dim on the uniformly dequantized CIFAR-10 test set and compare with existing baselines that use the same setup. We observe that PFGM achieves better likelihoods than discrete normalizing flow models, even without maximum likelihood training. Among the continuous flow models, sub-VP-ODE shows the lowest bits/dim, although its sample quality is worse than VP-ODE and PFGM (Table 1). The exploration of the seeming trade-off between likelihood and sample quality is left for future works.
191
+
192
+ Table 2: Bits/dim on CIFAR-10
193
+
194
+ <table><tr><td></td><td>bits/dim ↓</td></tr><tr><td>RealNVP [6]</td><td>3.49</td></tr><tr><td>Glow [19] Residual Flow [3]</td><td>3.35 3.28</td></tr><tr><td>Flow++ [14]</td><td>3.29</td></tr><tr><td>DDPM(L)[16]</td><td>≤3.70*</td></tr><tr><td>DDPM++backbone</td><td></td></tr><tr><td>VP-ODE [33]</td><td>3.20</td></tr><tr><td>sub-VP-ODE[33]</td><td>3.02</td></tr><tr><td>PFGM (ours)</td><td>3.19</td></tr></table>
195
+
196
+ Latent representation Since the samples are uniquely identifiable by their latents via the invertible mapping $\mathcal { M }$ , PFGM further supports image manipulation using its latent representation on the $z =$ $z _ { \mathrm { m a x } }$ hyperplane. We include the results of image interpolation and the temperature scaling [6, 19, 33] to Appendix D.4 and Appendix D.5. For interpolation, it shows that we can travel along the latent space to obtain perceptually consistent interpolations between CelebA images.
197
+
198
+ # 5 Conclusion
199
+
200
+ We present a new deep generative model by solving the Poisson equation whose source term is the data distribution. We estimate the normalized gradient field of the solution in an augmented space with an additional dimension. For sampling, we devise a backward ODE that exponential decays on the physically meaningful additional dimension. Empirically, our approach has currently best performance over other normalizing flow baselines, and achieving $1 0 \times$ to $2 0 \times$ acceleration over the stochastic methods. Our backward ODE shows greater stability against errors than popular ODE-based methods, and enables efficient adaptive sampling. We further demonstrate the utilities of the forward ODE on likelihood evaluation and image interpolation. Future directions include improving the normalization of Poisson fields. More principled approaches can be used to get around the divergent near-field behavior. For example, we may exploit renormalization, a useful tool in physics, to make the Poisson field well-behaved in near fields.
201
+
202
+ # Acknowledgements
203
+
204
+ We are grateful to Shangyuan Tong, Timur Garipov and Yang Song for helpful discussion. We would like to thank Octavian Ganea and Wengong Jin for reviewing an early draft of this paper. YX and TJ acknowledge support from MIT-DSTA Singapore collaboration, from NSF Expeditions grant (award 1918839) ”Understanding the World Through Code”, and from MIT-IBM Grand Challenge project. ZL and MT would like to thank the Center for Brains, Minds, and Machines (CBMM) for hospitality. ZL and MT are supported by The Casey and Family Foundation, the Foundational Questions Institute, the Rothberg Family Fund for Cognitive Science and IAIFI through NSF grant PHY-2019786.
205
+
206
+ References
207
+ [1] Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. ArXiv, abs/1809.11096, 2019.
208
+ [2] 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, T. J. Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeff 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, abs/2005.14165, 2020.
209
+ [3] Ricky T. Q. Chen, Jens Behrmann, David Kristjanson Duvenaud, and Jorn-Henrik Jacobsen. ¨ Residual flows for invertible generative modeling. ArXiv, abs/1906.02735, 2019.
210
+ [4] Tian Qi Chen, Yulia Rubanova, Jesse Bettencourt, and David Kristjanson Duvenaud. Neural ordinary differential equations. ArXiv, abs/1806.07366, 2018.
211
+ [5] Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34:8780–8794, 2021.
212
+ [6] Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real nvp. ArXiv, abs/1605.08803, 2017.
213
+ [7] J. R. Dormand and P. J. Prince. A family of embedded runge-kutta formulae. Journal of Computational and Applied Mathematics, 6:19–26, 1980.
214
+ [8] Yilun Du and Igor Mordatch. Implicit generation and generalization in energy-based models. ArXiv, abs/1903.08689, 2019.
215
+ [9] Herbert Goldstein, Charles Poole, and John Safko. Classical mechanics, 2002.
216
+ [10] Will Grathwohl, Ricky T. Q. Chen, Jesse Bettencourt, Ilya Sutskever, and David Kristjanson Duvenaud. Ffjord: Free-form continuous dynamics for scalable reversible generative models. ArXiv, abs/1810.01367, 2019.
217
+ [11] David J Griffiths. Introduction to electrodynamics, 2005.
218
+ [12] Ishaan Gulrajani, Faruk Ahmed, Mart´ın Arjovsky, Vincent Dumoulin, and Aaron C. Courville. Improved training of wasserstein gans. In NIPS, 2017.
219
+ [13] 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 NIPS, 2017.
220
+ [14] Jonathan Ho, Xi Chen, A. Srinivas, Yan Duan, and P. Abbeel. Flow $^ { + + }$ : Improving flowbased generative models with variational dequantization and architecture design. ArXiv, abs/1902.00275, 2019.
221
+ [15] Jonathan Ho and Stefano Ermon. Generative adversarial imitation learning. In NIPS, 2016.
222
+ [16] Jonathan Ho, Ajay Jain, and P. Abbeel. Denoising diffusion probabilistic models. ArXiv, abs/2006.11239, 2020.
223
+ [17] Tero Karras, Miika Aittala, Janne Hellsten, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Training generative adversarial networks with limited data. ArXiv, abs/2006.06676, 2020.
224
+ [18] Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 4401–4410, 2019.
225
+ [19] Diederik P. Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. In NeurIPS, 2018.
226
+
227
+ [20] Diederik P. Kingma, Shakir Mohamed, Danilo Jimenez Rezende, and Max Welling. Semisupervised learning with deep generative models. ArXiv, abs/1406.5298, 2014.
228
+
229
+ [21] Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. CoRR, abs/1312.6114, 2014.
230
+
231
+ [22] Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. Cifar-10 (canadian institute for advanced research). 2009.
232
+
233
+ [23] F Shampine Lawrence. Some practical runge-kutta formulas. Mathematics of Computation, 46:135–150, 1986.
234
+
235
+ [24] Kwonjoon Lee, Huiwen Chang, Lu Jiang, Han Zhang, Zhuowen Tu, and Ce Liu. Vitgan: Training gans with vision transformers. ArXiv, abs/2107.04589, 2021.
236
+
237
+ [25] Daiqing Li, Junlin Yang, Karsten Kreis, Antonio Torralba, and Sanja Fidler. Semantic segmentation with generative models: Semi-supervised learning and strong out-of-domain generalization. 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 8296–8307, 2021.
238
+
239
+ [26] Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. ArXiv, abs/1802.05957, 2018.
240
+
241
+ [27] Henry Ricardo. A modern introduction to differential equations. 2002.
242
+
243
+ [28] Hannes Risken. Fokker-planck equation. 1984.
244
+
245
+ [29] Tim Salimans, Ian J. Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. ArXiv, abs/1606.03498, 2016.
246
+
247
+ [30] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. ArXiv, abs/2010.02502, 2021.
248
+
249
+ [31] Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. ArXiv, abs/1907.05600, 2019.
250
+
251
+ [32] Yang Song and Stefano Ermon. Improved techniques for training score-based generative models. ArXiv, abs/2006.09011, 2020.
252
+
253
+ [33] Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. ArXiv, abs/2011.13456, 2021.
254
+
255
+ [34] Christian Szegedy, V. Vanhoucke, S. Ioffe, Jon Shlens, and Z. Wojna. Rethinking the inception architecture for computer vision. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 2818–2826, 2016.
256
+
257
+ [35] Aaron 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. In SSW, 2016.
258
+
259
+ [36] Aaron van den Oord, Nal Kalchbrenner, Lasse Espeholt, Koray Kavukcuoglu, Oriol Vinyals, ¨ and Alex Graves. Conditional image generation with pixelcnn decoders. In NIPS, 2016.
260
+
261
+ [37] Pauli Virtanen, Ralf Gommers, Travis E. Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, Stefan J. ´ van der Walt, Matthew Brett, Joshua Wilson, K. Jarrod Millman, Nikolay Mayorov, Andrew R. J. Nelson, Eric Jones, Robert Kern, Eric Larson, C J Carey, Ilhan Polat, Yu Feng, Eric W. Moore, J. Vanderplas, Denis Laxalde, Josef Perktold, Robert Cimrman, Ian Daniel Henriksen, E. A. Quintero, Charles R. Harris, Anne M. Archibald, Antonio H. Ribeiro, Fabian Pedregosa, ˆ Paul van Mulbregt, Aditya Alessandro Pietro Alex Andreas Andreas Anthony Ant Vijaykumar Bardelli Rothberg Hilboll Kloeckner Sco, Aditya Vijaykumar, Alessandro Pietro Bardelli, Alex Rothberg, Andreas Hilboll, Andre Kloeckner, Anthony M. Scopatz, Antony Lee, Ariel S. Rokem, C. Nathan Woods, Chad Fulton, Charles Masson, Christian Haggstr ¨ om, Clark Fitzgerald, ¨
262
+
263
+ David A. Nicholson, David R. Hagen, Dmitrii V. Pasechnik, Emanuele Olivetti, Eric Martin, Eric Wieser, Fabrice Silva, Felix Lenders, Florian Wilhelm, Gert Young, Gavin A. Price, GertLudwig Ingold, Gregory E. Allen, Gregory R. Lee, Herve Audren, Irvin Probst, Jorg P. Dietrich, ´ Jacob Silterra, James T. Webber, Janko Slavi, Joel Nothman, Johannes Buchner, Johannes Kulick, Johannes L. Schonberger, Jos ¨ e Vin ´ ´ıcius de Miranda Cardoso, Joscha Reimer, Joseph E. Harrington, Juan Luis Cano Rodr´ıguez, Juan Nunez-Iglesias, Justin Kuczynski, Kevin Lee Tritz, Martin Dr Thoma, Matt Newville, Matthias Kummerer, Maximilian Bolingbroke, Michael ¨ Tartre, Mikhail Pak, Nathaniel J. Smith, Nikolai Nowaczyk, Nikolay Shebanov, Oleksandr Pavlyk, Per Andreas Brodtkorb, Perry Lee, Robert T. McGibbon, Roman Feldbauer, Sam Lewis, Sam Tygier, Scott Sievert, Sebastiano Vigna, Stefan Peterson, Surhud More, Tadeusz Pudlik, Taku Oshima, Thomas J. Pingel, Thomas P. Robitaille, Thomas Spura, Thouis Raymond Jones, Tim Cera, Tim Leslie, Tiziano Zito, Tom Krauss, U. Upadhyay, Yaroslav O. Halchenko, and Y. Vazquez-Baeza. Scipy 1.0: fundamental algorithms for scientific computing in python. ´ Nature Methods, 17:261 – 272, 2020.
264
+ [38] Shuo Yang, Ping Luo, Chen Change Loy, and Xiaoou Tang. From facial parts responses to face detection: A deep learning approach. 2015 IEEE International Conference on Computer Vision (ICCV), pages 3676–3684, 2015.
265
+ [39] Fisher Yu, Yinda Zhang, Shuran Song, Ari Seff, and Jianxiong Xiao. Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop. ArXiv, abs/1506.03365, 2015.
266
+
267
+ # Checklist
268
+
269
+ 1. For all authors...
270
+
271
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
272
+ (b) Did you describe the limitations of your work? [Yes] See Appendix G.
273
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Appendix H.
274
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
275
+
276
+ 2. If you are including theoretical results...
277
+
278
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Appendix A. (b) Did you include complete proofs of all theoretical results? [Yes] See Appendix A.
279
+
280
+ 3. If you ran experiments...
281
+
282
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See the abstract.
283
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix B.1.
284
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
285
+ (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] All the experiments are run on a single NVIDIA A100 GPU.
286
+
287
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
288
+
289
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
290
+ (b) Did you mention the license of the assets? [N/A] The assets are public/open-source datasets and codes.
291
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
292
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
293
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
294
+
295
+ 5. If you used crowdsourcing or conducted research with human subjects...
296
+
297
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
298
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
299
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/w1UbdvWH_R3/w1UbdvWH_R3.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/xkjqJYqRJy/xkjqJYqRJy.md ADDED
@@ -0,0 +1,658 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BAYESIAN NEURAL NETWORK PRIORS REVISITED
2
+
3
+ Vincent Fortuin∗ ETH Zürich, Switzerland fortuin@inf.ethz.ch
4
+
5
+ Adrià Garriga-Alonso∗
6
+ University of Cambridge, United Kingdom
7
+ ag919@cam.ac.uk
8
+ Sebastian W. Ober
9
+ University of Cambridge, United Kingdom
10
+ swo25@cam.ac.uk
11
+
12
+ Florian Wenzel Google AI Berlin, Germany florianwenzel@google.com
13
+
14
+ Gunnar Rätsch ETH Zürich, Switzerland raetsch@inf.ethz.ch
15
+
16
+ Richard E. Turner University of Cambridge, United Kingdom ret26@eng.cam.ac.uk
17
+
18
+ Mark van der Wilk† Imperial College London, United Kingdom m.vdwilk@imperial.ac.uk
19
+
20
+ Laurence Aitchison† University of Bristol, United Kingdom laurence.aitchison@bristol.ac.uk
21
+
22
+ # ABSTRACT
23
+
24
+ Isotropic Gaussian priors are the de facto standard for modern Bayesian neural network inference. However, it is unclear whether these priors accurately reflect our true beliefs about the weight distributions or give optimal performance. To find better priors, we study summary statistics of neural network weights in networks trained using stochastic gradient descent (SGD). We find that convolutional neural network (CNN) and ResNet weights display strong spatial correlations, while fully connected networks (FCNNs) display heavy-tailed weight distributions. We show that building these observations into priors can lead to improved performance on a variety of image classification datasets. Surprisingly, these priors mitigate the cold posterior effect in FCNNs, but slightly increase the cold posterior effect in ResNets.
25
+
26
+ # 1 INTRODUCTION
27
+
28
+ In a Bayesian neural network (BNN), we specify a prior $p ( w )$ over the neural network parameters, and compute the posterior distribution over parameters conditioned on training data, $\bar { p ( w | x , y ) = }$ $p ( y | w , x ) p ( w ) / p ( y | x )$ . This procedure should give considerable advantages for reasoning about predictive uncertainty, which is especially relevant in the small-data setting. Crucially, to perform Bayesian inference, we need to choose a prior that accurately reflects our beliefs about the parameters before seeing any data (Bayes, 1763; Gelman et al., 2013). However, the most common choice of prior for BNN weights is the simplest one: the isotropic Gaussian. Isotropic Gaussians are used across almost all fields of Bayesian deep learning, ranging from variational inference (e.g., Hernández-Lobato & Adams, 2015; Louizos & Welling, 2017; Dusenberry et al., 2020), samplingbased inference (e.g., Neal, 1992; Zhang et al., 2019), and Laplace’s method (e.g., Osawa et al., 2019; Immer et al., 2021b), to even infinite networks (e.g., Lee et al., 2017; Garriga-Alonso et al., 2019). It is troubling that no alternatives are usually considered, since better choices likely exist.
29
+
30
+ Indeed, despite the progress on more accurate and efficient inference procedures, in some settings, the posterior predictive distribution of BNNs using Gaussian priors still leads to worse predictive performance than a baseline obtained by training the network with standard stochastic gradient descent (SGD) (e.g., Zhang et al., 2019; Heek & Kalchbrenner, 2019; Wenzel et al., 2020a). Surprisingly, these issues can largely be fixed by artificially reducing posterior uncertainty using “cold posteriors” (Wenzel et al., 2020a). The cold posterior is $p ( w | x , y ) ^ { \frac { 1 } { T } }$ for a temperature $0 < T < 1$ , where the original Bayes posterior would be obtained by setting $T = 1$ (see Eq. 1). Using cold posteriors can be interpreted as overcounting the data and, hence, deviating from the Bayesian paradigm. This should not happen if the prior and likelihood accurately reflect our beliefs. Assuming inference is working correctly, the Bayesian solution, $T = 1$ , really should be optimal (Gelman et al., 2013). Hence, it raises the possibility that either the prior (Wenzel et al., 2020a) or likelihood (Aitchison, 2020b) (or both) are misspecified.
31
+
32
+ In this work, we study empirically whether isotropic Gaussian priors are indeed suboptimal for BNNs and whether this can explain the cold posterior effect. We analyze the performance of different BNN priors for different network architectures and compare them to the empirical weight distributions of standard SGD-trained neural networks. We conclude that correlated Gaussian priors are better in ResNets, while uncorrelated heavy-tailed priors are better in fully connected neural networks (FCNNs). Thus, we would recommend these choices instead of the widely-used isotropic Gaussian priors. While these priors eliminate the cold posterior effect in FCNNs, they slightly increase the cold posterior effect in ResNets. This provides evidence that the cold posterior effect arises due to a misspecification of the prior (Wenzel et al., 2020a) in FCNNs. In ResNets, it is difficult to draw any strong conclusions about the cold posterior effect from our results. Our observations are compatible with the hypothesis that the cold posterior effect arises in large-scale image models due to a misspecified likelihood (Aitchison, 2020b) or due to data augmentation (Izmailov et al., 2020), but there could of course be a prior that we did not consider that improves performance and eliminates the cold posterior effect. We make our library available on Github1, inviting other researchers to join us in studying the role of priors in BNNs using state-of-the-art inference.
33
+
34
+ # 1.1 CONTRIBUTIONS
35
+
36
+ Our main contributions are:
37
+
38
+ • An analysis of the empirical weight distributions of SGD-trained neural networks with different architectures, suggesting that FCNNs learn heavy-tailed weight distributions (Sec. 3.1), while CNN and ResNet weight distributions show significant spatial correlations (Sec. 3.2).
39
+
40
+ • Experiments in Bayesian FCNNs showing that heavy-tailed priors give better classification performance than the widely-used Gaussian priors (Sec. 4.2).
41
+
42
+ • Experiments in Bayesian ResNets showing that spatially correlated Gaussian priors give better classification performance than isotropic priors (Sec. 4.3).
43
+
44
+ ![](images/ac78a6a3d5c1d047a0c131887b4cfc1b751e353424b873668852787285e7e31f.jpg)
45
+ Figure 1: Empirical marginal weight distributions of a layer of FCNNs and CNNs trained with SGD on MNIST, and an early layer of several ResNets trained on CIFAR-10. We show weight histograms (left) and quantile-quantile (Q-Q) plots with different distributions (right). The empirical weights are clearly heavier-tailed than a Gaussian (green line), and better fit by a Laplace (orange line).
46
+
47
+ • Experiments showing that the cold posterior effect can be reduced by choosing better, heavy-tailed priors in FCNNs, while the cold posterior is slightly increased when using better, spatially correlated priors in ResNets (Sec. 4).
48
+
49
+ # 2 BACKGROUND: THE COLD POSTERIOR EFFECT
50
+
51
+ When performing inference in Bayesian models, we can temper the posterior by a positive temperature $T$ , giving
52
+
53
+ $$
54
+ \log p ( w | x , y ) ^ { \frac { 1 } { T } } = { \frac { 1 } { T } } [ \log p ( y | w , x ) + \log p ( w ) ] + Z ( T )
55
+ $$
56
+
57
+ for neural network weights $w$ , inputs $x$ regression targets or class-labels $y$ , prior $p ( w )$ , likelihood $p ( y | w , x )$ , and a normalizing constant $Z ( T )$ . Setting $T = 1$ yields the standard Bayesian posterior. The temperature parameter can be easily handled when simulating Langevin dynamics, as used in molecular dynamics and MCMC (Leimkuhler & Matthews, 2012).
58
+
59
+ In their recent work, Wenzel et al. (2020a) have drawn attention to the fact that cooling the posterior in BNNs (i.e., setting $T < 1$ ), often improves performance. Testing different hypotheses for potential problems with the inference, likelihood, and prior, they conclude that the BNN priors (which were Gaussian in their experiments) are misspecified—at least when used in conjuction with standard neural network architectures on standard benchmark tasks—which could be one of the main causes of the cold posterior effect (c.f., Germain et al., 2016; van der Wilk et al., 2018). Reversing this argument, we can hypothesize that choosing better priors for BNNs may lead to a less pronounced cold posterior effect, which we can use to evaluate different candidate priors.
60
+
61
+ # 3 EMPIRICAL ANALYSIS OF NEURAL NETWORK WEIGHTS
62
+
63
+ As we have discussed, standard Gaussian priors may not be the optimal choice for modern BNN architectures. But how can we find more suitable priors? Since it is hard to directly formulate reasonable prior beliefs about neural network weights, we turn to an empirical approach. We trained fully connected neural networks (FCNNs), convolutional neural networks (CNNs), and ResNets with SGD on various image classification tasks to obtain an approximation of the empirical distribution of the fitted weights, that is, the distribution of the maximum a posteriori (MAP) solutions reached by SGD. If the distributions over SGD-fitted weights differ strongly from the usual isotropic Gaussian prior, that provides evidence that those features should be incorporated into the prior. Hence, we can use our insights by inspecting the empirical weight distribution to propose better-suited priors.
64
+
65
+ Formally, this procedure can be viewed as approximate human-in-the-loop expectation maximization (EM). In particular, in expectation maximization, we alternate expectation $\mathrm { ( E ) }$ and maximization (M) steps. In the expectation (E) step, we infer the posterior $p ( w | x , y , \theta _ { t - 1 } )$ over the weights, $w$ , given the parameters of the prior from the previous step, $\theta _ { t - 1 }$ . In our case, we approximately infer the weights using SGD. Then, in the maximization step, we compute new prior parameters $\theta _ { t }$ , by sampling weights $w$ from the posterior computed in the E step, and maximizing the joint probability of sampled weights and data. As $y$ is independent of the prior parameters if the weights are known, the M-step reduces to fitting a prior distribution to the weights sampled from the posterior, that is,
66
+
67
+ $$
68
+ \begin{array} { r l } & { \mathcal { L } _ { t } ( \theta ) = \mathbb { E } _ { p ( w | x , y , \theta _ { t - 1 } ) } [ \log p ( y | x , w ) + \log p ( w | \theta ) ] } \\ & { \qquad = \mathbb { E } _ { p ( w | x , y , \theta _ { t - 1 } ) } [ \log p ( w | \theta ) ] + \mathrm { c o n s t } } \\ & { \qquad \theta _ { t } = \arg \operatorname* { m a x } \mathcal { L } _ { t } ( \theta ) ~ . } \end{array}
69
+ $$
70
+
71
+ Intuitively, this procedure allows the prior (and therefore the posterior) to assign more probability mass to the SGD solutions, which are known to work well in practice. This is also related to ideas from empirical Bayes (Robbins, 1992), where the (few) hyperparameters of the prior are fit to the data, and to recent ideas in PAC-Bayesian theory, where data-dependent priors have been shown to improve generalization guarantees over data-independent ones (Rivasplata et al., 2020; Dziugaite et al., 2021). While such approaches introduce a certain risk of overfitting (Ober et al., 2021), we would argue that standard BNNs are typically thought to be underfitting (Neal, 1996; Wenzel et al., 2020a; Dusenberry et al., 2020) and that we do not directly fit the prior parameters, but merely draw inspiration for the choice of prior family from the qualitative shape of the empirical weight distributions.
72
+
73
+ We begin by considering whether the weights of FCNNs and CNNs are heavy-tailed, and move on to look at correlational structure in the weights of CNNs and ResNets. Note that in the exploratory experiments here, we used SGD to perform MAP inference with a uniform prior (that is, maximum likelihood fitting). This avoids any prior assumptions obscuring interesting patterns in the inferred weights. These patterns inspired our choice of priors, and we then evaluated these priors in BNNs, showing that they improved classification performance (see Sec. 4).
74
+
75
+ ![](images/b7e9eb441dff689600e4a1d6cf60b3e0d85b998b7742ad3db1f44646323f24f2.jpg)
76
+ Figure 2: (a) Degrees of freedom for Student-t distributions fitted to the weights of a ResNet20 trained on CIFAR-10. The degrees of freedom get larger in deeper layers, implying that the weight distributions become less heavy-tailed and more similar to Gaussians. The layers marked with asterisks $( ^ { * } )$ are the first layers of their respective ResNet blocks. (b) Spatial covariance of the weights within CNN filters for a three-hidden layer network trained on MNIST, normalized by the number of channels. The weights correlate strongly with neighboring pixels, and anti-correlate (layer 1) or do not correlate (layer 2) with distant ones. Each delineated square shows the covariances of a filter location (marked with $\times$ ) with all other locations.
77
+
78
+ # 3.1 FCNN WEIGHTS ARE HEAVY-TAILED
79
+
80
+ We trained an FCNN (Fig. 1, top) and a CNN (Fig. 1, middle) on MNIST (LeCun et al., 1998). The FCNN is a three layer network with 100 hidden units per layer and ReLU nonlinearities. The CNN is a three layer network, with two convolutional layers and one fully connected layer. The convolutional layers have 64 channels and use $3 \times 3$ convolutions, followed by $2 \times 2$ max-pooling layers. All layers use ReLU nonlinearities. Networks were trained with SGD for 450 epochs using a learning rate schedule of 0.05, 0.005, and 0.0005 for 150 epochs each. We can see in Figure 1 that the weight values of the FCNNs and CNNs follow a more heavy-tailed distribution than a Gaussian, with the tails being reasonably well approximated by a Laplace distribution. This suggests that “true” BNN priors might be more heavy-tailed than isotropic Gaussians.
81
+
82
+ Next, we did a similar analysis for a ResNet20 trained on CIFAR-10 (Krizhevsky, 2009) (Fig. 1, bottom). Since this network had many layers, we quantified the degree of heavy-tailedness by fitting the degrees of freedom parameter $\nu$ of a Student-t distribution. For $\nu \to \infty$ , the Student-t becomes Gaussian, so large values of $\nu$ indicate that the weights are approximately Gaussian, whereas smaller values indicate heavy-tailed behavior (see Sec. 4.1). We found that at lower layers, $\nu$ was small, so the weights were somewhat heavy-tailed, whereas at higher layers, $\nu$ became much larger, so the weights were approximately Gaussian (Fig. 2a).
83
+
84
+ These results are perhaps expected if we assume that the filters have (using neuroscience terminology) “localized receptive fields”, like those in Olshausen & Field (1997). Such filters contain a large number of near-zero weights outside the receptive field, with a number of very large weights inside the receptive field (Sahani & Linden, 2003; Smyth et al., 2003), and thus will follow a heavy-tailed distribution. As we get into the deeper layers of the networks, receptive fields are expected to become larger, so this effect may be less relevant.
85
+
86
+ # 3.2 CNN WEIGHTS ARE SPATIALLY CORRELATED
87
+
88
+ In the second part of our empirical inspection of fitted weight distributions, we looked at spatial correlations in CNN filters. In particular, we considered 9-dimensional vectors formed by the $3 \times 3$ filters for every input and output channel. We studied our three-layer network trained on MNIST and found strong correlations between nearby pixels, and lesser (layer 2) or even negative (layer 1) correlations at more distant pixels (Fig. 2b). We found similar spatial correlations in a ResNet20 trained on CIFAR-10, across all layers, with correlation strength increasing as we move to later layers (Fig. 3). We found by far the strongest evidence of correlations spatially, that is, between weights within the same convolutional filter. This could potentially be due to the smoothness and translation equivariance properties of natural images (Simoncelli, 2009). However, we also found some evidence for spatial correlations in the input layer of an FCNN (Fig. A.1 in the appendix), but no evidence for correlations between the channels of a convolutional layer (Fig. A.5 in the appendix). Note though that this methodology cannot find structured correlations between channels, except at the input and output. This is because NN functions are invariant to permutations of channels (Sussmann, 1992; MacKay, 1992; Bishop et al., 1995; Aitchison, 2020a; Aitchison et al., 2020).
89
+
90
+ ![](images/defd8afc3d89116adef03a657a994bca0cde18868bcfa8e043fcd8c855fcd3de.jpg)
91
+ Figure 3: Spatial covariances for the convolutional weights of the layers of a ResNet-20, normalized by the maximum variance for each layer, which is shown on the bottom right. We trained the network with SGD on CIFAR-10 with data augmentation (10 times). Layer 1 is the closest to the input. The first layer of every ResNet block is marked with an asterisk $( ^ { \ast } )$ . We see that there are significant covariances in all layers, but that their strength increases for later layers.
92
+
93
+ These findings suggest that better priors could be designed by explicitly taking this correlation structure into account. We hypothesize that multivariate distributions with non-diagonal covariance matrices could be good candidates for convolutional layer priors, especially when the covariances are large for neighboring pixels within the convolutional filters (see Sec. 4.3).
94
+
95
+ Additional evidence for the usefulness of correlated weights comes from the theory of infinitely wide CNNs and ResNets. Novak et al. (2019) noticed that the effect of weight-sharing disappears when infinite filters are used with isotropic priors. More recently, Garriga-Alonso & van der Wilk (2021) showed that this effect can be avoided by using spatially correlated priors, leading to improved performance. Our experiments investigate whether this prior is also useful in the finite-width case.
96
+
97
+ # 4 EMPIRICAL STUDY OF BAYESIAN NEURAL NETWORK PRIORS
98
+
99
+ We performed experiments on MNIST and on CIFAR-10. We compare Bayesian FCNNs, CNNs, and ResNets on these tasks. For the BNN inference, we used Stochastic Gradient Markov Chain Monte Carlo (SG-MCMC), in order to scale to large training datasets. To obtain posterior samples that are close to the true posterior, we used an inference method that builds on the inference approach used in Wenzel et al. (2020a), which has been shown to produce high-quality samples. In particular, we combined the gradient-guided Monte Carlo (GG-MC) scheme from Garriga-Alonso & Fortuin (2021) with the cyclical learning rate schedule from Zhang et al. (2019) and the preconditioning and convergence diagnostics from Wenzel et al. (2020a). We ran each chain for 60 cycles of 45 epochs each, taking one sample at the end of each of the last five epochs of each cycle, thus yielding 300 samples after 2,700 epochs, out of which we discarded the first 50 samples as a burn-in. Per temperature setting, dataset, model, and prior, we ran five such chains as replicates. Additional experimental results can be found in Appendix A, details about the evaluation metrics in Appendix B, about the priors in Appendix C, and about the implementation in Appendix D. In the figures, we generally include an SGD baseline for the predictive error, where it is often competitive with some of the priors. For the likelihood, calibration, and OOD detection, the SGD baselines were out of the plotting range and are therefore not shown. For completeness, we show them in Appendix A.4. We show results for higher temperatures $T > 1 \AA ,$ ) in Appendix A.6, for different prior variances in Appendix A.7, and for different network architectures in Appendix A.8. Moreover, while we focus on image classification tasks in this section, we provide results on UCI regression tasks in Appendix A.9. We also show inference diagnostics highlighting the accuracy of our MCMC sampling in Appendix A.10. Finally, we replicate our experiments on ResNets and CIFAR-10 for mean-field variational inference (Blundell et al., 2015) in Appendix A.11.
100
+
101
+ # 4.1 PRIORS UNDER CONSIDERATION
102
+
103
+ We contrast the widely used isotropic Gaussian priors with heavy-tailed distributions, including the Laplace and Student-t distributions, and with correlated Gaussian priors. We chose these distributions based on our observations of the empirical weight distributions of SGD-trained networks (see Sec. 3) and for their ease of implementation and optimization. Further details on the distributions and their density functions can be found in Appendix C.
104
+
105
+ The isotropic Gaussian distribution (Gauss, 1809) is the de-facto standard for BNN priors in recent work (e.g., Hernández-Lobato & Adams, 2015; Louizos & Welling, 2017; Dusenberry et al., 2020; Wenzel et al., 2020a; Neal, 1992; Zhang et al., 2019; Osawa et al., 2019; Immer et al., 2021b; Lee et al., 2017; Garriga-Alonso et al., 2019). However, its tails are relatively light compared to some of the other distributions that we will consider and compared to the empirical weight distributions described above. The Laplace distribution (Laplace, 1774), for instance, has heavier tails than the Gaussian. It is often used in the context of (frequentist) lasso regression (Tibshirani, 1996). Similarly, the Student-t distribution is also heavy-tailed. Moreover, it can be seen as a Gaussian scale-mixture, where the scales are inverse-Gamma distributed (Helmert, 1875; Lüroth, 1876).
106
+
107
+ For our correlated Bayesian CNN priors, we use multivariate Gaussian priors and define the covariance $\pmb { \Sigma }$ to be block-diagonal, such that the covariance between weights in different filters is 0 and between weights in the same filter is given by a Matérn kernel $( \nu = 1 / 2$ ) on the pixel distances. Formally, for the weights $w _ { i , j }$ and $w _ { i ^ { \prime } , j ^ { \prime } }$ in filters $i$ and $i ^ { \prime }$ and for pixels $j$ and $j ^ { \prime }$ , the covariance is
108
+
109
+ $$
110
+ \begin{array} { r } { \mathrm { c o v } ( w _ { i , j } , w _ { i ^ { \prime } , j ^ { \prime } } ) = \left\{ \begin{array} { l l } { \sigma ^ { 2 } \exp \left( \frac { - d ( j , j ^ { \prime } ) } { \lambda } \right) } & { \mathrm { i f ~ } i = i ^ { \prime } } \\ { 0 } & { \mathrm { o t h e r w i s e } } \end{array} \right. , } \end{array}
111
+ $$
112
+
113
+ where $d ( \cdot , \cdot )$ is the Euclidean distance between pixel positions and we set $\sigma = \lambda = 1$ . This kernel was chosen to capture the decay with distance of spatial correlations (Fig. 3).
114
+
115
+ # 4.2 BAYESIAN FCNN PERFORMANCE WITH DIFFERENT PRIORS
116
+
117
+ Following our observations from the empirical weight distributions (Sec. 3.1), we hypothesized that heavy-tailed priors should work better than Gaussian priors for Bayesian FCNNs. We tested this hypothesis by performing BNN inference with the same network architecture as in Sec. 3, using different priors. We report the predictive error and log likelihood on the MNIST test set. We follow Ovadia et al. (2019) in reporting the calibration of the uncertainty estimates on rotated MNIST digits and the out-of-distribution (OOD) detection accuracy on FashionMNIST (Xiao et al., 2017). For more details about our evaluation metrics, see Appendix B.
118
+
119
+ We observe that the heavy-tailed priors indeed outperform the Gaussian prior in terms of test error and test NLL in all cases, except for the Student-t distribution on MNIST at low temperatures (Fig. 4). That said, calibration and OOD metrics are less clear, with heavy-tailed priors giving worse calibration and roughly similar OOD detection on MNIST and better calibration but worse OOD detection on FashionMNIST. Despite the unclear results on calibration and OOD detection, the error and NLL performance improvement for heavy-tailed priors at $T = 1$ is considerable, and suggests that Gaussian priors over the weights of FCNNs induce poor priors in the function space and inhibit the posterior from assigning probability mass to high-likelihood solutions, such as the SGD solutions analyzed above (Sec. 3). Finally, the cold posterior effect is removed—or even inverted—when using heavy-tailed priors, which supports the hypothesis that it is caused by prior misspecification in
120
+
121
+ ![](images/c5f463610de8f57af7350874b176d727679259f4263dc141b4e96d46dc5b5dfe.jpg)
122
+ Figure 4: Performances of fully connected BNNs with different priors on MNIST and FashionMNIST (see Sec. 4.2). The heavy-tailed priors generally perform better, especially at higher temperatures, and lead to a less pronounced cold posterior effect. Note the reversed y-axis for OOD detection on the right to ensure that lower values are better in all plots. Shaded regions represent one standard error.
123
+
124
+ ![](images/2bfa363013ede5d437daf4690bc41f1ebfe1a0ac17b6fd374e0b7f71f4e8204f.jpg)
125
+ Figure 5: Performances of convolutional BNNs with different priors on MNIST, FashionMNIST, and CIFAR-10 (see Sec. 4.3). The (Fashion)MNIST experiments used CNNs, while the CIFAR-10 experiments used ResNet20. The correlated prior generally performs better than the isotropic ones, but still exhibits a cold posterior effect, while the heavy-tailed priors reduce the cold posterior effect, but yield a worse performance. Note the reversed y-axis for OOD detection on the right to ensure that lower values are better in all plots. Shaded regions represent one standard error.
126
+
127
+ FCNNs. Note that the cold posterior effect is typically observed in terms of performance metrics like error and NLL, and not calibration and OOD detection performance (Wenzel et al., 2020a). As such, even with Gaussian priors, we do not necessarily expect calibration and OOD detection to exhibit a cold posterior effect. Indeed, only calibration for FashionMNIST exhibits a cold posterior effect, with calibration for MNIST and all OOD detection results exhibiting an inverted cold posterior effect. Notably, we see in Appendix A.5 and Appendix A.7 that these observations generalize to different activation functions and prior variances and in Appendix A.6 that warm posteriors $( T > 1 )$ ) deteriorate the performance for all considered priors, such that for the heavy-tailed priors, $T \approx 1$ is indeed ideal.
128
+
129
+ # 4.3 BAYESIAN CNN AND RESNET PERFORMANCE WITH DIFFERENT PRIORS
130
+
131
+ We repeated the same experiment for Bayesian CNNs on MNIST and FashionMNIST (Fig. 5, first two rows). Given our observations about SGD-trained weights (Sec. 3.1), we might again expect heavy-tailed priors to outperform Gaussian priors. However, this is not the case: the Gaussian and correlated Gaussian priors perform better in almost all cases, with the exception of calibration for
132
+
133
+ FashionMNIST. Interestingly, the performance of different methods tends to be very similar at $T = 1$ , and to diverge for lower temperatures, with performance improving for Gaussian and correlated Gaussian priors (indicating a cold posterior effect), and worsening for heavy-tailed priors, indicating no cold posterior effect.
134
+
135
+ Our analysis of SGD-trained weights (Sec. 3.2) also suggested that introducing spatial correlations in the prior (Sec. 4.1) might help. We observe that introducing correlations indeed improves performance compared to the isotropic Gaussian prior (Fig. 5). Notably, the performance improvement is small for CNNs trained on MNIST and FashionMNIST, and for ResNets trained on CIFAR-10 at higher temperatures, but more considerable for ResNets at lower temperatures. As such, correlated priors actually increase the magnitude of the cold posterior effect in ResNets trained on CIFAR-10. This might be because ResNets trained at very low temperatures on CIFAR-10 have a tendency to overfit, and imposing the prior helps to mitigate this overfitting. To support this hypothesis, we indeed see that correlated priors considerably improve over all other methods in terms of calibration and OOD detection at low temperatures for ResNets trained on CIFAR-10.
136
+
137
+ To reiterate a point raised in Sec. 4.2, the original cold posterior paper (Wenzel et al., 2020a) considered only predictive performance (error and likelihood), and not other measures of uncertainty such as calibration and OOD detection. Indeed, we see different effects of temperature on these measures, with calibration improving for FashionMNIST at lower temperatures, but worsening for MNIST and CIFAR-10. At the same time, we see performance at OOD detection worsen at lower temperatures in the smaller CNN model trained on MNIST and FashionMNIST, but increase at lower temperatures in the ResNet trained on CIFAR-10. These results are consistent with other observations that measures of uncertainty do not necessarily correlate with predictive performance (Ovadia et al., 2019; Izmailov et al., 2021), and indicate that the cold posterior effect is a complex phenomenon that demands careful future investigation. Again, we see in Appendix A.5 and Appendix A.7 that these observations generalize to different activation functions and prior variances and in Appendix A.6 that warm posteriors $( T > 1$ ) deteriorate the performance for all considered priors.
138
+
139
+ In practice, models on this dataset are often trained using data augmentation (as is our model in Fig. 5). While this does indeed improve the performance (Fig. A.11 in the appendix), it also strengthens the cold posterior effect. When we do not use data augmentation, the cold posterior effect (at least between $T = 1$ and lower temperatures) is almost entirely eliminated (see Fig. A.11 in the appendix and Wenzel et al., 2020a; Izmailov et al., 2021). This observation raises the question of why data augmentation drives the cold posterior effect. Given that data augmentation adds terms to the likelihood while leaving the prior unchanged, we could expect that the problem is in the likelihood, as was recently argued by Aitchison (2020b). On the other hand, van der Wilk et al. (2018) argued that treating synthetic augmented data as extra datapoints for the purposes of the likelihood is incorrect from a Bayesian point of view. Instead, they express data augmentation in the prior, by constraining the classification functions to be invariant to certain transformations. More investigation is hence needed into how data augmentation and the cold posterior effect relate.
140
+
141
+ # 5 RELATED WORK
142
+
143
+ Empirical analysis of weight distributions. There is some history in neuroscience of analysing the statistics of data to inform inductive priors for learning algorithms, especially when it comes to vision (Simoncelli, 2009). For instance, it has been noted that correlations help in modeling natural images (Srivastava et al., 2003), as well as sparsity in the parameters (Smyth et al., 2003; Sahani & Linden, 2003). In the context of machine learning, the empirical weight distributions of standard neural networks have also been studied before (Bellido & Fiesler, 1993; Go & Lee, 1999), including the insight that SGD can produce heavy-tailed weights (Gurbuzbalaban & Simsekli, 2020), but these works have not systematically compared different architectures and did not use their insights to inform Bayesian prior choices.
144
+
145
+ BNNs in practice. Since the inception of Bayesian neural networks, scholars have thought about choosing good priors for them, including hierarchical (MacKay, 1992) and heavy-tailed ones (Neal, 1996). In the context of infinite-width limits of such networks (Lee et al., 2017; Matthews et al., 2018; Garriga-Alonso et al., 2019; Yang, 2019; Tsuchida et al., 2019) it has also been shown that networks with very heavy-tailed (i.e., infinite variance) priors have different properties from finite-variance priors (Neal, 1996; Peluchetti et al., 2020). However, most modern applications of BNNs still relied on simple Gaussian priors. Although a few different priors have been proposed for BNNs, these were mostly designed for specific tasks (Atanov et al., 2018; Ghosh & Doshi-Velez, 2017; Overweg et al., 2019; Nalisnick, 2018; Cui et al., 2020; Hafner et al., 2020) or relied heavily on non-standard inference methods (Sun et al., 2019; Ma et al., 2019; Karaletsos & Bui, 2020; Pearce et al., 2020). Moreover, while many interesting distributions have been proposed as variational posteriors for BNNs (Louizos & Welling, 2017; Swiatkowski et al., 2020; Dusenberry et al., 2020; Ober & Aitchison, 2020; Aitchison et al., 2020), these approaches have still used Gaussian priors. Others use a nonGaussian prior, but approximate the posterior with a diagonal Gaussian (Blundell et al., 2015; Ghosh & Doshi-Velez, 2017; Nalisnick et al., 2015), somewhat limiting the prior’s effect. Another BNN posterior approximation is dropout (Gal & Ghahramani, 2016; Kingma et al., 2015), which is often poorly calibrated (Foong et al., 2019), but can also be seen to induce a scale-mixture prior, similar to our heavy-tailed priors (Molchanov et al., 2017).
146
+
147
+ BNN priors. Finally, previous work has investigated the performance of neural network priors chosen without reference to the empirical distributions of SGD-trained networks (Blundell et al., 2015; Ghosh & Doshi-Velez, 2017; Wu et al., 2018; Atanov et al., 2018; Nalisnick, 2018; Overweg et al., 2019; Farquhar et al., 2019; Cui et al., 2020; Rothfuss et al., 2020; Hafner et al., 2020; Matsubara et al., 2020; Tran et al., 2020; Ober & Aitchison, 2020; Garriga-Alonso & van der Wilk, 2021; Fortuin, 2021; Immer et al., 2021a). While these priors might in certain circumstances offer performance improvements, they did not offer a recipe for finding potentially valuable features to incorporate into the weight priors. In contrast, we offer such a recipe by examining the distribution of weights trained under a uniform prior with SGD. Importantly, unlike prior work, we use SG-MCMC with carefully evaluated convergence metrics and systematically address the cold posterior effect.
148
+
149
+ Contemporaneous work2 (Izmailov et al., 2021) compared gold-standard HMC inference with the more practical cyclical SG-MCMC used in our work. They confirmed that cyclical SG-MCMC methods indeed have high-fidelity to the true posterior, and interestingly show that heavy-tailed priors offer slight performance improvements for language modeling tasks (though they do not assess the interaction of the cold posterior effect with these priors).
150
+
151
+ # 6 CONCLUSION
152
+
153
+ We consider empirical weight distributions in non-Bayesian networks trained using SGD, finding that FCNNs displayed heavy-tailed weight distributions, and CNNs and ResNets displayed spatial correlations in the convolutional filters. We therefore tested the performance of these priors and their interaction with the cold posterior effect. Indeed, we found that these priors improved performance, but their impact on the cold posterior effect was more complex, with heavy-tailed priors in FCNNs eliminating the cold posterior effect, correlated priors in CNNs trained on MNIST and FashionMNIST leaving the cold posterior largely unchanged, and correlated priors in ResNets trained on CIFAR-10 actually increasing the cold posterior effect, as they yield much larger performance improvements at lower temperatures. Importantly though, we do not expect there to be one “universal” prior that improves performance in all architectures and all tasks. The best prior is almost certain to be highly task- and architecture-dependent, and indeed we found that heavy-tailed priors offer little or no benefits for regression on UCI datasets (Sec. A.9).
154
+
155
+ Thus, we can conclude that isotropic Gaussian priors are often non-optimal, and that it is worth exploring other priors more generally (as always though, the correct prior will heavily depend on the architecture and dataset). However, it is difficult to come to any strong conclusions regarding the origin of the cold posterior effect. At least in FCNNs, it does indeed appear that a misspecified prior can cause the cold posterior effect. However, in perhaps more relevant large-scale image models, we found that better (correlated) priors actually increase the cold posterior effect, which is consistent with other hypotheses, such as a misspecified likelihood (Aitchison, 2020b), though of course we cannot rule out that there is a better prior that eliminates the cold posterior effect that we did not consider. We hope that our PyTorch library for BNN inference with different priors will catalyze future research efforts in this area and will also be useful on real-world tasks.
156
+
157
+ # ACKNOWLEDGMENTS
158
+
159
+ VF was supported by a PhD fellowship from the Swiss Data Science Center. AGA was supported by a UK Engineering and Physical Sciences Research Council studentship [1950008]. We thank Alexander Immer, Andrew Foong, David Burt, Seth Nabarro, and Kevin Roth for helpful discussions and the anonymous reviewers for valuable feedback. We also thank Edwin Thompson Jaynes for constant inspiration.
160
+
161
+ # REFERENCES
162
+
163
+ Laurence Aitchison. Why bigger is not always better: on finite and infinite neural networks. In International Conference on Machine Learning, pp. 156–164. PMLR, 2020a.
164
+
165
+ Laurence Aitchison. A statistical theory of cold posteriors in deep neural networks. arXiv preprint arXiv:2008.05912, 2020b.
166
+
167
+ Laurence Aitchison, Adam X Yang, and Sebastian W Ober. Deep kernel processes. arXiv preprint arXiv:2010.01590, 2020.
168
+
169
+ Andrei Atanov, Arsenii Ashukha, Kirill Struminsky, Dmitry Vetrov, and Max Welling. The deep weight prior. arXiv preprint arXiv:1810.06943, 2018.
170
+
171
+ Thomas Bayes. An essay towards solving a problem in the doctrine of chances. Philosophical transactions of the Royal Society of London, 53:370–418, 1763. By the late Rev. Mr. Bayes, FRS communicated by Mr. Price, in a letter to John Canton, AMFRS.
172
+
173
+ I Bellido and Emile Fiesler. Do backpropagation trained neural networks have normal weight distributions? In International Conference on Artificial Neural Networks, pp. 772–775. Springer, 1993.
174
+
175
+ Patrick Billingsley. The Lindeberg-Lévy theorem for martingales. Proceedings of the American Mathematical Society, 12(5):788–792, 1961.
176
+
177
+ Christopher M Bishop. Pattern recognition and machine learning. Springer, 2006.
178
+
179
+ Christopher M Bishop et al. Neural networks for pattern recognition. Oxford university press, 1995.
180
+
181
+ Charles Blundell, Julien Cornebise, Koray Kavukcuoglu, and Daan Wierstra. Weight uncertainty in neural network. In Proceedings of the 32nd International Conference on Machine Learning, 2015.
182
+
183
+ Luis Pedro Coelho. Jug: Software for parallel reproducible computation in Python. Journal of Open Research Software., 5:30, 2017. doi: 10.5334/jors.161.
184
+
185
+ Tianyu Cui, A. Havulinna, P. Marttinen, and S. Kaski. Informative Gaussian scale mixture priors for Bayesian neural networks. arXiv preprint arXiv:2002.10243, 2020.
186
+
187
+ Michael W Dusenberry, Ghassen Jerfel, Yeming Wen, Yi-an Ma, Jasper Snoek, Katherine Heller, Balaji Lakshminarayanan, and Dustin Tran. Efficient and scalable Bayesian neural nets with rank-1 factors. arXiv preprint arXiv:2005.07186, 2020.
188
+
189
+ Gintare Karolina Dziugaite, Kyle Hsu, Waseem Gharbieh, Gabriel Arpino, and Daniel Roy. On the role of data in PAC-Bayes. In International Conference on Artificial Intelligence and Statistics, pp. 604–612. PMLR, 2021.
190
+
191
+ Sebastian Farquhar, Michael Osborne, and Yarin Gal. Radial Bayesian neural networks: Robust variational inference in big models. arXiv preprint arXiv:1907.00865, 2019.
192
+
193
+ Andrew YK Foong, David R Burt, Yingzhen Li, and Richard E Turner. On the expressiveness of approximate inference in Bayesian neural networks. arXiv preprint arXiv:1909.00719, 2019.
194
+
195
+ Vincent Fortuin. Priors in Bayesian deep learning: A review. arXiv preprint arXiv:2105.06868, 2021.
196
+
197
+ 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. PMLR, 2016.
198
+
199
+ Adrià Garriga-Alonso and Vincent Fortuin. Exact Langevin dynamics with stochastic gradients. arXiv preprint arXiv:2102.01691, 2021.
200
+
201
+ Adrià Garriga-Alonso and Mark van der Wilk. Correlated weights in infinite limits of deep convolutional neural networks. arXiv preprint arXiv:2101.04097, 2021.
202
+
203
+ Adrià Garriga-Alonso, Carl Edward Rasmussen, and Laurence Aitchison. Deep convolutional networks as shallow Gaussian processes. In 7th International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $=$ Bklfsi0cKm.
204
+
205
+ Carl Friedrich Gauss. Theoria motvs corporvm coelestivm in sectionibvs conicis solem ambientivm. Sumtibus F. Perthes et IH Besser, 1809.
206
+
207
+ Andrew Gelman, John B Carlin, Hal S Stern, David B Dunson, Aki Vehtari, and Donald B Rubin. Bayesian data analysis. CRC press, 2013.
208
+
209
+ Pascal Germain, Francis Bach, Alexandre Lacoste, and Simon Lacoste-Julien. PAC-Bayesian theory meets Bayesian inference. arXiv preprint arXiv:1605.08636, 2016.
210
+
211
+ Soumya Ghosh and Finale Doshi-Velez. Model selection in Bayesian neural networks via horseshoe priors. arXiv preprint arXiv:1705.10388, 2017.
212
+
213
+ Tilmann Gneiting and Adrian E Raftery. Strictly proper scoring rules, prediction, and estimation. Journal of the American Statistical Association, 102(477):359–378, 2007.
214
+
215
+ Jinwook Go and Chulhee Lee. Analyzing weight distribution of neural networks. In IJCNN’99. International Joint Conference on Neural Networks. Proceedings (Cat. No. 99CH36339), volume 2, pp. 1154–1157. IEEE, 1999.
216
+
217
+ Alex Graves. Practical variational inference for neural networks. In J. Shawe-Taylor, R. Zemel, P. Bartlett, F. Pereira, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems, volume 24. Curran Associates, Inc., 2011. URL https://proceedings.neurips. cc/paper/2011/file/7eb3c8be3d411e8ebfab08eba5f49632-Paper.pdf.
218
+
219
+ Klaus Greff, Aaron Klein, Martin Chovanec, Frank Hutter, and Jürgen Schmidhuber. The Sacred Infrastructure for Computational Research. In Katy Huff, David Lippa, Dillon Niederhut, and M Pacer (eds.), Proceedings of the 16th Python in Science Conference, pp. 49 – 56, 2017. doi: 10.25080/shinma-7f4c6e7-008.
220
+
221
+ Mert Gurbuzbalaban and Lingjiong Simsekli, Umut an Zhu. The heavy-tail phenomenon in SGD. arXiv preprint arXiv:2006.04740, 2020.
222
+
223
+ Danijar Hafner, Dustin Tran, Timothy Lillicrap, Alex Irpan, and James Davidson. Noise contrastive priors for functional uncertainty. In Uncertainty in Artificial Intelligence, pp. 905–914. PMLR, 2020.
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
+ Jonathan Heek and Nal Kalchbrenner. Bayesian inference for large scale image classification. arXiv preprint arXiv:1908.03491, 2019.
228
+
229
+ Friedrich Robert Helmert. Über die Berechnung des wahrscheinlichen Fehlers aus einer endlichen Anzahl wahrer Beobachtungsfehler. Z. Math. U. Physik, 20(1875):300–303, 1875.
230
+
231
+ José Miguel Hernández-Lobato and Ryan Adams. Probabilistic backpropagation for scalable learning of Bayesian neural networks. In International Conference on Machine Learning, pp. 1861–1869. PMLR, 2015.
232
+
233
+ Alexander Immer, Matthias Bauer, Vincent Fortuin, Gunnar Rätsch, and Mohammad Emtiyaz Khan. Scalable marginal likelihood estimation for model selection in deep learning. arXiv preprint arXiv:2104.04975, 2021a.
234
+
235
+ Alexander Immer, Maciej Korzepa, and Matthias Bauer. Improving predictions of Bayesian neural nets via local linearization. In International Conference on Artificial Intelligence and Statistics, pp. 703–711. PMLR, 2021b.
236
+
237
+ Pavel Izmailov, Wesley J Maddox, Polina Kirichenko, Timur Garipov, Dmitry Vetrov, and Andrew Gordon Wilson. Subspace inference for Bayesian deep learning. In Uncertainty in Artificial Intelligence, pp. 1169–1179. PMLR, 2020.
238
+
239
+ Pavel Izmailov, Sharad Vikram, Matthew D Hoffman, and Andrew Gordon Wilson. What are Bayesian neural network posteriors really like? arXiv preprint arXiv:2104.14421, 2021.
240
+
241
+ Theofanis Karaletsos and Thang D Bui. Hierarchical Gaussian process priors for Bayesian neural network weights. arXiv preprint arXiv:2002.04033, 2020.
242
+
243
+ Alex Kendall and Yarin Gal. What uncertainties do we need in Bayesian deep learning for computer vision? In Advances in neural information processing systems, pp. 5574–5584, 2017.
244
+
245
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations, 2015.
246
+
247
+ Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In International Conference on Learning Representations, ICLR, 2014.
248
+
249
+ Diederik P Kingma, Tim Salimans, and Max Welling. Variational dropout and the local reparameterization trick. In Proceedings of the 28th International Conference on Neural Information Processing Systems-Volume 2, pp. 2575–2583, 2015.
250
+
251
+ Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
252
+
253
+ Ravin Kumar, Colin Carroll, Ari Hartikainen, and Osvaldo Martin. ArviZ a unified library for exploratory analysis of Bayesian models in Python. Journal of Open Source Software, 4(33):1143, 2019. doi: 10.21105/joss.01143. URL https://doi.org/10.21105/joss.01143.
254
+
255
+ Pierre Simon Laplace. Mémoire sur la probabilité de causes par les évenements. Memoire de l’Academie Royale des Sciences, 1774.
256
+
257
+ 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.
258
+
259
+ Jaehoon Lee, Yasaman Bahri, Roman Novak, Samuel S Schoenholz, Jeffrey Pennington, and Jascha Sohl-Dickstein. Deep neural networks as Gaussian processes. arXiv preprint arXiv:1711.00165, 2017.
260
+
261
+ Benedict Leimkuhler and Charles Matthews. Rational Construction of Stochastic Numerical Methods for Molecular Sampling. Applied Mathematics Research eXpress, 2013(1):34–56, 06 2012. ISSN 1687-1200. doi: 10.1093/amrx/abs010.
262
+
263
+ Christos Louizos and Max Welling. Multiplicative normalizing flows for variational Bayesian neural networks. arXiv preprint arXiv:1703.01961, 2017.
264
+
265
+ J Lüroth. Vergleichung von zwei Werthen des wahrscheinlichen Fehlers. Astronomische Nachrichten, 87:209, 1876.
266
+
267
+ Chao Ma, Yingzhen Li, and José Miguel Hernández-Lobato. Variational implicit processes. In International Conference on Machine Learning, pp. 4222–4233, 2019.
268
+
269
+ David J.C. MacKay. A practical Bayesian framework for backpropagation networks. Neural computation, 4(3):448–472, 1992.
270
+
271
+ Takuo Matsubara, Chris J Oates, and François-Xavier Briol. The ridgelet prior: A covariance function approach to prior specification for Bayesian neural networks. arXiv preprint arXiv:2010.08488, 2020.
272
+
273
+ Alexander G de G Matthews, Mark Rowland, Jiri Hron, Richard E Turner, and Zoubin Ghahramani. Gaussian process behaviour in wide deep neural networks. arXiv preprint arXiv:1804.11271, 2018.
274
+
275
+ Dmitry Molchanov, Arsenii Ashukha, and Dmitry Vetrov. Variational dropout sparsifies deep neural networks. In International Conference on Machine Learning, pp. 2498–2507. PMLR, 2017.
276
+
277
+ Mahdi Pakdaman Naeini, Gregory F Cooper, and Milos Hauskrecht. Obtaining well calibrated probabilities using Bayesian binning. In Proceedings of the... AAAI Conference on Artificial Intelligence. AAAI Conference on Artificial Intelligence, volume 2015, pp. 2901. NIH Public Access, 2015.
278
+
279
+ Eric T Nalisnick. On priors for Bayesian neural networks. PhD thesis, UC Irvine, 2018.
280
+
281
+ Eric T Nalisnick, Anima Anandkumar, and Padhraic Smyth. A scale mixture perspective of multiplicative noise in neural networks. arXiv preprint arXiv:1506.03208, 2015.
282
+
283
+ Radford M. Neal. Bayesian training of backpropagation networks by the Hybrid Monte Carlo method. Technical report, University of Toronto, 1992.
284
+
285
+ Radford M. Neal. Bayesian learning for neural networks, volume 118. Springer, 1996.
286
+
287
+ Roman Novak, Lechao Xiao, Yasaman Bahri, Jaehoon Lee, Greg Yang, Daniel A. Abolafia, Jeffrey Pennington, and Jascha Sohl-dickstein. Bayesian deep convolutional networks with many channels are Gaussian processes. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $_ { \cdot } =$ B1g30j0qF7.
288
+
289
+ Sebastian W Ober and Laurence Aitchison. Global inducing point variational posteriors for Bayesian neural networks and deep Gaussian processes. arXiv preprint arXiv:2005.08140, 2020.
290
+
291
+ Sebastian W Ober, Carl E Rasmussen, and Mark van der Wilk. The promises and pitfalls of deep kernel learning. arXiv preprint arXiv:2102.12108, 2021.
292
+
293
+ 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, 1997.
294
+
295
+ Kazuki Osawa, Siddharth Swaroop, Mohammad Emtiyaz E Khan, Anirudh Jain, Runa Eschenhagen, Richard E Turner, and Rio Yokota. Practical deep learning with Bayesian principles. In Advances in neural information processing systems, pp. 4287–4299, 2019.
296
+
297
+ 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. In Advances in Neural Information Processing Systems, pp. 13991–14002, 2019.
298
+
299
+ Hiske Overweg, Anna-Lena Popkes, Ari Ercole, Yingzhen Li, José Miguel Hernández-Lobato, Yordan Zaykov, and Cheng Zhang. Interpretable outcome prediction with sparse Bayesian neural networks in intensive care. arXiv preprint arXiv:1905.02599, 2019.
300
+
301
+ Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. PyTorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32, pp. 8024–8035. 2019.
302
+
303
+ Tim Pearce, Russell Tsuchida, Mohamed Zaki, Alexandra Brintrup, and Andy Neely. Expressive priors in Bayesian neural networks: Kernel combinations and periodic functions. In Uncertainty in Artificial Intelligence, pp. 134–144. PMLR, 2020.
304
+
305
+ Stefano Peluchetti, Stefano Favaro, and Sandra Fortini. Stable behaviour of infinitely wide deep neural networks. In International Conference on Artificial Intelligence and Statistics, pp. 1137–1146. PMLR, 2020.
306
+
307
+ Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In International Conference on Machine Learning, 2014.
308
+
309
+ Omar Rivasplata, Ilja Kuzborskij, Csaba Szepesvári, and John Shawe-Taylor. PAC-Bayes analysis beyond the usual bounds. arXiv preprint arXiv:2006.13057, 2020.
310
+
311
+ Herbert E Robbins. An empirical Bayes approach to statistics. In Breakthroughs in statistics, pp. 388–394. Springer, 1992.
312
+
313
+ Jonas Rothfuss, Vincent Fortuin, and Andreas Krause. PACOH: Bayes-optimal meta-learning with PAC-guarantees. arXiv preprint arXiv:2002.05551, 2020.
314
+
315
+ Maneesh Sahani and Jennifer F Linden. Evidence optimization techniques for estimating stimulusresponse functions. Advances in neural information processing systems, pp. 317–324, 2003.
316
+
317
+ Eero P Simoncelli. Capturing visual image properties with probabilistic models. In The Essential Guide to Image Processing, pp. 205–223. Elsevier, 2009.
318
+
319
+ Darragh Smyth, Ben Willmore, Gary E Baker, Ian D Thompson, and David J Tolhurst. The receptivefield organization of simple cells in primary visual cortex of ferrets under natural scene stimulation. Journal of Neuroscience, 23(11):4746–4759, 2003.
320
+
321
+ Anuj Srivastava, Ann B Lee, Eero P Simoncelli, and S-C Zhu. On advances in statistical modeling of natural images. Journal of mathematical imaging and vision, 18(1):17–33, 2003.
322
+
323
+ Student. The probable error of a mean. Biometrika, pp. 1–25, 1908.
324
+
325
+ Shengyang Sun, Guodong Zhang, Jiaxin Shi, and Roger Grosse. Functional variational Bayesian neural networks. arXiv preprint arXiv:1903.05779, 2019.
326
+
327
+ Héctor J Sussmann. Uniqueness of the weights for minimal feedforward nets with a given input-output map. Neural networks, 5(4):589–593, 1992.
328
+
329
+ Jakub Swiatkowski, Kevin Roth, Bastiaan S Veeling, Linh Tran, Joshua V Dillon, Stephan Mandt, Jasper Snoek, Tim Salimans, Rodolphe Jenatton, and Sebastian Nowozin. The k-tied normal distribution: A compact parameterization of Gaussian mean field posteriors in Bayesian neural networks. arXiv preprint arXiv:2002.02655, 2020.
330
+
331
+ Robert Tibshirani. Regression shrinkage and selection via the lasso. Journal of the Royal Statistical Society: Series B (Methodological), 58(1):267–288, 1996.
332
+
333
+ Ba-Hien Tran, Simone Rossi, Dimitrios Milios, and Maurizio Filippone. All you need is a good functional prior for Bayesian deep learning. arXiv preprint arXiv:2011.12829, 2020.
334
+
335
+ Brian Trippe and Richard Turner. Overpruning in variational Bayesian neural networks. arXiv preprint arXiv:1801.06230, 2018.
336
+
337
+ Russell Tsuchida, Fred Roosta, and Marcus Gallagher. Richer priors for infinitely wide multi-layer perceptrons. arXiv preprint arXiv:1911.12927, 2019.
338
+
339
+ Mark van der Wilk, Matthias Bauer, ST John, and James Hensman. Learning invariances using the marginal likelihood. In Advances in Neural Information Processing Systems, volume 31, pp. 9938–9948, 2018. URL https://proceedings.neurips.cc/paper/2018/file/ d465f14a648b3d0a1faa6f447e526c60-Paper.pdf.
340
+
341
+ Aki Vehtari, Andrew Gelman, Daniel Simpson, Bob Carpenter, and Paul-Christian Bürkner. Ranknormalization, folding, and localization: an improved $\widehat { R }$ for assessing convergence of MCMC. Bayesian analysis, 1(1):1–28, 2021.
342
+
343
+ Martin J Wainwright, Michael I Jordan, et al. Graphical models, exponential families, and variational inference. Foundations and Trends $\textsuperscript { \textregistered }$ in Machine Learning, 2008.
344
+
345
+ Florian Wenzel, Kevin Roth, Bastiaan S Veeling, Jakub Swi atkowski, Linh Tran, Stephan Mandt, ´ Jasper Snoek, Tim Salimans, Rodolphe Jenatton, and Sebastian Nowozin. How good is the Bayes posterior in deep neural networks really? In International Conference on Machine Learning, 2020a.
346
+
347
+ Florian Wenzel, Jasper Snoek, Dustin Tran, and Rodolphe Jenatton. Hyperparameter ensembles for robustness and uncertainty quantification. In Advances in Neural Information Processing Systems, 2020b.
348
+
349
+ Anqi Wu, Sebastian Nowozin, Edward Meeds, Richard E Turner, José Miguel Hernández-Lobato, and Alexander L Gaunt. Deterministic variational inference for robust Bayesian neural networks. arXiv preprint arXiv:1810.03958, 2018.
350
+
351
+ Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-MNIST: a novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017.
352
+
353
+ Greg Yang. Wide feedforward or recurrent neural networks of any architecture are Gaussian processes. In Advances in Neural Information Processing Systems, pp. 9951–9960, 2019.
354
+
355
+ Wenzhao Yang, Chunyu Chen, and Robert J Tempelman. Improving the computational efficiency of fully Bayes inference and assessing the effect of misspecification of hyperparameters in wholegenome prediction models. Genetics Selection Evolution, 47(1):1–14, 2015.
356
+
357
+ Ruqi Zhang, Chunyuan Li, Jianyi Zhang, Changyou Chen, and Andrew Gordon Wilson. Cyclical stochastic gradient MCMC for Bayesian deep learning. arXiv preprint arXiv:1902.03932, 2019.
358
+
359
+ # A ADDITIONAL EXPERIMENTAL RESULTS
360
+
361
+ A.1 COVARIANCE MATRICES OF FCNN, CNN AND RESNET
362
+
363
+ Here we report the full covariance matrices for the layers that were analyzed above (Sec. 3.2). We display the covariances for the FCNN for layer 1 (Fig. A.1), layer 2 (Fig. A.2) and layer 3 (Fig. A.3). The only discernable structure is in the first layer, presumably because the weights from neighboring pixels will be correlated. The other plots are less smooth than an empirical covariance matrix from an isotropic Gaussian (left image of every pair), but tend to have no discernible structure.
364
+
365
+ Next, we give the covariances of CNN weights in layer 1 (Fig. A.4) and layer 2 (Fig. A.5). We have omitted layer 3 of the CNN because it is just a fully connected layer and also showed no interesting structure.
366
+
367
+ Finally, Fig. A.6 (left) measures the amount of covariance of every layer in the ResNet. We fit the lengthscale of a Gaussian distribution with squared exponential kernel, on the spatial correlations of the convolutional filters. The right-hand figure is the same as Fig. 2a.
368
+
369
+ # A.2 EMPIRICAL OFF-DIAGONAL COVARIANCES
370
+
371
+ We report results for the distributions of off-diagonal covariances for the respective second layers of our FCNN and CNN in Figure A.7. The empirical distribution of off-diagonal elements in the covariance matrices is shown as a histogram, overlayed with a kernel density estimate of the expected distribution if the weights were samples from an isotropic Gaussian. We see that the empirical covariance distributions are generally more heavy-tailed than the ideal ones, that is, the empirical weights generally have larger covariances than would be expected from isotropic Gaussian weights. Note that, as observed above, the strongest covariances by far are found spatially in the CNN weights, that is, between weights within the same CNN filter. We report the same results for the other layers in the following. The FCNN results are shown in Figures A.8 and A.9 and the CNN results in Figure A.10.
372
+
373
+ # A.3 THE INFLUENCE OF DATA AUGMENTATION ON THE COLD POSTERIOR EFFECT
374
+
375
+ When running the CIFAR-10 experiments with Bayesian ResNets with and without data augmentation, we find that data augmentation seems to significantly increase the cold posterior effect (Fig. A.11). Moreover, data augmentation seems to increase the performance of the models a lot at colder temperatures, but not at the true Bayes posterior $T = 1$ . This suggests that data augmentation can also be one of the reasons for the cold posterior effect, as already hypothesized by Wenzel et al. (2020a) and Aitchison (2020b).
376
+
377
+ # A.4 SGD BASELINES
378
+
379
+ In terms of likelihood, calibration, and OOD detection, almost all our BNN models consistently outperformed the SGD baselines. The results including SGD are shown for FCNNs in Figure A.12, for CNNs in Figure A.13, and for ResNets in Figure A.14.
380
+
381
+ # A.5 ALTERNATIVE ACTIVATION FUNCTIONS
382
+
383
+ We repeated the experiments on MNIST with Bayesian FCNNs and CNNs and replaced the ReLU activation functions from Figure 4 and Figure 5 with sigmoid (see Fig. A.15) and tanh (see Fig. A.16) activations respectively. We observe that while the performances are overall worse than with ReLU activations (as is generally expected), the effects of the different priors are qualitatively very similar.
384
+
385
+ # A.6 HIGHER TEMPERATURES
386
+
387
+ In the main body of the paper, we followed Wenzel et al. (2020a) in showing only posteriors with temperatures $T \leq 1$ , because we were interested in studying cold posteriors. Here, we also show results for warm posteriors, that is, $T > 1$ . We see in Figure A.17 and Figure A.18 that these
388
+
389
+ ![](images/df366dfb0d1bcba67aacfc09f1ed3c8fd634ad8ecfe352090df44f9f1e578385.jpg)
390
+ Figure A.1: FCNN layer 1 empirical covariances of the weights, trained with SGD on MNIST. We can see correlations in the spatial direction in the weights of the input layer (left). In the other directions, the covariance matrix is less smooth than we would expect from an isotropic Gaussian draw of the same size (left matrix of every pair), but otherwise has no discernible structure. This suggests that the weights are not isotropic Gaussian.
391
+
392
+ ![](images/b2fb37900d1c96d6ee9e997869edaa97fe43a816994de29164f3b1cb207c2c3d.jpg)
393
+ Figure A.2: FCNN layer 2 empirical covariances of the weights, trained with SGD on MNIST. The covariance matrix is less smooth than we would expect from an isotropic Gaussian draw, but has no discernible structure.
394
+
395
+ ![](images/55d93470d6826448a113883dfb5cbcac4d257f64416c522c9c88e638fe5857e8.jpg)
396
+ Figure A.3: FCNN layer 3 empirical covariances of the weights, trained with SGD on MNIST. The covariance matrix is less smooth than we would expect from an isotropic Gaussian draw, but has no discernible structure.
397
+
398
+ ![](images/5616fbaab1ad8cf83defaccc2f28b472ae1cbd2d09eea4feccac7e7fb58f0339.jpg)
399
+ Figure A.4: CNN layer 1 empirical covariance of the weights, trained with SGD on MNIST. The input (also spatial) direction has correlations, also shown in Figure 2b. The output direction has no discernible structure.
400
+
401
+ ![](images/bbb70558a7643e824059db7d45cf762c12a5446590de496033e015adb5efd7ee.jpg)
402
+ Figure A.5: CNN layer 2 empirical covariance of the weights, trained with SGD on MNIST. The input direction is less smooth than the isotropic Gaussian, and some low-rank structures can be observed. It should display the spatial correlation of Figure 2b. The output direction has no discernible structure.
403
+
404
+ warm posteriors generally do not improve the performance and that hence some of the priors (e.g., heavy-tailed priors in FCNNs) do indeed achieve their optimal performance for $T \approx 1$ .
405
+
406
+ # A.7 DIFFERENT PRIOR VARIANCES
407
+
408
+ In the main text, we use models where the prior variance is chosen according to the He initialization (He et al., 2016), which is motivated by the conservation of the activation norm across the depth of the networks. Here, we see in Figures A.19, A.20, A.21, A.22, and A.23 that our main observations regarding the ordering of the different priors and the cold posterior effect still hold, even for different prior variances (in this case, four times larger and smaller than the He variance).
409
+
410
+ # A.8 DIFFERENT FCNN ARCHITECTURES
411
+
412
+ In the main text, we use FCNN models with three layers. Here, we see in Figure A.24 that our main observations regarding the ordering of the different priors and the cold posterior effect still hold, even for different architectures (in this case, between 2 and 4 layers).
413
+
414
+ # A.9 UCI REGRESSION
415
+
416
+ While the experiments in the main paper focus on image classification, we also performed BNN experiments on UCI regression tasks. The architecture is a 3-layer FCNN, the hidden layers are 64 units wide. We run GGMC for 30,000 epochs without minibatching on “boston”, “energy”, “yacht”, and “wine”, discarding runs where the potential diverges. For the other datasets, which are larger, we run 3000 epochs, also without minibatching. The learning rate is a flat $5 \cdot 1 0 ^ { - 5 }$ , and we do not use a cosine schedule.
417
+
418
+ Even with full batch MCMC, it is clear that the dynamics for regression networks are much less stable, especially at lower temperatures (which have a “sharper” potential landscape). Figure A.25 shows that $T = 1$ is best for all datasets, in terms of the median mean squared error (MSE) as well as the quantiles and outliers. The priors are generally reasonably close in performance, such that it is harder in this case to strongly prescribe a certain prior choice. Of course, it is absolutely expect that different priors will be appropriate for different problems, especially when those problems are quite so distinct as regression and image classification.
419
+
420
+ ![](images/7cc5e85fa2400c9e7b04b6a589817abe291a611e63170e953e2cd5ab316b69dc.jpg)
421
+ Figure A.6: Left: fitted lengthscale of a multivariate Gaussian with a squared exponential kernel (see eq. 4) to the data of Figure 3. All the entries of the SE covariance are positive, so this cannot capture all the features of the data, which has negative empirical covariance. Right: fitted degrees of freedom of a multivariate t-distribution, to same data. The empirical covariance was used in this case. The fitting criterion is the log-likelihood of the data. This is the same plot as Figure 2a.
422
+
423
+ ![](images/4a521fe32224f27143eb872c16451e54843f1c1102831729e861fb9febbdd09a.jpg)
424
+ Figure A.7: Distributions of off-diagonal elements in the empirical covariances of the layer 2 weights of FCNNs and CNNs trained with SGD on MNIST. The empirical distributions are plotted as histograms, while the idealized random Gaussian weights are overlaid in orange. We see that the covariances of the empirical weights are more heavy-tailed than for the Gaussian weights.
425
+
426
+ ![](images/629e729d2c91c77d7dcd63fb3a16762d4f02fc901432d2f1dffa4369abc5ad7d.jpg)
427
+ Figure A.8: Distributions of off-diagonal elements in the empirical covariances of the weights of the FCNN in layers 1 and 3. The empirical distributions are plotted as histograms, while the idealized random Gaussian weights are overlaid in orange. We see that the covariances of the empirical weights are more heavy-tailed than for the Gaussian weights.
428
+
429
+ ![](images/b2d99ebc277cee79ed7e12540da425942ce0f5b2c3cab9b2e08ccbad4d66d71b.jpg)
430
+ Figure A.9: Distributions of singular values of the weight matrices of the FCNN in layers 1 and 3. We see that the spectra of the empirical weights decay faster than the ones of the Gaussian weights.
431
+
432
+ The split- $\widehat { R }$ diagnostics are considerably higher for regression (Table A.1) than for the classification setting (Sec. A.10.2, for which the diagnostics look very good). Thus, the results here should be taken with a grain of salt. They are representative of how GGMC-trained BNNs behave at each of these temperatures and priors, but the results may be different for other (more accurate) ways of approximating the posterior. However, one thing is clear: UCI regression datasets exhibit no cold posterior effect, and for lower temperatures, the GGMC chains are less stable.
433
+
434
+ Table A.1: Diagnostics and median performance at temperature $T = 1$ for every prior and UCI dataset. The split- $\widehat { R }$ is generally high, which shows the chain has not fully explored the posterior. The best prior (in terms of median mean squared error, MSE) for each dataset is bolded, no prior is better overall. Additionally, each prior’s performance is very similar for each dataset, which implies that the choice of prior does not matter much here (at least among these three).
435
+
436
+ <table><tr><td colspan="4">split-R diagnostic</td><td colspan="3">Median MSE</td></tr><tr><td></td><td>laplace</td><td>gaussian</td><td>student-t</td><td>laplace</td><td>gaussian</td><td>student-t</td></tr><tr><td>boston</td><td>1.984856</td><td>1.664200</td><td>2.164047</td><td>0.051899</td><td>0.061199</td><td>0.056180</td></tr><tr><td>concrete</td><td>1.923906</td><td>1.960722</td><td>1.654736</td><td>0.962948</td><td>0.802203</td><td>0.728850</td></tr><tr><td>energy</td><td>2.026471</td><td>1.939554</td><td>2.309070</td><td>0.000759</td><td>0.000705</td><td>0.001500</td></tr><tr><td>kin8nm</td><td>1.523657</td><td>1.795404</td><td>1.609185</td><td>0.976947</td><td>1.520133</td><td>0.958203</td></tr><tr><td>naval</td><td>1.506857</td><td>1.700794</td><td>1.583324</td><td>1.241157</td><td>1.146679</td><td>1.679176</td></tr><tr><td>power</td><td>1.666368</td><td>1.738743</td><td>2.471113</td><td>0.156302</td><td>0.286625</td><td>0.148974</td></tr><tr><td>protein</td><td>1.574833</td><td>2.037037</td><td>1.510434</td><td>1.151049</td><td>1.296588</td><td>1.259395</td></tr><tr><td>wine</td><td>2.133220</td><td>1.936430</td><td>1.844044</td><td>0.674713</td><td>0.617795</td><td>0.604185</td></tr><tr><td>yacht</td><td>2.034536</td><td>1.880282</td><td>2.414279</td><td>0.000612</td><td>0.000559</td><td>0.000599</td></tr></table>
437
+
438
+ # A.10 INFERENCE DIAGNOSTICS
439
+
440
+ One of the main goals of our work is to make statements about the true BNN posteriors that are as accurate as possible. To this end, we closely monitored the accuracy of our inference algorithm. In order to check the correctness of our SG-MCMC inference, we estimated the temperature of the sampler using the two diagnostics from Wenzel et al. (2020a), namely the kinetic temperature and the configurational temperature.
441
+
442
+ The kinetic temperature is derived from the sampler’s momentum $\ b { m } \in \mathbb { R } ^ { d }$ . The inner product $\scriptstyle { \frac { 1 } { d } } m ^ { \mathsf { T } } M ^ { - 1 } m$ , for the (in this case diagonal) mass matrix $M$ , is an estimate of the scaled variance of the momenta. If the sampler is correct it should, in expectation, be equal to the desired temperature. The configurational temperature is slightly more involved and is discussed in Appendix A.10.1.
443
+
444
+ As an example, we show the estimated kinetic temperatures for our ResNet experiment on CIFAR-10 in Figure A.26. The desired temperature is shown as a dotted horizontal line. The kinetic temperatures for the other experiments look qualitatively similar and are shown in Appendix A.10.1. We see that the kinetic temperatures generally agree well with the true temperatures, so the sampler works as expected there. In contrast, the configurational temperature estimates can be somewhat larger than $T$ , especially when $T$ is small (see Appendix A.10.1). This suggests that there could be small inference inaccuracies at low temperatures. However, these inaccuracies are small, and the configurational temperature certainly decreases as $T$ decreases, so there should be no impact on the overall trends.
445
+
446
+ We also computed the rank-normalized split- $\widehat { R }$ diagnostic Vehtari et al. (2021), which measures how well a collection of independent Markov chains have mixed. The split- $\widehat { R }$ is related to the ratio of between-chain and within-chain variances, and should be as close to 1 as possible. Given the complexity of neural network weight posteriors, we report the $\widehat { R }$ for the quantities we are interested in estimating (the y-values in Figs. 4 and 5). For every considered model and function, Table A.2 contains the worst (highest) $\widehat { R }$ estimate we obtained across all priors. Appendix A.10.2 contains a more detailed explanation and empirical $\widehat { R }$ estimates for different priors.
447
+
448
+ We can see that, for most experiments, the chains have mixed sufficiently. Only for the larger models (CIFAR10 ResNets)—and, to a lesser extent, Student-t FCNNs—the chains have mixed less well. Interestingly, for all convolutional networks, the correlated prior mixes best. This further supports its suitability as a prior for image data and CNNs.
449
+
450
+ # A.10.1 KINETIC AND CONFIGURATIONAL TEMPERATURE ESTIMATES
451
+
452
+ As described above, we use two temperature diagnostics (inspired by Wenzel et al. (2020a)): the kinetic temperature and the configurational temperature. The kinetic temperature is derived from the sampler’s momentum $\pmb { m } \in \mathbb { R } ^ { d }$ . The inner product $\scriptstyle { \frac { 1 } { d } } m ^ { \mathsf { T } } M ^ { - 1 } m$ , for the (in this case diagonal) mass matrix $M$ , is an estimate of the scaled variance of the momenta. It is always positive and should, in expectation, be equal to the desired temperature. In contrast, the configurational temperature is $\begin{array} { r } { \frac { 1 } { d } \pmb { \theta } ^ { \top } \dot { \nabla } H ( \pmb { \theta } , \pmb { m } ) } \end{array}$ , where $\begin{array} { r } { H ( \pmb \theta , \pmb m ) = - \log \hat { p } ( \pmb \theta | \mathcal { D } ) _ { + } + \frac { 1 } { 2 } \pmb { m } ^ { \top } M ^ { - 1 } \pmb { m } + \mathrm { c o n s } } \end{array}$ t is the Hamiltonian. In expectation, this should also equal $T$ . Unlike the kinetic temperature estimator, the configurational temperature estimator is not guaranteed to be always positive, even though the temperature is always positive. Using subsets of a parameter or momentum also yields estimators of the temperature.
453
+
454
+ In both cases, we estimate the mean and its standard error from a weighted average of parameters or momenta. That is, for each separate NN weight matrix or bias vector, we estimate its kinetic and configurational temperature using the expressions above. Then, we take their average and standard-deviation, weighted by the number of elements in that parameter matrix or vector.
455
+
456
+ We show the estimated temperatures of all our BNN experiments in Figures A.27, A.28, A.29, A.30, A.31, and A.32, as a mean $\pm$ one standard error. The desired temperature is shown as a dotted horizontal line. The kinetic temperatures generally agree well with the true temperatures, so our sampler works as expected there.
457
+
458
+ The configurational temperature estimates have a higher variance than the kinetic ones. Especially in the regime of small true temperatures, they often tend to slightly over- or underestimate the temperature. This is not surprising, since at low temperatures the noise in the gradients is dominated by the minibatching as opposed to the temperature noise. Correctly estimating the temperature from the gradients thus becomes harder.
459
+
460
+ Note that while the relative deviations can seem large in this regime, the absolute deviations are still quite small. Note also that while the conditioned momenta are strictly positive, the inner products between gradients and parameters can become negative in principle, which is why at low temperatures (close to 0) the configurational temperature estimates might sometimes be a bit below 0. Overall, the sampler is still within the tolerance levels of working correctly here, but there could be some small inaccuracies at low temperatures. However, judging from the shape of the actual tempering curves (see Sec. 4), the measures usually change more in the higher temperature regimes than in the lower ones, so there is no strong reason to believe that the inference at low temperatures was too inaccurate to support the results.
461
+
462
+ # A.10.2 BETWEEN-CHAIN AND WITHIN-CHAIN VARIANCES
463
+
464
+ The split- $\widehat { R }$ estimator measures the difference between posterior variance estimate in each chain, and between chains. It is roughly the square root of the between-chain variance divided by the within-chain variance (Vehtari et al., 2021, eq. 1–3). Its value is usually not smaller than 1, and a chain that has mixed well should have a value no larger than $\widehat { R } \leq 1 . 0 1$ (Vehtari et al., 2021). (Previously, a threshold of 1.1 was considered enough (Gelman et al., 2013, Section 11.5).)
465
+
466
+ Neural network functional forms have a large number of parameter symmetries (for example, permutation invariance). Accordingly, the true BNN posterior should sample from all these modified parameters with probability proportional to their prior. However, for prediction purposes, it does not matter if the parameters are stuck in a single “permutation” and do not mix.
467
+
468
+ Therefore, for the purposes of this paper, we calculate the $\widehat { R }$ diagnostic not directly on the parameters, but on symmetry-invariant functions of the parameters. In practice, this amounts to evaluating the NN on a test set, and calculating the $\widehat { R }$ diagnostic for functions of the logits and the prior probability.
469
+
470
+ Table A.3: Estimated $\widehat { R }$ values for the different models and priors with respect to the loss.
471
+
472
+ <table><tr><td></td><td>Gaussian</td><td>Laplace</td><td>Student-t</td><td>Correlated</td></tr><tr><td>MNISTFCNN</td><td>1.000</td><td>1.001</td><td>1.006</td><td>一</td></tr><tr><td>FashionMNISTFCNN</td><td>1.000</td><td>1.000</td><td>1.007</td><td>=</td></tr><tr><td>MNIST CNN</td><td>1.000</td><td>1.000</td><td>1.002</td><td>1.000</td></tr><tr><td>FashionMNIST CNN</td><td>1.001</td><td>1.003</td><td>1.009</td><td>1.001</td></tr><tr><td>CIFAR10ResNet</td><td>1.115</td><td>1.115</td><td>1.125</td><td>1.109</td></tr><tr><td>CIFAR10 ResNet (augmented)</td><td>1.057</td><td>1.054</td><td>1.047</td><td>1.066</td></tr></table>
473
+
474
+ Table A.4: Estimated $\widehat { R }$ values for the different models and priors with respect to the potential.
475
+
476
+ <table><tr><td></td><td>Gaussian</td><td>Laplace</td><td>Student-t</td><td>Correlated</td></tr><tr><td>MNISTFCNN</td><td>1.000</td><td>1.002</td><td>1.023</td><td>=</td></tr><tr><td>FashionMNISTFCNN</td><td>1.000</td><td>1.000</td><td>1.013</td><td>=</td></tr><tr><td>MNISTCNN</td><td>1.000</td><td>1.000</td><td>1.001</td><td>1.000</td></tr><tr><td>FashionMNIST CNN</td><td>1.000</td><td>1.002</td><td>1.007</td><td>1.000</td></tr><tr><td>CIFAR10 ResNet</td><td>1.166</td><td>1.147</td><td>1.171</td><td>1.139</td></tr><tr><td>CIFAR10 ResNet (augmented)</td><td>1.085</td><td>1.083</td><td>1.073</td><td>1.090</td></tr></table>
477
+
478
+ Tables A.3, A.4 and A.5 display the value of the diagnostic $\hat { R }$ for different such functions: the log-likelihood, the unnormalized log-posterior (potential), and the log-prior, respectively.
479
+
480
+ We employ the rank-normalized $\widehat { R }$ estimator (Vehtari et al., 2021, eq. 14) as implemented in the ArviZ library (Kumar et al., 2019).
481
+
482
+ The diagnostics are generally favorable $ { \widehat { R } } \leq 1 . 0 1$ , mostly) for smaller NNs (FCNNs and 2-layer CNNs) and for MNIST. Within the ResNets applied to CIFAR10, the prior distribution with the $\widehat { R }$ closer to 1 is the correlated Gaussian. This provides evidence that inference is easier in the case of the correlated Gaussian, and therefore that the correlated Gaussian is a better prior (Gelman et al., 2013; Yang et al., 2015). This is because if the prior is good, the data are plausible simulations from it; so the posterior is close to the prior and will be easy to approximate.
483
+
484
+ # A.11 VARIATIONAL INFERENCE
485
+
486
+ In this paper, our experimental results have focused on inference with SG-MCMC, as we wished to obtain the most reliable posterior possible. However, non-sampling approaches such as variational inference (VI; e.g., Graves, 2011; Blundell et al., 2015; Dusenberry et al., 2020) and Laplace’s method (e.g. Immer et al., 2021b) remain popular in the literature. Therefore, it might be valuable to understand the effect of the prior on the performance of these methods. In this section, we focus on variational inference (Wainwright et al., 2008), in particular the mean-field VI (MFVI) approach (Graves, 2011; Blundell et al., 2015).
487
+
488
+ Table A.5: Estimated $\widehat { R }$ values for the different models and priors with respect to the log prior.
489
+
490
+ <table><tr><td></td><td>Gaussian</td><td>Laplace</td><td>Student-t</td><td>Correlated</td></tr><tr><td>MNISTFCNN</td><td>1.000</td><td>1.005</td><td>1.101</td><td></td></tr><tr><td>FashionMNISTFCNN</td><td>1.000</td><td>1.003</td><td>1.104</td><td></td></tr><tr><td>MNIST CNN</td><td>1.001</td><td>1.002</td><td>1.013</td><td>1.001</td></tr><tr><td>FashionMNISTCNN</td><td>1.002</td><td>1.006</td><td>1.013</td><td>1.001</td></tr><tr><td>CIFAR10ResNet</td><td>1.404</td><td>1.232</td><td>1.366</td><td>1.195</td></tr><tr><td>CIFAR10 ResNet (augmented)</td><td>1.274</td><td>1.346</td><td>1.264</td><td>1.198</td></tr></table>
491
+
492
+ Variational inference attempts to approximate the true intractable posterior $p ( w | x , y )$ by a tractable approximate posterior $q ( w )$ from an approximating family $\mathcal { Q }$ by maximizing the evidence lower bound (ELBO):
493
+
494
+ $$
495
+ q ^ { * } ( w ) = \underset { q \in \mathcal { Q } } { \arg \operatorname* { m a x } } \mathcal { L } ( q ; \lambda ) = \underset { q \in \mathcal { Q } } { \arg \operatorname* { m a x } } \mathbb { E } _ { q } [ \log p ( y | x , w ) ] - \lambda \mathrm { K L } ( q ( w ) | | p ( w ) ) .
496
+ $$
497
+
498
+ For $\lambda = 1$ , the ELBO is a true lower bound to the marginal likelihood of the model, and the true posterior is recovered as the optimal solution when $Q$ is the family of all distributions over $w$ . For MFVI, we restrict the approximating distribution to be a fully-factorized Gaussian, that is, $\begin{array} { r } { q ( w ) = \prod _ { i } \mathcal { N } ( w _ { i } | \mu _ { i } , \sigma _ { i } ^ { 2 } ) } \end{array}$ , so that there is no correlation structure in the approximate posterior. The variational parameters $\{ \mu _ { i } , \sigma _ { i } \}$ can then be optimized using the reparameterization trick (Kingma & Welling, 2014; Rezende et al., 2014).
499
+
500
+ As with (SG-)MCMC, we can temper the posterior by adjusting $\lambda$ , with $0 < \lambda < 1$ resulting in a “cold posterior”. However, we note that apart from the case $\lambda = T = 1$ , where we target the true posterior in both VI and MCMC, there is no straightforward, direct relationship between the cold posterior obtained in Eq. 1 and that obtained from Eq. 5 (for discussion see Wenzel et al. (2020a), particularly App. E).
501
+
502
+ # A.11.1 EXPERIMENTAL DETAILS AND RESULTS
503
+
504
+ We replicate the experiment in Sec. 4.3 for the ResNet architecture using CIFAR-10. We train each model for 1,000 epochs on batches of 500 augmented datapoints, using Adam (Kingma & Ba, 2015) with an initial learning rate of 0.01, which we reduce to 0.001 after 500 epochs. We are able to use these relatively high learning rates because we follow the parameterization introduced in Ober & Aitchison (2020); we also follow their step-wise tempering scheme for the first 100 epochs, which gradually increases the influence of the KL term. We use 1 sample from the approximate posterior for training and 10 samples for testing. Finally, we again run 5 replicates for each model.
505
+
506
+ We plot the results of this experiment in Figure A.33. We immediately make a few observations. First, the performance of MFVI is far worse than that of SG-MCMC on all metrics with the exception of calibration. We note that the performance at $\lambda = 1$ is particularly bad, which reflects the welldocumented behavior that tempering with $\lambda < 1$ is required for decent performance with MFVI (e.g., Wenzel et al., 2020a). Finally, it does not seem that the choice of prior has much effect on the performance of MFVI, as all priors perform similarly. We hypothesize that this is largely due to the mean-field assumption imposed on the approximate posterior, which severely restricts its expressiveness and can lead to pathological behavior (Foong et al., 2019; Trippe & Turner, 2018). The mean-field assumption leads to a poor approximation to the true posterior, and therefore will not be as influenced by the choice of prior as SG-MCMC. However, we leave a full investigation of these effects to future work.
507
+
508
+ # B EVALUATION METRICS
509
+
510
+ When using BNNs, practitioners might care about different outcomes. In some applications, the predictive accuracy might be the only metric of interest, while in other applications calibrated uncertainty estimates could be crucial. We therefore use a range of different metrics in our experiments in order to highlight the respective strengths and weaknesses of different priors. Moreover, we compare the priors to the empirical weight distributions of conventionally trained networks.
511
+
512
+ # B.1 EMPIRICAL TEST PERFORMANCE
513
+
514
+ Test error The test error is probably the most widely used metric in supervised learning. It intuitively measures the performance of the model on a held-out test set and is often seen as an empirical approximation to the true generalization error. While it is often used for model selection, it comes with the risk of overfitting to the used test set (Bishop, 2006) and in the case of BNNs also fails to account for the predictive variance of the posterior.
515
+
516
+ Test log-likelihood The predictive log-likelihood also requires a test set for its evaluation, but it takes the predictive posterior variance into account. It can thus offer a built-in tradeoff between the mean fit and the quality of the uncertainty estimates. Moreover, it is a proper scoring rule (Gneiting & Raftery, 2007).
517
+
518
+ # B.2 UNCERTAINTY ESTIMATES
519
+
520
+ Uncertainty calibration Bayesian methods are often chosen for their superior uncertainty estimates, so many users of BNNs will not be satisfied with only fitting the posterior mean well. The calibration measures how well the uncertainty estimates of the model correlate with predictive performance. Intuitively, when the model is for instance $70 \%$ certain about a prediction, this prediction should be correct with $70 \%$ probability. Many deep learning models are not well calibrated, because they are often overconfident and assign too low uncertainties to their predictions (Ovadia et al., 2019; Wenzel et al., 2020b). When the models are supposed to be used in safety-critical scenarios, it is often crucial to be able to tell when they encounter an input that they are not certain about (Kendall & Gal, 2017). For these applications, metrics such as the expected calibration error (Naeini et al., 2015) might be the most important criteria.
521
+
522
+ Out-of-distribution detection The out-of-distribution (OOD) detection measures how well one can tell in-distribution and out-of-distribution examples apart based on the uncertainties. This is important when we believe that the model might be deployed under some degree of dataset shift. In this case, the model should be able to detect these OOD examples and be able to reject them, that is, refuse to make a prediction on them.
523
+
524
+ # C DETAILS ABOUT THE CONSIDERED PRIORS
525
+
526
+ We contrast the widely used isotropic Gaussian priors with heavy-tailed distributions, including the Laplace and Student-t distributions, and with correlated Gaussian priors. We chose these distributions based on our observations of the empirical weight distributions of SGD-trained networks (see Sec. 3) and for their ease of implementation and optimization. We now give a quick overview over these different distributions and their most salient properties.
527
+
528
+ Gaussian. The isotropic Gaussian distribution (Gauss, 1809) is the de-facto standard for BNN priors in recent work (e.g., Hernández-Lobato & Adams, 2015; Louizos & Welling, 2017; Dusenberry et al., 2020; Wenzel et al., 2020a; Neal, 1992; Zhang et al., 2019; Osawa et al., 2019; Immer et al., 2021b; Lee et al., 2017; Garriga-Alonso et al., 2019). Its probability density function (PDF) is
529
+
530
+ $$
531
+ p ( x ; \mu , \sigma ^ { 2 } ) = { \frac { 1 } { \sqrt { 2 \pi \sigma ^ { 2 } } } } \exp \left( - { \frac { ( x - \mu ) ^ { 2 } } { 2 \sigma ^ { 2 } } } \right)
532
+ $$
533
+
534
+ with mean $\mu$ and standard deviation $\sigma$ . It is attractive, because it is the central limit of all finitevariance distributions (Billingsley, 1961) and the maximum entropy distribution for a given mean and scale (Bishop, 2006). However, its tails are relatively light compared to some of the other distributions that we will consider.
535
+
536
+ Laplace. The Laplace distribution (Laplace, 1774) has heavier tails than the Gaussian and is discontinuous at $x = \mu$ . Its PDF is
537
+
538
+ $$
539
+ p ( x ; \mu , b ) = { \frac { 1 } { 2 b } } \exp \left( - { \frac { | x - \mu | } { b } } \right)
540
+ $$
541
+
542
+ with mean $\mu$ and scale $b$ . It is often used in the context of (frequentist) lasso regression (Tibshirani, 1996).
543
+
544
+ Student-t. The Student-t distribution characterizes the mean of a finite number of samples from a Gaussian distribution (Student, 1908). Its PDF is
545
+
546
+ $$
547
+ p ( x ; \mu , \nu ) = \frac { \Gamma ( \frac { \nu + 1 } { 2 } ) } { \Gamma ( \frac { \nu } { 2 } ) \sqrt { \nu \pi } } \left( 1 + \frac { ( x - \mu ) ^ { 2 } } { \nu } \right) ^ { - \frac { \nu + 1 } { 2 } } ,
548
+ $$
549
+
550
+ where $\mu$ is the mean, $\Gamma$ is the gamma function, and $\nu$ are the degrees of freedom. The Student-t also arises as the marginal distribution over Gaussians with an inverse-Gamma prior over the variances (Helmert, 1875; Lüroth, 1876). For $\nu \to \infty$ , the Student-t distribution approaches the Gaussian. For any finite $\nu$ it has heavier tails than the Gaussian. Its $k$ -th moment is only finite for $\nu > k$ . The $\nu$ parameter thus offers a convenient way to adjust the heaviness of the tails. Note that it also controls the variance of the distribution, which is $\nu / ( \bar { \nu } - 2 )$ (or else undefined). Unless otherwise stated, we set $\nu = 3$ in our experiments, such that the distribution has rather heavy tails, while still having a finite mean and variance.
551
+
552
+ Multivariate Gaussian with Matérn covariance. For our correlated Bayesian CNN priors, we use multivariate Gaussian priors
553
+
554
+ $$
555
+ \begin{array} { l } { \displaystyle { p ( \pmb { x } ; \pmb { \mu } , \pmb { \Sigma } ) = \frac { 1 } { \sqrt { ( 2 \pi ) ^ { d } \operatorname* { d e t } \pmb { \Sigma } } } \exp \left( - \frac { 1 } { 2 } \| \pmb { x } - \pmb { \mu } \| _ { \pmb { \Sigma } ^ { - 1 } } ^ { 2 } \right) } } \\ { \mathrm { ~ w i t h ~ } \quad \| \pmb { x } - \pmb { \mu } \| _ { \pmb { \Sigma } ^ { - 1 } } ^ { 2 } = ( \pmb { x } - \pmb { \mu } ) ^ { \top } \pmb { \Sigma } ^ { - 1 } ( \pmb { x } - \pmb { \mu } ) , } \end{array}
556
+ $$
557
+
558
+ where $d$ is the dimensionality.
559
+
560
+ In our experiments, we set ${ \pmb \mu } = { \bf 0 }$ and define the covariance $\pmb { \Sigma }$ to be block-diagonal, such that the covariance between weights in different filters is 0 and between weights in the same filter is given by a Matérn kernel $( \nu = 1 / 2$ ) on the pixel distances, as applied by Garriga-Alonso $\&$ van der Wilk (2021) in the infinite-width case. Formally, for the weights $w _ { i , j }$ and $w _ { i ^ { \prime } , j ^ { \prime } }$ in filters $i$ and $i ^ { \prime }$ and for pixels $j$ and $j ^ { \prime }$ , the covariance is
561
+
562
+ $$
563
+ \begin{array} { r } { \mathrm { c o v } ( w _ { i , j } , w _ { i ^ { \prime } , j ^ { \prime } } ) = \left\{ \begin{array} { l l } { \sigma ^ { 2 } \exp \left( \frac { - d ( j , j ^ { \prime } ) } { \lambda } \right) } & { \mathrm { i f ~ } i = i ^ { \prime } } \\ { 0 } & { \mathrm { e l s e } } \end{array} \right. , } \end{array}
564
+ $$
565
+
566
+ where $d ( \cdot , \cdot )$ is the Euclidean distance in pixel space and we set $\sigma = \lambda = 1$ .
567
+
568
+ # D IMPLEMENTATION DETAILS
569
+
570
+ Training setup. For all the MNIST BNN experiments, we perform 60 cycles of SG-MCMC (Zhang et al., 2019) with 45 epochs each. We draw one sample each at the end of the respective last five epochs of each cycle. From these 300 samples, we discard the first 50 as a burn-in of the chain. Moreover, in each cycle, we only add Langevin noise in the last 15 epochs (similar to Zhang et al. (2019)). We start each cycle with a learning rate of 0.01 and decay to 0 using a cosine schedule. We use a mini-batch size of 128.
571
+
572
+ For the SGD experiments yielding the empirical weight distributions, we use the same settings, but do not add any Langevin noise. We also do not use any cycles and just train the networks once to convergence, which in our case took 600 epochs.
573
+
574
+ We ran the experiments on GPUs of the type NVIDIA GeForce GTX 1080 Ti and NVIDIA GeForce RTX 2080 Ti on our local cluster. The main experiments (see Fig. 4 and Fig. 5) took around 10,000 GPU hours to run.
575
+
576
+ FCNN architecture. For the FCNN experiments, we used a feedforward neural network with three layers, a hidden layer width of 100, and ReLU activations.
577
+
578
+ CNN architecture. For the CNN experiments, we use a convolutional network with two convolutional layers and one fully connected layer. The hidden convolutional layers have 64 channels each and use $3 \times 3$ convolutions and ReLU activations. Each convolutional layer is followed by a $2 \times 2$ max-pooling layer.
579
+
580
+ ResNet architecture and data augmentation. For the ResNet experiments on CIFAR-10, we use a ResNet20 architecture (He et al., 2016), equal to the one used in Wenzel et al. (2020a). For data augmentation, we pad all the images with 4 pixels on each border and then randomly crop out a $3 2 \mathrm { x } 3 2 $ image out of that padded one and then randomly flip half of the images horizontally
581
+
582
+ Software packages. We implemented the inference and models with the PyTorch library (Paszke et al., 2019). To manage our experiments and schedule runs with several settings, we used Sacred (Greff et al., 2017) and Jug (Coelho, 2017) respectively. For the diagnostics, we also use Arviz (Kumar et al., 2019).
583
+
584
+ ![](images/0935368dfbe35909e2221a1709bacf50cd31b59a94d43fa4fb0784998f6673f0.jpg)
585
+ Figure A.10: Distributions of off-diagonal elements in the empirical covariances of the weights and singular values of the CNN in the other layer. The empirical distributions are plotted as histograms, while the idealized random Gaussian weights are overlaid as an orange line. We see that the covariances of the empirical weights are more heavy-tailed than for the Gaussian weights and that the singular value spectrum for the empirical weights decays faster than the Gaussian ones.
586
+
587
+ ![](images/e372182bb4160e1f74b3fb774f2348059c83a71ef08a84ee345fd0be473a21a3.jpg)
588
+ Figure A.11: Performances of Bayesian ResNets with different priors on CIFAR-10 with and without data augmentation in terms of different metrics. Data augmentation seems to increase the cold posterior effect.
589
+
590
+ ![](images/8438a29a2dd65ce50e6a2cf6ae75fcacc6a79845d706e407070e4d5f84547d98.jpg)
591
+ Figure A.12: Performances of fully connected BNNs with different priors on MNIST and FashionMNIST in terms of different metrics, compared to SGD solutions. The heavy-tailed priors perform better for Fashion MNIST, and perform better for MNIST at least for Laplace for error and NLL. heavy-tailed priors also eliminate the cold posterior effect (they get worse as temperature falls).
592
+
593
+ ![](images/3b4202fce3f2c874669d10a7e34a1a6bde401ebb2e8d3ab35b54d0f45fb36c3c.jpg)
594
+ Figure A.13: Performances of convolutional BNNs with different priors on MNIST and FashionMNIST in terms of different metrics, compared to SGD solutions. The correlated prior generally performs better than the isotropic ones, but still exhibits a cold posterior effect, while the heavy-tailed priors reduce the cold posterior effect, but yield a worse performance.
595
+
596
+ ![](images/de46403aee7a890ead1e2bcf318d7325bc1aa417c897f123ec8bc00d3a20afe5.jpg)
597
+ Figure A.14: Performances of Bayesian ResNets with different priors on CIFAR-10 with and without data augmentation in terms of different metrics, compared to SGD solutions. The correlated prior generally outperforms the other ones. Moreover, data augmentation seems to increase the cold posterior effect.
598
+
599
+ ![](images/07d1d6f4ad1561c2dd6a0c50b3c778760ed05d14e67df195cc133f64f4a85b62.jpg)
600
+ Figure A.15: Performances of fully connected and convolutional BNNs with sigmoid activation functions on MNIST. The observed effects are qualitatively similar to the ones with ReLU activations in the main body of the paper.
601
+
602
+ ![](images/7ab71a5c8610cd1e6a68152fd8e4610e8e211ba677ffbcef6895979181a40629.jpg)
603
+ Figure A.16: Performances of fully connected and convolutional BNNs with tanh activation functions on MNIST. The observed effects are qualitatively similar to the ones with ReLU activations in the main body of the paper.
604
+
605
+ ![](images/aba841fe22150126257a76643ea4dd52dbd4ffd814407d470e32744f397669b5.jpg)
606
+ Figure A.17: Performances of Bayesian FCNNs with different priors on (Fashion-)MNIST, including temperatures $T > 1$ . The performances generally do not improve for warm posteriors, such that $T \approx 1$ is indeed optimal for some priors.
607
+
608
+ ![](images/c5e32bbdcce2bd5806a32e65e3621431c66458082ba087102405be7beb775bee.jpg)
609
+ Figure A.18: Performances of Bayesian CNNs and Resnets with different priors on (Fashion-)MNIST and CIFAR, including temperatures $T > 1$ . The performances generally do not improve for warm posteriors, such that $T \approx 1$ is indeed optimal for some priors. Note that here, we do not use data augmentation for CIFAR.
610
+
611
+ ![](images/0f6ec1c37a9c1ee2e9a1e77f65c7e19450d1bf9f97ebad7e4fb26469dbefb4eb.jpg)
612
+ Figure A.19: Performances of Bayesian FCNNs with different priors and different prior variances on MNIST. The qualitative behavior is similar to the one for the He variance in the main text.
613
+
614
+ ![](images/5af9e991b374e17a23a03551bc7be4a2fa61e34a5b9d720979d8d2df74ac53d0.jpg)
615
+ Figure A.20: Performances of Bayesian CNNs with different priors and different prior variances on MNIST. The qualitative behavior is similar to the one for the He variance in the main text.
616
+
617
+ ![](images/671d37c4fa5cd969d146da0059298102cabcfadc26b58bfcd1a3811a0047ca5f.jpg)
618
+ Figure A.21: Performances of Bayesian FCNNs with different priors and different prior variances on Fashion-MNIST. The qualitative behavior is similar to the one for the He variance in the main text.
619
+
620
+ ![](images/34e65ee0651972a187d1b05885768b7574aef3922fcf0b89ae201c378d7109b3.jpg)
621
+ Figure A.22: Performances of Bayesian CNNs with different priors and different prior variances on Fashion-MNIST. The qualitative behavior is similar to the one for the He variance in the main text.
622
+
623
+ ![](images/ea35a75c257a105dbb06351be5640a396738118771f6275aad18eced943d915e.jpg)
624
+ Figure A.23: Performances of Bayesian Resnets with different priors and different prior variances on CIFAR-10. The qualitative behavior is similar to the one for the He variance in the main text. Note that here, we do not use data augmentation.
625
+
626
+ ![](images/1592c644c1e5d905c7633b6986ce446a4ad95fff53062fbb854c58e4b772e4be.jpg)
627
+ Figure A.24: Performances of Bayesian FCNNs with different priors and different depths on MNIST. The qualitative behavior for the different numbers of layers is similar to the one for three layers in the main text.
628
+
629
+ ![](images/f6d0254494eb0c1a904baada90ba1bb5c7d579ca970b05770dc4e34452fa7a91.jpg)
630
+ Figure A.25: Box plots of the mean-squared error of Bayesian FCNNs doing regression on UCI datasets. For each temperature, and prior, each box displays the median $\pm 1 . 5$ times the inter-quartile range. Outliers are plotted as $\times$ . We exclude runs where the potential diverges. Temperature 1 is clearly best for all datasets, but otherwise there is no clear trend.
631
+
632
+ ![](images/fac4861f3b7b55fb935a8acd3e98629f96e797f9ef51e36ebbcf27dc9688ebdd.jpg)
633
+ Figure A.26: Kinetic temperature diagnostics of the ResNet CIFAR-10 experiments with data augmentation. We see that the kinetic temperatures agree almost perfectly with the target temperature of the sampler.
634
+
635
+ Table A.2: Worst (highest) $\widehat { R }$ values for different models and neuron-permutation-invariant functions.
636
+
637
+ <table><tr><td></td><td>Loss</td><td>Potential</td><td>Log-prior</td></tr><tr><td>FCNN MNIST</td><td>1.006</td><td>1.023</td><td>1.101</td></tr><tr><td>FCNN Fashion</td><td>1.007</td><td>1.013</td><td>1.104</td></tr><tr><td>CNNMNIST</td><td>1.002</td><td>1.001</td><td>1.013</td></tr><tr><td>CNNFashion</td><td>1.009</td><td>1.007</td><td>1.013</td></tr><tr><td>ResNet CIFAR-10</td><td>1.125</td><td>1.171</td><td>1.404</td></tr><tr><td>ResNet C.-10 (aug)</td><td>1.066</td><td>1.090</td><td>1.346</td></tr></table>
638
+
639
+ ![](images/3b391964884eb2c8e977841c5f054805fc0f6eaeee8ab8c4462e460b4b8f2624.jpg)
640
+ Figure A.27: Temperature diagnostics of the MNIST experiment with FCNNs.
641
+
642
+ ![](images/8ecaf1d5c3ca7df4fb096729ac74c933073ee69128366c19f0c6108bb425d812.jpg)
643
+ Figure A.28: Temperature diagnostics of the MNIST experiment with CNNs.
644
+
645
+ ![](images/1bfb5e474a0e21ccc18caae747164e0f4001274c88a2206097037e47503d0f36.jpg)
646
+ Figure A.29: Temperature diagnostics of the FashionMNIST experiment with FCNNs.
647
+
648
+ ![](images/a2fa557c0edd534288d022dc31bb8a62e33cf5ab0bc554e9ac506116daacd74b.jpg)
649
+ Figure A.30: Temperature diagnostics of the FashionMNIST experiment with CNNs.
650
+
651
+ ![](images/43c38ea569d77ac4f5841b3902813473cccfbcea28ff00b0f56f5cb9726a41e1.jpg)
652
+ Figure A.31: Temperature diagnostics of the CIFAR-10 experiment with ResNets without data augmentation.
653
+
654
+ ![](images/ce833c46efd72db7ff9b0943df4c4fa0d6bc7e619e133a40047293d606ad1a2a.jpg)
655
+ Figure A.32: Temperature diagnostics of the CIFAR-10 experiment with ResNets with data augmentation.
656
+
657
+ ![](images/c23b775e2682788e53ed37ce3c575e0d8d725a439cf2128a765bb49167377ff6.jpg)
658
+ Figure A.33: Performances of mean-field variational inference ResNets with different priors on CIFAR-10. Note the reversed y-axis for OOD detection on the right to ensure that lower values are better in all plots. Shaded regions represent one standard error.